本文整理汇总了Python中EventEngine.DyEvent.data['data']方法的典型用法代码示例。如果您正苦于以下问题:Python DyEvent.data['data']方法的具体用法?Python DyEvent.data['data']怎么用?Python DyEvent.data['data']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventEngine.DyEvent
的用法示例。
在下文中一共展示了DyEvent.data['data']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: putStockMarketStrengthUpdateEvent
# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data['data'] [as 别名]
def putStockMarketStrengthUpdateEvent(self, strategyCls, time, marketStrengthInfo):
event = DyEvent(DyEventType.stockMarketStrengthUpdate)
event.data['class'] = strategyCls
event.data['time'] = time
event.data['data'] = marketStrengthInfo
self._eventEngine.put(event)
示例2: _stockPosSyncFromBrokerHandler
# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data['data'] [as 别名]
def _stockPosSyncFromBrokerHandler(self, event):
"""
收到来自券商接口的持仓同步事件
!!!如果交易不是通过策略,或者持仓同步不是在开盘时,可能会导致信息不一致或者错误。
"""
# unpack
header = event.data['header']
rows = event.data['rows']
# it's synchronized from broker
self._curPosSyncData = {}
for data in rows:
# unpack from 券商接口持仓数据
code = DyStockCommon.getDyStockCode(data[header.index(self.headerNameMap['position']['code'])])
name = data[header.index(self.headerNameMap['position']['name'])]
totalVolume = float(data[header.index(self.headerNameMap['position']['totalVolume'])])
availVolume = float(data[header.index(self.headerNameMap['position']['availVolume'])])
price = float(data[header.index(self.headerNameMap['position']['price'])])
cost = float(data[header.index(self.headerNameMap['position']['cost'])])
# get position
pos = self._curPos.get(code)
if pos is None:
continue
# set sync data firstly
self._curPosSyncData[code] = {'volumeAdjFactor': totalVolume/pos.totalVolume,
'priceAdjFactor': pos.cost/cost,
'cost': cost
}
# syn with positions from broker
pos.price = price
pos.cost = cost
pos.totalVolume = totalVolume
pos.availVolume = availVolume
pos.priceAdjFactor = self._curPosSyncData[code]['priceAdjFactor']
pos.volumeAdjFactor = self._curPosSyncData[code]['volumeAdjFactor']
if pos.priceAdjFactor != 1:
pos.xrd = True
pos.sync = True
# 发送行情监控事件
self._putStockMarketMonitorEvent()
# 发送股票持仓同步事件
event = DyEvent(DyEventType.stockPosSyncFromAccountManager)
event.data['broker'] = self.broker
event.data['data'] = self._curPosSyncData
self._eventEngine.put(event)
示例3: putStockMarketMonitorUiEvent
# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data['data'] [as 别名]
def putStockMarketMonitorUiEvent(self, strategyCls, data=None, newData=False, op=None, signalDetails=None, datetime_=None):
"""
触发策略行情监控事件(通常用于通知GUI更新)
@strategyCls: strategy class
@data: 策略显示数据, [[]]
@newData: True-策略显示数据是全新的数据,False-只是更新策略显示数据
@op: 策略操作数据, [[]]。
若策略是运行状态(实盘状态)并且绑定券商账户,则op是实盘操作。若策略是监控状态或者没有绑定券商账户,则op就是非实盘操作。
其实非实盘时,可以不向UI推送操作,这么做只是为了非真正实盘时,能看到策略的操作明细。
信号明细和操作明细是不同的,有信号未必就会有操作,因为实盘时的操作牵涉到风控和资金管理。
@signalDetails: 策略信号明细数据, [[]]
@datetime_: 行情数据时有效
"""
event = DyEvent(DyEventType.stockMarketMonitorUi + strategyCls.name)
# data
if data:
event.data['data'] = {'data': data,
'new': newData,
'datetime': datetime_
}
# indication
ind = {}
if op:
ind['op'] = op
if signalDetails:
ind['signalDetails'] = signalDetails
if ind:
event.data['ind'] = ind
# put event
if event.data:
event.data['class'] = strategyCls
self._eventEngine.put(event)