当前位置: 首页>>代码示例>>Python>>正文


Python DyEvent.data方法代码示例

本文整理汇总了Python中EventEngine.DyEvent.data方法的典型用法代码示例。如果您正苦于以下问题:Python DyEvent.data方法的具体用法?Python DyEvent.data怎么用?Python DyEvent.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventEngine.DyEvent的用法示例。


在下文中一共展示了DyEvent.data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _histDaysMannualUpdate

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _histDaysMannualUpdate(self):
        if self._histDaysMannualUpdateAction.text() == '停止':
            self._mainEngine._info.print('停止股票(指数)历史日线数据手动更新...', DyLogData.ind)

            # change UI
            self._stopRunningMutexAction()

            event = DyEvent(DyEventType.stopUpdateStockHistDaysReq)
            self._mainEngine.eventEngine.put(event)

        else: # 开始手动更新
            data = {}
            if DyStockDataHistDaysManualUpdateDlg(data, self).exec_():
                self._mainEngine._info.print('开始股票(指数,基金)历史日线数据手动更新[{0}, {1}]...'.format(data['startDate'], data['endDate']), DyLogData.ind)

                # change UI
                self._startRunningMutexAction(self._histDaysMannualUpdateAction)

                event = DyEvent(DyEventType.updateStockHistDays)
                event.data = data
                event.data['codes'] = DyStockCommon.getDyStockCodes(event.data['codes'])

                # 是否要更新指数的日线数据
                if event.data['index']:
                    if event.data['codes'] is None:
                        event.data['codes'] = []

                    event.data['codes'].extend(list(DyStockCommon.indexes))

                self._mainEngine.eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:32,代码来源:DyStockDataMainWindow.py

示例2: print

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def print(self, description, type=DyLogData.info):
        if not self._enabled and type != DyLogData.error and type != DyLogData.warning: return

        event = DyEvent(DyEventType.subLog_ + '_' + str(self._paramGroupNo) + str(self._period))
        event.data = DyLogData(description, type)

        self._outQueue.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:9,代码来源:DyCommon.py

示例3: cancel

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def cancel(self, cancelEntrust):
        """
            取消委托
        """
        # find corresponding entrust
        entrusts = self._curEntrusts.get(cancelEntrust.code)
        if entrusts is None:
            return False

        for entrust in entrusts:
            if entrust.dyEntrustId == cancelEntrust.dyEntrustId:
                break
        else:
            return False

        if entrust.isDone():
            self._info.print('{}: 撤销委托失败: {}'.format(self.__class__.__name__, entrust.__dict__, DyLogData.warning))
            return False

        if entrust.brokerEntrustId is None:
            self._curWorkingCancelEntrusts.append(entrust)
            return True

        # put cancel event
        event = DyEvent(DyEventType.stockCancel + self.broker)
        event.data = copy.copy(entrust)

        self._eventEngine.put(event)

        return True
开发者ID:hack1943,项目名称:DevilYuan,代码行数:32,代码来源:DyStockAccountManager.py

示例4: _newEntrust

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _newEntrust(self, type, datetime, strategyCls, code, name, price, volume):
        """
            生成新的委托,并向交易接口发送委托事件
        """
        # check if there's same code and type of entrust not done for different strategy
        entrusts = self._curEntrusts.get(code)
        if entrusts is not None:
            for entrust in entrusts:
                if (not entrust.isDone()) and entrust.type == type and entrust.strategyCls != strategyCls:
                    self._info.print('{}: 策略[{}]委托失败({}, {}, {}, 价格={}, 数量={}): 策略[{}]有未完成的委托'.format(self.__class__.__name__, strategyCls.chName,
                                                                                                   code, name, type, price, volume,
                                                                                                   entrust.strategyCls.chName), DyLogData.warning)
                                                                                                               
                    return None

        # create a new entrust
        curEntrustCount = self.newCurEntrustCount()

        entrust = DyStockEntrust(datetime, type, code, name, price, volume)
        entrust.dyEntrustId = '{0}.{1}_{2}'.format(self.broker, self._curTDay, curEntrustCount)
        entrust.strategyCls = strategyCls

        # add into 当日委托
        self._curEntrusts.setdefault(code, [])
        self._curEntrusts[code].append(copy.copy(entrust))

        # put buy/sell event
        eventType = DyEventType.stockBuy if type == DyStockOpType.buy else DyEventType.stockSell
        event = DyEvent(eventType + self.broker)
        event.data = copy.copy(entrust)

        self._eventEngine.put(event)

        return entrust
开发者ID:hack1943,项目名称:DevilYuan,代码行数:36,代码来源:DyStockAccountManager.py

示例5: _updateStockHistDays_Handler

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _updateStockHistDays_Handler(self, event):
        # unpack
        codes = event.data

        # check stop flag firstly
        if self._isStopped:
            self._printCount()
            self._eventEngine.put(DyEvent(DyEventType.stopAck))
            return

        # update one code each time
        code = sorted(codes)[0]
        self._updateOneCode(code, codes[code])

        # update progress
        self._progress.update()

        # delete updated code
        del codes[code]

        if not codes: # all codes are are updated
            self._printCount()
            self._eventEngine.put(DyEvent(DyEventType.finish))
            return

        # send for next updating
        event = DyEvent(DyEventType.updateStockHistDays_)
        event.data = codes

        self._eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:32,代码来源:DyStockDataDaysEngine.py

示例6: handle_msg_all

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def handle_msg_all(self, msg):
        if msg['user']['name'] == 'self':

            event = DyEvent(DyEventType.wxQueryStockStrategy)
            event.data = msg['content']['data']

            self._eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:9,代码来源:DyStockTradeWxEngine.py

