Python bitstamp api无效非

2024-10-04 01:25:06 发布

您现在位置:Python中文网/ 问答频道 /正文

一个python脚本在运行,现在没有了。在

                public_client = bitstamp.client.Public()

                data=backTestBitCoin.getHistoricalPrices();

                trading_client = bitstamp.client.Trading(username='AAA', key='BBB', secret='CCC')
                tick=trading_client.ticker();

                lastBid = float(tick['bid']);
                lastAsk = float(tick['ask']);
                balances = trading_client.account_balance(); #error thrown from this line

我得到以下错误:

^{pr2}$

有人经历过吗?对图书馆不太熟悉,所以不知道是什么原因造成的。在


Tags: key脚本clientdatausernamepublicfloattick
1条回答
网友
1楼 · 发布于 2024-10-04 01:25:06

生成新的api密钥/密钥解决了此问题。我相信这是由于混合使用了php api和python api或iphone Bitstamp应用程序造成的。我将证实这一怀疑,但总体解决方案是拔下插头,然后再插上。在


简化的解决方案:我的问题来自于使用以下php和python库

phppython

两者都是A+的伟大和易于使用。在

错误的产生是因为他们在创建nonce的方法上存在以下差异(在我看来,两者都不是“正确的”,只是不同而已)。在

php

                // generate a nonce as microtime, with as-string handling to avoid problems with 32bits systems
                $mt = explode(' ', microtime());
                $req['nonce'] = $mt[1] . substr($mt[0], 2, 6);
                $req['key'] = $key;
                $req['signature'] = $this->get_signature($req['nonce']);

python

^{pr2}$

其中time.time()给出:1403366728.072785 并且microtime()给你:1403366859731819。在

我提出的解决方案是将python代码更改为:

self._nonce = max(int(time.time()*1000000), nonce)并解决错误。在

相关问题 更多 >