BOTのAPIのレートリミット、制限について

Pocket

BOTトレードを行う際に、考慮する必要がるAPIのレート制限についてです。

APIのレート制限(リミット)とは?

ほとんどのAPIは好き放題に実行できません。
例えば、一定時間内に一定回数以上のアクセスを行うと
サービス提供側のサーバーがアクセス制限を行い
APIで実行したリクエストを処理してくれません。
(レートリミットにかかっているという内容の返事がきます)
つまりレートリミットを超えた場合は、APIから注文を入れても無視されます。

※但し、WebSocket通信など一部の通信方法にはレート制限がかかりません(後述)

 

自分のBOTで、よく利用しているAPIは以下の3つです。

  1. CryptoWatchのAPI(過去の価格取得用)
  2. bitflyerのAPI(注文、ポジション取得用)
  3. BitMEXのAPI(注文、ポジション取得用)

 

・各APIのレート制限は以下です

CryptoWatchのAPIレート制限について

CryptowatchのAPI レート制限は
一定時間で一定回数以内という制限ではなく
CPU処理時間によって制限されます。
CPU処理時間とはサーバーがAPIに対する
レスポンスを返すのに利用したCPUの処理時間です。
Cryptowatchが提供するAPIは何種類かあり、
実行するAPIによってサーバーでの処理の重さが異なります。

Cryptowatchのレートリミット
1時間でサーバーが返事を返すのにかかるCPUの処理時間の合計が8秒を超えた場合に発生します。
この合計時間は1時間毎にクリアされます。

・公式のドキュメントURL
https://cryptowatch.jp/docs/api

残りのCPU処理時間を知りたい場合、下記のURLにアクセスすればわかります。
https://api.cryptowat.ch/
“allowance”の”remaining”が残りCPU処理時間(単位はナノ秒)

bitFlyerのAPIレート制限について

~公式ドキュメントより引用~
API制限
HTTP API は、以下のとおり呼出回数を制限いたします。
Private API は 1 分間に約 200 回を上限とします。
IP アドレスごとに 1 分間に約 500 回を上限とします。

注文数量が 0.01 以下の注文を大量に発注するユーザーは、一時的に、発注できる注文数が 1 分間に約 10 回までに制限されることがあります。
システムに負荷をかける目的での発注を繰り返していると当社が判断した場合は、API の使用が制限されることがあります。ご了承ください。

注文を行うAPIは Private API のため
bitFlyerのレートリミットは 1 分間約 200 回となります。

・公式のドキュメントURL
https://lightning.bitflyer.com/docs?lang=ja

 

BitMEXのAPIレート制限について

~公式ドキュメントより引用~
REST API へのリクエストのレートは、5 分間あたり 300 リクエストに制限されています。 このカウンタは間断なく補充されます。 ログインしていない場合、レート制限は 5 分あたり 150 です。

**使用ツールが投入するエラーの数には十分な注意が必要です!**短時間に多数の 4xx または 5xx が返された場合、お使いの IP は 1 時間禁止されることがあります。 短期間に何度か禁止されると、禁止期間は 1 週間になります。

BOTにてトレードを行う場合、通常ログインしていない状態が想定されるため、BitMEXのAPIレートリミットは5 分間で 150 回となります。

・公式のドキュメントURL
https://www.bitmex.com/app/restAPI#%E5%88%B6%E9%99%90

 

APIレート制限の対象外!?WebSocket通信について

上記APIレート制限の対象外として、WebSocket通信というものがあります。

通常のREST APIは通信毎に、BOTと取引所が接続(コネクション)を繋ぐ処理を行っていますが、WebSocketの場合、一度接続を行うとその接続を繋ぎっぱなしにしてデータのやり取りを行います。

取引所のサーバーの接続処理のコストが減り、APIレート制限の対象外となることから、WebSocket通信で行える処理(価格やポジションの取得など、取引所によって異なる)については、積極的に利用するほうがいいといえます。

但し、そもそも高頻度で取引を行う必要がないBOTの場合は利用する必要はありません。処理が複雑になりやすいためです。

 

まとめ

・CryptoWatchのレート制限

1時間内のCPU処理時間の合計が8秒
同じAPIでも実行タイミングによってCPU処理時間が異なるため、
正確な時間は算出できませんでした。
※アクセス集中してると上がるかも?

・bitflyerのレート制限

1 分間に約 200 回 ≒ 約0.3秒に1回はアクセスOK

・BitMEXのレート制限

5 分間で 150 回 ≒ 2秒に1回はアクセスOK

・WebSocket通信

APIレート制限の対象外となる
高頻度で取引を行うBOTでない場合は利用する必要はない

 

