hbdmapi / huobi_futures_Python

An Asynchronous Event-driven High-frequency Trading System,huobi future,huobi coin margined swap, huobi usdt margined swap included.
MIT License
267 stars 113 forks source link

After disconnect/reconnect, how to recover ALL OPEN ORDERS from server? #30

Closed igkoh closed 4 years ago

igkoh commented 4 years ago

If program runs for n hours with 1 min disconnected/reconnected, self.trader.orders does not contain the 1 min disconnected period. What is the method to get the persistent data of ALL OPEN ORDERS from server? self.trader.orders contains ONLY while on connected. Best regards, Ingyu

foonsun commented 4 years ago

@igkoh Hi,You can register a timer to check the open orders,just like this:https://github.com/hbdmapi/hbdm_Python/blob/master/examples/huobi_option_mm/strategy.py#L159

igkoh commented 4 years ago

In recovery procedure of crashed hbdm_Python, the situation runs as T1 : hbdm_Python started T2 : 80 open orders issued T3 : hbdm_Python crashed T4 : hbdm_Python restarted self.trader.orders do not have 80 open orders.

How can I restore full 80 open orders before the machine crushed. If I cannot restore, revoke_order() to cancel everything.

Best regards, Ingyu

foonsun commented 4 years ago

Hi @igkoh When hbdm_Python restarted,the open orders will be requested for the first time:https://github.com/hbdmapi/hbdm_Python/blob/master/alpha/platforms/huobi_future_trade.py#L227 .What do you mean 80 open orders?

igkoh commented 4 years ago

@foonsun, I really appreciate for your precise answers to develop successful system. In initialization of quant.start() through loop.run_forever()->run_once()->callback-> await method, _success,error=rest_api.get_open_orders(symbol) in alpha/platforms/huobi_future_trade.py restores 80 open orders made before crash.

Detailed previous 80 open orders are recovered through success['data']['orders'] which is 80 length with full open order data.

Once your precise guidance clears obstacle, real progresses are made. Best regards, Ingyu

foonsun commented 4 years ago

Np.Happy Trading.