【发布时间】:2017-11-04 11:51:19
【问题描述】:
我正在使用 Bittrex 的 websockets API。
我可以毫无问题地获取市场摘要。
此外,调用中心方法“SubscribeToExchangeDeltas”,为我获取请求的交换增量。
但是,当我尝试调用中心方法“QueryExchangeState”来获取某个市场的订单历史记录时,什么都没有发生,我什至没有收到错误,因此该方法显然已被调用。
有没有人对此有更多的了解、有这方面的经验或让这个工作发挥作用?请告诉我!
下面的代码是我正在使用的。 它为我提供了“ETC-MEME”的摘要更新和交换增量。
但如何获取特定市场的订单历史记录(本例中为“ETC-MEME”)?
import pprint
from requests import Session # pip install requests
from signalr import Connection # pip install signalr-client
def handle_received(*args, **kwargs):
print('\nreceived')
print('\nargs:')
pprint.pprint(args)
print('\nkwargs:')
pprint.pprint(kwargs)
def print_error(error):
print('error: ', error)
def main():
with Session() as session:
connection = Connection("https://www.bittrex.com/signalR/", session)
chat = connection.register_hub('corehub')
connection.start()
# Handle any pushed data from the socket
connection.received += handle_received
connection.error += print_error
for market in ["BTC-MEME"]:
chat.server.invoke('SubscribeToExchangeDeltas', market)
chat.server.invoke('QueryExchangeState', market)
pass
while True:
connection.wait(1)
if __name__ == "__main__":
main()
【问题讨论】:
标签: python-3.x websocket algorithmic-trading