「BOTのAPIのレートリミット、制限について」への75件のフィードバック

  1. I’m now not sure where you are getting your information, but great topic.

    I needs to spend some time studying more or working out more.
    Thanks for magnificent information I used to be looking for this info for my mission.

  2. Hello Dear, are you actually visiting this website
    regularly, if so then you will definitely take pleasant experience.

  3. I am not sure where you’re getting your information, but good topic.
    I needs to spend some time learning more or understanding more.
    Thanks for great info I was looking for this info for my mission.

  4. Nice post. I was checking continuously this blog and I’m impressed!
    Very useful info specially the last part 🙂 I care for
    such info much. I was seeking this particular info for a very long time.
    Thank you and good luck.

  5. I all the time used to read post in news papers but now as I am a user of net so from now I am using net for articles, thanks to
    web.

  6. Nice blog! Is your theme custom made or did you download it from somewhere?

    A theme like yours with a few simple tweeks would really make
    my blog jump out. Please let me know where you got your
    theme. Bless you

  7. A motivating discussion is definitely worth comment. I
    do think that you should write more on this topic, it may not be a
    taboo subject but usually folks don’t talk about these issues.

    To the next! Kind regards!!

  8. Wonderful work! This is the kind of info that are meant to be shared across the net.
    Shame on Google for not positioning this put
    up upper! Come on over and talk over with my site . Thanks =)

  9. Greetings from Carolina! I’m bored at work so I decided to check out your blog on my iphone during lunch break.

    I really like the knowledge you provide here
    and can’t wait to take a look when I get home.
    I’m surprised at how quick your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, good blog!

  10. Wow, wonderful blog format! How long have you ever been blogging for?

    you made running a blog look easy. The full
    look of your website is fantastic, let alone the content!

  11. Online Secure Bentyl Free Consultation Levitra Directions Cialis Y Esteroides Forum Cialis Tadalafil Buy Nolvadex For Lab Rats

  12. You ought to take part in a contest for one of the greatest sites on the internet.
    I am going to highly recommend this website!

  13. Hey! Do you know if they make any plugins to
    assist with SEO? I’m trying to get my blog to rank for
    some targeted keywords but I’m not seeing very good
    results. If you know of any please share. Many thanks!

  14. Hello just wanted to give you a quick heads up and let you know a few of the
    images aren’t loading properly. I’m not sure why but I think its a linking issue.
    I’ve tried it in two different web browsers and both show the same outcome.

  15. You could certainly see your enthusiasm in the article you write.
    The arena hopes for even more passionate writers such as you who are not afraid to say how they believe.
    All the time go after your heart.

  16. I truly love your blog.. Very nice colors & theme. Did you build this web site yourself?
    Please reply back as I’m trying to create my own blog and would love to know
    where you got this from or just what the theme is named. Cheers!

  17. You actually make it seem so easy with your presentation however I find this
    topic to be actually something that I believe I might by no means understand.
    It kind of feels too complicated and very wide for me.

    I am looking ahead for your subsequent publish, I’ll try to get the grasp
    of it!

  18. Hey there! I know this is kinda off topic but I was
    wondering which blog platform are you using for this website?
    I’m getting sick and tired of WordPress because I’ve had
    issues with hackers and I’m looking at alternatives for another platform.
    I would be fantastic if you could point me in the direction of a good platform.

  19. I blog often and I truly appreciate your content. This
    article has truly peaked my interest. I will take a note of your website and keep checking for new information about once a week.
    I opted in for your Feed as well.

  20. After looking over a number of the blog articles on your
    web site, I really appreciate your way of blogging. I book marked it to
    my bookmark webpage list and will be checking back soon. Please visit my website as
    well and let me know your opinion.

  21. I am now not positive the place you’re getting your info, however great
    topic. I needs to spend some time learning more
    or working out more. Thanks for wonderful info I
    used to be looking for this information for my mission.

  22. It’s truly very complex in this full of activity life to listen news on Television, so I just use web for that purpose,
    and get the most up-to-date information.

  23. Hi! I could have sworn I’ve been to your blog before but after looking
    at some of the posts I realized it’s new to me. Anyways, I’m definitely delighted I came
    across it and I’ll be bookmarking it and checking back frequently!

  24. May I simply just say what a relief to find someone
    that genuinely understands what they’re talking about on the web.
    You actually realize how to bring an issue to light and make it important.

    More people should read this and understand this side of your story.
    It’s surprising you’re not more popular given that
    you definitely have the gift.

  25. Pretty nice post. I simply stumbled upon your blog and wished to mention that I have really loved surfing
    around your weblog posts. After all I will be subscribing in your feed and I am hoping you write again very soon!

  26. Have you ever considered creating an e-book or guest authoring on other websites?
    I have a blog based on the same subjects you discuss and would love to have
    you share some stories/information. I know my audience would value your work.
    If you’re even remotely interested, feel free to shoot
    me an email.

  27. I have been surfing online more than three hours as of late, but I
    by no means found any attention-grabbing article like yours.
    It’s beautiful price sufficient for me. Personally, if all website owners and bloggers made just right content material as you
    did, the web will be much more helpful than ever before.

  28. Great blog you’ve got here.. It’s hard to find high-quality
    writing like yours these days. I honestly appreciate individuals like you!
    Take care!!

  29. I’ve been browsing online more than three hours today, but I never
    discovered any attention-grabbing article like yours.
    It’s beautiful price enough for me. In my view,
    if all website owners and bloggers made good content as you probably did, the net
    shall be a lot more helpful than ever before.

  30. Good post however , I was wanting to know if you could write a litte more
    on this topic? I’d be very thankful if you could elaborate a little bit more.
    Bless you!

  31. We stumbled over here from a different page and thought I might check things out.
    I like what I see so now i’m following you. Look forward to
    looking over your web page again.

  32. I do not even know how I ended up here, but I thought this
    post was good. I don’t know who you are but certainly you’re going to a famous blogger
    if you aren’t already 😉 Cheers!

  33. Hello it’s me, I am also visiting this web site
    daily, this web site is actually nice and the viewers are
    genuinely sharing nice thoughts.

  34. Do you mind if I quote a couple of your articles as long
    as I provide credit and sources back to your site? My blog is in the very same area of interest as yours and my users would really benefit from
    a lot of the information you provide here. Please
    let me know if this okay with you. Thanks!

  35. Pretty great post. I just stumbled upon your blog and wanted to say
    that I’ve truly loved browsing your weblog posts. After all I’ll be subscribing to your
    feed and I hope you write once more soon!

コメントは停止中です。