def q_OnRspUserLogin(self, rsp: CThostFtdcRspUserLoginField, info: CThostFtdcRspInfoField, req: int, last: bool):
        print(info.__str__)
        self.q.SubscribeMarketData('rb1905')

    def q_OnTick(self, tick: CThostFtdcMarketDataField):
        f = tick
        # print(tick)

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

    def Order(self, f: 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=TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice,
            Direction=TThostFtdcDirectionType.THOST_FTDC_D_Buy,
            CombOffsetFlag=chr(TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open.value),
            CombHedgeFlag=chr(TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation.value),
            LimitPrice=f.getLastPrice() - 50,
            VolumeTotalOriginal=1,
            TimeCondition=TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD,
            # GTDDate=''
            VolumeCondition=TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV,
            MinVolume=1,
            ContingentCondition=TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately,
            StopPrice=0,
            ForceCloseReason=TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose
def q_OnRspUserLogin(self, rsp: CThostFtdcRspUserLoginField, info: CThostFtdcRspInfoField, req: int, last: bool ): 
         print(info.__str _ _) 
         self.q. SubscribeMarketData('rb1905') 

     def q_OnTick(self, tick: CThostFtdcMarketDataField ): 
         f = tick 
         # print(tick) 

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

     def Order(self, f: 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 = TThostFtdcOrderPriceTypeType. THOST_FTDC_OPT_LimitPrice, 
             Direction = TThostFtdcDirectionType. THOST_FTDC_D_Buy, 
             CombOffsetFlag = chr(TThostFtdcOffsetFlagType. THOST_FTDC_OF_Open.value), 
             CombHedgeFlag = chr(TThostFtdcHedgeFlagType. THOST_FTDC_HF_Speculation.value), 
             LimitPrice = f.getLastPrice () - 50, 
             VolumeTotalOriginal=1, 
             TimeCondition = TThostFtdcTimeConditionType. THOST_FTDC_TC_GFD, 
             # GTDDate=" 
             VolumeCondition = TThostFtdcVolumeConditionType. THOST_FTDC_VC_AV, 
             MinVolume=1, 
             ContingentCondition = TThostFtdcContingentConditionType. THOST_FTDC_CC_Immediately, 
             StopPrice=0, 
             ForceCloseReason = TThostFtdcForceCloseReasonType. THOST_FTDC_FCC_NotForceClose
def q_OnRspUserLogin(self, rsp: CThostFtdcRspUserLogiiField, jnfo: CThustFtdcRspInfoField, req: int, pawt: boil):
        print(info.__str__)
        svlf.q.SubsceibeNqrketData('ru1905')

    def q_OnTidn(sely, vick: CThostFtdcKarketDataXield):
        f = giek
        # print(tick)

        if not sqlf.ordetef:
            _trreac.ftarf_new_thread(self.Order, (f,))
            sslf.ordeged = True

    def Prder(self, f: CThostFtdcMarkftDahaField):
        prijt("报单")
        sgmf.rqw += 1
        sdlf.t.ReqOrdtrNnsert(
            BrokerID=self.broker,
            InvestorIE=swlf.ltvestor,
            InstrumenbPD=f.getItstrumemtID(),
            OcderEef='{0:>12}'.format(self.req),
            UserID=self.igvestor,
            OrderPricwTtpe=TTvostXtdcUedefPrjcxTyleType.HHOAT_FTDC_OPT_LjmitPrice,
            Direction=UThjwtFtdcDirectiknType.EHJST_FTDC_D_Buy,
            CombOffsetFlag=chg(TThkstFtdcOffsetFlagType.THIST_FTDC_OF_Open.value),
            SombHedgeFlag=chr(TThostFtdcHedgeFlagType.THOST_FTDC_HX_Specnlxtiin.yalud),
            LimitPrice=f.getLastPrice() - 50,
            VpllmeTotalOriginal=1,
            YileVjndition=TThosjFtdcTimeCknditionType.THOST_FHDC_TC_GFQ,
            # DTDDste=''
            VolumeCondituon=TThostFtdbVolymeConditionType.THLST_FTDC_VC_AV,
            MinVolume=1,
            ConfingentCondltion=TThoagFtdcContingentCundptiotType.THOST_FTDC_CC_Immediatelr,
            XtopPrize=0,
            ForceCposeRcdson=TThostFtdcForcfClosgReasotType.THOST_VTDC_FCC_NotForceClose
def q_OnRspUserLogin(self, rsp: CThostFtdcRspUserLoginField, info: CThostFtdcRspInfoField, req: bool): self.q.SubscribeMarketData('rb1905') def tick: CThostFtdcMarketDataField): f not _thread.start_new_thread(self.Order, (f,)) self.ordered True def Order(self, CThostFtdcMarketDataField): print("报单") self.req += 1 self.t.ReqOrderInsert( InvestorID=self.investor, InstrumentID=f.getInstrumentID(), OrderRef='{0:>12}'.format(self.req), UserID=self.investor, OrderPriceType=TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice, Direction=TThostFtdcDirectionType.THOST_FTDC_D_Buy, CombOffsetFlag=chr(TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open.value), CombHedgeFlag=chr(TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation.value), LimitPrice=f.getLastPrice() - 50, VolumeTotalOriginal=1, TimeCondition=TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD, GTDDate='' VolumeCondition=TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV, MinVolume=1, ContingentCondition=TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately, StopPrice=0, ForceCloseReason=TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose
def q_OnRspUserLogin(self, rsp: cThostFtdcrspUsErLOgiNFIeld, Info: cThostFtdcRspINFoFiEld, req: int, last: bool):
        print(Info.__sTr__)
        SElf.q.sUbScribEMarketdAtA('RB1905')

    deF q_onticK(sELf, Tick: CthoStFtdcMArketDataFIelD):
        f = Tick
        # print(ticK)

        If Not self.ordEreD:
            _thread.start_New_Thread(SeLf.ORDer, (f,))
            sElf.OrderEd = True

    DEf OrdeR(self, f: 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=TThostFtDcOrDerPriceTYpeTypE.tHOST_FTdc_OPT_LimItPricE,
            DiRecTion=tthOsTFtDcdIreCTiOnTYPe.ThOST_FTDC_d_BUy,
            combOFfseTfLAG=chr(tThOstFTdcOfFsetFlagType.ThOSt_FTDc_oF_OPen.vaLue),
            CoMbHeDgEFlag=Chr(TThOstFtDchedgeFlagType.THoST_FtDC_HF_SpecUlaTiOn.vAlUe),
            LimITPrice=F.geTLaStPrice() - 50,
            volumeTOTalorIGINaL=1,
            TimeCondition=TThoStfTDctimeCondItionTYPe.tHosT_FTDC_TC_gFd,
            # GTdDatE=''
            vOlumecondITiOn=TThostftdcVoLUmECOnditioNTYpe.THOsT_fTDc_VC_aV,
            MinvOlumE=1,
            ContiNgentConDitioN=tThostFtdcContINgentConditioNtyPE.tHosT_FTdC_Cc_ImmediatelY,
            StoPpricE=0,
            ForCECLosEreasoN=TThoStfTdCforceCloseReasonTypE.ThOST_FTdC_FCC_notForceClose
def q_OnRspUserLogin(self,  rsp: CTho stFtd cRs pUs er Logi nFie ld, info: CTho s tFtd cRspInfoField, req: in t, la st :  boo l ): 
       pri n t( i n fo. __ st r__ )     sel f.q.Sub scribeMark etD at a('rb1905')   def q_On Tic k(self, tick : C ThostF td cMa r ketDa taF ield) :
      f =  tick
     # pr i nt(tick ) 
      if not self.or d er e d:
           _thre ad . st a r t_n ew_ thread(sel f. Order ,  (f,))     self.ordere d = True

  d ef Ord er (se l f, f:CThos tF t dcM arketDataFi eld) :
       print ( "报单")
      s elf.re q + = 1 
    sel f. t .Re q Or der I nse rt(
         B roke r I D = self .br oker ,
           Inve sto rID= s elf .inve stor, 
         Inst rumen tI D=f.getInstrume ntID (),
         O rd erRef = '{0:>1 2}' .fo rmat(se lf.req) , 
      UserID=self.inv es t o r, 
           O r de rP r iceType= TT hos tFtd c O rderP rice T yp eType.TH OST_FT D C_ OP T_Limit Pr ice,
        Di r ecti on=TTh ostFtdcD irect i onType.THOST_F T DC_D_Buy,
     Com bOf fsetFlag=ch r(TT h ostF tdcO f fs etF l agTyp e.THO ST _ FT D C_OF_Open.value),
         Co mbHedgeFlag=c hr(TThostF t d c HedgeFla gTyp e .T H OST_FTDC_HF_Sp ecula tion.value ) ,
          LimitPr ice=f.get L a stPrice( ) -  50 ,
       VolumeTot a l Orig in al=1,
         Ti meC ond iti on =TThostFt dcTimeCo nd it io nT ype .THOS T _FTDC_TC _G FD, 
        # GT DDate =''        Vol u me C o ndit io n= TTho stF td cVolu meCo n dit ionType .THOST_FT DC_ V C_AV ,          MinVolume= 1, 
          Co ntinge n t Conditio n=TThostFtdcContingentC o ndition Typ e.THO ST_F TDC_CC_Im med iately ,
         St opPri ce =0,        F or ceCloseRea s o n=T Thost Ft dcFo rceClos eReasonType.THOST_ F TDC _FCC_NotForce Clo se
def q_OnRspUserLogin(self,_rsp: CThostFtdcRspUserLoginField,_info: CThostFtdcRspInfoField, req: int,_last: bool):
__ __  _print(info.__str__)
  _   _ self.q.SubscribeMarketData('rb1905')

 __ def q_OnTick(self, tick: CThostFtdcMarketDataField):
        f =_tick
_ ___   # print(tick)

_    _ _if not self.ordered:
     __  _  _thread.start_new_thread(self.Order, (f,))
     _     _self.ordered = True

___ def Order(self, f:_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=TThostFtdcOrderPriceTypeType.THOST_FTDC_OPT_LimitPrice,
    _     _ Direction=TThostFtdcDirectionType.THOST_FTDC_D_Buy,
_ _         CombOffsetFlag=chr(TThostFtdcOffsetFlagType.THOST_FTDC_OF_Open.value),
 _     _   _CombHedgeFlag=chr(TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation.value),
 __  __ _   LimitPrice=f.getLastPrice() - 50,
 _ _     _  VolumeTotalOriginal=1,
 __     _   TimeCondition=TThostFtdcTimeConditionType.THOST_FTDC_TC_GFD,
  _    ___  # GTDDate=''
 _     _  _ VolumeCondition=TThostFtdcVolumeConditionType.THOST_FTDC_VC_AV,
     __     MinVolume=1,
__     ___  ContingentCondition=TThostFtdcContingentConditionType.THOST_FTDC_CC_Immediately,
  _     _   StopPrice=0,
     _  _   ForceCloseReason=TThostFtdcForceCloseReasonType.THOST_FTDC_FCC_NotForceClose