我是 ibapi 新手并使用库“ https://pypi.org/project/ibapi/ ”。我想下载图片中红框内的所有订单详情。
代码是
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print("Error: ", reqId, " ", errorCode, " ", errorString)
def contractDetails(self, reqId, contractDetails):
print("contractDetails: ", reqId, " ", contractDetails)
def openOrder(self):
super().openOrder()
print("OpenOrder. PermId: ", order.permId, "ClientId:", order.clientId, " OrderId:", orderId, "Account:", order.account, "Symbol:", contract.symbol, "SecType:", contract.secType,"Exchange:", contract.exchange, "Action:", order.action, "OrderType:", order.orderType,"TotalQty:", order.totalQuantity, "CashQty:", order.cashQty, "LmtPrice:", order.lmtPrice, "AuxPrice:", order.auxPrice, "Status:", orderState.status)
order.contract = contract
self.permId2ord[order.permId] = order
def main():
app = TestApp()
app.connect("127.0.0.1", 1111, 0)
app.reqAllOpenOrders()
app.run()
app.disconnect()
main()
如果您有,请帮助我找出错误或分享一些完全不同的方法。