亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

由于日志記錄錯誤,無法連接到 Interactive Brokers Api

由于日志記錄錯誤,無法連接到 Interactive Brokers Api

汪汪一只貓 2023-07-27 16:41:46
所以我正在使用 python 交互式經紀商 api,并且我正在嘗試向交互式經紀商下限價單。我的代碼是:from ibapi.client import EClientfrom ibapi.wrapper import EWrapperfrom ibapi.contract import Contractfrom ibapi.order import Orderimport threadingimport timeclass 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 = 1order.lmtPrice = 10app.placeOrder(app.nextValidOrderId,contract,order)time.sleep(5) 我已確保選中“啟用活動和套接字客戶端”并且信任 IP 地址為 127.0.0.1 為什么我會收到此日志記錄錯誤?
查看完整描述

1 回答

?
GCT1015

TA貢獻1827條經驗 獲得超4個贊

我想class TradingApp(EWrapper, EClient):這就是你想做的。我認為沒有理由擴展 Contract 和 Order 類。

您更改了方法的名稱,它必須與超類相同。不要重復使用方法名稱作為變量名稱。

#def nextValidOrderId(self, orderId):
def nextValidId(self, orderId):
    self.nextValidOrderId = orderId


查看完整回答
反對 回復 2023-07-27
  • 1 回答
  • 0 關注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號