IBpy - 获得我的市场地位

时间:2017-03-27 19:36:51

标签: python-3.5 ibpy

假设我的IB账户中只有一个职位 要检索它,我运行以下:

from time import sleep
from ib.opt import Connection, message, ibConnection
from ib.ext.Contract import Contract

def acc_update(msg):
    global acc, expiry, exch, pExch, secType, symbol
    acc = msg.account
    exch = msg.contract.m_exchange
    pExch = msg.contract.m_primaryExch
    secType = msg.contract.m_secType
    expiry = msg.contract.m_expiry
    symbol = msg.contract.m_symbol
    return acc, expiry, exch, pExch, secType, symbol


tws = ibConnection(port= 7497)
tws.register(acc_update, message.position) 
tws.connect()
tws.reqPositions()
sleep(0.5)
tws.disconnect()
print( [symbol, acc, expiry, exch, pExch, secType])
这给了我:
['BAC','DUC00074','20170519',无,'','OPT']

  • 为什么不显示交换和primary_exchange数据?

0 个答案:

没有答案