Giter Club home page Giter Club logo

arbitrage_crypto's Issues

BinanceでHTTPエラーが発生する

binance API authentication errorが発生し取引が開始できませんでした。
いかにLogを記載します。
エラーを返したURLを見ると、{"code":-2014,"msg":"API-key format invalid."}となっており
フォーマットが変わってエラーを起こすようになったのでしょうか?

Trade mode
LTC/BTC
binance/bitz
minsize:0.1
binance API authentication error
Traceback (most recent call last):
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 364, in fetch
response.raise_for_status()
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\requests\models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.binance.com/api/v3/account?timestamp=1526686993168&recvWindow=5000&signature=4d6e377195c180b2bc4ab09e70855ba802942f5f1301f0a1cacddec4bd5bc9b9

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "arb.py", line 70, in
ex = tools.exchange(t1, t2, info_set, l)
File "c:\arb\tools.py", line 82, in init
self.check_api_state()
File "c:\arb\tools.py", line 112, in check_api_state
t1_base, t1_alt = self.balance(self.t1)
File "c:\arb\tools.py", line 140, in balance
bal = ts.fetch_balance()
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\binance.py", line 388, in fetch_balance
response = self.privateGetAccount(params)
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\binance.py", line 845, in request
response = self.fetch2(path, api, method, params, headers, body)
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 303, in fetch2
return self.fetch(request['url'], request['method'], request['headers'], request['body'])
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\base\exchange.py", line 376, in fetch
self.handle_errors(response.status_code, response.reason, url, method, self.last_response_headers, self.last_http_response)
File "C:\Users\d\AppData\Local\Programs\Python\Python36\lib\site-packages\ccxt\binance.py", line 838, in handle_errors
raise exceptions[error](self.id + ' ' + body)
ccxt.base.errors.InvalidNonce: binance {"code":-1021,"msg":"Timestamp for this request was 1000ms ahead of the server's time."}

[bug] インデックスアクセスでリスト範囲外アクセス起こりうるのでは

root_uやroot_dにある

    for i in range(10):
        idx[np.argmin([amount1[idx[0]], amount2[idx[1]], amount3[idx[2]]])] += 1

インクリメントが一箇所に固まった場合, idxが最大10をとり長さ10のamount範囲外ではないでしょうか.

適当な初期値を与えて(ratio, value)=(0, 0)とかにして,
idxが0のときの処理をforの中に入れるのが良いのではないでしょうか?

class 'ccxt.base.errors.InsufficientFund エラーについて

algori11様 有用なツールを公開してくれてありがとうございます。
AWSにて、起動ができてBNBの自動購入もできております。
設定はデフォルトにしております。

以下、nohupで運用していて数回同じ現象で止まってしまうのですが、

class 'ccxt.base.errors.InsufficientFund

それぞれの取引所にBTC(BNB)およびXRPが足りないのかと思い
現在は、
BinanceのBNB/XRPが
binace-balance
HitbtcにはBTC/XRP
hitbtc

にそれぞれ入れているのですが、
同じようなエラーが出てしまいます、何かコンフィグで設定し忘れているのでしょうか。

Binanceのサーバー時間問題

ccxtでBinanceの認証のためのnonceとして現在時刻を使うのですが、PC内時計とBinanceのサーバー時間のズレが大きいと無効なnonceと扱われて認証できない問題があるようです。

とりあえずPCとBinanceのどっちがズレてるかは

import time
import request
print(requests.session().get("https://api.binance.com/api/v1/time", timeout=2).json()["serverTime"])
print(time.time()*1000)
print(requests.session().get("https://ntp-a1.nict.go.jp/cgi-bin/json", timeout=2).json()["st"]*1000)

で確認できます。上から
①Binanceの時計
②PCの時計
③Webから引っ張ってきた正しい時計
の時間がミリ秒単位で出力されます。

正しい時計③に対してPCの時計②が狂っている場合、なんらかの手段でPCの時計合わせをすると解決します。

正しい時計③に対してBinanceの時計①がズレている状態がずっと続く場合の対応策はccxtに実装されているようで、
[EXCHANGE1]にbinanceを設定した場合は

t1.options["adjustForTimeDifference"] = True

[EXCHANGE2]にbinanceを設定した場合は

t2.options["adjustForTimeDifference"] = True

をそれぞれarb.pyの

t1.name = config.NAME1
t2.name = config.NAME2

の下の行に追記すれば、PCとサーバーの時間差を考慮するようになるようです。

手前の環境では問題が発生していなくてこれで解決するのかが不明なので、もしこの方法or他の方法で解決したという報告があればコメントください。
BinanceのサーバーのズレとユーザーのPCの時刻合わせのズレのどちらで問題がおきていたかもわかればコメントお願いします。

[question] 3通貨裁定取引におけるパラメータ

たびたびすみません.
板の取引量を換算する場面ではask2[-1]とaskの10番目を用いるのに対して,
最小単位を求める場面ではask2[0][0]の1.1倍を使用しています.

    limit0 = max(limit1*ask2[0][0]*1.1, limit2, limit3)

取引は板にある価格や量の範囲でしか行われないんですよね?
ask2[-1][0]ではまずいのでしょうか?
パラメータ1.1は経験によるものですか?

(arb.pyでは価格にask[0][0]の1.01を使用しているようですが)

[question] 3通貨裁定取引において各板取引量累積和について疑問

実行していないので誤解かもしれません.

tri_arb.pyの関数root_uに

    amount1 = np.cumsum(ask1[:, 1] * ask2[-1][0])
    amount2 = np.cumsum(ask2[:, 1])
    amount3 = np.cumsum(bid3[:, 1])

    ratio = bid3[:, 0][idx[2]]/(ask1[:, 0][idx[0]]* ask2[:, 0][idx[1]])
    if ratio < threshold:
        return 0, 0
    value = np.min([amount1[idx[0]], amount2[idx[1]], amount3[idx[2]]])

がありますが, 取引量ask1[:, 1]に値段ask2[-1][0]をかけているように見えるのですが,
なにを意味しているんでしょうか?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.