本文整理汇总了Python中vnpy.event.Event类的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Event类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: putSettingEvent
def putSettingEvent(self, settingName, algoSetting):
"""发出算法配置更新事件"""
algoSetting['settingName'] = settingName
event = Event(EVENT_ALGO_SETTING)
event.dict_['data'] = algoSetting
self.eventEngine.put(event)
开发者ID:aaront2000,项目名称:vnpy,代码行数:7,代码来源:algoEngine.py
示例2: writeCtaLog
def writeCtaLog(self, content):
"""快速发出CTA模块日志事件"""
log = VtLogData()
log.logContent = content
event = Event(type_=EVENT_CTA_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:porfavor,项目名称:vnpy,代码行数:7,代码来源:ctaEngine.py
示例3: writeDrLog
def writeDrLog(self, content):
"""快速发出日志事件"""
log = VtLogData()
log.logContent = content
event = Event(type_=EVENT_DATARECORDER_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:QuantFeng,项目名称:vnpy,代码行数:7,代码来源:drEngine.py
示例4: writeLog
def writeLog(self, content):
"""快速发出日志事件"""
print "%s.%s.%s" % (__name__, self.__class__.__name__, get_current_function_name())
log = VtLogData()
log.logContent = content
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:QuantFeng,项目名称:vnpy,代码行数:8,代码来源:vtEngine.py
示例5: writeLog
def writeLog(self, content):
"""快速发出日志事件"""
log = VtLogData()
log.logContent = content
log.gatewayName = 'MAIN_ENGINE'
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:roccox,项目名称:vnpy,代码行数:8,代码来源:vtEngine.py
示例6: writeLog
def writeLog(self, content):
"""发出日志事件"""
log = VtLogData()
log.logContent = content
log.gatewayName = 'JAQS_SERVICE'
event = Event(type_=EVENT_JS_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:GenesisOrg,项目名称:vnpy,代码行数:8,代码来源:jsEngine.py
示例7: writeLog
def writeLog(self, msg):
""""""
log = VtLogData()
log.logContent = msg
event = Event(EVENT_TC_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:roccox,项目名称:vnpy,代码行数:8,代码来源:tcEngine.py
示例8: writeLog
def writeLog(self, content):
"""发出日志 """
log = VtLogData()
log.logContent = content
event = Event(EVENT_OM_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:h1222443,项目名称:vnpy,代码行数:8,代码来源:omEngine.py
示例9: writeLog
def writeLog(self, content):
"""输出日志"""
log = VtLogData()
log.logContent = content
event = Event(EVENT_SPREADTRADING_ALGOLOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:h1222443,项目名称:vnpy,代码行数:9,代码来源:stEngine.py
示例10: putSpreadPosEvent
def putSpreadPosEvent(self, spread):
"""发出价差持仓事件"""
event1 = Event(EVENT_SPREADTRADING_POS+spread.name)
event1.dict_['data'] = spread
self.eventEngine.put(event1)
event2 = Event(EVENT_SPREADTRADING_POS)
event2.dict_['data'] = spread
self.eventEngine.put(event2)
开发者ID:h1222443,项目名称:vnpy,代码行数:9,代码来源:stEngine.py
示例11: putSpreadTickEvent
def putSpreadTickEvent(self, spread):
"""发出价差行情更新事件"""
event1 = Event(EVENT_SPREADTRADING_TICK+spread.name)
event1.dict_['data'] = spread
self.eventEngine.put(event1)
event2 = Event(EVENT_SPREADTRADING_TICK)
event2.dict_['data'] = spread
self.eventEngine.put(event2)
开发者ID:h1222443,项目名称:vnpy,代码行数:9,代码来源:stEngine.py
示例12: writeLog
def writeLog(self, content):
"""记录日志"""
log = VtLogData()
log.logContent = content
log.gatewayName = self.ENGINE_NAME
event = Event(EVENT_RTDSERVICE_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:GenesisOrg,项目名称:vnpy,代码行数:9,代码来源:rtdEngine.py
示例13: cancelOrder
def cancelOrder(self, cancelOrderReq, gatewayName):
"""对特定接口撤单"""
gateway = self.getGateway(gatewayName)
event1 = Event(type_=EVENT_PRE_CANCEL_ORDER)
event1.dict_['data'] = cancelOrderReq
self.eventEngine.put(event1)
if gateway:
gateway.cancelOrder(cancelOrderReq)
开发者ID:alonemelive,项目名称:vnpy,代码行数:10,代码来源:vtEngine.py
示例14: writeLog
def writeLog(self, content, algo=None):
"""输出日志"""
log = VtLogData()
log.logContent = content
if algo:
log.gatewayName = algo.algoName
event = Event(EVENT_ALGO_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:aaront2000,项目名称:vnpy,代码行数:11,代码来源:algoEngine.py
示例15: putStrategyEvent
def putStrategyEvent(self, name):
"""触发策略状态变化事件(通常用于通知GUI更新)"""
strategy = self.strategyDict[name]
d = {k:strategy.__getattribute__(k) for k in strategy.varList}
event = Event(EVENT_CTA_STRATEGY+name)
event.dict_['data'] = d
self.eventEngine.put(event)
d2 = {k:str(v) for k,v in d.items()}
d2['name'] = name
event2 = Event(EVENT_CTA_STRATEGY)
event2.dict_['data'] = d2
self.eventEngine.put(event2)
开发者ID:chongwei111,项目名称:vnpy,代码行数:14,代码来源:ctaEngine.py
示例16: writeRiskLog
def writeRiskLog(self, content):
"""快速发出日志事件"""
# 发出报警提示音
if platform.uname() == 'Windows':
import winsound
winsound.PlaySound("SystemHand", winsound.SND_ASYNC)
# 发出日志事件
log = VtLogData()
log.logContent = content
log.gatewayName = self.name
event = Event(type_=EVENT_LOG)
event.dict_['data'] = log
self.eventEngine.put(event)
开发者ID:GenesisOrg,项目名称:vnpy,代码行数:15,代码来源:rmEngine.py
示例17: sendOrder
def sendOrder(self, orderReq, gatewayName):
"""对特定接口发单"""
# 如果创建了风控引擎,且风控检查失败则不发单
if self.rmEngine and not self.rmEngine.checkRisk(orderReq, gatewayName):
return ''
gateway = self.getGateway(gatewayName)
event1 = Event(type_=EVENT_PRE_ORDER)
event1.dict_['data'] = orderReq
self.eventEngine.put(event1)
if gateway:
vtOrderID = gateway.sendOrder(orderReq)
self.dataEngine.updateOrderReq(orderReq, vtOrderID) # 更新发出的委托请求到数据引擎中
return vtOrderID
else:
return ''
开发者ID:alonemelive,项目名称:vnpy,代码行数:18,代码来源:vtEngine.py
示例18: putParamEvent
def putParamEvent(self, algo, d):
"""更新参数"""
algoName = algo.algoName
d['algoName'] = algoName
event = Event(EVENT_ALGO_PARAM)
event.dict_['data'] = d
self.eventEngine.put(event)
# RPC推送
if self.rpcServer:
self.rpcServer.publish('AlgoTrading', event)
# 保存数据到数据库
history = self.historyDict.setdefault(algoName, {})
history['algoName'] = algoName
history['param'] = d
self.mainEngine.dbUpdate(ALGOTRADING_DB_NAME,
HISTORY_COLLECTION_NAME,
history,
{'algoName': algoName},
True)
开发者ID:aaront2000,项目名称:vnpy,代码行数:23,代码来源:algoEngine.py
示例19: processTradeEvent
def processTradeEvent(self, event):
"""处理成交推送"""
# 检查成交是否需要处理
trade = event.dict_['data']
if trade.vtSymbol not in self.legDict:
return
# 更新腿持仓
leg = self.legDict[trade.vtSymbol]
direction = trade.direction
offset = trade.offset
if direction == DIRECTION_LONG:
if offset == OFFSET_OPEN:
leg.longPos += trade.volume
else:
leg.shortPos -= trade.volume
else:
if offset == OFFSET_OPEN:
leg.shortPos += trade.volume
else:
leg.longPos -= trade.volume
leg.netPos = leg.longPos - leg.shortPos
# 更新价差持仓
spread = self.vtSymbolSpreadDict[trade.vtSymbol]
spread.calculatePos()
# 推送价差持仓更新
event1 = Event(EVENT_SPREADTRADING_POS+spread.name)
event1.dict_['data'] = spread
self.eventEngine.put(event1)
event2 = Event(EVENT_SPREADTRADING_POS)
event2.dict_['data'] = spread
self.eventEngine.put(event2)
开发者ID:h1222443,项目名称:vnpy,代码行数:36,代码来源:stEngine.py
注:本文中的vnpy.event.Event类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论