def __init__(self, userid, password, brokerid, RegisterFront, product_info, app_id, auth_code): # 创建 Trade 的类 self.t = Trade() # 建立好 帐户类 self.userid = userid self.password = password self.brokerid = brokerid self.product_info = product_info self.auth_code = auth_code self.app_id = app_id api = self.t.CreateApi() spi = self.t.CreateSpi() self.t.RegisterSpi(spi) self.t.OnFrontConnected = self.onFrontConnected # 交易服务器登陆相应 self.t.OnFrontDisconnected = self.onFrontDisconnected # 交易服务器断开连接的情况 self.t.OnRspAuthenticate = self.onRspAuthenticate # 申请码检验 self.t.OnRspUserLogin = self.onRspUserLogin # 用户登陆 self.t.OnRspUserLogout = self.onRspUserLogout # 用户登出 self.t.OnRspQryDepthMarketData = self.onRspQryDepthMarketData # 查询涨跌停 self.t.OnRtnInstrumentStatus = self.onRtnInstrumentStatus self.t.OnRspQryInstrument = self.onRspQryInstrument self.t.OnErrRtnOrderInsert = self.onErrRtnOrderInsert self.t.OnRtnOrder = self.onRtnOrder self.t.OnRtnTrade = self.onRtnTrade self.t.RegCB() self.t.RegisterFront(RegisterFront) self.t.Init() self.isLogin = False
def __init__(self, userid, password, brokerid, RegisterFront, product_info, app_id, auth_code): # 初始化账号 self.t = Trade() self.userid = userid self.password = password self.brokerid = brokerid self.product_info = product_info self.app_id = app_id self.auth_code = auth_code api = self.t.CreateApi() spi = self.t.CreateSpi() self.t.RegisterSpi(spi) self.t.OnFrontConnected = self.onFrontConnected # 交易服务器登陆相应 self.t.OnFrontDisconnected = self.onFrontDisconnected self.t.OnRspAuthenticate = self.onRspAuthenticate # 申请码检验 self.t.OnRspUserLogin = self.onRspUserLogin # 用户登陆 self.t.OnRspUserLogout = self.onRspUserLogout # 用户登出 self.t.OnRtnInstrumentStatus = self.onRtnInstrumentStatus self.t.OnRspQryInstrument = self.onRspQryInstrument # 查询全部交易合约 self.t.OnRspSettlementInfoConfirm = self.onRspSettlementInfoConfirm # 结算单确认,显示登陆日期 self.t.OnRspQryTradingAccount = self.onRspQryTradingAccount # 查询账户 self.t.OnRtnOrder = self.onRtnOrder # 报单 self.t.OnRtnTrade = self.onRtnTrade # 成交 # self.t.OnRspParkedOrderInsert = self.onRspParkedOrderInsert self.t.OnErrRtnOrderInsert = self.onErrRtnOrderInsert self.t.OnRspQryDepthMarketData = self.onRspQryDepthMarketData # 查询涨跌停 self.t.RegCB() self.t.RegisterFront(RegisterFront) self.t.Init() self.islogin = False
def __init__(self): self.Session = '' self.q = Quote() self.t = Trade() self.req = 0 self.ordered = False self.needAuth = False self.RelogEnable = True
def __init__(self, address, broker, investor, passwd): self.Session = '' dllpath = os.path.join( os.path.split(os.path.realpath(__file__))[0], '..', 'dll') self.t = Trade( os.path.join( dllpath, 'ctp_trade.' + ('dll' if 'Windows' in platform.system() else 'so'))) self.address = address self.broker = broker self.investor = investor self.pwd = passwd self.RelogEnable = True self.req = 0
def __init__(self): self.Session = '' dllpath = os.path.join( os.path.split(os.path.realpath(__file__))[0], '..', 'dll') self.q = Quote( os.path.join( dllpath, 'ctp_quote.' + ('dll' if 'Windows' in platform.system() else 'so'))) self.t = Trade( os.path.join( dllpath, 'ctp_trade.' + ('dll' if 'Windows' in platform.system() else 'so'))) self.req = 0 self.ordered = False self.needAuth = False self.RelogEnable = True
def __init__(self, dll_relative_path: str = 'dll'): self.front_address = '' self.investor = '' self.password = '' self.broker = '' self.logined = False self.tradingday = '' self.instruments = {} self.orders = {} self.trades = {} self.account: TradingAccount = None self.positions = {} self.instrument_status = {} self._req = 0 self._session = '' self._orderid_sysid = {} self._posi = [] self.t = Trade(os.path.join(os.getcwd(), dll_relative_path, 'ctp_trade.' + ('dll' if 'Windows' in platform.system() else 'so')))