當前位置: 首頁>>代碼示例>>Python>>正文


Python DyEvent.data['data']方法代碼示例

本文整理匯總了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)
開發者ID:yutiansut,項目名稱:DevilYuan,代碼行數:9,代碼來源:DyStockCtaEngine.py

示例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)
開發者ID:hack1943,項目名稱:DevilYuan,代碼行數:60,代碼來源:DyStockAccountManager.py

示例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)
開發者ID:yutiansut,項目名稱:DevilYuan,代碼行數:39,代碼來源:DyStockCtaEngine.py


注:本文中的EventEngine.DyEvent.data['data']方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。