Closed HFLeon closed 3 years ago
具体怎么调用的?没有复现出类似的错误
try:
order_info = api_instance.get_order(order_id, currency_pair)
except GateApiException as ex:
self._l.error("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
self._l.error("Exception when calling SpotApi->get_order: %s\n" % e)
具体是在收到socket的spot.orders通知,去获取订单信息的时候,可能比较频繁
不是一直出现?只是偶尔触发?
from gate_api import ApiClient, Configuration, SpotApi
from gate_api.exceptions import GateApiException
def main():
config = Configuration(key='<your key>', secret='<your secret>')
spot_api = SpotApi(ApiClient(config))
order = spot_api.get_order('<real-id>', 'GT_USDT')
print(order.id)
try:
order = spot_api.get_order('<fake-id>', 'GT_USDT')
print(order.id)
except GateApiException as ex:
print(ex.label, ex.message)
if __name__ == '__main__':
main()
我试着用这个最小代码片段调用是正常的
其中有几次是正常的,有几次就报这错
在 2021年6月17日,19:22,revilwang @.***> 写道:
不是一直出现?只是偶尔触发?
from gate_api import ApiClient, Configuration, SpotApi from gate_api.exceptions import GateApiException
def main(): config = Configuration(key='
', secret=' ') spot_api = SpotApi(ApiClient(config)) order = spot_api.get_order(' ', 'GT_USDT') print(order.id) try: order = spot_api.get_order(' ', 'GT_USDT') print(order.id) except GateApiException as ex: print(ex.label, ex.message) if name == 'main': main() 我试着用这个最小代码片段调用是正常的
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
猜测是不是有多线程 SpotApi 实例混用的情况,如果你配置的 SpotApi 没有配置 key
和 secret
就会按照公共接口来处理不做任何请求加密,访问私有接口的时候就会被认证拒绝。比如下面这种方式是会报无效请求头的错误
spot_api = SpotApi(ApiClient(Configuration()))
order = spot_api.get_order('<real-id>', 'GT_USDT')
Python-SDK 4.21.2
get_order 报错