本文整理汇总了Python中ib.ext.TickType.TickType.getField方法的典型用法代码示例。如果您正苦于以下问题:Python TickType.getField方法的具体用法?Python TickType.getField怎么用?Python TickType.getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ib.ext.TickType.TickType
的用法示例。
在下文中一共展示了TickType.getField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: my_callback_handler
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def my_callback_handler(self, msg):
""" Simple call back handler """
if msg.typeName == "contractDetails":
opt_contract = msg.values()[1]
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_conId'] = opt_contract.m_summary.m_conId
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_symbol'] = opt_contract.m_summary.m_symbol
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_secType'] = opt_contract.m_summary.m_secType
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_expiry'] = opt_contract.m_summary.m_expiry
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_strike'] = opt_contract.m_summary.m_strike
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_right'] = opt_contract.m_summary.m_right
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_multiplier'] = opt_contract.m_summary.m_multiplier
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_exchange'] = opt_contract.m_summary.m_exchange
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_currency'] = opt_contract.m_summary.m_currency
OPTIONS.loc[str(opt_contract.m_summary.m_conId).replace(" ", ""),\
'm_localSymbol'] = opt_contract.m_summary.m_localSymbol
elif msg.typeName == "tickOptionComputation":
sys.stdout.write('=> option computation update for tickerId %s\n' \
% msg.tickerId)
if tt.getField(msg.field) == "askOptComp" or \
tt.getField(msg.field) == "bidOptComp" or \
tt.getField(msg.field) == "modelOptComp":
field = "bid" if tt.getField(msg.field) == "bidOptComp" else \
"ask" if tt.getField(msg.field) == "askOptComp" else "last"
OPTIONS.loc[str(msg.tickerId), '%s_impliedVol' % field] = \
msg.impliedVol
OPTIONS.loc[str(msg.tickerId), '%s_delta' % field] = msg.delta
OPTIONS.loc[str(msg.tickerId), '%s_gamma' % field] = msg.gamma
OPTIONS.loc[str(msg.tickerId), '%s_theta' % field] = msg.theta
OPTIONS.loc[str(msg.tickerId), '%s_vega' % field] = msg.vega
OPTIONS.loc[str(msg.tickerId), '%s_optPrice' % field] = \
msg.optPrice
OPTIONS.loc[str(msg.tickerId), '%s_undPrice' % field] = \
msg.undPrice
elif msg.typeName == "historicalData":
if ('finished' in str(msg.date)) == False:
addentry = True
entrydate = int(msg.date) * 1000
if self.latestdate and entrydate < self.latestdate:
addentry = False
if addentry:
dataStr = [entrydate, msg.open, msg.high, msg.low, \
msg.close]
self.NEWDATALIST = self.NEWDATALIST + [dataStr]
volStr = [entrydate, msg.volume]
self.NEWVOLUMELIST = self.NEWVOLUMELIST + [volStr]
示例2: fieldTypes
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def fieldTypes():
""" Creates mapping of ticker data fields to field names.
@return field to field name mapping
"""
items = [(k, getattr(TickType, k)) for k in dir(TickType)]
items = [(k, v) for k, v in items if isinstance(v, int)]
unknown = TickType.getField(-1)
items = [(v, TickType.getField(v)) for k, v in items]
return dict([(k, v) for k, v in items if v != unknown])
示例3: setupTree
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def setupTree(self):
""" Configure the model and initial items for this instance.
@return None
"""
tree = self.controlsTree
self.controlsTreeModel = model = QStandardItemModel(self)
tree.setModel(model)
model.setHorizontalHeaderLabels(['Line', 'Value'])
tree.sortByColumn(0, Qt.AscendingOrder)
try:
ticker = self.collection[self.key]
except (KeyError, TypeError, ):
pass
else:
for field, series in ticker.series.items():
self.addSeries(TickType.getField(field), series)
self.connect(model, Signals.standardItemChanged,
self.on_controlsTree_itemChanged)
for col in range(model.columnCount()):
tree.resizeColumnToContents(col)
tree.addActions(
[self.actionChangeCurveStyle,
self.actionChangeDataMarker,
self.actionChangeCurveAxisX,
self.actionChangeCurveAxisY,])
tree.expandAll()
示例4: tickEFP
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickEFP(cls, tickerId, tickType, basisPoints, formattedBasisPoints, impliedFuture, holdDays, futureExpiry, dividendImpact, dividendsToExpiry):
""" generated source for method tickEFP """
return "id=" + str(tickerId) + " " + TickType.getField(tickType) \
+ ": basisPoints = " + str(basisPoints) + "/" + formattedBasisPoints \
+ " impliedFuture = " + str(impliedFuture) + " holdDays = " + str(holdDays) \
+ " futureExpiry = " + futureExpiry + " dividendImpact = " + str(dividendImpact) \
+ " dividends to expiry = " + str(dividendsToExpiry)
示例5: fieldSpecs
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def fieldSpecs(maxValue=10):
""" Yields one description dictionary for every TickType field.
"""
values = [getattr(TickType, k) for k in dir(TickType)]
for value in [v for v in values if isinstance(v, int) and v < maxValue]:
title = tickFieldTitle(TickType.getField(value))
yield dict(value=value, title=title)
示例6: fieldSpecs
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def fieldSpecs():
""" Yields one description dictionary for every TickType field.
"""
values = [getattr(TickType, k) for k in dir(TickType)]
for value in [v for v in values if isinstance(v, int)]:
name = TickType.getField(value)
title = tickFieldTitle(name)
yield dict(sort=value, value=value, name=name, title=title)
示例7: tickEFP
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickEFP(cls, tickerId,
tickType,
basisPoints,
formattedBasisPoints,
impliedFuture,
holdDays,
futureExpiry,
dividendImpact,
dividendsToExpiry):
return "id=" + tickerId + " " + TickType.getField(tickType) + ": basisPoints = " + basisPoints + "/" + formattedBasisPoints + " impliedFuture = " + impliedFuture + " holdDays = " + holdDays + " futureExpiry = " + futureExpiry + " dividendImpact = " + dividendImpact + " dividends to expiry = " + dividendsToExpiry
示例8: on_session_createdSeries
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def on_session_createdSeries(self, key, field):
""" Signal handler called when new Series objects are created.
@param key id of ticker with new series
@param field series field
"""
if key != self.key:
return
series = self.collection[self.key].series[field]
self.addSeries(TickType.getField(field), series)
self.controlsTree.sortByColumn(0, Qt.AscendingOrder)
示例9: tickSizeHandler
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickSizeHandler(self, msg):
"""Handle TickSize messages from IB.
Store tick data in db
@param msg ib.opt.message.TickSize Message sent by IB
"""
symb = self.getSymbolFromId(msg.tickerId)
if symb:
#print "[{1}] {0}: {2}".format(symb, fieldType[msg.field], msg.size)
db.tickers.update({"symbol": symb},
{"$set": {TickType.getField(msg.field): msg.size}},
upsert = True)
示例10: tickOptionComputation
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickOptionComputation(cls, tickerId, field, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice):
""" generated source for method tickOptionComputation """
toAdd = "id=" + str(tickerId) + " " + TickType.getField(field) \
+ ": vol = " + (str(impliedVol) if (impliedVol >= 0 and impliedVol != Double.MAX_VALUE) else "N/A") \
+ " delta = " + (str(delta) if (abs(delta) <= 1) else "N/A") \
+ " gamma = " + (str(gamma) if (abs(gamma) <= 1) else "N/A") \
+ " vega = " + (str(vega) if (abs(vega) <= 1) else "N/A") \
+ " theta = " + (str(theta) if (abs(theta) <= 1) else "N/A") \
+ " optPrice = " + (str(optPrice) if (optPrice >= 0 and optPrice != Double.MAX_VALUE) else "N/A") \
+ " pvDividend = " + (str(pvDividend) if (pvDividend >= 0 and pvDividend != Double.MAX_VALUE) else "N/A") \
+ " undPrice = " + (str(undPrice) if (undPrice >= 0 and undPrice != Double.MAX_VALUE) else "N/A")
return toAdd
示例11: tickOptionComputation
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickOptionComputation(cls, tickerId,
field,
impliedVol,
delta,
optPrice,
pvDividend,
gamma,
vega,
theta,
undPrice):
toAdd = "id=" + tickerId + " " + TickType.getField(field) + ": vol = " + (impliedVol if impliedVol >= 0 and (impliedVol != float('inf')) else "N/A") + " delta = " + (delta if abs(delta) <= 1 else "N/A") + " gamma = " + (gamma if abs(gamma) <= 1 else "N/A") + " vega = " + (vega if abs(vega) <= 1 else "N/A") + " theta = " + (theta if abs(theta) <= 1 else "N/A") + " optPrice = " + (optPrice if optPrice >= 0 and (optPrice != float('inf')) else "N/A") + " pvDividend = " + (pvDividend if pvDividend >= 0 and (pvDividend != float('inf')) else "N/A") + " undPrice = " + (undPrice if undPrice >= 0 and (undPrice != float('inf')) else "N/A")
return toAdd
示例12: tickPriceHandler
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickPriceHandler(self, msg):
"""Handle TickPrice messages from IB.
Remove the globals and implement a Producer/Consumer
@param msg ib.opt.message.TickPrice Message sent by IB
"""
self.ticks[msg.tickerId] = msg
symb = self.getSymbolFromId(msg.tickerId)
if symb:
db.tickers.update({"symbol": symb},
{"$set": {TickType.getField(msg.field): msg.price}},
upsert = True)
self.event.set()
示例13: my_callback_handler
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def my_callback_handler(msg):
#for reference on this /home/deep/development/IbPy/ib/ext/TickType
#another class method tt.getField(msg.field)
if msg.field in [tt.BID,tt.ASK,tt.LAST,tt.HIGH,tt.LOW,tt.OPEN,tt.CLOSE]:
print tt.getField(msg.field), msg.price
elif msg.field in [tt.BID_SIZE,tt.ASK_SIZE,tt.LAST_SIZE,tt.VOLUME,tt.AVG_VOLUME]:
print tt.getField(msg.field), msg.size
elif msg.field in [tt,LAST_TIMESTAMP]:
print tt.getField(msg.field), msg.time
示例14: on_tick
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def on_tick(self, msg):
''' Callback for market data requests
'''
tick_id = msg.tickerId
if msg.typeName == 'tickSize':
field_name = TickType.getField(msg.field)
value = msg.size
elif msg.typeName == 'tickPrice':
field_name = TickType.getField(msg.field)
value = msg.price
elif msg.typeName in ['tickGeneric', 'tickString']:
field_name = TickType.getField(msg.tickType)
value = msg.value
if tick_id in self.print_once:
if tick_id not in self.ticker_data:
ticker_data = dict()
else:
ticker_data = self.ticker_data[tick_id]
ticker_data[field_name] = value
self.ticker_data[tick_id] = ticker_data
elif tick_id in self.tick_callbacks:
self.tick_callbacks[tick_id](field_name, value)
示例15: tickSize
# 需要导入模块: from ib.ext.TickType import TickType [as 别名]
# 或者: from ib.ext.TickType.TickType import getField [as 别名]
def tickSize(cls, tickerId, field, size):
return "id=" + tickerId + " " + TickType.getField(field) + "=" + size