【问题标题】:python-bittrex missing positional argumentspython-bittrex 缺少位置参数
【发布时间】:2018-09-06 15:05:55
【问题描述】:

我正在尝试通过 bittrex api 进行限购购买,但我收到错误消息,指出我的论点放错了位置。

from bittrex.bittrex import API_V2_0, Bittrex
import json

my_bittrex = Bittrex("zzzzz", "zzzzz", api_version=API_V2_0)

trade = 'BTC'
currency = 'TRX'
market = '{0}-{1}'.format(trade, currency)


b = (my_bittrex.buy_limit({market, 100, float(0.00005550)}))

错误:

Traceback (most recent call last):
  File "bittrex/apitest.py", line 17, in <module>
    b = (my_bittrex.buy_limit({market, 100, float(0.00005550)}))
TypeError: buy_limit() missing 2 required positional arguments: 'quantity' and 'rate'

如何正确定位我对 bittrex 的论点?

更新: 我试过了

b = (my_bittrex.trade_buy({market, 100, float(0.00005550)}))

b = my_bittrex.trade_buy(market=market, quantity=100, rate=float(0.00005550))

params = {'market': market, 'quantity': 100, 'rate': float(0.00005550)}
#b = my_bittrex.trade_buy(**params)
print (b)

会话的错误输出:

{'result': None, 'success': False, 'message': 'There was a problem processing your request.  If this problem persists, please email support@bittrex.com with this error id - 4feb00b8-fbe9-4dd3-b11f-95fd7bf5250f'}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'message': 'There was a problem processing your request.  If this problem persists, please email support@bittrex.com with this error id - e0396c8d-8a4c-41c5-b6c4-6842c31386e2', 'success': False, 'result': None}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'success': False, 'result': None, 'message': 'NO_API_RESPONSE'}
root@raspberrypi3:/var/www/html/jango# python3 bittrex/apitest.py
{'message': 'NO_API_RESPONSE', 'success': False, 'result': None}
root@raspberrypi3:/var/www/html/jango# nano -c bittrex/apitest.py

最终更新: 我在这里感到困惑

:param time_in_effect: TIMEINEFFECT_GOOD_TIL_CANCELLED = 'GOOD_TIL_CANCELLED',
                TIMEINEFFECT_IMMEDIATE_OR_CANCEL = 'IMMEDIATE_OR_CANCEL', or TIMEINEFFECT_FILL_OR_KILL = 'FILL_OR_KILL'

来自 https://github.com/ericsomdahl/python-bittrex/blob/master/bittrex/bittrex.py#L740

使用正确的函数调用。

最终:

b= my_bittrex.trade_buy(market='BTC-TRX', order_type='LIMIT', quantity=100, rate=float(0.00000555), time_in_effect='GOOD_TIL_CANCELLED',condition_type='None', target=float(0.0))

而我的限价单就在 gui 中等待着我。

【问题讨论】:

    标签: python xmlhttprequest bitcoin


    【解决方案1】:

    ericsomdahl/python-bittrex看源码

    对于buy_limit 函数,您似乎错误地将值传递给函数。您不应该传递字典,而是应该看起来像这样:

    b = my_bittrex.buy_limit(market=market, quantity=100, rate=float(0.00005550))
    

    或者这个

    params = {'market': market, 'quantity': 100, 'rate': float(0.00005550)}
    b = my_bittrex.buy_limit(**params)
    

    对于trade_buy 方法,您可以通过类似的方式传递参数:

    b = my_bittrex.trade_buy(
        market=market, 
        quantity=100, 
        rate=float(0.00005550))
    

    【讨论】:

    • 我都试过了,都产生了同样的错误 -> raise Exception('method call not available under API version {}'.format(self.api_version)) Exception: method call not available under API version v2.0
    • 你想用什么方法?您在原始问题中调用了 buy_limit 方法,但在更新问题时使用了 trade_buy 方法。 trade_buy 方法有不同的参数。
    • 特别 -> 端点:1.1 /market/buylimit 2.0 否直接等效。使用 trade_buy 进行 LIMIT 和 MARKET 购买
    • 你指向了buy_limit函数的return语句?我将更新我的原始答案,以展示如何使用 trade_buy 函数
    猜你喜欢
    • 1970-01-01
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    • 2021-12-25
    • 2018-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多