LoginSignup
3
3

More than 3 years have passed since last update.

仮想通貨アービトラージBinanceAPIのLOT_SIZEエラー

Last updated at Posted at 2019-09-20

はじめに

各国の取引所をクローリングして
価格差で利益を得るアービトラージシステムを作って回しているのですが
たまにBinanceでオーダーエラーが発生して
ググってもろくな情報がなくいつも困っているので
メモとして残しておこうと思います。

BinanceのLOT_SIZEエラーとは

公式ドキュメントを見ると・・・

The LOT_SIZE filter defines the quantity (aka "lots" in auction terms) rules for a symbol. There are 3 parts:
 ● minQty defines the minimum quantity/icebergQty allowed.
 ● maxQty defines the maximum quantity/icebergQty allowed.
 ● stepSize defines the intervals that a quantity/icebergQty can beincreased/decreased by.

In order to pass the lot size, the following must be true for quantity/icebergQty:
 ● quantity >= minQty
 ● quantity <= maxQty
 ● (quantity-minQty) % stepSize == 0

/exchangeInfo format:
{
  "filterType": "LOT_SIZE",
  "minQty": "0.00100000",
  "maxQty": "100000.00000000",
  "stepSize": "0.00100000"
}

はぁ・・・
って感じです(^^;)

書いてある内容

上2つは見た通りすごく簡単で
・最小取引額
・最大取引額
これの中でオーダーしろよってことですね。

問題は最後の1つ・・・
・(quantity-minQty) % stepSize == 0

うーん・・・って感じですが
結論から言ってしまうと最小単位が決まってるってことです。

小数点以下の桁が小さ過ぎるのはダメ。
細かい単位を指定するな!ということでした。

最小額・最大額・最小単位

これは通過毎に決まっていて、ここから確認できます。
イーサリアムの場合には

    "symbols": [
        {
            "symbol": "ETHBTC",
*途中省略*
                {
                    "filterType": "LOT_SIZE",
                    "minQty": "0.00100000",
                    "maxQty": "100000.00000000",
                    "stepSize": "0.00100000"
                },

ということで
僕が指定していた額が「5.1132 ETH」だったので
小数点以下は3桁までにしろ!!って怒られたという訳です (^^;)

stepSize以下は切り捨てるか・切り上げるか・四捨五入するか・・・
アービトラージなのでしっかり利益が取れるようにすることが重要です。
設計し直してプログラムを改修します。

最後に

このアービトラージシステムは初月で月利8%を記録しています。
とんでもない数字ですね。
(銀行なんて年利で・・・)

株式会社アポロではブロックチェーンで様々なプロダクトを作って利益をあげています。
世界初のAIの開発もしていますので、ご興味ある方は是非こちらをご覧ください (^^)

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3