本文整理汇总了Python中ib.ext.Contract.Contract.m_conId方法的典型用法代码示例。如果您正苦于以下问题:Python Contract.m_conId方法的具体用法?Python Contract.m_conId怎么用?Python Contract.m_conId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ib.ext.Contract.Contract
的用法示例。
在下文中一共展示了Contract.m_conId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_market_data
# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_conId [as 别名]
def get_market_data(self, connection):
""" IB function to retrieve market data per contract """
sys.stdout.write("Calling Market Data\n")
# Loop through all options contracts
for _, option in OPTIONS.iterrows():
contract_values = Contract()
contract_values.m_symbol = option['m_symbol']
contract_values.m_localSymbol = option['m_localSymbol']
contract_values.m_exchange = "SMART"
contract_values.m_currency = "USD"
contract_values.m_secType = "OPT"
contract_values.m_multiplier = option['m_expiry']
contract_values.m_expiry = option['m_expiry']
contract_values.m_strike = option['m_strike']
contract_values.m_right = option['m_right']
contract_values.m_conId = option['m_conId']
connection.reqMktData(str(option['m_conId']), \
contract_values, "", True)
sleep(1)
sleep(30)
示例2: processMsg
# 需要导入模块: from ib.ext.Contract import Contract [as 别名]
# 或者: from ib.ext.Contract.Contract import m_conId [as 别名]
#.........这里部分代码省略.........
status = self.readStr()
filled = self.readInt()
remaining = self.readInt()
avgFillPrice = self.readDouble()
permId = 0
if version >= 2:
permId = self.readInt()
parentId = 0
if version >= 3:
parentId = self.readInt()
lastFillPrice = 0
if version >= 4:
lastFillPrice = self.readDouble()
clientId = 0
if version >= 5:
clientId = self.readInt()
whyHeld = None
if version >= 6:
whyHeld = self.readStr()
self.eWrapper().orderStatus(id, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld)
elif msgId == self.ACCT_VALUE:
version = self.readInt()
key = self.readStr()
val = self.readStr()
cur = self.readStr()
accountName = None
if version >= 2:
accountName = self.readStr()
self.eWrapper().updateAccountValue(key, val, cur, accountName)
elif msgId == self.PORTFOLIO_VALUE:
version = self.readInt()
contract = Contract()
if version >= 6:
contract.m_conId = self.readInt()
contract.m_symbol = self.readStr()
contract.m_secType = self.readStr()
contract.m_expiry = self.readStr()
contract.m_strike = self.readDouble()
contract.m_right = self.readStr()
if version >= 7:
contract.m_multiplier = self.readStr()
contract.m_primaryExch = self.readStr()
contract.m_currency = self.readStr()
if version >= 2:
contract.m_localSymbol = self.readStr()
position = self.readInt()
marketPrice = self.readDouble()
marketValue = self.readDouble()
averageCost = 0.0
unrealizedPNL = 0.0
realizedPNL = 0.0
if version >= 3:
averageCost = self.readDouble()
unrealizedPNL = self.readDouble()
realizedPNL = self.readDouble()
accountName = None
if version >= 4:
accountName = self.readStr()
if (version == 6) and (self.m_parent.serverVersion() == 39):
contract.m_primaryExch = self.readStr()
self.eWrapper().updatePortfolio(contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName)
elif msgId == self.ACCT_UPDATE_TIME:
version = self.readInt()
timeStamp = self.readStr()
self.eWrapper().updateAccountTime(timeStamp)
elif msgId == self.ERR_MSG: