交互式代理Python API错误-1322处理请求
我正在尝试取消所有订单,但收到此错误消息 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线程中未处理的异常 回溯(最近一次呼叫最后一次):交互式代理Python API错误-1322处理请求,python,api,tws,Python,Api,Tws,我正在尝试取消所有订单,但收到此错误消息 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 E
不确定这到底意味着什么……如果查询历史数据并同时使用相同的tickerId查询另一个历史数据请求,则会出现“322”错误。虽然tickerId可以重复使用,但在使用相同的tickerId值之前,确保完成现有请求是至关重要的。或者,您可以为每个请求指定唯一的tickerId。请查看历史数据请求,以查看您的程序如何使用Id值。
322处理API客户端请求时出现服务器错误
显示跟踪,发生的情况是您在某个地方出错,因此它会断开连接。我猜是非传统的线程。api是异步的,从不使用睡眠。猜得好!非常感谢。不确定这到底意味着什么……如果查询历史数据并同时使用相同的tickerId查询另一个历史数据请求,则会出现“322”错误。虽然tickerId可以重复使用,但在使用相同的tickerId值之前,确保完成现有请求是至关重要的。或者,您可以为每个请求指定唯一的tickerId。请查看历史数据请求,以查看您的程序如何使用Id值。322处理API客户端请求时出现服务器错误
显示跟踪,发生的情况是您在某个地方出错,因此它会断开连接。我猜是非传统的线程。api是异步的,从不使用睡眠。猜得好!非常感谢。
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()