def OnFrontConnected(self): print('*************** OnFrontConnected') self.ReqUserLogin( ApiStruct.ReqUserLogin(BrokerID=self._broker, UserID=self._investor, Password=self._password), self.req_id, )
def OnFrontConnected(self): print('*************** OnFrontConnected') self.ReqAuthenticate( ApiStruct.ReqAuthenticate(BrokerID=self._broker, UserID=self._investor, AppID=self._app_id, AuthCode=self._auth_code), self.req_id, )
def OnRspSettlementInfoConfirm(self, pSettlementInfoConfirm, pRspInfo, nRequestID, bIsLast): if pRspInfo.ErrorID > 0: print( '*************** OnRspSettlementInfoConfirm ERROR: {}'.format( pRspInfo.ErrorMsg.decode(encoding='gb2312'))) else: print('*************** OnRspSettlementInfoConfirm') self.ReqQryInstrument( ApiStruct.QryInstrument(), self.req_id, )
def OnRspAuthenticate(self, pRspAuthenticate, pRspInfo, nRequestID, bIsLast): if pRspInfo is not None and pRspInfo.ErrorID > 0: print('*************** OnRspAuthenticate ERROR: {}'.format( pRspInfo.ErrorMsg.decode(encoding='gb2312'))) return print('*************** OnRspAuthenticate') self.ReqUserLogin( ApiStruct.ReqUserLogin(BrokerID=self._broker, UserID=self._investor, Password=self._password), self.req_id, )
def OnRspUserLogin(self, pRspUserLogin, pRspInfo, nRequestID, bIsLast): if pRspInfo.ErrorID > 0: print('*************** OnRspUserLogin ERROR: {}'.format( pRspInfo.ErrorMsg.decode(encoding='gb2312'))) else: print('*************** OnRspUserLogin') self._front_id, self._session_id = pRspUserLogin.FrontID, pRspUserLogin.SessionID if pRspUserLogin.MaxOrderRef: self._order_ref = int( pRspUserLogin.MaxOrderRef.decode(encoding='gb2312')) self.ReqSettlementInfoConfirm( ApiStruct.SettlementInfoConfirm(BrokerID=self._broker, InvestorID=self._investor), self.req_id, )
def send_order(self, code, direction, volume, price, offset_flag): order = ApiStruct.InputOrder( BrokerID=self._broker, InvestorID=self._investor, UserID=self._investor, OrderRef=bytes(self.order_ref, encoding='gb2312'), InstrumentID=bytes(code, encoding='gb2312'), Direction=direction, VolumeTotalOriginal=volume, LimitPrice=price, CombOffsetFlag=offset_flag, OrderPriceType=b'2', VolumeCondition=b'1', MinVolume=1, ForceCloseReason=b'0', IsAutoSuspend=0, UserForceClose=0, CombHedgeFlag=b'1', ContingentCondition=b'1', TimeCondition=b'3', ) self.ReqOrderInsert(order, self.req_id)