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

ClientOSError(10054,... in sub_callback in class HuobiSwapTrade(Websocket) #38

Closed igkoh closed 4 years ago

igkoh commented 4 years ago

After several days of running, sub_callback in class HuobiSwapTrade(Websocket) of huobi_swap_trade.py in alpha/platforms has errors error ClientOSError(10054, 'Current connection was forcibly disconnected by remote host', None, 10054, None) in: success, error = await self._rest_api.get_open_orders(self._symbol) if error: e = Error("get open orders failed!") SingleTask.run(self._init_success_callback, False, e)

        for order_info in success["data"]["orders"]:
            order_info["ts"] = order_info["created_at"]
            self._update_order(order_info)
        SingleTask.run(self._init_success_callback, True, None)

Since error in _rest_api.get_open_orders, success is None and not subscriptable as success["data"]["orders"]. How can I modify for continuous operation?

Best regards, Ingyu

igkoh commented 4 years ago

Temporary measure is taken as:
success, error = await self._rest_api.get_open_orders(self._symbol) if error: ...e = Error("get open orders failed!") ... SingleTask.run(self._init_success_callback, False, e) else: ...for order_info in success["data"]["orders"]: ......order_info["ts"] = order_info["created_at"] ......self._update_order(order_info) SingleTask.run(self._init_success_callback, True, None)

What is the best method to maintain continuous operation of huobi swap? Best regards, Ingyu

foonsun commented 4 years ago

Hi,we have added the logics to handle the error several days ago. eg: https://github.com/hbdmapi/hbdm_Python/blob/master/alpha/platforms/huobi_swap_trade.py#L227

igkoh commented 4 years ago

@foonsun, I followed your instruction in sub_callback of class HuobiSwapTrade(Websocket), logic steps through to success['data'] to update_order.

Until now, I have not reached else case of ('Unknown error') and it is free of unknown error upto now.

Thanks for kind instructions. Best regards, Ingyu

foonsun commented 4 years ago

@igkoh thanks for your feedback.