0

假设我的 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']

  • 为什么没有显示 exchange 和 primary_exchange 数据?
4

0 回答 0