def _snapShotTrigger(self, event): # 未选择即时行情触发 # if not self._dataModel.getConfigModel().hasSnapShotTrigger() or not self.isRealTimeStatus(): # return # # # 该合约不触发 # if event.getContractNo() not in self._dataModel.getConfigModel().getTriggerContract(): # return if not self.isRealTimeStatus(): return # 对应字段没有变化不触发 data = event.getData() if len(data) == 0 or (not set(data[0]["FieldData"].keys()) & set([4, 11, 17, 18, 19, 20])): # 4:最新价 11:成交量 17:最优买价 18:买量 19:最优卖价 20:卖量 return dateTimeStamp, tradeDate, lv1Data = self.getTriggerTimeAndData( event.getContractNo()) event = Event({ "EventCode": ST_TRIGGER_SANPSHOT_FILL, "ContractNo": event.getContractNo(), "KLineType": None, "KLineSlice": None, "Data": { "Data": lv1Data, "DateTimeStamp": dateTimeStamp, "TradeDate": tradeDate, "IsLastPriceChanged": 4 in data[0]["FieldData"], # 最新价是否改变 } }) self.sendTriggerQueue(event)
def _snapShotTrigger(self, event): if not self._dataModel.getConfigModel().hasSnapShotTrigger(): return if event.getContractNo() not in self._dataModel.getConfigModel( ).getTriggerContract(): return if not self.isRealTimeStatus(): return lv1DataAndUpdateTime = self._dataModel.getQuoteModel( ).getLv1DataAndUpdateTime(event.getContractNo()) event = Event({ "EventCode": ST_TRIGGER_SANPSHOT, "ContractNo": event.getContractNo(), "Data": { "TriggerType": "SnapShot", "Data": lv1DataAndUpdateTime } }) self.sendTriggerQueue(event)