python - 使用 Python API 从另一个网络连接到盈透证券交易平台
问题描述
我正在尝试从另一个网络连接到我的 TWS 应用程序(在我的家庭网络上),但我的 TWS 应用程序没有收到任何连接。
我确保我启用了“ActiveX 和套接字客户端”,设置了主 API 客户端 ID,使用了正确的端口,甚至将我的公共 IP 地址添加为“受信任的 IP”,但我没有弹出接受连接的弹出窗口。
这是我的代码:
class IBapi(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def tickPrice(self, reqId, tickType, price, attrib):
if tickType == 2 and reqId == 1:
print('The current ask price is: ', price)
def run_loop():
app.run()
app = IBapi()
app.connect('PUBLIC_IPV4_ADDRESS', 7497, MASTER_API_CLIENT_ID)
我收到以下错误:
ERROR -1 502 Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket EClients"
is enabled and connection port is the same as "Socket Port" on the
TWS "Edit->Global Configuration...->API->Settings" menu. Live Trading ports:
TWS: 7496; IB Gateway: 4001. Simulated Trading ports for new installations
of version 954.1 or newer: TWS: 7497; IB Gateway: 4002
ERROR 1 504 Not connected
有什么我错过的吗?
解决方案
推荐阅读
- android - java.lang.IllegalArgumentException: 南纬超过北纬 (23.029011581089936 > 23.0060917)
- node.js - 自动迁移创建数据库名称“未定义”,在 loopback-connector-cassandra 中的“未定义”数据库中创建表
- javascript - 卸载或卸载扩展程序时,Chrome Native Messaging 退出 NodeJS 主机
- sql - 在员工领取高薪的部门工作的员工姓名
- flutter - 颤振:处理 File.path 空/空
- gemfire - Gemfire 9.8.4 的主机要求
- c# - .net如何在zipfile中包含目录和文件关系
- ngxs - ngxs 实验室 immer 要求完整状态?
- sql - 如何查找 SQL 数据库信息
- php - 如何在 php 中动态设计表格,在 td 和数据之后有 3 行