Example #1
0
 def Order(self, f: ctp.CThostFtdcMarketDataField):
     print("报单")
     self.req += 1
     self.t.ReqOrderInsert(
         BrokerID=self.broker,
         InvestorID=self.investor,
         InstrumentID=f.getInstrumentID(),
         OrderRef='{0:>12}'.format(self.req),
         UserID=self.investor,
         OrderPriceType=ctp.OrderPriceTypeType.LimitPrice,
         Direction=ctp.DirectionType.Buy,
         CombOffsetFlag=ctp.OffsetFlagType.Open.__char__(),
         CombHedgeFlag=ctp.HedgeFlagType.Speculation.__char__(),
         LimitPrice=f.getLastPrice() - 50,
         VolumeTotalOriginal=1,
         TimeCondition=ctp.TimeConditionType.GFD,
         # GTDDate=''
         VolumeCondition=ctp.VolumeConditionType.AV,
         MinVolume=1,
         ContingentCondition=ctp.ContingentConditionType.Immediately,
         StopPrice=0,
         ForceCloseReason=ctp.ForceCloseReasonType.NotForceClose,
         IsAutoSuspend=0,
         IsSwapOrder=0,
         UserForceClose=0)
Example #2
0
 def q_OnTick(self, tick: ctp.CThostFtdcMarketDataField):
     print("----enter q_OnTick---------", tick.getUpdateTime(),
           tick.getInstrumentID(), tick.getLastPrice())
     instrustmentId = tick.getInstrumentID()
     OrderDict[instrustmentId].lastPrice = tick.getLastPrice()
     OrderDict[instrustmentId].attr = tick
     print(OrderDict[instrustmentId].lastPrice)
Example #3
0
 def Order(self, f: ctp.CThostFtdcMarketDataField):
     print("报单")
     self.req += 1
     self.t.ReqOrderInsert(
         BrokerID=self.broker,
         InvestorID=self.investor,
         InstrumentID=f.getInstrumentID(),
         OrderRef='{0:>12}'.format(self.req),
         UserID=self.investor,
         OrderPriceType=ctp.TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice,
         Direction=ctp.TThostFtdcDirectionType.THOST_FTDC_D_Buy,
         CombOffsetFlag=chr(ctp.TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open.value),
         CombHedgeFlag=chr(ctp.TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation.value),
         LimitPrice=f.getLastPrice() - 50,
         VolumeTotalOriginal=1,
         TimeCondition=ctp.TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD,
         # GTDDate=''
         VolumeCondition=ctp.TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV,
         MinVolume=1,
         ContingentCondition=ctp.TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately,
         StopPrice=0,
         ForceCloseReason=ctp.TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose,
         IsAutoSuspend=0,
         IsSwapOrder=0,
         UserForceClose=0)
Example #4
0
    def q_OnTick(self, tick: ctp.CThostFtdcMarketDataField):
        print("----enter q_OnTick---------", tick.getUpdateTime(),
              tick.getInstrumentID(), tick.getLastPrice())
        f = tick
        # print(tick)

        if not self.ordered:
            _thread.start_new_thread(self.Order, (f, ))
            self.ordered = True