4.26K 浏览
0

论坛有个大佬写了单策略多合约,我有些想法 ,我现在是单合约多策略,但是总感觉之前那位大佬,写的多合约直接这样循环有问题,会堵塞吧??然后TQ又不能调用多进程,多线程不安全,多合约同一策略确实是个大问题。。
while True:
        # print('主循环启动')
        tq_api.wait_update()
        #tq_api.is_changing(qtick)
        #print('最新 :',qtick.last_price)
        #print('买一:',qtick.bid_price1)
        #print('卖一:',qtick.ask_price1)
        # 多合约运行的话,需要循环检测哪个合约的行情产生了变化,进行处理
         for symbol in list_code:
            if tq_api.is_changing(kLineDic[symbol]):

益善 已回答的问题 2019年12月10日
0

不会堵塞,可以试试看

小 明 发表新评论 2019年12月10日

(‘2019-12-10 14:59:46.095000’, ‘DCE.i2001’, None, 682.0, None, 698.0, 682.0, 688.5)
{‘datetime’: ‘2019-12-10 14:59:48.614000’, ‘ask_price1’: 603.0, ‘ask_volume1’: 7, ‘bid_price1’: 602.5, ‘bid_volume1’: 415, ‘last_price’: 602.5, ‘highest’: 615.0, ‘lowest’: 600.5, ‘open’: 607.0, ‘close’: nan, ‘average’: 608.0, ‘volume’: 68316, ‘amount’: 4155308800.0, ‘open_interest’: 113112, ‘settlement’: nan, ‘upper_limit’: 651.5, ‘lower_limit’: 544.5, ‘pre_open_interest’: 114960, ‘pre_settlement’: 598.0, ‘pre_close’: 606.0, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2009’}
63
================
(‘2019-12-10 14:59:48.614000’, ‘DCE.i2009’, None, 607.0, None, 615.0, 600.5, 602.5)
{‘datetime’: ‘2019-12-10 14:59:49.114000’, ‘ask_price1’: 603.5, ‘ask_volume1’: 30, ‘bid_price1’: 603.0, ‘bid_volume1’: 196, ‘last_price’: 603.0, ‘highest’: 615.0, ‘lowest’: 600.5, ‘open’: 607.0, ‘close’: nan, ‘average’: 608.0, ‘volume’: 68330, ‘amount’: 4156153000.0, ‘open_interest’: 113116, ‘settlement’: nan, ‘upper_limit’: 651.5, ‘lower_limit’: 544.5, ‘pre_open_interest’: 114960, ‘pre_settlement’: 598.0, ‘pre_close’: 606.0, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2009’}
64
================
(‘2019-12-10 14:59:49.114000’, ‘DCE.i2009’, None, 607.0, None, 615.0, 600.5, 603.0)
{‘datetime’: ‘2019-12-10 14:59:51.617000’, ‘ask_price1’: 688.5, ‘ask_volume1’: 122, ‘bid_price1’: 688.0, ‘bid_volume1’: 212, ‘last_price’: 688.0, ‘highest’: 698.0, ‘lowest’: 682.0, ‘open’: 682.0, ‘close’: nan, ‘average’: 689.5, ‘volume’: 366982, ‘amount’: 25309113600.0, ‘open_interest’: 492126, ‘settlement’: nan, ‘upper_limit’: 713.5, ‘lower_limit’: 633.5, ‘pre_open_interest’: 568588, ‘pre_settlement’: 673.5, ‘pre_close’: 686.5, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2001’}
237
================
(‘2019-12-10 14:59:51.617000’, ‘DCE.i2001’, None, 682.0, None, 698.0, 682.0, 688.0)
{‘datetime’: ‘2019-12-10 14:59:52.113000’, ‘ask_price1’: 688.5, ‘ask_volume1’: 321, ‘bid_price1’: 688.0, ‘bid_volume1’: 221, ‘last_price’: 688.5, ‘highest’: 698.0, ‘lowest’: 682.0, ‘open’: 682.0, ‘close’: nan, ‘average’: 689.5, ‘volume’: 367102, ‘amount’: 25317370000.0, ‘open_interest’: 492016, ‘settlement’: nan, ‘upper_limit’: 713.5, ‘lower_limit’: 633.5, ‘pre_open_interest’: 568588, ‘pre_settlement’: 673.5, ‘pre_close’: 686.5, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2001’}
238
================
(‘2019-12-10 14:59:52.113000’, ‘DCE.i2001’, None, 682.0, None, 698.0, 682.0, 688.5)
{‘datetime’: ‘2019-12-10 14:59:52.618000’, ‘ask_price1’: 688.5, ‘ask_volume1’: 320, ‘bid_price1’: 688.0, ‘bid_volume1’: 197, ‘last_price’: 688.0, ‘highest’: 698.0, ‘lowest’: 682.0, ‘open’: 682.0, ‘close’: nan, ‘average’: 689.5, ‘volume’: 367154, ‘amount’: 25320947800.0, ‘open_interest’: 491978, ‘settlement’: nan, ‘upper_limit’: 713.5, ‘lower_limit’: 633.5, ‘pre_open_interest’: 568588, ‘pre_settlement’: 673.5, ‘pre_close’: 686.5, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2001’}
239
================
(‘2019-12-10 14:59:52.618000’, ‘DCE.i2001’, None, 682.0, None, 698.0, 682.0, 688.0)
{‘datetime’: ‘2019-12-10 14:59:53.616000’, ‘ask_price1’: 688.5, ‘ask_volume1’: 251, ‘bid_price1’: 688.0, ‘bid_volume1’: 185, ‘last_price’: 688.5, ‘highest’: 698.0, ‘lowest’: 682.0, ‘open’: 682.0, ‘close’: nan, ‘average’: 689.5, ‘volume’: 367378, ‘amount’: 25336369000.0, ‘open_interest’: 491920, ‘settlement’: nan, ‘upper_limit’: 713.5, ‘lower_limit’: 633.5, ‘pre_open_interest’: 568588, ‘pre_settlement’: 673.5, ‘pre_close’: 686.5, ‘price_tick’: 0.5, ‘price_decs’: 1, ‘volume_multiple’: 100, ‘max_limit_order_volume’: 1000, ‘max_market_order_volume’: 1000, ‘min_limit_order_volume’: 0, ‘min_market_order_volume’: 0, ‘underlying_symbol’: ”, ‘strike_price’: nan, ‘change’: nan, ‘change_percent’: nan, ‘expired’: False, ‘margin’: 5132.0, ‘commission’: 6.415, ‘instrument_id’: ‘DCE.i2001’}
240
================

确实不会堵塞

您正在查看1个答案中的1个,单击此处查看所有答案。