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

huobi_usdt_swap_cross: NOT-REACHABLE for async def on_ticker,cancel_orders,place_orders #59

Closed igkoh closed 3 years ago

igkoh commented 3 years ago

In huobi_usdt_swap_cross, async def on_ticker,cancel_orders,place_orders are not reached through quant.loop.run_forever.

Orderbook and trade data are properly received through on_event_trade_update and on_event_orderbook_update are properly reached with

__D [2021-03-22 12:15:12,094] [-] [HuobiUsdtSwapMarket] data: {"ch": "market.FIL-USDT.trade.detail", "ts": 1616382912443, "tick": {"id": 12312271536, "ts": 1616382912427, "data": [{"amount": 120, "quantity": 12, "trade_turnover": 948.936, "ts": 1616382912427, "id": 123122715360000, "price": 79.078, "direction": "sell"}, {"amount": 180, "quantity": 18, "trade_turnover": 1423.404, "ts": 1616382912427, "id": 123122715360001, "price": 79.078, "direction": "sell"}, {"amount": 26, "quantity": 2.6, "trade_turnover": 205.5872, "ts": 1616382912427, "id": 123122715360002, "price": 79.072, "direction": "sell"}, D [2021-03-22 12:15:13,580] [-] [HuobiUsdtSwapMarket] data: {"ch": "market.FIL-USDT.depth.step6", "ts": 1616382913928, "tick": {"mrid": 12312273776, "id": 1616382913, "bids": [[79.061, 781], [79.06, 685], [79.057, 25], [79.056, 165], [79.051, 35], [79.049, 32], [79.041, 806], [79.033, 371], [79.032, 562], [79.031, 42], [79.03, 3], [79.02, 1550], [79.019, 131], [79.017, 3086], [79.016, 122], [79.008, 122], [79.004, 190], [79.003, 51], [79.002, 48], [79, 924]], "asks": [[79.062, 14], [79.063, 3235], [79.082, 600], [79.087, 152], [79.101, 940], [79.102, 100], [79.103, 500], [79.105, 150], [79.111, 300], [79.113, 160], [79.115, 100], [79.119, 2524], [79.127, 101], [79.128, 87], [79.13, 4], [79.136, 170], [79.138, 131], [79.144, 122], [79.145, 405], [79.151, 160]], "ts": 1616382913922, "version": 1616382913, "ch": "market.FIL-USDT.depth.step6"}}__

The config.json is: _{ "SERVER_ID": "swap_maker_strategy", "LOG": { "console": true, "level": "DEBUG", "path": "D:/data/logs/servers/future_maker_strategy", "name": "future_maker_strategy.log", "clear": true, "backup_count": 5 }, "ACCOUNTS": [ { "platform": "huobi_usdt_swap_cross", "account": "xxx", "host": "https://api.hbdm.vn", "wss": "wss://api.hbdm.vn", "access_key": "xxx", "secret_key": "xxx" } ], "MARKETS": [ { "platform": "huobi_usdt_swap_cross", "channels":[ "orderbook", "kline", "trade" ], "orderbook_length": 10, "orderbooks_length": 100, "klines_length": 100, "trades_length": 100, "wss": "wss://api.hbdm.vn"

    }
],
"strategy": "my_test_strategy",
"symbol": "FIL-USDT",
"contract_type": "USDTSWAP"

}_

Best regards, Ingyu

igkoh commented 3 years ago

LoopRunTask.register(self.on_ticker,1) was erased in experimenting with the code. Thus cancel_orders and place_orders called inside on_ticker are not reached. By restoring LoopRunTask, it is confirmed that cancel_orders and place_orders are properly reached. Thanks, Foonsun