Interactive Broker Python API 显示错误:IB AttributeError: 'IBapi' object has no attribute 'connState' [英] Interactive Broker Python API shows error: IB AttributeError: 'IBapi' object has no attribute 'connState'

查看:56
本文介绍了Interactive Broker Python API 显示错误:IB AttributeError: 'IBapi' object has no attribute 'connState'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试制作一个简单的 Python 程序,该程序通过 IB 原生 API 连接到我的模拟账户.但是当我运行程序时出现错误:IB AttributeError: 'IBapi' object has no attribute 'connState'

I tried to make a simple Python program, that connects via the IB native API to my Demo Account. But when I run the program it comes an error: IB AttributeError: 'IBapi' object has no attribute 'connState'

程序如下所示:

from ibapi.wrapper import EWrapper  

class IBapi(EWrapper, EClient):
     def init(self):
         EClient.init(self, self) 

app = IBapi()
app.connect('127.0.0.1', 7497, 123)
app.run()

我使用了这个网站的教程:https://algotrading101.com/learn/interactive-brokers-python-api-native-guide/

I used the tutorial from this website: https://algotrading101.com/learn/interactive-brokers-python-api-native-guide/

感谢您的帮助!

推荐答案

在创建对象实例后自动调用的python初始化方法名为__init__,而不是init代码>.

The python initialization method that is automatically called after an object instance has been created is named __init__, not init.

https://docs.python.org/3/reference/datamodel.html#object.init

在您的代码中,永远不会调用 init 方法.应该是:

In your code the init method will never be called. It should be:

from ibapi.client import EClient 
from ibapi.wrapper import EWrapper


class IBapi(EWrapper, EClient):
    def __init__(self):         
        EClient.__init__(self, self)

...

您可能对 Traders 中的 Python API 课程感兴趣'学院在IBKR网站上.

You might be interested in the Python API course in the Traders' Academy on the IBKR website.

这篇关于Interactive Broker Python API 显示错误:IB AttributeError: 'IBapi' object has no attribute 'connState'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