所以我正在使用 python 交互式经纪商 api,并且我正在尝试向交互式经纪商下限价单。我的代码是:
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.order import Order
import threading
import time
class TradingApp(EWrapper, EClient, Contract, Order):
def __init__(self):
EClient.__init__(self, self)
def nextValidOrderId(self, orderId):
super().nextValidId(orderId)
self.nextValidOrderId = orderId
print("NextValidId:", orderId)
def websocket_con():
app.run()
app = TradingApp()
app.connect("127.0.0.1", 7497, clientId=1)
con_thread = threading.Thread(target=websocket_con, daemon=True)
con_thread.start()
time.sleep(1)
contract=Contract()
contract.symbol = 'AMD'
contract.secType = 'STK'
contract.currency = 'USD'
contract.exchange = 'SMART'
order=Order()
order.action = 'BUY'
order.orderType = 'LMT'
order.totalQuantity = 1
order.lmtPrice = 10
app.placeOrder(app.nextValidOrderId,contract,order)
time.sleep(5)
我已确保选中“启用活动和套接字客户端”并且信任 IP 地址为 127.0.0.1 为什么我会收到此日志记录错误?
GCT1015
相关分类