def on_rsp_qry_instrument(self, instrument, rsp_err_id, rsp_err_msg, request_id, is_last): print(self.__class__.__name__, tdapi.get_current_function_name(), instrument, rsp_err_id, rsp_err_msg, request_id, is_last) inst_id = instrument['InstrumentID'] if inst_id in self._inst_info: self._inst_info[inst_id][0] = instrument else: self._inst_info[inst_id] = [copy.copy(instrument), None, None] param = { 'BrokerID': self._broker_id, 'InstrumentID': instrument['InstrumentID'], 'InvestorID': self._investor_id, 'ExchangeID': instrument['ExchangeID'] } self._api.req_qry_otp_ins_comm_rate(param, self.get_next_id()) param['HedgeFlag'] = userapidef.KS_OTP_CIDT_UnCovered self._api.req_qry_otp_ins_margin_rate(param, self.get_next_id()) self._instruments.append(instrument['InstrumentID']) self._qry_inst_ok = is_last self._isOk = is_last
def on_rsp_user_login(self, rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last): if not is_last: return print(self.__class__.__name__, tdapi.get_current_function_name(), rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last) print(rsp_err_msg.decode('GBK')) # print("login", self._api.get_trading_day()) # print(rsp_user_login['SystemName'].decode('GBK')) self._api.subscribe_private_topic(userapidef.KS_OTP_TERT_RESUME) self._api.subscribe_public_topic(userapidef.KS_OTP_TERT_RESUME) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_settlement_info_confirm(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_trading_account(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor(param, self.get_next_id()) param = {'ExchangeID': self._exchange} print self._api.req_qry_instrument(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor_position(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor_position_detail( param, self.get_next_id())
def on_rsp_user_login(self, rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last): if not is_last: return print( self.__class__.__name__, tdapi.get_current_function_name(), rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last) print(rsp_err_msg.decode('GBK')) # print("login", self._api.get_trading_day()) # print(rsp_user_login['SystemName'].decode('GBK')) self._api.subscribe_private_topic(userapidef.KS_OTP_TERT_RESUME) self._api.subscribe_public_topic(userapidef.KS_OTP_TERT_RESUME) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_settlement_info_confirm(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_trading_account(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor(param, self.get_next_id()) param = {'ExchangeID': self._exchange} print self._api.req_qry_instrument(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor_position(param, self.get_next_id()) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id} print self._api.req_qry_investor_position_detail(param, self.get_next_id())
def on_rsp_user_login(self, rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last): print( self.__class__.__name__, tdapi.get_current_function_name(), rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last) print("login", self._api.get_trading_day()) print(self._api.subscribe_market_data(self._instruments))
def on_rsp_qry_order(self, order, rsp_err_id, rsp_err_msg, request_id, is_last): global orders if len(order) > 0: #order['VolumeTotalOriginal'] = order['VolumeTraded'] if order['OrderSysID'] != 0: print( self.__class__.__name__, tdapi.get_current_function_name(), order, rsp_err_id, rsp_err_msg, request_id, is_last) param = {'BrokerID': self._broker_id, 'InvestorID': self._investor_id, 'OrderRef': order['OrderRef'], 'FrontID': order['FrontID'], 'SessionID': order['SessionID'], 'ExchangeID': order['ExchangeID'], 'OrderSysID': order['OrderSysID']} print(self._api.req_order_action(param, self.get_next_id())) if order['OrderStatus'] in (userapidef.KS_OTP_OST_Canceled, userapidef.KS_OTP_OST_AllTraded): orders.clear()
def on_rsp_qry_instrument(self, instrument, rsp_err_id, rsp_err_msg, request_id, is_last): print( self.__class__.__name__, tdapi.get_current_function_name(), instrument, rsp_err_id, rsp_err_msg, request_id, is_last) inst_id = instrument['InstrumentID'] if inst_id in self._inst_info: self._inst_info[inst_id][0] = instrument else: self._inst_info[inst_id] = [copy.copy(instrument), None, None] param = {'BrokerID': self._broker_id, 'InstrumentID': instrument['InstrumentID'], 'InvestorID': self._investor_id, 'ExchangeID': instrument['ExchangeID']} self._api.req_qry_otp_ins_comm_rate(param, self.get_next_id()) param['HedgeFlag'] = userapidef.KS_OTP_CIDT_UnCovered self._api.req_qry_otp_ins_margin_rate(param, self.get_next_id()) self._instruments.append(instrument['InstrumentID']) self._qry_inst_ok = is_last self._isOk = is_last
def on_rsp_qry_order(self, order, rsp_err_id, rsp_err_msg, request_id, is_last): global orders if len(order) > 0: #order['VolumeTotalOriginal'] = order['VolumeTraded'] if order['OrderSysID'] != 0: print(self.__class__.__name__, tdapi.get_current_function_name(), order, rsp_err_id, rsp_err_msg, request_id, is_last) param = { 'BrokerID': self._broker_id, 'InvestorID': self._investor_id, 'OrderRef': order['OrderRef'], 'FrontID': order['FrontID'], 'SessionID': order['SessionID'], 'ExchangeID': order['ExchangeID'], 'OrderSysID': order['OrderSysID'] } print(self._api.req_order_action(param, self.get_next_id())) if order['OrderStatus'] in (userapidef.KS_OTP_OST_Canceled, userapidef.KS_OTP_OST_AllTraded): orders.clear()
def on_rsp_user_login(self, rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last): print(self.__class__.__name__, tdapi.get_current_function_name(), rsp_user_login, rsp_err_id, rsp_err_msg, request_id, is_last) print("login", self._api.get_trading_day()) print(self._api.subscribe_market_data(self._instruments))
def on_rtn_trade(self, trade): print(self.__class__.__name__, tdapi.get_current_function_name(), trade)
def on_rtn_order(self, order): print(self.__class__.__name__, tdapi.get_current_function_name(), order)
def on_rsp_order_insert(self, input_order, rsp_err_id, rsp_err_msg, request_id, is_last): print(rsp_err_msg.decode('GBK')) print(self.__class__.__name__, tdapi.get_current_function_name(), input_order, rsp_err_id, rsp_err_msg, request_id, is_last)
def on_rsp_order_insert(self, input_order, rsp_err_id, rsp_err_msg, request_id, is_last): print(rsp_err_msg.decode('GBK')) print( self.__class__.__name__, tdapi.get_current_function_name(), input_order, rsp_err_id, rsp_err_msg, request_id, is_last)