當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。