HuobiRDCenter / huobi_Python

Python SDK for Huobi Spot API
https://huobiapi.github.io/docs/spot/v1/en
Apache License 2.0
682 stars 333 forks source link

On receive of orderbook and trade in spot #75

Closed igkoh closed 3 years ago

igkoh commented 3 years ago

To receive market data of order book and trade on subscription of spot,

  1. MarketClient object is created
  2. subscribe by market_client.sub_trade_detail("btcusdt", callback) for trade receive in callback trade_event.print_objet()
  3. subscribe by market_client.sub_pricedepth("btcusdt", DepthStep.STEP0, callback, error) for orderbook receive in SubPriceDepthService.parse(dict_data)

How can I write in such a way to receive (orderbook, trade) where MarketClient object is defined. I want to write strategy for spot trading upon reception of (orderbook, trade) in the same method.

Best regards, Ingyu

eynzhang commented 3 years ago

@igkoh I am afraid that your question is not part of current responsibility of SDK, you need to manage that yourself. One solution is you need to create a dedicated thread (with a shared memory) to get the orderbook data, and create the order request based on your strategy.