示例7: progressSingle

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def progressSingle(self, percent):
        if self._progressSingle != percent:
            self._progressSingle = percent

            event = DyEvent(DyEventType.progressSingle)
            event.data = percent

            self._eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:10,代码来源:DyCommon.py

示例8: progressTotal

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def progressTotal(self, percent):
        if self._progressTotal != percent:
            self._progressTotal = percent

            event = DyEvent(DyEventType.progressTotal)
            event.data = percent

            self._eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:10,代码来源:DyCommon.py

示例9: _updateStrategyDeal

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _updateStrategyDeal(self, deal):
        """
            向UI推送策略成交事件
        """
        event = DyEvent(DyEventType.stockStrategyDealsUpdate + deal.strategyCls.name)
        event.data = [deal]

        self._eventEngine.put(event)
开发者ID:yutiansut,项目名称:DevilYuan,代码行数:10,代码来源:DyStockCtaEngine.py

示例10: _putTickEvent

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _putTickEvent(self, ctaTickDatas):
        if not ctaTickDatas:
            return

        event = DyEvent(DyEventType.stockMarketTicks)
        event.data = ctaTickDatas

        self._eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:10,代码来源:DyStockMarketEngine.py

示例11: _updateStrategyEntrust

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _updateStrategyEntrust(self, entrust):
        """
            向UI推送策略委托事件
        """
        # because only one entrust, no need OrderedDict
        event = DyEvent(DyEventType.stockStrategyEntrustsUpdate + entrust.strategyCls.name)
        event.data = {entrust.dyEntrustId: copy.copy(entrust)}

        self._eventEngine.put(event)
开发者ID:yutiansut,项目名称:DevilYuan,代码行数:11,代码来源:DyStockCtaEngine.py

示例12: _startStockCtaStrategyHandler

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _startStockCtaStrategyHandler(self, event):
        """ 启动策略, 创建唯一策略实例 """
        strategyCls = event.data['class']
        state = event.data['state']

        self._info.print('开始启动策略: {0}, 状态: {1},...'.format(strategyCls.chName, state.state), DyLogData.ind)

        # 是否是唯一策略实例
        if strategyCls.name in self._strategies:
            self._info.print('重复启动策略: {0}'.format(strategyCls.chName), DyLogData.error)
            return

        # !!!It's tricky for live trading but not accurate.
        sleep(1) # sleep so that UI related dynamic windows can be created firstly.

        # 实例化策略
        strategy = strategyCls(self, self._info, state)

        # 策略开盘前初始化
        if not strategy.onOpen(datetime.now().strftime("%Y-%m-%d"), strategy.onOpenCodes()):
            self._info.print('策略: {0}启动失败'.format(strategyCls.chName), DyLogData.error)
            return

        # 启动策略的账户管理
        if state.isState(DyStockStrategyState.running):
            if strategy.broker is not None: # Strategy has configured the broker
                if not self._startAccountManager(strategyCls):
                    return

                # 从券商管理类同步策略持仓
                self._accountManagers[strategy.broker].syncStrategyPos(strategy)
        
        # 获取策略要监控的股票池
        monitoredStocks = strategy.onMonitor()

        # 添加到策略字典
        self._strategies[strategyCls.name] = (strategy, DyStockMarketFilter(monitoredStocks))

        # 添加到bar聚合字典
        if 'bar' in strategyCls.liveMode:
            if strategyCls.liveMode not in self._barAggs:
                self._barAggs[strategyCls.liveMode] = DyStockCtaBarAggFast(strategyCls.liveMode, monitoredStocks)
            else:
                self._barAggs[strategyCls.liveMode].add(monitoredStocks)

        # 向股票市场发送监控的股票池
        monitoredStocks = monitoredStocks + [DyStockCommon.etf300, DyStockCommon.etf500] # always add ETF300 and ETF500 for 大盘参考。主要原因是历史分笔数据没有指数的,所以只能用ETF替代。
        if monitoredStocks:
            event = DyEvent(DyEventType.stockMarketMonitor)
            event.data = monitoredStocks

            self._eventEngine.put(event)

        # 向UI推送策略的账户相关事件
        self._updateStrategyAccount(strategy)

        self._info.print('策略: {0}启动成功'.format(strategyCls.chName), DyLogData.ind)
开发者ID:yutiansut,项目名称:DevilYuan,代码行数:59,代码来源:DyStockCtaEngine.py

示例13: _updateStrategyPos

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _updateStrategyPos(self, strategy):
        """
            向UI推送策略持仓更新事件
        """
        # 持仓
        event = DyEvent(DyEventType.stockStrategyPosUpdate + strategy.name)
        event.data = copy.deepcopy(strategy.curPos)

        self._eventEngine.put(event)
开发者ID:yutiansut,项目名称:DevilYuan,代码行数:11,代码来源:DyStockCtaEngine.py

示例14: putEvent

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def putEvent(self, type, data):
        """
            推送一个事件到事件引擎
            @type: 事件类型
            @data: 事件数据,一般为dict
        """
        event = DyEvent(type)
        event.data = data

        self._eventEngine.put(event)
开发者ID:yutiansut,项目名称:DevilYuan,代码行数:12,代码来源:DyStockCtaEngine.py

示例15: _limitUpStatsAct

# 需要导入模块: from EventEngine import DyEvent [as 别名]
# 或者: from EventEngine.DyEvent import data [as 别名]
    def _limitUpStatsAct(self):
        data = {}
        if not DyDateDlg(data).exec_():
            return

        event = DyEvent(DyEventType.plotReq)
        event.data =  data
        event.data['type'] = 'limitUpStats'

        self._mainEngine.eventEngine.put(event)
开发者ID:hack1943,项目名称:DevilYuan,代码行数:12,代码来源:DyStockSelectMainWindow.py


注:本文中的EventEngine.DyEvent.data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。