简体   繁体   English

盈透证券 API - 如何断开 IB 网关的现有连接并使用 Python 建立新连接?

[英]Interactive Brokers API - How to disconnect an existing connection of IB Gateway and establish a new connection using Python?

I am testing Interactive Brokers Python API in a Hobby project.我正在一个爱好项目中测试盈透证券 Python API。 I am using Interactive Brokers Gateway (rather TWS).我正在使用盈透证券网关(而不是 TWS)。 My project is a simple Django-based application.我的项目是一个简单的基于 Django 的应用程序。 I can connect successfully and receive real-time data using the method reqMktData() .我可以使用reqMktData()方法成功连接并接收实时数据。 Everything is OK so far.到目前为止一切都很好。

But when I refresh the page it shows 504 Not Connected , although in IB Gateway it shows there is a running connection.但是当我刷新页面时它显示504 Not Connected ,尽管在 IB Gateway 中它显示有一个正在运行的连接。 To stop this, During a page reload I am trying to disconnect the previous connection using the Eclient disconnect() method available in the API, but it can not disconnect the running connection.为了阻止这种情况,在页面重新加载期间,我尝试使用 API 中可用的Eclient disconnect()方法断开先前的连接,但它无法断开正在运行的连接。

Can anyone have any idea how can I disconnect a running connection in IB Gateway and start a new connection?谁能知道如何断开 IB 网关中正在运行的连接并开始新的连接?

Changing my client Id seems to fix it for me.更改我的客户 ID 似乎可以为我解决问题。 Maybe toggle back and forth between 2 of them?也许在其中两个之间来回切换?

To disconnect from TWS IBAPI (python)断开TWS IBAPI (python)

  1. set attribute ib.conn = None设置属性ib.conn = None
  2. then call ib.disconnect() function,然后调用ib.disconnect() function,
  3. then the callback function would stop() of EWrapper class然后回调 function 将stop()EWrapper class

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用盈透证券 (IB) API (ib_insync) 为 Python 复制括号定单功能 - How to replicate bracket orders functionality using Interactive Brokers (IB) API (ib_insync) for Python 如何使用 IB API 或 ib_insync 为 Interactive 代理设置错误处理程序? Python - How to set up an error handler for Interactive brokers using IB API or ib_insync? Python Python Interactive brokers IB API 非常非常慢 - Python Interactive brokers IB API very very slow Interactive Brokers管道Python断开连接失败 - Interactive Brokers Broken pipe python connection fail 在 Linux 上使用 IB Python API 和 IB 网关客户端连接到盈透证券服务器 - Connecting to Interactive Broker Server using IB Python API & IB Gateway client on Linux 连接到 IB 经纪人 API PYTHON - Connection to IB broker API PYTHON Interactive Brokers (IB) Python API:无法在 VS Code 上运行 IB 教程示例 - Interactive Brokers (IB) Python API: Unable to run the IB tutorial sample on VS Code 如何使用本机Interactive Brokers Python API创建条件订单? - How to create a conditional order using the native Interactive Brokers Python API? 具有IbPy的Interactive Brokers,API连接在Mac OsX上不起作用 - Interactive Brokers with IbPy, API connection not working on Mac OsX 盈透证券 API (IBAPI) - 使用 threading.Timer object 在数据连接中断时自动退出 - Interactive Brokers API (IBAPI) - Using threading.Timer object to auto exit when the data connection is broken
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM