Interactive Brokers Python数据请求

时间:2018-05-31 18:21:38

标签: python-3.x api interactive-brokers

我正在运行以下代码,但我获取快照价格的请求在python控制台上没有返回任何内容。我需要打印方法吗?对不起,我不熟悉愚蠢的oop,只做了程序和功能。

谢谢

from ibapi.client   import EClient
from ibapi.wrapper  import EWrapper
from ibapi.common   import *
from ibapi.contract import *

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

my_connection = TestApp()

my_connection.connect("127.0.0.1", 7497,0)

ym = Contract()
ym.symbol          = "YM"
ym.secType         = "FUT"
ym.ContractMonth   = "JUN18"
ym.primaryExchange = "ECBOT"
ym.currency        = "USD"

my_connection.reqMktData(1000, contract = ym , genericTickList = "9", snapshot = True, regulatorySnapshot = False, mktDataOptions = [])`

1 个答案:

答案 0 :(得分:0)

您需要覆盖EWrapper类中的回调函数,以定义处理返回数据的方式:

sudo setsebool -P httpd_can_network_connect on 
chcon -Rt httpd_sys_content_t /var/www/

还要注意,期货合约定义不正确,在以下位置有示例:

http://interactivebrokers.github.io/tws-api/basic_contracts.html#fut