def user_login(self, broker_id, investor_id, password): req = ApiStruct.ReqUserLogin(BrokerID=broker_id, UserID=investor_id, Password=password) self.request_id += 1 ret = self.ReqUserLogin(req, self.request_id)
def formatOrder(self, inst, direc, open_close, volume, price): return ApiStruct.InputOrder( InstrumentID=inst, Direction=direc, # ApiStruct.D_Buy or ApiStruct.D_Sell OrderRef=str(Strategy.traderSpi.inc_request_id()), LimitPrice=price, VolumeTotalOriginal=volume, OrderPriceType=ApiStruct.OPT_LimitPrice, BrokerID=Strategy.traderSpi.broker_id, InvestorID=Strategy.traderSpi.investor_id, CombOffsetFlag=open_close, # OF_Open, OF_Close, OF_CloseToday CombHedgeFlag=ApiStruct.HF_Speculation, VolumeCondition=ApiStruct.VC_AV, MinVolume=1, ForceCloseReason=ApiStruct.FCC_NotForceClose, IsAutoSuspend=1, UserForceClose=0, TimeCondition=ApiStruct.TC_GFD, )
def OnRspUserLogin(self, userlogin, info, rid, is_last): if is_last and not self.isErrorRspInfo(info): logger.info('OnRspUserLogin %s' % is_last) req = ApiStruct.SettlementInfoConfirm(BrokerID=self.broker_id, InvestorID=self.investor_id) self.ReqSettlementInfoConfirm(req, self.inc_request_id())
def OnFrontConnected(self): logger.info('OnFrontConnected') req = ApiStruct.ReqUserLogin(BrokerID=self.broker_id, UserID=self.investor_id, Password=self.passwd) self.ReqUserLogin(req, self.inc_request_id())