交互式代理Python API错误1322处理请求

2024-06-29 01:08:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试取消所有订单,但收到此错误消息

openOrder id:62 ES FUT@GLOBEX:BUY STP 13.0预先提交 orderStatus-orderid:62状态:预提交已填写0.0剩余13.0 lastFillPrice 0.0

openOrder id:63 ES FUT@GLOBEX:BUY LMT 13.0预先提交 orderStatus-orderid:63状态:预提交已填写0.0剩余13.0 lastFillPrice 0.0

openOrder id:61 ES FUT@GLOBEX:SELL STP LMT 13.0已提交 orderStatus-orderid:61状态:已提交已填写0.0剩余13.0 lastFillPrice 0.0

错误-1 2104市场数据场连接正常:usfuture

错误-1216 HMDS数据场连接正常:ushmds

错误-1 2158 Sec def数据场连接正常:secdefil

错误-1322错误处理请求:-“bt”:原因-jextend.bt.l(bt.java:59)

EReader线程中未处理的异常

回溯(最近一次呼叫最后一次):

class IBapi(EWrapper, EClient):
                    posns = []
                    fname = 'OpenPos.txt'
                    def __init__(self):
                        EClient.__init__(self, self)
                    
                    def nextValidId(self, orderId: int):
                        super().nextValidId(orderId)
                        self.nextorderId = orderId
                        

                    def orderStatus(self, orderId, status, filled, remaining, avgFullPrice, permId, parentId, lastFillPrice, clientId, whyHeld, mktCapPrice):
                        print('orderStatus - orderid:', orderId, 'status:', status, 'filled', filled, 'remaining', remaining, 'lastFillPrice', lastFillPrice)
    
                    def openOrder(self, orderId, contract, order, orderState):
                        print('openOrder id:', orderId, contract.symbol, contract.secType, '@', contract.exchange, ':', order.action, order.orderType, order.totalQuantity, orderState.status)

                    def execDetails(self, reqId, contract, execution):
                        print('Order Executed: ', reqId, contract.symbol, contract.secType, contract.currency, execution.execId, execution.orderId, execution.shares, execution.lastLiquidity)
                      
                def run_loop():
                    app.run()
                    
                app = IBapi()
                app.connect('127.0.0.1', 7497, 123)
                time.sleep(2)
                
                app.nextorderId = None
                api_thread = threading.Thread(target=run_loop, daemon=True)
                api_thread.start()
                app.reqGlobalCancel()
                time.sleep(3)
                done=True
                time.sleep(1)
                app.disconnect()

Tags: selfidappesdefstatus错误order