# encoding:utf-8
# distutils: language=c++
from cpython cimport PyObject
from libc.stdlib cimport malloc, free
from libc.string cimport const_char
from libcpp cimport bool as cbool

from .cython2c.ThostFtdcUserApiStruct cimport *
from .cython2c.cTraderApi cimport CTraderSpi, CTraderApi, CreateFtdcTraderApi

# from libcpp.memory cimport shared_ptr,make_shared
import ctypes
import configparser

from imp import reload
import time
from   datetime import datetime
import pymysql
import sys
import collections
import traceback

import ptp_env            as myEnv
import cfg.ptp_can_change_env as myDEnv

from ptp       import py_ApiStructure

def  toString(val):
    if isinstance(val,bytes):
        myVal = bytes.decode(val,encoding="gb18030", errors="ignore")
    elif isinstance(val,(int,float)):
        myVal = str(val)
    else:
        myVal = val

    return myVal

def nvl(p1, p2):
  if p1 is None:
    return p2
  else:
    return p1
    
def  printString(fileName, key, val, dwTimes=1):
    config = configparser.ConfigParser()
    config.read("ptp.ini",encoding="utf-8")

    if isinstance(val,bytes):
        myVal = bytes.decode(val,encoding="gb18030", errors="ignore")
    elif isinstance(val,(int,float)):
        myVal = str(val)
    else:
        myVal = val
    try:
        detail = config.get("PYTHON_SWITCH", "detail")
        debug  = config.get("PYTHON_SWITCH", "debug")
    except Exception as err:
        print(err)

    if debug == "1":
        with open("py2c_"+ fileName + ".log", "a+") as f:
            f.write(str(dwTimes) + ":" + key + "=" + myVal + "\n")
    if detail == "1":
        with open("py2c_all.log", "a+") as f:
            f.write(str(dwTimes) + ":" + key + "=" + myVal + "\n")

def  printNumber(fileName, key, val, dwTimes=1):
    config = configparser.ConfigParser()
    config.read("ptp.ini",encoding="utf-8")
    try:
        detail = config.get("PYTHON_SWITCH", "detail")
        debug = config.get("PYTHON_SWITCH", "debug")
    except Exception as err:
        print(err)

    if debug == "1":
        with open("py2c_"+ fileName + ".log", "a+") as f:
            f.write(str(dwTimes) + ":" + key + "=" + str(val) + "\n")
    if detail == "1":
        with open("py2c_all.log", "a+") as f:
            f.write(str(dwTimes) + ":" + key + "=" + str(val) + "\n")

def nvl(p1, p2):
  if p1 is None:
    return p2
  else:
    return p1

cdef class TraderApiWrapper:
    cdef CTraderApi *_api
    cdef CTraderSpi *_spi
    
    def __cinit__(self):
        funName = "%s.%s" % ("TraderApiWrapper", "__cinit__")
        printString("Trader_call_stack","call->",funName)

        try:
            self._api = NULL
            self._spi = NULL 
            

            self.__update_factor_date = datetime.now()
            self.__RequestID = 1
            self.__id        = 1
            self.__instrument_trade_list = []
            #记录报单，用于模拟时行情驱动自动成交的报单簿
            self.__instrument_req_order_dict = collections.OrderedDict()
            #记录报单回报，用于撤单
            self.__instrument_rtn_order_dict = collections.OrderedDict()
            #记录仓位回报，用于平仓
            self.__instrument_position_dict = collections.OrderedDict()
            #合约属性
            self.__instrument_attr_dict = collections.OrderedDict()

            try:
                myEnv.logger.info("get config for Trader")

                self.config= configparser.ConfigParser()
                self.config.read("ptp.ini",encoding="utf-8")

                self.sim         = int(self.config.get("TRADE_RULE", "sim"))
                self.upload      = int(self.config.get("CLOUD", "upload"))
                self.cloud_debug = int(self.config.get("CLOUD", "debug"))
                self.array_size  = int(self.config.get("CLOUD", "array_size"))
            except Exception as err:
                myEnv.logger.error('Trader get config error', exc_info=True)


            printString("Trader_call_stack","call-<",funName)

        except Exception as err:
            myEnv.logger.error('Tader.__cinit__', exc_info=True)

    def Inc_RequestID(self):
        self.__RequestID = self.__RequestID + 1
        return self.__RequestID

    
    def  get_InstrumentAttr(self, instrumentID):
        l_dict={}

        if not instrumentID is None :
            l_dict= self.__instrument_attr_dict.get(instrumentID)

        return l_dict

    def get_Order_list(self, instrumentID):
        l_list=[]
        if not instrumentID is None :
            l_list= self.__instrument_rtn_order_dict.get(instrumentID)

        return l_list


    def get_Position(self, instrumentID):
        l_list=[]

        if not instrumentID is None :
            l_list= self.__instrument_position_dict.get(instrumentID)

        return l_list

    def get_ReqOrderList(self, instrumentID):
        l_list=[]

        if not instrumentID is None :
            l_list= self.__instrument_req_order_dict.get(instrumentID)

        return l_list 

    def __dealloc__(self):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)
        self.Release()
        printString("Trader_call_stack","call-<",funName)

    def Create(self, const_char *pszFlowPath):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)
        self._api = CreateFtdcTraderApi(pszFlowPath)
        if not self._api:
            raise MemoryError()
        printString("Trader_call_stack","call-<",funName)

    @staticmethod
    def GetApiVersion():
        funName = "%s.%s" % ("Trader", "GetApiVersion")
        printString("Trader_call_stack","call->",funName)
        return CTraderApi.GetApiVersion()
        printString("Trader_call_stack","call-<",funName)

    def Release(self):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        if self._api is not NULL:
            self._api.RegisterSpi(NULL)
            self._api.Release()
            self._api = NULL
            self._spi = NULL

        printString("Trader_call_stack","call-<",funName)

    def Init(self):
        try:
          funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
          printString("Trader_call_stack","call->",funName)

          self.Create(self.pszFlowPath.encode())
          logDes="step 1(of 5 step)"
          myEnv.logger.info(logDes)

          if self._api is not NULL:
            self._spi = new CTraderSpi(<PyObject *> self)

            if self._spi is not NULL:
              self._api.RegisterSpi(self._spi)
              logDes="step 2(of 5 step)"

              self.SubscribePrivateTopic(self.PrivateSubscribeTopic)
              self.SubscribePublicTopic( self.PublicSubscribeTopic)
              logDes="step 3(of 5 step)"

              #SSL前置格式：ssl://192.168.0.1:41205
              #TCP前置格式：tcp://192.168.0.1:41205
              #此处注册多个前置，连接的时候会随机选择一个
              #pUserMdApi->RegisterFront(“tcp://192.168.0.1:41213”);
              #pUserMdApi->RegisterFront(“tcp://192.168.0.2:41213”);
              for server in self.trader_server:
                #server = "tcp://" + self.md_server + ":" + str(self.md_port)
                myEnv.logger.info("regist " + server)
                self.RegisterFront(server.encode())
              logDes="step 4(of 5 step)"

              time.sleep(1)

              self._api.Init()
              logDes="step 5(of 5 step)"
            else:
              myEnv.logger.error('new CTraderSpi')
              raise MemoryError()
          else:
            myEnv.logger.error('Create')

          myEnv.logger.info(logDes)
          time.sleep(1)

          printString("Trader_call_stack","call-<",funName)

        except Exception as err:
            myEnv.logger.error('Tader.Init', exc_info=True)

    def Join(self):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        cdef int result
        try:
            if self._spi is not NULL:
                with nogil:
                    result = self._api.Join()
                return result

        except Exception as err:
            myEnv.logger.error('Join', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

    def GetTradingDay(self):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        cdef const_char *result

        try:
            if self._spi is not NULL:
                with nogil:
                    result = self._api.GetTradingDay()
                return result
        except Exception as err:
            myEnv.logger.error('GetTradingDay', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

    def RegisterFront(self, char *pszFrontAddress):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        try:
            if self._api is not NULL:
                self._api.RegisterFront(pszFrontAddress)
        except Exception as err:
            myEnv.logger.error('RegisterFront', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

    def RegisterNameServer(self, char *pszNsAddress):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        try:
            if self._api is not NULL:
                self._api.RegisterNameServer(pszNsAddress)
        except Exception as err:
            myEnv.logger.error('RegisterNameServer', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

    def RegisterFensUserInfo(self, pFensUserInfo):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)

        cdef size_t address
        try:
            if self._api is not NULL:
                address = ctypes.addressof(pFensUserInfo)

                self._api.RegisterFensUserInfo(<CThostFtdcFensUserInfoField *> address)

        except Exception as err:
            myEnv.logger.error('RegisterFensUserInfo', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

    def SubscribePrivateTopic(self, THOST_TE_RESUME_TYPE nResumeType):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)
        try:
            if self._api is not NULL:
                self._api.SubscribePrivateTopic(nResumeType)
        except Exception as err:
            myEnv.logger.error('SubscribePrivateTopic', exc_info=True)
        printString("Trader_call_stack","call-<",funName)

    #订阅公共流。
    #@param nResumeType 公共流重传方式
    #        THOST_TERT_RESTART:从本交易日开始重传
    #        THOST_TERT_RESUME:从上次收到的续传
    #        THOST_TERT_QUICK:只传送登录后公共流的内容
    #@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。
    def SubscribePublicTopic(self, THOST_TE_RESUME_TYPE nResumeType):
        funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
        printString("Trader_call_stack","call->",funName)
        try:
            if self._api is not NULL:
                self._api.SubscribePublicTopic(nResumeType)
        except Exception as err:
            myEnv.logger.error('SubscribePublicTopic', exc_info=True)

        printString("Trader_call_stack","call-<",funName)

        
    ##############################################################    
    def SimNow(self,InvestorID, InstrumentID, LastPrice, Volume):
        if InvestorID   is None or InstrumentID is None or LastPrice    is None or Volume < 1:
           return

        try:
          l_list= self.__instrument_req_order_dict.get(InstrumentID)
          if l_list is None:
            return

          bTraded=0
          for it_order in l_list:
            bTraded=0
            if it_order["Direction"] == '0' and LastPrice <= it_order["LimitPrice"]   and not it_order["OrderStatus"] in ('0','5'):
              #买单成交
              bTraded=1
              it_order["OrderStatus"] = '0'
              printNumber("SimNow",InstrumentID+".buyPrice:",it_order["LimitPrice"])
              printNumber("SimNow",InstrumentID+".TradePrice:",LastPrice)

            elif it_order["Direction"] == '1' and LastPrice >= it_order["LimitPrice"] and not it_order["OrderStatus"] in ('0','5'):
              #卖单成交
              bTraded=1
              it_order["OrderStatus"] = '0'
              printNumber("SimNow",InstrumentID+".sellPrice:",it_order["LimitPrice"])
              printNumber("SimNow",InstrumentID+".TradePrice:",LastPrice)

            #通过更改报单状态来实现，然后将成交入库
            if bTraded==1:
              the_SQL  ="""
                        INSERT INTO T_SimNow_AutoTrade(InvestorID,InstrumentID,Express,Direction,CombOffsetFlag,Order_Time,Order_Price,Order_MDPrice,Trade_Price,Trade_Volume)
                                                VALUES(%s        ,%s          ,%s     ,%s       ,%s            ,%s        ,%s         ,%s           ,%s         ,%s)
                        """
              the_data =[(InvestorID, InstrumentID, it_order["Express"], it_order["Direction"], it_order["CombOffsetFlag"],it_order["OrderTime"]
                         ,it_order["LimitPrice"],it_order["MD_Last_Price"],LastPrice, Volume)]
              self.SQL2DB(the_SQL,the_data)

        except Exception as err:
            myEnv.logger.error('__cinit__', exc_info=True)

    def connectDB(self):
      dbConnect = None

      try:
        PTP_DB_TYPE   = self.config.get("CLOUD", "PTP_DB_TYPE")
        PTP_DB_SERVER = self.config.get("CLOUD", "PTP_DB_SERVER")
        PTP_DB_USER   = self.config.get("CLOUD", "PTP_DB_USER")
        PTP_DB_PWD    = self.config.get("CLOUD", "PTP_DB_PWD")
        PTP_DB_NAME   = self.config.get("CLOUD", "PTP_DB_NAME")
        PTP_DB_PORT   = int(self.config.get("CLOUD", "PTP_DB_PORT"))
      except Exception as err:
        PTP_DB_TYPE   = None
        PTP_DB_SERVER = None
        PTP_DB_USER   = None
        PTP_DB_PWD    = None
        PTP_DB_NAME   = None
        PTP_DB_PORT   = None

      PTP_DB_TYPE   = nvl(PTP_DB_TYPE  ,"mysql"       )
      #PTP_DB_SERVER = nvl(PTP_DB_SERVER,"103.235.232.142")
      PTP_DB_SERVER = nvl(PTP_DB_SERVER,"127.0.0.1"   )
      PTP_DB_USER   = nvl(PTP_DB_USER  ,"sim_test"    )
      PTP_DB_PWD    = nvl(PTP_DB_PWD   ,"SimTest@2019")
      PTP_DB_NAME   = nvl(PTP_DB_NAME  ,"sim_test"    )
      PTP_DB_PORT   = nvl(PTP_DB_PORT  ,3306          )

      dbConnect = pymysql.Connect(host=PTP_DB_SERVER , user=PTP_DB_USER
                                    , passwd=PTP_DB_PWD, db  =PTP_DB_NAME
                                    , charset="utf8"   , port=PTP_DB_PORT)
      return dbConnect

    def SQL2DB(self, szSQL, listVal):
      ###########
      tryTimes = 0
      done = 0

      while True:
        #再次执行
        try:
          #首次执行
          try:
            tryTimes = tryTimes + 1

            if self.upload == 1:
              if self.cloud_debug== 1:
                  myEnv.logger.debug(szSQL)
                  myEnv.logger.debug(str(listVal))

              myDB = self.connectDB()
              if myDB is None:
                 raise Exception( -1, "Connect DB Failed")

              mycursor = myDB.cursor()
              mycursor.executemany(szSQL, listVal)
              done = 1
          except Exception as err1:
            myEnv.logger.error('Trader excute sql faild in SQL2DB' + str(err1), exc_info=True)

            #retCode = err1.args[0]
            #if retCode == 2013:

            myDB = self.connectDB()
            if myDB is None:
               raise Exception( -1, "re Connect DB Failed")

            mycursor = myDB.cursor()
            mycursor.executemany(szSQL, listVal)

            done = 1

        except Exception as err2:
          myEnv.logger.debug(szSQL)
          myEnv.logger.debug(str(listVal))
          myEnv.logger.error('Trader re excute sql faild in SQL2DB'  + str(err2), exc_info=True)

        try:

          if done == 1:
            myDB.commit()
            break

        except Exception as err3:
          myEnv.logger.error('releas source'  + str(err3), exc_info=True)

        if tryTimes > 5:
            break

    def ExecuteQuery(self,i_strSQL):
      myDB = self.connectDB()
      mycursor = myDB.cursor()
      results = ()
      try:
          if len(i_strSQL) == 0:
              return results;

          if type(mycursor) != pymysql.cursors.Cursor:
              return results


          mycursor.execute(i_strSQL)
          # 获取所有记录列表
          results = mycursor.fetchall()

      except Exception as err:
          myEnv.logger.error('ExecuteQuery', exc_info=True)

      return results;

    def InitFactor(self):
      factor={}

      for name in myDEnv.Init_Factor_Zero:
        factor[name] = 0
    
      #行情的最新时间
      factor["UpdateTime"]           = "01:01:01"
    
      #报单的 book
      factor["bid_order_book"]  = {}
      factor["ask_order_book"]  = {}
      #成交 book
      factor["trade_book"]      = {}

      return factor                
    
    def statMD(self,factor, pMD):
        #####################
        #管理价格和Vol的BOOK 
          
        #最新价
        old_val = factor["LastPrice"]
        new_val = pMD["LastPrice"]

        ##############
        #价格的统计业务
        if new_val > old_val:
        #上涨
          #本次
          factor["LastPrice_Cur_Up"] = factor["LastPrice_Cur_Up"] + 1
          #累计
          factor["LastPrice_Acc_Up"] = factor["LastPrice_Acc_Up"] + 1
          #本次下单后上涨次数
          factor["order_acc_up"]     = factor["order_acc_up"] + 1

          #调整其它方向
          factor["LastPrice_Cur_Keep"] = 0
          factor["LastPrice_Cur_Down"] = 0
          #factor["order_acc_up"]       = 0
          #factor["order_acc_keep"]     = 0

        elif old_val == new_val:
        #保持
          #本次
          factor["LastPrice_Cur_Keep"] = factor["LastPrice_Cur_Keep"] + 1
          #累计
          factor["LastPrice_Acc_Keep"] = factor["LastPrice_Acc_Keep"] + 1
          #本次下单后保持次数
          factor["order_acc_keep"]   = factor["order_acc_keep"] + 1

          #调整其它方向
          #factor["order_acc_up"]       = 0
          #factor["order_acc_down"]     = 0
          factor["LastPrice_Cur_Down"] = 0
          factor["LastPrice_Cur_Up"]   = 0

        else:
        #下跌
          #本次
          factor["LastPrice_Cur_Down"] = factor["LastPrice_Cur_Down"] + 1
          #累计
          factor["LastPrice_Acc_Down"] = factor["LastPrice_Acc_Down"] + 1
          #本次下单后下跌次数
          factor["order_acc_down"]   = factor["order_acc_down"] + 1

          #调整其它方向
          #factor["order_acc_keep"]     = 0
          #factor["order_acc_down"]     = 0
          factor["LastPrice_Cur_Keep"] = 0
          factor["LastPrice_Cur_Up"]   = 0
        ##############   
        #数量
        if pMD["Volume"] >= 1.79e+308:
            l_Volume = 0
        else:
            l_Volume=pMD["Volume"]
        factor["vol_diff"]          = pMD["Volume"] - factor["Volume"]
        factor["order_TradeVolume"] = factor["order_TradeVolume"] + factor["vol_diff"] 

        l_LastPrice=pMD["LastPrice"]
        l_trade_order_book = factor["trade_book"]
        try:
          l_trade_order_book[l_LastPrice] = l_trade_order_book[l_LastPrice] + factor["vol_diff"]
        except Exception as err:
          l_trade_order_book[l_LastPrice] = factor["vol_diff"]
        factor["trade_book"] = l_trade_order_book   
         
        #申买价一
        if pMD["BidPrice1"] >= 1.79e+308:
            l_BidPrice1 = 0
        else:
            l_BidPrice1=pMD["BidPrice1"]
        factor["BidPrice1"]            = l_BidPrice1

        ############################
        #申买量一
        if pMD["BidVolume1"] >= 1.79e+308:
            l_BidVolume1 = 0
        else:
            l_BidVolume1=pMD["BidVolume1"]
        factor["BidVolume1"]            = l_BidVolume1

        factor["BidVolume"]       = factor["BidVolume"] + l_BidVolume1
        factor["order_BidVolume"] = factor["order_BidVolume"] + l_BidVolume1

        l_bid_order_book = factor["bid_order_book"]
        try:
            l_bid_order_book[l_BidPrice1] = l_bid_order_book[l_BidPrice1] + l_BidVolume1
        except Exception as err:
            l_bid_order_book[l_BidPrice1] = l_BidVolume1
        factor["bid_order_book"] = l_bid_order_book
        ############################

        #申卖价一
        if pMD["AskPrice1"] >= 1.79e+308:
            l_AskPrice1 = 0
        else:
            l_AskPrice1=pMD["AskPrice1"]
        factor["AskPrice1"]            = l_AskPrice1

        #####################################
        #申卖量一
        if pMD["AskVolume1"] >= 1.79e+308:
            l_AskVolume1 = 0
        else:
            l_AskVolume1=pMD["AskVolume1"]
        factor["AskVolume1"]            = l_AskVolume1

        factor["AskVolume"]       = factor["AskVolume"] + l_AskVolume1
        factor["order_AskVolume"] = factor["order_AskVolume"] + l_AskVolume1

        l_ask_order_book = factor["ask_order_book"]
        try:
            l_ask_order_book[l_AskPrice1] = l_ask_order_book[l_AskPrice1] + l_AskVolume1
        except Exception as err:
            l_ask_order_book[l_AskPrice1] = l_AskVolume1
        factor["ask_order_book"] = l_ask_order_book
 
    def restOrderFactor(self,instrument):

      try:
         dwTime  = self.Inc_RequestID()

         funName = "%s.%s" % ('MdApiWrapper', 'restOrderFactor')
         #printString("MD_call_stack","call->",funName,dwTime)

         factor = self.__instrument_attr_dict.get(instrument)
         if factor is None:
           factor = self.InitFactor()
         else:
           #发生报单后，累计下跌
           factor["order_acc_down"]    = 0

           ##发生报单后，累计上涨
           factor["order_acc_up"]      = 0

           ##发生报单后，累计保持
           factor["order_acc_keep"]    = 0

           ##发生报单后，累计买量
           factor["order_BidVolume"]   = 0

           ##发生报单后，累计卖量
           factor["order_AskVolume"]   = 0

           ##发生报单后，累计成交量
           factor["order_TradeVolume"] = 0

         self.__instrument_attr_dict[instrument] = factor

      except Exception as err:
           myEnv.logger.error('restOrderFactor', exc_info=True)
           
    def push_md2trade(self, szInstrumentID, dict_new_md):
      tmp={}
      if szInstrumentID is None:
        return tmp

      try:
        l_dict_InstrumentAttr=self.get_InstrumentAttr(szInstrumentID)
        #做些行情统计的事情
        self.statMD(l_dict_InstrumentAttr, dict_new_md)
        
        #更新合约属性        
        if dict_new_md is None :
          return self.get_InstrumentAttr(szInstrumentID)

        if isinstance(dict_new_md, dict):
          dict_new_md["ExchangeID"] = l_dict_InstrumentAttr["ExchangeID"] #行情中这个信息是缺失的
          l_dict_InstrumentAttr.update(dict_new_md) #merge dict_new_md into l_dict_InstrumentAttr
        
        #间隔 10 秒推送 tushare 因子
        l_cur_dt = datetime.now()
        if (l_cur_dt - self.__update_factor_date).seconds > myEnv.update_factor_period: 
          self.updateFactor() 
          self.__update_factor_date = l_cur_dt 
          
      except Exception as err:
        myEnv.logger.error('push_md2trade', exc_info=True)
   
    #返回-1：缺少计算因子
    #返回-2：合约没有查询到
    def Calc_Express(self,instrument, strExpress):
        exe_Result = 0
        calc_Val = 0
        try:

            dictInputVal = self.__instrument_attr_dict.get(instrument)
            if not dictInputVal is None:
              calc_Val = eval(strExpress, dictInputVal)
            else:
              exe_Result = -2

        except Exception as err:
            exe_Result = -1
            myEnv.logger.error('Calc_Express', exc_info=True)

        return (exe_Result, calc_Val)    

    def Factor2String(self, instrument):
      strRet=instrument + ':{'
      factor = self.__instrument_attr_dict[instrument]
      try:
        if not instrument is None and not factor is None:
          for (k,v) in self.__instrument_attr_dict.items():
            strRet = strRet + toString(k) + toString(v)

      except Exception as err:
        myEnv.logger.error('Factor2String', exc_info=True)

      strRet=strRet + '}'

      return strRet 
    
    def checkVersion(self, day):
        try:
            if day is None:
              l_bizDay = self.GetTradingDay()
              l_bizDay = l_bizDay.decode()
            else:
              l_bizDay = day

            if l_bizDay is None:
              myEnv.logger.debug("GetTradingDay failed")
              raise MemoryError()
            else:
              if l_bizDay >= '20190631':
                myEnv.logger.debug("The version is too old")
                myEnv.logger.debug(l_bizDay)
                time.sleep(1)

        except Exception as err:
            myEnv.logger.error('checkVersion', exc_info=True)
            
    def updateFactor(self):
      try:
       l_sql = "select id,InstrumentID,factor_name,factor_val from t_factor t where t.id>%s order by id asc"%(self.__id)
       l_factor_list = self.ExecuteQuery(l_sql);
       myEnv.logger.debug('set dynamic factor cnt:' + str(len(l_factor_list)))
       for it_factor in l_factor_list:
         try:
          myEnv.logger.debug('set dynamic factor' + it_factor[1] + ':' + it_factor[2] + ':' + str(it_factor[3]) )
          
          l_InstrumentID=it_factor[1]
          factor = self.__instrument_attr_dict.get(l_InstrumentID)
          if factor is None:
            factor = self.InitFactor()
          self.__instrument_attr_dict[l_InstrumentID] = factor
          factor[it_factor[2]] = it_factor[3]
          
          #下一次从这个新的位置开始读取因子
          self.__id=it_factor[0]
         except Exception as err:
          myEnv.logger.error('set dynamic factor failed' + ':' + it_factor[1] + ':' + it_factor[2], exc_info=True)
      except Exception as err:
          myEnv.logger.error('updateFactor failed', exc_info=True)

    def setFactor(self,instrument,key,val):
      try:
        dwTime  = self.Inc_RequestID()

        funName = "%s.%s" % ('MdApiWrapper', 'setFactor')
        printString("MD_call_stack","call->" + funName + instrument + key, val,dwTime)

        self.__instrument_attr_dict[instrument][key] = val

        printString("MD_call_stack","call-<",funName,dwTime)


      except Exception as err:
        myEnv.logger.error('setFactor', exc_info=True)
        
    def withdraw_buy(self, investor_id, instrument_id, exchange_ID=""):
      l_retVal = -1
      try:
        l_ExchageID = exchange_ID
        if l_ExchageID is None or len(l_ExchageID) == 0:
            l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

        l_order_list = self.get_Order_list(instrument_id)
        if not l_order_list is None:
          for it_Order in l_order_list:
            # (1)撤掉买
            if it_Order["Direction"] == '0' and it_Order["OrderStatus"] not in ['0', '5', 'a']:
              l_OrderSysID = it_Order["OrderSysID"]
              pOrderAction = py_ApiStructure.InputOrderActionField(
                  BrokerID=self.broker_id,
                  InvestorID=investor_id,
                  UserID=investor_id,
                  ExchangeID=l_ExchageID,
                  ActionFlag='0',  # ///删除报单
                  OrderSysID=l_OrderSysID,
                  InstrumentID=instrument_id
              )
              self.ReqOrderAction(pOrderAction)

        l_retVal = 0
        return l_retVal

      except Exception as err:
          myEnv.logger.error('withdraw_buy', exc_info=True)
          return l_retVal

    def withdraw_sell(self, investor_id, instrument_id, exchange_ID=""):
        l_retVal = -1
        try:
            l_ExchageID = exchange_ID
            if l_ExchageID is None or len(l_ExchageID) == 0:
                l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

            l_order_list = self.get_Order_list(instrument_id)
            if not l_order_list is None:
                for it_Order in l_order_list:
                    # (1)撤掉买
                    if it_Order["Direction"] == '1' and it_Order["OrderStatus"] not in ['0', '5', 'a']:
                        l_OrderSysID = it_Order["OrderSysID"]
                        pOrderAction = py_ApiStructure.InputOrderActionField(
                            BrokerID=self.broker_id,
                            InvestorID=investor_id,
                            UserID=investor_id,
                            ExchangeID=l_ExchageID,
                            ActionFlag='0',  # ///删除报单
                            OrderSysID=l_OrderSysID,
                            InstrumentID=instrument_id
                        )
                        self.ReqOrderAction(pOrderAction)

            l_retVal = 0
            return l_retVal

        except Exception as err:
            myEnv.logger.error('withdraw_sell', exc_info=True)
            return l_retVal

    def buy_open(self, investor_id, instrument_id, order_price, order_vol, last_price=0, exchange_ID=""):
        l_retVal = -1
        try:
            l_ExchageID = exchange_ID
            if l_ExchageID is None or len(l_ExchageID) == 0:
                l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

            pBuyOpen = py_ApiStructure.InputOrderField(
                BrokerID=self.broker_id,
                InvestorID=investor_id,
                ExchangeID=l_ExchageID,
                InstrumentID=instrument_id,
                UserID=investor_id,
                OrderPriceType='2',
                Direction='0',
                CombOffsetFlag='0',  # ///开仓
                CombHedgeFlag='1',
                LimitPrice=order_price,
                VolumeTotalOriginal=order_vol,
                TimeCondition='3',
                VolumeCondition='1',
                MinVolume=1,
                ContingentCondition='1',
                StopPrice=0,
                ForceCloseReason='0',
                IsAutoSuspend=0
            )
            l_retVal = self.ReqOrderInsert(pBuyOpen, 'buy_open', last_price)
            self.restOrderFactor(instrument_id)

        except Exception as err:
            myEnv.logger.error('buy_open', exc_info=True)
            l_retVal = -1

        return l_retVal

    def sell_open(self, investor_id, instrument_id, order_price, order_vol, last_price=0,
                  exchange_ID=""):
        l_retVal = -1
        try:
            l_ExchageID = exchange_ID
            if l_ExchageID is None or len(l_ExchageID) == 0:
                l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

            pSellOpen = py_ApiStructure.InputOrderField(
                BrokerID=self.broker_id,
                InvestorID=investor_id,
                ExchangeID=l_ExchageID,
                InstrumentID=instrument_id,
                UserID=investor_id,
                OrderPriceType='2',
                Direction='1',
                CombOffsetFlag='0',  # ///开仓
                CombHedgeFlag='1',
                LimitPrice=order_price,
                VolumeTotalOriginal=order_vol,
                TimeCondition='3',
                VolumeCondition='1',
                MinVolume=1,
                ContingentCondition='1',
                StopPrice=0,
                ForceCloseReason='0',
                IsAutoSuspend=0
            )
            l_retVal = self.ReqOrderInsert(pSellOpen, 'sell_open', last_price)
            self.restOrderFactor(instrument_id)


        except Exception as err:
            myEnv.logger.error('sell_open', exc_info=True)
            l_retVal = -1
        return l_retVal

    def buy_close(self, investor_id, instrument_id, order_price, order_vol, last_price=0,
                  exchange_ID=""):
        l_retVal = -1
        try:
            l_ExchageID = exchange_ID
            if l_ExchageID is None or len(l_ExchageID) == 0:
                l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

            # 获取仓位
            l_position_list = self.get_Position(instrument_id)
            l_remain = order_vol
            if not l_position_list is None:
                for it_pos in l_position_list:
                    if it_pos["PosiDirection"] == '3' and it_pos["Position"] > 0 and l_remain > 0:  # ///空头
                        l_close_vol = 1
                        if l_ExchageID == 'SHFE':
                            if it_pos["TodayPosition"] > 0:
                                l_CombOffsetFlag = '3'  # 平今
                                l_close_vol = min(it_pos["TodayPosition"], l_remain)
                            else:
                                l_CombOffsetFlag = '4'  # 平昨
                                l_close_vol = min(it_pos["YdPosition"], l_remain)
                        else:
                            l_CombOffsetFlag = '1'  # 平仓
                            l_close_vol = min(it_pos["Position"], l_remain)

                        # 改进，撤掉以前价格不合理的平仓
                        # 报买平单
                        pBuyClose = py_ApiStructure.InputOrderField(
                            BrokerID=self.broker_id,
                            InvestorID=investor_id,
                            ExchangeID=l_ExchageID,
                            InstrumentID=instrument_id,
                            UserID=investor_id,
                            OrderPriceType='2',
                            Direction='0',
                            CombOffsetFlag=l_CombOffsetFlag,
                            CombHedgeFlag='1',
                            LimitPrice=order_price,  # 可以考虑减少一个tick确保能卖掉
                            VolumeTotalOriginal=l_close_vol,
                            TimeCondition='3',
                            VolumeCondition='1',
                            MinVolume=1,
                            ContingentCondition='1',
                            StopPrice=0,
                            ForceCloseReason='0',
                            IsAutoSuspend=0
                        )
                        l_retVal = self.ReqOrderInsert(pBuyClose, 'buy_close', last_price)
                        self.restOrderFactor(instrument_id)
                        l_remain = l_remain - l_close_vol
        except Exception as err:
            myEnv.logger.error('buy_close', exc_info=True)

    def sell_close(self, investor_id, instrument_id, order_price, order_vol, last_price=0,
                   exchange_ID=""):
      l_retVal = -1
      try:
        l_ExchageID = exchange_ID
        if l_ExchageID is None or len(l_ExchageID) == 0:
            l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

        # 获取仓位
        l_position_list = self.get_Position(instrument_id)
        l_remain = order_vol
        # TThostFtdcVolumeType	YdPosition;    ///上日持仓
        # TThostFtdcVolumeType	Position;      ///今日总持仓
        # TThostFtdcVolumeType	TodayPosition; ///今日持仓
        if not l_position_list is None:
          for it_pos in l_position_list:
                if it_pos["PosiDirection"] == '2' and it_pos["Position"] > 0 and l_remain > 0:  # ///多头
                    l_close_vol = 1
                    if l_ExchageID == 'SHFE':
                        if it_pos["TodayPosition"] > 0:
                            l_CombOffsetFlag = '3'  # 平今
                            l_close_vol = min(it_pos["TodayPosition"], l_remain)
                        else:
                            l_CombOffsetFlag = '4'  # 平昨
                            l_close_vol = min(it_pos["YdPosition"], l_remain)
                    else:
                        l_CombOffsetFlag = '1'  # 平仓
                        l_close_vol = min(it_pos["Position"], l_remain)

                    # 改进，撤掉以前价格不合理的平仓，
                    # 报卖平单
                    pSellClose = py_ApiStructure.InputOrderField(
                        BrokerID=self.broker_id,
                        InvestorID=investor_id,
                        ExchangeID=l_ExchageID,
                        InstrumentID=instrument_id,
                        UserID=investor_id,
                        OrderPriceType='2',
                        Direction='1',
                        CombOffsetFlag=l_CombOffsetFlag,
                        CombHedgeFlag='1',
                        LimitPrice=order_price,  # 可以考虑减少一个tick确保能卖掉
                        VolumeTotalOriginal=l_close_vol,
                        TimeCondition='3',
                        VolumeCondition='1',
                        MinVolume=1,
                        ContingentCondition='1',
                        StopPrice=0,
                        ForceCloseReason='0',
                        IsAutoSuspend=0
                    )
                    l_retVal = self.ReqOrderInsert(pSellClose, 'sell_close', last_price)
                    self.restOrderFactor(instrument_id)
                    l_remain = l_remain - l_close_vol
      except Exception as err:
          myEnv.logger.error('sell_close', exc_info=True)

    def  AIAutoTrade(self, i_InvestorID, i_InstrumentID, i_MD_LastPrice = 0, exchange_ID=""):
       reload(myDEnv)	
       myEnv.logger.info(i_InvestorID)     
	     #撤单
       try:
         factor=myDEnv.AI_Strategy[i_InvestorID][i_InstrumentID]
       except Exception as err:
         myEnv.logger.warning('There is no strategy of(' + i_InvestorID + ',' + i_InstrumentID + ')')
         return;

       l_buy_open_price   = -1
       l_buy_open_express = None
       l_retVal = -1
       try:
        l_order_list    = self.get_Order_list(i_InstrumentID)
        l_position_list = self.get_Position  (i_InstrumentID)
        
        l_ExchageID=exchange_ID
        if l_ExchageID is None or len(l_ExchageID) == 0:
          l_ExchageID = self.get_exchangeID_of_instrument(i_InstrumentID)        
        if l_ExchageID is None or len(l_ExchageID) == 0:
            return;

        ###########################
        #买策略
        l_buy_open_express = factor["buy_open_express"]
        (retCode, l_buy_open_flag) = self.Calc_Express(i_InstrumentID, l_buy_open_express);
        if retCode != 0:
           return l_retVal;
        elif  l_buy_open_flag   == True:
           l_buy_open_price_express = factor["buy_open_price"]
           (retCode, l_buy_open_price) = self.Calc_Express(i_InstrumentID, l_buy_open_price_express);
           if retCode != 0:
             return l_retVal;
           else:
            #下买单
            l_buy_open_vol = factor["buy_open_vol"]
            p_buy_open = py_ApiStructure.InputOrderField(
                    BrokerID=self.broker_id,
                    InvestorID=i_InvestorID,
                    ExchangeID=l_ExchageID,
                    InstrumentID=i_InstrumentID,
                    UserID=i_InvestorID,
                    OrderPriceType='2',
                    Direction='0',
                    CombOffsetFlag='0',  # ///开仓
                    CombHedgeFlag='1',
                    LimitPrice=l_buy_open_price,
                    VolumeTotalOriginal=l_buy_open_vol,
                    TimeCondition='3',
                    VolumeCondition='1',
                    MinVolume=1,
                    ContingentCondition='1',
                    StopPrice=0,
                    ForceCloseReason='0',
                    IsAutoSuspend=0
                )
            l_retVal = self.ReqOrderInsert(p_buy_open, l_buy_open_express + ':' + l_buy_open_price_express, i_MD_LastPrice)
        ###########################
        #卖策略
        l_sell_open_express = factor["sell_open_express"]
        (retCode, l_sell_open_flag) = self.Calc_Express(i_InstrumentID, l_sell_open_express);
        if retCode != 0:
           return l_retVal;
        elif  l_sell_open_flag   == True:
           l_sell_open_price_express = factor["sell_open_price"]
           (retCode, l_sell_open_price) = self.Calc_Express(i_InstrumentID, l_sell_open_price_express);
           if retCode != 0:
             return l_retVal;
           else:
            #下卖单
            l_sell_open_vol = factor["sell_open_vol"]
            p_sell_Open = py_ApiStructure.InputOrderField(
                    BrokerID=self.broker_id,
                    InvestorID=i_InvestorID,
                    ExchangeID=l_ExchageID,
                    InstrumentID=i_InstrumentID,
                    UserID=i_InvestorID,
                    OrderPriceType='2',
                    Direction='1',
                    CombOffsetFlag='0',  # ///开仓
                    CombHedgeFlag='1',
                    LimitPrice=l_sell_open_price,
                    VolumeTotalOriginal=l_sell_open_vol,
                    TimeCondition='3',
                    VolumeCondition='1',
                    MinVolume=1,
                    ContingentCondition='1',
                    StopPrice=0,
                    ForceCloseReason='0',
                    IsAutoSuspend=0
                )
            l_retVal = self.ReqOrderInsert(p_sell_Open, l_sell_open_express + ':' + l_sell_open_price_express, i_MD_LastPrice)

        ###########################
        #平仓策略
        if not l_position_list is None and len(l_position_list) > 0:
            l_close_express = factor["buy_close_express"]
            (retCode, l_buy_close_flag) = self.Calc_Express(i_InstrumentID, l_close_express);
            if retCode != 0:
               return l_retVal;
            elif l_buy_close_flag == True:
               l_close_price_express = factor["buy_close_price"]
               (retCode, l_Calc_Price) = self.Calc_Express(i_InstrumentID, l_close_price_express);
               if retCode != 0:
                 return l_retVal;
               l_Volume = factor["buy_close_vol"]
               
               self.buy_close(i_InvestorID,i_InstrumentID,l_Calc_Price,l_Volume,i_MD_LastPrice,l_ExchageID)               

            l_close_express = factor["sell_close_express"]
            (retCode, l_sell_close_flag) = self.Calc_Express(i_InstrumentID, l_close_express);
            if retCode != 0:
               return l_retVal;
            elif l_sell_close_flag == True:
               l_close_price_express = factor["sell_close_price"]
               (retCode, l_Calc_Price) = self.Calc_Express(i_InstrumentID, l_close_price_express);
               if retCode != 0:
                 return l_retVal;
               l_Volume = factor["sell_close_vol"]
               
               self.sell_close(i_InvestorID,i_InstrumentID,l_Calc_Price,l_Volume,i_MD_LastPrice,l_ExchageID)               

       except Exception as err:
         myEnv.logger.error('AIAutoTrade(' + i_InvestorID + ':' + i_InstrumentID + ':'+ str(i_MD_LastPrice) + ')', exc_info=True)
         return l_retVal;
         
    def ai_buy_open(self, investor_id, instrument_id, order_price, order_vol, last_price=0,
                    exchange_ID=""):
      l_retVal = -1
      try:
        l_ExchageID = exchange_ID
        if l_ExchageID is None or len(l_ExchageID) == 0:
            l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

        pBuyOpen = py_ApiStructure.InputOrderField(
            BrokerID=self.broker_id,
            InvestorID=investor_id,
            ExchangeID=l_ExchageID,
            InstrumentID=instrument_id,
            UserID=investor_id,
            OrderPriceType='2',
            Direction='0',
            CombOffsetFlag='0',  # ///开仓
            CombHedgeFlag='1',
            LimitPrice=order_price,
            VolumeTotalOriginal=order_vol,
            TimeCondition='3',
            VolumeCondition='1',
            MinVolume=1,
            ContingentCondition='1',
            StopPrice=0,
            ForceCloseReason='0',
            IsAutoSuspend=0
        )
        l_retVal = self.ReqOrderInsert(pBuyOpen, 'ai_buy_open', last_price)
        self.restOrderFactor(instrument_id)

        l_order_list = self.get_Order_list(instrument_id)
        if not l_order_list is None:
          for it_Order in l_order_list:
            # 如果有反方向报单
            # (1)撤掉卖及高价的买
            if (it_Order["CombOffsetFlag"] == '0') and ((it_Order["Direction"] == '1') or (
                    it_Order["Direction"] == '0' and it_Order["LimitPrice"] < order_price)):
                l_OrderSysID = it_Order["OrderSysID"]
                pOrderAction = py_ApiStructure.InputOrderActionField(
                    BrokerID=self.broker_id,
                    InvestorID=investor_id,
                    UserID=investor_id,
                    ExchangeID=l_ExchageID,
                    ActionFlag='0',  # ///删除报单
                    OrderSysID=l_OrderSysID,
                    InstrumentID=instrument_id
                )
                self.ReqOrderAction(pOrderAction)

        l_retVal = 0
        return l_retVal

      except Exception as err:
          myEnv.logger.error('ai_buy_open', exc_info=True)
          return l_retVal

    def ai_sell_open(self, investor_id, instrument_id, order_price, order_vol, last_price=0,
                     exchange_ID=""):
        l_retVal = -1
        try:
            l_ExchageID = exchange_ID
            if l_ExchageID is None or len(l_ExchageID) == 0:
                l_ExchageID = self.get_exchangeID_of_instrument( instrument_id)

            pSellOpen = py_ApiStructure.InputOrderField(
                BrokerID=self.broker_id,
                InvestorID=investor_id,
                ExchangeID=l_ExchageID,
                InstrumentID=instrument_id,
                UserID=investor_id,
                OrderPriceType='2',
                Direction='1',
                CombOffsetFlag='0',  # ///开仓
                CombHedgeFlag='1',
                LimitPrice=order_price,
                VolumeTotalOriginal=order_vol,
                TimeCondition='3',
                VolumeCondition='1',
                MinVolume=1,
                ContingentCondition='1',
                StopPrice=0,
                ForceCloseReason='0',
                IsAutoSuspend=0
            )
            l_retVal = self.ReqOrderInsert(pSellOpen, 'ai_sell_open', last_price)
            self.restOrderFactor(instrument_id)

            l_order_list = self.get_Order_list(instrument_id)
            if not l_order_list is None:
                for it_Order in l_order_list:
                  # 如果有反方向报单
                  # (1)撤掉买及低价的卖
                  # 如果有买方向报单
                  if (it_Order["CombOffsetFlag"] == '0') and ((it_Order["Direction"] == '0') or (
                          it_Order["Direction"] == '1' and it_Order["LimitPrice"] > order_price)):
                      l_OrderSysID = it_Order["OrderSysID"]
                      pOrderAction = py_ApiStructure.InputOrderActionField(
                          BrokerID=self.broker_id,
                          InvestorID=investor_id,
                          UserID=investor_id,
                          ExchangeID=l_ExchageID,
                          ActionFlag='0',  # ///删除报单
                          OrderSysID=l_OrderSysID,
                          InstrumentID=instrument_id
                      )
                      self.ReqOrderAction(pOrderAction)

            return l_retVal

        except Exception as err:
            myEnv.logger.error('ai_sell_open', exc_info=True)
          
    def get_exchangeID_of_instrument(self,  instrument_id):
        l_ExchageID = ""
        try:
            #if not isinstance(trader, py_CtpTrader) or not isinstance(instrument_id, str) or len(instrument_id) == 0:
            if not isinstance(instrument_id, str) or len(instrument_id) == 0:
              return l_ExchageID

            l_instrument_Attr_dict = self.get_InstrumentAttr(instrument_id)
            if l_instrument_Attr_dict is None:
               return l_ExchageID

            l_ExchageID = l_instrument_Attr_dict['ExchangeID']
            
        except Exception as err:
            myEnv.logger.error('get_exchangeID_of_instrument failed', exc_info=True)
            l_ExchageID = ""
            
        return l_ExchageID 
        
    ##############################################################
    
    #客户端认证请求
    def  ReqAuthenticate(self, pReqAuthenticateField, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pReqAuthenticateField","BrokerID",pReqAuthenticateField.BrokerID,dwTime);
            printString("pReqAuthenticateField","UserID",pReqAuthenticateField.UserID,dwTime);
            printString("pReqAuthenticateField","UserProductInfo",pReqAuthenticateField.UserProductInfo,dwTime);
            printString("pReqAuthenticateField","AuthCode",pReqAuthenticateField.AuthCode,dwTime);

            self.pReqAuthenticateField2DB(pReqAuthenticateField)

            if self._spi is not NULL:
              address = ctypes.addressof(pReqAuthenticateField)
              with nogil:
                result = self._api.ReqAuthenticate(<CThostFtdcReqAuthenticateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqAuthenticate', exc_info=True)
        return result

    #用户登录请求
    def  ReqUserLogin(self, pReqUserLoginField, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
          dwTime  = self.Inc_RequestID()
          funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
          printString("Trader_call_stack","call->",funName,dwTime)
          printString("pReqUserLoginField","TradingDay",pReqUserLoginField.TradingDay,dwTime);
          printString("pReqUserLoginField","BrokerID",pReqUserLoginField.BrokerID,dwTime);
          printString("pReqUserLoginField","UserID",pReqUserLoginField.UserID,dwTime);
          printString("pReqUserLoginField","Password",pReqUserLoginField.Password,dwTime);
          printString("pReqUserLoginField","UserProductInfo",pReqUserLoginField.UserProductInfo,dwTime);
          printString("pReqUserLoginField","InterfaceProductInfo",pReqUserLoginField.InterfaceProductInfo,dwTime);
          printString("pReqUserLoginField","ProtocolInfo",pReqUserLoginField.ProtocolInfo,dwTime);
          printString("pReqUserLoginField","MacAddress",pReqUserLoginField.MacAddress,dwTime);
          printString("pReqUserLoginField","OneTimePassword",pReqUserLoginField.OneTimePassword,dwTime);
          printString("pReqUserLoginField","ClientIPAddress",pReqUserLoginField.ClientIPAddress,dwTime);
          printString("pReqUserLoginField","LoginRemark",pReqUserLoginField.LoginRemark,dwTime);

          self.pReqUserLoginField2DB(pReqUserLoginField)

          #if self.sim == 0:
          if self._spi is not NULL:
            address = ctypes.addressof(pReqUserLoginField)
            with nogil:
              result = self._api.ReqUserLogin(<CThostFtdcReqUserLoginField *> address, nRequestID)
          printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqUserLogin', exc_info=True)
        return result

    #登出请求
    def  ReqUserLogout(self, pUserLogout, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0

        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pUserLogout","BrokerID",pUserLogout.BrokerID,dwTime);
            printString("pUserLogout","UserID",pUserLogout.UserID,dwTime);

            self.pUserLogout2DB(pUserLogout)

            #if self.sim == 0:
            if self._spi is not NULL:
              address = ctypes.addressof(pUserLogout)
              with nogil:
                result = self._api.ReqUserLogout(<CThostFtdcUserLogoutField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqUserLogout', exc_info=True)

        return result

    #用户口令更新请求
    def  ReqUserPasswordUpdate(self, pUserPasswordUpdate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pUserPasswordUpdate","BrokerID",pUserPasswordUpdate.BrokerID,dwTime);
            printString("pUserPasswordUpdate","UserID",pUserPasswordUpdate.UserID,dwTime);
            printString("pUserPasswordUpdate","OldPassword",pUserPasswordUpdate.OldPassword,dwTime);
            printString("pUserPasswordUpdate","NewPassword",pUserPasswordUpdate.NewPassword,dwTime);

            self.pUserPasswordUpdate2DB(pUserPasswordUpdate)

            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pUserPasswordUpdate)
                with nogil:
                  result = self._api.ReqUserPasswordUpdate(<CThostFtdcUserPasswordUpdateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqUserPasswordUpdate', exc_info=True)

        return result

    #资金账户口令更新请求
    def  ReqTradingAccountPasswordUpdate(self, pTradingAccountPasswordUpdate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0

        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pTradingAccountPasswordUpdate","BrokerID",pTradingAccountPasswordUpdate.BrokerID,dwTime);
            printString("pTradingAccountPasswordUpdate","AccountID",pTradingAccountPasswordUpdate.AccountID,dwTime);
            printString("pTradingAccountPasswordUpdate","OldPassword",pTradingAccountPasswordUpdate.OldPassword,dwTime);
            printString("pTradingAccountPasswordUpdate","NewPassword",pTradingAccountPasswordUpdate.NewPassword,dwTime);
            printString("pTradingAccountPasswordUpdate","CurrencyID",pTradingAccountPasswordUpdate.CurrencyID,dwTime);

            self.pTradingAccountPasswordUpdate2DB(pTradingAccountPasswordUpdate)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pTradingAccountPasswordUpdate)
                with nogil:
                  result = self._api.ReqTradingAccountPasswordUpdate(<CThostFtdcTradingAccountPasswordUpdateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqTradingAccountPasswordUpdate', exc_info=True)

        return result

    #登录请求2
    def  ReqUserLogin2(self, pReqUserLogin, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pReqUserLogin","TradingDay",pReqUserLogin.TradingDay,dwTime);
            printString("pReqUserLogin","BrokerID",pReqUserLogin.BrokerID,dwTime);
            printString("pReqUserLogin","UserID",pReqUserLogin.UserID,dwTime);
            printString("pReqUserLogin","Password",pReqUserLogin.Password,dwTime);
            printString("pReqUserLogin","UserProductInfo",pReqUserLogin.UserProductInfo,dwTime);
            printString("pReqUserLogin","InterfaceProductInfo",pReqUserLogin.InterfaceProductInfo,dwTime);
            printString("pReqUserLogin","ProtocolInfo",pReqUserLogin.ProtocolInfo,dwTime);
            printString("pReqUserLogin","MacAddress",pReqUserLogin.MacAddress,dwTime);
            printString("pReqUserLogin","OneTimePassword",pReqUserLogin.OneTimePassword,dwTime);
            printString("pReqUserLogin","ClientIPAddress",pReqUserLogin.ClientIPAddress,dwTime);
            printString("pReqUserLogin","LoginRemark",pReqUserLogin.LoginRemark,dwTime);

            self.pReqUserLogin2DB(pReqUserLogin)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pReqUserLogin)
                with nogil:
                  result = self._api.ReqUserLogin2(<CThostFtdcReqUserLoginField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqUserLogin2', exc_info=True)

        return result

    #用户口令更新请求2
    def  ReqUserPasswordUpdate2(self, pUserPasswordUpdate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pUserPasswordUpdate","BrokerID",pUserPasswordUpdate.BrokerID,dwTime);
            printString("pUserPasswordUpdate","UserID",pUserPasswordUpdate.UserID,dwTime);
            printString("pUserPasswordUpdate","OldPassword",pUserPasswordUpdate.OldPassword,dwTime);
            printString("pUserPasswordUpdate","NewPassword",pUserPasswordUpdate.NewPassword,dwTime);

            self.pUserPasswordUpdate2DB(pUserPasswordUpdate)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pUserPasswordUpdate)
                with nogil:
                  result = self._api.ReqUserPasswordUpdate2(<CThostFtdcUserPasswordUpdateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqUserPasswordUpdate2', exc_info=True)

        return result

    #报单录入请求
    def  ReqOrderInsert(self, pInputOrder, int nRequestID, express="ctp", md_lastPrice=0):
        cdef int result = 0
        cdef size_t address = 0
        try:
          dwTime  = self.Inc_RequestID()
          funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
          printString("Trader_call_stack","call->",funName,dwTime)
          printString("pInputOrder","BrokerID",pInputOrder.BrokerID,dwTime);
          printString("pInputOrder","InvestorID",pInputOrder.InvestorID,dwTime);
          printString("pInputOrder","InstrumentID",pInputOrder.InstrumentID,dwTime);
          printString("pInputOrder","OrderRef",pInputOrder.OrderRef,dwTime);
          printString("pInputOrder","UserID",pInputOrder.UserID,dwTime);
          printString("pInputOrder","OrderPriceType",pInputOrder.OrderPriceType,dwTime);
          printString("pInputOrder","Direction",pInputOrder.Direction,dwTime);
          printString("pInputOrder","CombOffsetFlag",pInputOrder.CombOffsetFlag,dwTime);
          printString("pInputOrder","CombHedgeFlag",pInputOrder.CombHedgeFlag,dwTime);
          printNumber("pInputOrder","LimitPrice",pInputOrder.LimitPrice,dwTime);
          printNumber("pInputOrder","VolumeTotalOriginal",pInputOrder.VolumeTotalOriginal,dwTime);
          printString("pInputOrder","TimeCondition",pInputOrder.TimeCondition,dwTime);
          printString("pInputOrder","GTDDate",pInputOrder.GTDDate,dwTime);
          printString("pInputOrder","VolumeCondition",pInputOrder.VolumeCondition,dwTime);
          printNumber("pInputOrder","MinVolume",pInputOrder.MinVolume,dwTime);
          printString("pInputOrder","ContingentCondition",pInputOrder.ContingentCondition,dwTime);
          printNumber("pInputOrder","StopPrice",pInputOrder.StopPrice,dwTime);
          printString("pInputOrder","ForceCloseReason",pInputOrder.ForceCloseReason,dwTime);
          printNumber("pInputOrder","IsAutoSuspend",pInputOrder.IsAutoSuspend,dwTime);
          printString("pInputOrder","BusinessUnit",pInputOrder.BusinessUnit,dwTime);
          printNumber("pInputOrder","RequestID",pInputOrder.RequestID,dwTime);
          printNumber("pInputOrder","UserForceClose",pInputOrder.UserForceClose,dwTime);
          printNumber("pInputOrder","IsSwapOrder",pInputOrder.IsSwapOrder,dwTime);
          printString("pInputOrder","ExchangeID",pInputOrder.ExchangeID,dwTime);
          printString("pInputOrder","InvestUnitID",pInputOrder.InvestUnitID,dwTime);
          printString("pInputOrder","AccountID",pInputOrder.AccountID,dwTime);
          printString("pInputOrder","CurrencyID",pInputOrder.CurrencyID,dwTime);
          printString("pInputOrder","ClientID",pInputOrder.ClientID,dwTime);
          printString("pInputOrder","IPAddress",pInputOrder.IPAddress,dwTime);
          printString("pInputOrder","MacAddress",pInputOrder.MacAddress,dwTime);
          printString("pInputOrder","Express",express,dwTime);
          printNumber("pInputOrder","MD_Last_Price",md_lastPrice,dwTime);

          l_order={}
          l_order['BrokerID']                     = pInputOrder.BrokerID.decode(encoding='gb18030', errors='ignore')
          l_order['InvestorID']                   = pInputOrder.InvestorID.decode(encoding='gb18030', errors='ignore')
          l_order['InstrumentID']                 = pInputOrder.InstrumentID.decode(encoding='gb18030', errors='ignore')
          l_order['OrderRef']                     = pInputOrder.OrderRef.decode(encoding='gb18030', errors='ignore')
          l_order['UserID']                       = pInputOrder.UserID.decode(encoding='gb18030', errors='ignore')
          l_order['OrderPriceType']               = pInputOrder.OrderPriceType.decode(encoding='gb18030', errors='ignore')
          l_order['Direction']                    = pInputOrder.Direction.decode(encoding='gb18030', errors='ignore')
          l_order['CombOffsetFlag']               = pInputOrder.CombOffsetFlag.decode(encoding='gb18030', errors='ignore')
          l_order['CombHedgeFlag']                = pInputOrder.CombHedgeFlag.decode(encoding='gb18030', errors='ignore')
          l_order['LimitPrice']                   = pInputOrder.LimitPrice
          l_order['VolumeTotalOriginal']          = pInputOrder.VolumeTotalOriginal
          l_order['TimeCondition']                = pInputOrder.TimeCondition.decode(encoding='gb18030', errors='ignore')
          l_order['GTDDate']                      = pInputOrder.GTDDate.decode(encoding='gb18030', errors='ignore')
          l_order['VolumeCondition']              = pInputOrder.VolumeCondition.decode(encoding='gb18030', errors='ignore')
          l_order['MinVolume']                    = pInputOrder.MinVolume
          l_order['ContingentCondition']          = pInputOrder.ContingentCondition.decode(encoding='gb18030', errors='ignore')
          l_order['StopPrice']                    = pInputOrder.StopPrice
          l_order['ForceCloseReason']             = pInputOrder.ForceCloseReason.decode(encoding='gb18030', errors='ignore')
          l_order['IsAutoSuspend']                = pInputOrder.IsAutoSuspend
          l_order['BusinessUnit']                 = pInputOrder.BusinessUnit.decode(encoding='gb18030', errors='ignore')
          l_order['RequestID']                    = pInputOrder.RequestID
          l_order['UserForceClose']               = pInputOrder.UserForceClose
          l_order['IsSwapOrder']                  = pInputOrder.IsSwapOrder
          l_order['ExchangeID']                   = pInputOrder.ExchangeID.decode(encoding='gb18030', errors='ignore')
          l_order['InvestUnitID']                 = pInputOrder.InvestUnitID.decode(encoding='gb18030', errors='ignore')
          l_order['AccountID']                    = pInputOrder.AccountID.decode(encoding='gb18030', errors='ignore')
          l_order['CurrencyID']                   = pInputOrder.CurrencyID.decode(encoding='gb18030', errors='ignore')
          l_order['ClientID']                     = pInputOrder.ClientID.decode(encoding='gb18030', errors='ignore')
          l_order['Express']                      = express
          l_order['OrderStatus']                  = '2'
          l_order["OrderTime"]                    = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
          l_order["MD_Last_Price"]                = md_lastPrice
          #l_order['IPAddress']                    = pInputOrder.IPAddress.decode(encoding='gb18030', errors='ignore')
          #l_order['MacAddress']                   = pInputOrder.MacAddress.decode(encoding='gb18030', errors='ignore')

          l_order_list= self.__instrument_req_order_dict.get(l_order['InstrumentID'])
          if l_order_list is None:
            l_order_list=[]
          l_order_list.append(l_order)
          self.__instrument_req_order_dict[l_order['InstrumentID']]=l_order_list;

          self.pInputOrder2DB(pInputOrder)


          if self.sim == 0:
            if self._spi is not NULL:
              address = ctypes.addressof(pInputOrder)
              with nogil:
                result = self._api.ReqOrderInsert(<CThostFtdcInputOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqOrderInsert', exc_info=True)
        return result

    #预埋单录入请求
    def  ReqParkedOrderInsert(self, pParkedOrder, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pParkedOrder","BrokerID",pParkedOrder.BrokerID,dwTime);
            printString("pParkedOrder","InvestorID",pParkedOrder.InvestorID,dwTime);
            printString("pParkedOrder","InstrumentID",pParkedOrder.InstrumentID,dwTime);
            printString("pParkedOrder","OrderRef",pParkedOrder.OrderRef,dwTime);
            printString("pParkedOrder","UserID",pParkedOrder.UserID,dwTime);
            printString("pParkedOrder","OrderPriceType",pParkedOrder.OrderPriceType,dwTime);
            printString("pParkedOrder","Direction",pParkedOrder.Direction,dwTime);
            printString("pParkedOrder","CombOffsetFlag",pParkedOrder.CombOffsetFlag,dwTime);
            printString("pParkedOrder","CombHedgeFlag",pParkedOrder.CombHedgeFlag,dwTime);
            printNumber("pParkedOrder","LimitPrice",pParkedOrder.LimitPrice,dwTime);
            printNumber("pParkedOrder","VolumeTotalOriginal",pParkedOrder.VolumeTotalOriginal,dwTime);
            printString("pParkedOrder","TimeCondition",pParkedOrder.TimeCondition,dwTime);
            printString("pParkedOrder","GTDDate",pParkedOrder.GTDDate,dwTime);
            printString("pParkedOrder","VolumeCondition",pParkedOrder.VolumeCondition,dwTime);
            printNumber("pParkedOrder","MinVolume",pParkedOrder.MinVolume,dwTime);
            printString("pParkedOrder","ContingentCondition",pParkedOrder.ContingentCondition,dwTime);
            printNumber("pParkedOrder","StopPrice",pParkedOrder.StopPrice,dwTime);
            printString("pParkedOrder","ForceCloseReason",pParkedOrder.ForceCloseReason,dwTime);
            printNumber("pParkedOrder","IsAutoSuspend",pParkedOrder.IsAutoSuspend,dwTime);
            printString("pParkedOrder","BusinessUnit",pParkedOrder.BusinessUnit,dwTime);
            printNumber("pParkedOrder","RequestID",pParkedOrder.RequestID,dwTime);
            printNumber("pParkedOrder","UserForceClose",pParkedOrder.UserForceClose,dwTime);
            printString("pParkedOrder","ExchangeID",pParkedOrder.ExchangeID,dwTime);
            printString("pParkedOrder","ParkedOrderID",pParkedOrder.ParkedOrderID,dwTime);
            printString("pParkedOrder","UserType",pParkedOrder.UserType,dwTime);
            printString("pParkedOrder","Status",pParkedOrder.Status,dwTime);
            printNumber("pParkedOrder","ErrorID",pParkedOrder.ErrorID,dwTime);
            printString("pParkedOrder","ErrorMsg",pParkedOrder.ErrorMsg,dwTime);
            printNumber("pParkedOrder","IsSwapOrder",pParkedOrder.IsSwapOrder,dwTime);
            printString("pParkedOrder","AccountID",pParkedOrder.AccountID,dwTime);
            printString("pParkedOrder","CurrencyID",pParkedOrder.CurrencyID,dwTime);
            printString("pParkedOrder","ClientID",pParkedOrder.ClientID,dwTime);
            printString("pParkedOrder","InvestUnitID",pParkedOrder.InvestUnitID,dwTime);
            printString("pParkedOrder","IPAddress",pParkedOrder.IPAddress,dwTime);
            printString("pParkedOrder","MacAddress",pParkedOrder.MacAddress,dwTime);

            self.pParkedOrder2DB(pParkedOrder)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pParkedOrder)
                with nogil:
                  result = self._api.ReqParkedOrderInsert(<CThostFtdcParkedOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqParkedOrderInsert', exc_info=True)

        return result

    #预埋撤单录入请求
    def  ReqParkedOrderAction(self, pParkedOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pParkedOrderAction","BrokerID",pParkedOrderAction.BrokerID,dwTime);
            printString("pParkedOrderAction","InvestorID",pParkedOrderAction.InvestorID,dwTime);
            printNumber("pParkedOrderAction","OrderActionRef",pParkedOrderAction.OrderActionRef,dwTime);
            printString("pParkedOrderAction","OrderRef",pParkedOrderAction.OrderRef,dwTime);
            printNumber("pParkedOrderAction","RequestID",pParkedOrderAction.RequestID,dwTime);
            printNumber("pParkedOrderAction","FrontID",pParkedOrderAction.FrontID,dwTime);
            printNumber("pParkedOrderAction","SessionID",pParkedOrderAction.SessionID,dwTime);
            printString("pParkedOrderAction","ExchangeID",pParkedOrderAction.ExchangeID,dwTime);
            printString("pParkedOrderAction","OrderSysID",pParkedOrderAction.OrderSysID,dwTime);
            printString("pParkedOrderAction","ActionFlag",pParkedOrderAction.ActionFlag,dwTime);
            printNumber("pParkedOrderAction","LimitPrice",pParkedOrderAction.LimitPrice,dwTime);
            printNumber("pParkedOrderAction","VolumeChange",pParkedOrderAction.VolumeChange,dwTime);
            printString("pParkedOrderAction","UserID",pParkedOrderAction.UserID,dwTime);
            printString("pParkedOrderAction","InstrumentID",pParkedOrderAction.InstrumentID,dwTime);
            printString("pParkedOrderAction","ParkedOrderActionID",pParkedOrderAction.ParkedOrderActionID,dwTime);
            printString("pParkedOrderAction","UserType",pParkedOrderAction.UserType,dwTime);
            printString("pParkedOrderAction","Status",pParkedOrderAction.Status,dwTime);
            printNumber("pParkedOrderAction","ErrorID",pParkedOrderAction.ErrorID,dwTime);
            printString("pParkedOrderAction","ErrorMsg",pParkedOrderAction.ErrorMsg,dwTime);
            printString("pParkedOrderAction","InvestUnitID",pParkedOrderAction.InvestUnitID,dwTime);
            printString("pParkedOrderAction","IPAddress",pParkedOrderAction.IPAddress,dwTime);
            printString("pParkedOrderAction","MacAddress",pParkedOrderAction.MacAddress,dwTime);

            self.pParkedOrderAction2DB(pParkedOrderAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pParkedOrderAction)
                with nogil:
                  result = self._api.ReqParkedOrderAction(<CThostFtdcParkedOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqParkedOrderAction', exc_info=True)

        return result

    #报单操作请求
    def  ReqOrderAction(self, pInputOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputOrderAction","BrokerID",pInputOrderAction.BrokerID,dwTime);
            printString("pInputOrderAction","InvestorID",pInputOrderAction.InvestorID,dwTime);
            printNumber("pInputOrderAction","OrderActionRef",pInputOrderAction.OrderActionRef,dwTime);
            printString("pInputOrderAction","OrderRef",pInputOrderAction.OrderRef,dwTime);
            printNumber("pInputOrderAction","RequestID",pInputOrderAction.RequestID,dwTime);
            printNumber("pInputOrderAction","FrontID",pInputOrderAction.FrontID,dwTime);
            printNumber("pInputOrderAction","SessionID",pInputOrderAction.SessionID,dwTime);
            printString("pInputOrderAction","ExchangeID",pInputOrderAction.ExchangeID,dwTime);
            printString("pInputOrderAction","OrderSysID",pInputOrderAction.OrderSysID,dwTime);
            printString("pInputOrderAction","ActionFlag",pInputOrderAction.ActionFlag,dwTime);
            printNumber("pInputOrderAction","LimitPrice",pInputOrderAction.LimitPrice,dwTime);
            printNumber("pInputOrderAction","VolumeChange",pInputOrderAction.VolumeChange,dwTime);
            printString("pInputOrderAction","UserID",pInputOrderAction.UserID,dwTime);
            printString("pInputOrderAction","InstrumentID",pInputOrderAction.InstrumentID,dwTime);
            printString("pInputOrderAction","InvestUnitID",pInputOrderAction.InvestUnitID,dwTime);
            printString("pInputOrderAction","IPAddress",pInputOrderAction.IPAddress,dwTime);
            printString("pInputOrderAction","MacAddress",pInputOrderAction.MacAddress,dwTime);

            self.pInputOrderAction2DB(pInputOrderAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputOrderAction)
                with nogil:
                  result = self._api.ReqOrderAction(<CThostFtdcInputOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqOrderAction', exc_info=True)

        return result

    #查询最大报单数量请求
    def  ReqQueryMaxOrderVolume(self, pQueryMaxOrderVolume, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQueryMaxOrderVolume","BrokerID",pQueryMaxOrderVolume.BrokerID,dwTime);
            printString("pQueryMaxOrderVolume","InvestorID",pQueryMaxOrderVolume.InvestorID,dwTime);
            printString("pQueryMaxOrderVolume","InstrumentID",pQueryMaxOrderVolume.InstrumentID,dwTime);
            printString("pQueryMaxOrderVolume","Direction",pQueryMaxOrderVolume.Direction,dwTime);
            printString("pQueryMaxOrderVolume","OffsetFlag",pQueryMaxOrderVolume.OffsetFlag,dwTime);
            printString("pQueryMaxOrderVolume","HedgeFlag",pQueryMaxOrderVolume.HedgeFlag,dwTime);
            printNumber("pQueryMaxOrderVolume","MaxVolume",pQueryMaxOrderVolume.MaxVolume,dwTime);
            printString("pQueryMaxOrderVolume","ExchangeID",pQueryMaxOrderVolume.ExchangeID,dwTime);
            printString("pQueryMaxOrderVolume","InvestUnitID",pQueryMaxOrderVolume.InvestUnitID,dwTime);

            self.pQueryMaxOrderVolume2DB(pQueryMaxOrderVolume)

            if self._spi is not NULL:
              address = ctypes.addressof(pQueryMaxOrderVolume)
              with nogil:
                result = self._api.ReqQueryMaxOrderVolume(<CThostFtdcQueryMaxOrderVolumeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQueryMaxOrderVolume', exc_info=True)

        return result

    #投资者结算结果确认
    def  ReqSettlementInfoConfirm(self, pSettlementInfoConfirm, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pSettlementInfoConfirm","BrokerID",pSettlementInfoConfirm.BrokerID,dwTime);
            printString("pSettlementInfoConfirm","InvestorID",pSettlementInfoConfirm.InvestorID,dwTime);
            printString("pSettlementInfoConfirm","ConfirmDate",pSettlementInfoConfirm.ConfirmDate,dwTime);
            printString("pSettlementInfoConfirm","ConfirmTime",pSettlementInfoConfirm.ConfirmTime,dwTime);
            printNumber("pSettlementInfoConfirm","SettlementID",pSettlementInfoConfirm.SettlementID,dwTime);
            printString("pSettlementInfoConfirm","AccountID",pSettlementInfoConfirm.AccountID,dwTime);
            printString("pSettlementInfoConfirm","CurrencyID",pSettlementInfoConfirm.CurrencyID,dwTime);

            self.pSettlementInfoConfirm2DB(pSettlementInfoConfirm)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pSettlementInfoConfirm)
                with nogil:
                  result = self._api.ReqSettlementInfoConfirm(<CThostFtdcSettlementInfoConfirmField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqSettlementInfoConfirm', exc_info=True)

        return result

    #请求删除预埋单
    def  ReqRemoveParkedOrder(self, pRemoveParkedOrder, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pRemoveParkedOrder","BrokerID",pRemoveParkedOrder.BrokerID,dwTime);
            printString("pRemoveParkedOrder","InvestorID",pRemoveParkedOrder.InvestorID,dwTime);
            printString("pRemoveParkedOrder","ParkedOrderID",pRemoveParkedOrder.ParkedOrderID,dwTime);
            printString("pRemoveParkedOrder","InvestUnitID",pRemoveParkedOrder.InvestUnitID,dwTime);

            self.pRemoveParkedOrder2DB(pRemoveParkedOrder)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pRemoveParkedOrder)
                with nogil:
                  result = self._api.ReqRemoveParkedOrder(<CThostFtdcRemoveParkedOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqRemoveParkedOrder', exc_info=True)

        return result

    #请求删除预埋撤单
    def  ReqRemoveParkedOrderAction(self, pRemoveParkedOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pRemoveParkedOrderAction","BrokerID",pRemoveParkedOrderAction.BrokerID,dwTime);
            printString("pRemoveParkedOrderAction","InvestorID",pRemoveParkedOrderAction.InvestorID,dwTime);
            printString("pRemoveParkedOrderAction","ParkedOrderActionID",pRemoveParkedOrderAction.ParkedOrderActionID,dwTime);
            printString("pRemoveParkedOrderAction","InvestUnitID",pRemoveParkedOrderAction.InvestUnitID,dwTime);

            self.pRemoveParkedOrderAction2DB(pRemoveParkedOrderAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pRemoveParkedOrderAction)
                with nogil:
                  result = self._api.ReqRemoveParkedOrderAction(<CThostFtdcRemoveParkedOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqRemoveParkedOrderAction', exc_info=True)

        return result

    #执行宣告录入请求
    def  ReqExecOrderInsert(self, pInputExecOrder, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputExecOrder","BrokerID",pInputExecOrder.BrokerID,dwTime);
            printString("pInputExecOrder","InvestorID",pInputExecOrder.InvestorID,dwTime);
            printString("pInputExecOrder","InstrumentID",pInputExecOrder.InstrumentID,dwTime);
            printString("pInputExecOrder","ExecOrderRef",pInputExecOrder.ExecOrderRef,dwTime);
            printString("pInputExecOrder","UserID",pInputExecOrder.UserID,dwTime);
            printNumber("pInputExecOrder","Volume",pInputExecOrder.Volume,dwTime);
            printNumber("pInputExecOrder","RequestID",pInputExecOrder.RequestID,dwTime);
            printString("pInputExecOrder","BusinessUnit",pInputExecOrder.BusinessUnit,dwTime);
            printString("pInputExecOrder","OffsetFlag",pInputExecOrder.OffsetFlag,dwTime);
            printString("pInputExecOrder","HedgeFlag",pInputExecOrder.HedgeFlag,dwTime);
            printString("pInputExecOrder","ActionType",pInputExecOrder.ActionType,dwTime);
            printString("pInputExecOrder","PosiDirection",pInputExecOrder.PosiDirection,dwTime);
            printString("pInputExecOrder","ReservePositionFlag",pInputExecOrder.ReservePositionFlag,dwTime);
            printString("pInputExecOrder","CloseFlag",pInputExecOrder.CloseFlag,dwTime);
            printString("pInputExecOrder","ExchangeID",pInputExecOrder.ExchangeID,dwTime);
            printString("pInputExecOrder","InvestUnitID",pInputExecOrder.InvestUnitID,dwTime);
            printString("pInputExecOrder","AccountID",pInputExecOrder.AccountID,dwTime);
            printString("pInputExecOrder","CurrencyID",pInputExecOrder.CurrencyID,dwTime);
            printString("pInputExecOrder","ClientID",pInputExecOrder.ClientID,dwTime);
            printString("pInputExecOrder","IPAddress",pInputExecOrder.IPAddress,dwTime);
            printString("pInputExecOrder","MacAddress",pInputExecOrder.MacAddress,dwTime);

            self.pInputExecOrder2DB(pInputExecOrder)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputExecOrder)
                with nogil:
                  result = self._api.ReqExecOrderInsert(<CThostFtdcInputExecOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqExecOrderInsert', exc_info=True)

        return result

    #执行宣告操作请求
    def  ReqExecOrderAction(self, pInputExecOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputExecOrderAction","BrokerID",pInputExecOrderAction.BrokerID,dwTime);
            printString("pInputExecOrderAction","InvestorID",pInputExecOrderAction.InvestorID,dwTime);
            printNumber("pInputExecOrderAction","ExecOrderActionRef",pInputExecOrderAction.ExecOrderActionRef,dwTime);
            printString("pInputExecOrderAction","ExecOrderRef",pInputExecOrderAction.ExecOrderRef,dwTime);
            printNumber("pInputExecOrderAction","RequestID",pInputExecOrderAction.RequestID,dwTime);
            printNumber("pInputExecOrderAction","FrontID",pInputExecOrderAction.FrontID,dwTime);
            printNumber("pInputExecOrderAction","SessionID",pInputExecOrderAction.SessionID,dwTime);
            printString("pInputExecOrderAction","ExchangeID",pInputExecOrderAction.ExchangeID,dwTime);
            printString("pInputExecOrderAction","ExecOrderSysID",pInputExecOrderAction.ExecOrderSysID,dwTime);
            printString("pInputExecOrderAction","ActionFlag",pInputExecOrderAction.ActionFlag,dwTime);
            printString("pInputExecOrderAction","UserID",pInputExecOrderAction.UserID,dwTime);
            printString("pInputExecOrderAction","InstrumentID",pInputExecOrderAction.InstrumentID,dwTime);
            printString("pInputExecOrderAction","InvestUnitID",pInputExecOrderAction.InvestUnitID,dwTime);
            printString("pInputExecOrderAction","IPAddress",pInputExecOrderAction.IPAddress,dwTime);
            printString("pInputExecOrderAction","MacAddress",pInputExecOrderAction.MacAddress,dwTime);

            self.pInputExecOrderAction2DB(pInputExecOrderAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputExecOrderAction)
                with nogil:
                  result = self._api.ReqExecOrderAction(<CThostFtdcInputExecOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqExecOrderAction', exc_info=True)

        return result

    #询价录入请求
    def  ReqForQuoteInsert(self, pInputForQuote, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputForQuote","BrokerID",pInputForQuote.BrokerID,dwTime);
            printString("pInputForQuote","InvestorID",pInputForQuote.InvestorID,dwTime);
            printString("pInputForQuote","InstrumentID",pInputForQuote.InstrumentID,dwTime);
            printString("pInputForQuote","ForQuoteRef",pInputForQuote.ForQuoteRef,dwTime);
            printString("pInputForQuote","UserID",pInputForQuote.UserID,dwTime);
            printString("pInputForQuote","ExchangeID",pInputForQuote.ExchangeID,dwTime);
            printString("pInputForQuote","InvestUnitID",pInputForQuote.InvestUnitID,dwTime);
            printString("pInputForQuote","IPAddress",pInputForQuote.IPAddress,dwTime);
            printString("pInputForQuote","MacAddress",pInputForQuote.MacAddress,dwTime);

            self.pInputForQuote2DB(pInputForQuote)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputForQuote)
                with nogil:
                  result = self._api.ReqForQuoteInsert(<CThostFtdcInputForQuoteField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqForQuoteInsert', exc_info=True)

        return result

    #报价录入请求
    def  ReqQuoteInsert(self, pInputQuote, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputQuote","BrokerID",pInputQuote.BrokerID,dwTime);
            printString("pInputQuote","InvestorID",pInputQuote.InvestorID,dwTime);
            printString("pInputQuote","InstrumentID",pInputQuote.InstrumentID,dwTime);
            printString("pInputQuote","QuoteRef",pInputQuote.QuoteRef,dwTime);
            printString("pInputQuote","UserID",pInputQuote.UserID,dwTime);
            printNumber("pInputQuote","AskPrice",pInputQuote.AskPrice,dwTime);
            printNumber("pInputQuote","BidPrice",pInputQuote.BidPrice,dwTime);
            printNumber("pInputQuote","AskVolume",pInputQuote.AskVolume,dwTime);
            printNumber("pInputQuote","BidVolume",pInputQuote.BidVolume,dwTime);
            printNumber("pInputQuote","RequestID",pInputQuote.RequestID,dwTime);
            printString("pInputQuote","BusinessUnit",pInputQuote.BusinessUnit,dwTime);
            printString("pInputQuote","AskOffsetFlag",pInputQuote.AskOffsetFlag,dwTime);
            printString("pInputQuote","BidOffsetFlag",pInputQuote.BidOffsetFlag,dwTime);
            printString("pInputQuote","AskHedgeFlag",pInputQuote.AskHedgeFlag,dwTime);
            printString("pInputQuote","BidHedgeFlag",pInputQuote.BidHedgeFlag,dwTime);
            printString("pInputQuote","AskOrderRef",pInputQuote.AskOrderRef,dwTime);
            printString("pInputQuote","BidOrderRef",pInputQuote.BidOrderRef,dwTime);
            printString("pInputQuote","ForQuoteSysID",pInputQuote.ForQuoteSysID,dwTime);
            printString("pInputQuote","ExchangeID",pInputQuote.ExchangeID,dwTime);
            printString("pInputQuote","InvestUnitID",pInputQuote.InvestUnitID,dwTime);
            printString("pInputQuote","ClientID",pInputQuote.ClientID,dwTime);
            printString("pInputQuote","IPAddress",pInputQuote.IPAddress,dwTime);
            printString("pInputQuote","MacAddress",pInputQuote.MacAddress,dwTime);

            self.pInputQuote2DB(pInputQuote)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputQuote)
                with nogil:
                  result = self._api.ReqQuoteInsert(<CThostFtdcInputQuoteField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQuoteInsert', exc_info=True)

        return result

    #报价操作请求
    def  ReqQuoteAction(self, pInputQuoteAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputQuoteAction","BrokerID",pInputQuoteAction.BrokerID,dwTime);
            printString("pInputQuoteAction","InvestorID",pInputQuoteAction.InvestorID,dwTime);
            printNumber("pInputQuoteAction","QuoteActionRef",pInputQuoteAction.QuoteActionRef,dwTime);
            printString("pInputQuoteAction","QuoteRef",pInputQuoteAction.QuoteRef,dwTime);
            printNumber("pInputQuoteAction","RequestID",pInputQuoteAction.RequestID,dwTime);
            printNumber("pInputQuoteAction","FrontID",pInputQuoteAction.FrontID,dwTime);
            printNumber("pInputQuoteAction","SessionID",pInputQuoteAction.SessionID,dwTime);
            printString("pInputQuoteAction","ExchangeID",pInputQuoteAction.ExchangeID,dwTime);
            printString("pInputQuoteAction","QuoteSysID",pInputQuoteAction.QuoteSysID,dwTime);
            printString("pInputQuoteAction","ActionFlag",pInputQuoteAction.ActionFlag,dwTime);
            printString("pInputQuoteAction","UserID",pInputQuoteAction.UserID,dwTime);
            printString("pInputQuoteAction","InstrumentID",pInputQuoteAction.InstrumentID,dwTime);
            printString("pInputQuoteAction","InvestUnitID",pInputQuoteAction.InvestUnitID,dwTime);
            printString("pInputQuoteAction","ClientID",pInputQuoteAction.ClientID,dwTime);
            printString("pInputQuoteAction","IPAddress",pInputQuoteAction.IPAddress,dwTime);
            printString("pInputQuoteAction","MacAddress",pInputQuoteAction.MacAddress,dwTime);

            self.pInputQuoteAction2DB(pInputQuoteAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputQuoteAction)
                with nogil:
                  result = self._api.ReqQuoteAction(<CThostFtdcInputQuoteActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQuoteAction', exc_info=True)

        return result

    #批量报单操作请求
    def  ReqBatchOrderAction(self, pInputBatchOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputBatchOrderAction","BrokerID",pInputBatchOrderAction.BrokerID,dwTime);
            printString("pInputBatchOrderAction","InvestorID",pInputBatchOrderAction.InvestorID,dwTime);
            printNumber("pInputBatchOrderAction","OrderActionRef",pInputBatchOrderAction.OrderActionRef,dwTime);
            printNumber("pInputBatchOrderAction","RequestID",pInputBatchOrderAction.RequestID,dwTime);
            printNumber("pInputBatchOrderAction","FrontID",pInputBatchOrderAction.FrontID,dwTime);
            printNumber("pInputBatchOrderAction","SessionID",pInputBatchOrderAction.SessionID,dwTime);
            printString("pInputBatchOrderAction","ExchangeID",pInputBatchOrderAction.ExchangeID,dwTime);
            printString("pInputBatchOrderAction","UserID",pInputBatchOrderAction.UserID,dwTime);
            printString("pInputBatchOrderAction","InvestUnitID",pInputBatchOrderAction.InvestUnitID,dwTime);
            printString("pInputBatchOrderAction","IPAddress",pInputBatchOrderAction.IPAddress,dwTime);
            printString("pInputBatchOrderAction","MacAddress",pInputBatchOrderAction.MacAddress,dwTime);

            self.pInputBatchOrderAction2DB(pInputBatchOrderAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputBatchOrderAction)
                with nogil:
                  result = self._api.ReqBatchOrderAction(<CThostFtdcInputBatchOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqBatchOrderAction', exc_info=True)

        return result

    #期权自对冲录入请求
    def  ReqOptionSelfCloseInsert(self, pInputOptionSelfClose, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputOptionSelfClose","BrokerID",pInputOptionSelfClose.BrokerID,dwTime);
            printString("pInputOptionSelfClose","InvestorID",pInputOptionSelfClose.InvestorID,dwTime);
            printString("pInputOptionSelfClose","InstrumentID",pInputOptionSelfClose.InstrumentID,dwTime);
            printString("pInputOptionSelfClose","OptionSelfCloseRef",pInputOptionSelfClose.OptionSelfCloseRef,dwTime);
            printString("pInputOptionSelfClose","UserID",pInputOptionSelfClose.UserID,dwTime);
            printNumber("pInputOptionSelfClose","Volume",pInputOptionSelfClose.Volume,dwTime);
            printNumber("pInputOptionSelfClose","RequestID",pInputOptionSelfClose.RequestID,dwTime);
            printString("pInputOptionSelfClose","BusinessUnit",pInputOptionSelfClose.BusinessUnit,dwTime);
            printString("pInputOptionSelfClose","HedgeFlag",pInputOptionSelfClose.HedgeFlag,dwTime);
            printString("pInputOptionSelfClose","OptSelfCloseFlag",pInputOptionSelfClose.OptSelfCloseFlag,dwTime);
            printString("pInputOptionSelfClose","ExchangeID",pInputOptionSelfClose.ExchangeID,dwTime);
            printString("pInputOptionSelfClose","InvestUnitID",pInputOptionSelfClose.InvestUnitID,dwTime);
            printString("pInputOptionSelfClose","AccountID",pInputOptionSelfClose.AccountID,dwTime);
            printString("pInputOptionSelfClose","CurrencyID",pInputOptionSelfClose.CurrencyID,dwTime);
            printString("pInputOptionSelfClose","ClientID",pInputOptionSelfClose.ClientID,dwTime);
            printString("pInputOptionSelfClose","IPAddress",pInputOptionSelfClose.IPAddress,dwTime);
            printString("pInputOptionSelfClose","MacAddress",pInputOptionSelfClose.MacAddress,dwTime);

            self.pInputOptionSelfClose2DB(pInputOptionSelfClose)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputOptionSelfClose)
                with nogil:
                  result = self._api.ReqOptionSelfCloseInsert(<CThostFtdcInputOptionSelfCloseField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqOptionSelfCloseInsert', exc_info=True)

        return result

    #期权自对冲操作请求
    def  ReqOptionSelfCloseAction(self, pInputOptionSelfCloseAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputOptionSelfCloseAction","BrokerID",pInputOptionSelfCloseAction.BrokerID,dwTime);
            printString("pInputOptionSelfCloseAction","InvestorID",pInputOptionSelfCloseAction.InvestorID,dwTime);
            printNumber("pInputOptionSelfCloseAction","OptionSelfCloseActionRef",pInputOptionSelfCloseAction.OptionSelfCloseActionRef,dwTime);
            printString("pInputOptionSelfCloseAction","OptionSelfCloseRef",pInputOptionSelfCloseAction.OptionSelfCloseRef,dwTime);
            printNumber("pInputOptionSelfCloseAction","RequestID",pInputOptionSelfCloseAction.RequestID,dwTime);
            printNumber("pInputOptionSelfCloseAction","FrontID",pInputOptionSelfCloseAction.FrontID,dwTime);
            printNumber("pInputOptionSelfCloseAction","SessionID",pInputOptionSelfCloseAction.SessionID,dwTime);
            printString("pInputOptionSelfCloseAction","ExchangeID",pInputOptionSelfCloseAction.ExchangeID,dwTime);
            printString("pInputOptionSelfCloseAction","OptionSelfCloseSysID",pInputOptionSelfCloseAction.OptionSelfCloseSysID,dwTime);
            printString("pInputOptionSelfCloseAction","ActionFlag",pInputOptionSelfCloseAction.ActionFlag,dwTime);
            printString("pInputOptionSelfCloseAction","UserID",pInputOptionSelfCloseAction.UserID,dwTime);
            printString("pInputOptionSelfCloseAction","InstrumentID",pInputOptionSelfCloseAction.InstrumentID,dwTime);
            printString("pInputOptionSelfCloseAction","InvestUnitID",pInputOptionSelfCloseAction.InvestUnitID,dwTime);
            printString("pInputOptionSelfCloseAction","IPAddress",pInputOptionSelfCloseAction.IPAddress,dwTime);
            printString("pInputOptionSelfCloseAction","MacAddress",pInputOptionSelfCloseAction.MacAddress,dwTime);

            self.pInputOptionSelfCloseAction2DB(pInputOptionSelfCloseAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputOptionSelfCloseAction)
                with nogil:
                  result = self._api.ReqOptionSelfCloseAction(<CThostFtdcInputOptionSelfCloseActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqOptionSelfCloseAction', exc_info=True)

        return result

    #申请组合录入请求
    def  ReqCombActionInsert(self, pInputCombAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pInputCombAction","BrokerID",pInputCombAction.BrokerID,dwTime);
            printString("pInputCombAction","InvestorID",pInputCombAction.InvestorID,dwTime);
            printString("pInputCombAction","InstrumentID",pInputCombAction.InstrumentID,dwTime);
            printString("pInputCombAction","CombActionRef",pInputCombAction.CombActionRef,dwTime);
            printString("pInputCombAction","UserID",pInputCombAction.UserID,dwTime);
            printString("pInputCombAction","Direction",pInputCombAction.Direction,dwTime);
            printNumber("pInputCombAction","Volume",pInputCombAction.Volume,dwTime);
            printString("pInputCombAction","CombDirection",pInputCombAction.CombDirection,dwTime);
            printString("pInputCombAction","HedgeFlag",pInputCombAction.HedgeFlag,dwTime);
            printString("pInputCombAction","ExchangeID",pInputCombAction.ExchangeID,dwTime);
            printString("pInputCombAction","IPAddress",pInputCombAction.IPAddress,dwTime);
            printString("pInputCombAction","MacAddress",pInputCombAction.MacAddress,dwTime);
            printString("pInputCombAction","InvestUnitID",pInputCombAction.InvestUnitID,dwTime);

            self.pInputCombAction2DB(pInputCombAction)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pInputCombAction)
                with nogil:
                  result = self._api.ReqCombActionInsert(<CThostFtdcInputCombActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqCombActionInsert', exc_info=True)

        return result

    #请求查询报单
    def  ReqQryOrder(self, pQryOrder, int nRequestID):
    
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryOrder","BrokerID",pQryOrder.BrokerID,dwTime);
            printString("pQryOrder","InvestorID",pQryOrder.InvestorID,dwTime);
            printString("pQryOrder","InstrumentID",pQryOrder.InstrumentID,dwTime);
            printString("pQryOrder","ExchangeID",pQryOrder.ExchangeID,dwTime);
            printString("pQryOrder","OrderSysID",pQryOrder.OrderSysID,dwTime);
            printString("pQryOrder","InsertTimeStart",pQryOrder.InsertTimeStart,dwTime);
            printString("pQryOrder","InsertTimeEnd",pQryOrder.InsertTimeEnd,dwTime);
            printString("pQryOrder","InvestUnitID",pQryOrder.InvestUnitID,dwTime);

            self.pQryOrder2DB(pQryOrder)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryOrder)
              with nogil:
                result = self._api.ReqQryOrder(<CThostFtdcQryOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryOrder', exc_info=True)

        return result

    #请求查询成交
    def  ReqQryTrade(self, pQryTrade, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTrade","BrokerID",pQryTrade.BrokerID,dwTime);
            printString("pQryTrade","InvestorID",pQryTrade.InvestorID,dwTime);
            printString("pQryTrade","InstrumentID",pQryTrade.InstrumentID,dwTime);
            printString("pQryTrade","ExchangeID",pQryTrade.ExchangeID,dwTime);
            printString("pQryTrade","TradeID",pQryTrade.TradeID,dwTime);
            printString("pQryTrade","TradeTimeStart",pQryTrade.TradeTimeStart,dwTime);
            printString("pQryTrade","TradeTimeEnd",pQryTrade.TradeTimeEnd,dwTime);
            printString("pQryTrade","InvestUnitID",pQryTrade.InvestUnitID,dwTime);

            self.pQryTrade2DB(pQryTrade)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTrade)
              with nogil:
                result = self._api.ReqQryTrade(<CThostFtdcQryTradeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTrade', exc_info=True)

        return result

    #请求查询投资者持仓
    def  ReqQryInvestorPosition(self, pQryInvestorPosition, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestorPosition","BrokerID",pQryInvestorPosition.BrokerID,dwTime);
            printString("pQryInvestorPosition","InvestorID",pQryInvestorPosition.InvestorID,dwTime);
            printString("pQryInvestorPosition","InstrumentID",pQryInvestorPosition.InstrumentID,dwTime);
            printString("pQryInvestorPosition","ExchangeID",pQryInvestorPosition.ExchangeID,dwTime);
            printString("pQryInvestorPosition","InvestUnitID",pQryInvestorPosition.InvestUnitID,dwTime);

            self.pQryInvestorPosition2DB(pQryInvestorPosition)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestorPosition)
              with nogil:
                result = self._api.ReqQryInvestorPosition(<CThostFtdcQryInvestorPositionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestorPosition', exc_info=True)

        return result

    #请求查询资金账户
    def  ReqQryTradingAccount(self, pQryTradingAccount, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTradingAccount","BrokerID",pQryTradingAccount.BrokerID,dwTime);
            printString("pQryTradingAccount","InvestorID",pQryTradingAccount.InvestorID,dwTime);
            printString("pQryTradingAccount","CurrencyID",pQryTradingAccount.CurrencyID,dwTime);
            printString("pQryTradingAccount","BizType",pQryTradingAccount.BizType,dwTime);
            printString("pQryTradingAccount","AccountID",pQryTradingAccount.AccountID,dwTime);

            self.pQryTradingAccount2DB(pQryTradingAccount)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTradingAccount)
              with nogil:
                result = self._api.ReqQryTradingAccount(<CThostFtdcQryTradingAccountField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTradingAccount', exc_info=True)

        return result

    #请求查询投资者
    def  ReqQryInvestor(self, pQryInvestor, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestor","BrokerID",pQryInvestor.BrokerID,dwTime);
            printString("pQryInvestor","InvestorID",pQryInvestor.InvestorID,dwTime);

            self.pQryInvestor2DB(pQryInvestor)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestor)
              with nogil:
                result = self._api.ReqQryInvestor(<CThostFtdcQryInvestorField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestor', exc_info=True)

        return result

    #请求查询交易编码
    def  ReqQryTradingCode(self, pQryTradingCode, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTradingCode","BrokerID",pQryTradingCode.BrokerID,dwTime);
            printString("pQryTradingCode","InvestorID",pQryTradingCode.InvestorID,dwTime);
            printString("pQryTradingCode","ExchangeID",pQryTradingCode.ExchangeID,dwTime);
            printString("pQryTradingCode","ClientID",pQryTradingCode.ClientID,dwTime);
            printString("pQryTradingCode","ClientIDType",pQryTradingCode.ClientIDType,dwTime);
            printString("pQryTradingCode","InvestUnitID",pQryTradingCode.InvestUnitID,dwTime);

            self.pQryTradingCode2DB(pQryTradingCode)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTradingCode)
              with nogil:
                result = self._api.ReqQryTradingCode(<CThostFtdcQryTradingCodeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTradingCode', exc_info=True)

        return result

    #请求查询合约保证金率
    def  ReqQryInstrumentMarginRate(self, pQryInstrumentMarginRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInstrumentMarginRate","BrokerID",pQryInstrumentMarginRate.BrokerID,dwTime);
            printString("pQryInstrumentMarginRate","InvestorID",pQryInstrumentMarginRate.InvestorID,dwTime);
            printString("pQryInstrumentMarginRate","InstrumentID",pQryInstrumentMarginRate.InstrumentID,dwTime);
            printString("pQryInstrumentMarginRate","HedgeFlag",pQryInstrumentMarginRate.HedgeFlag,dwTime);
            printString("pQryInstrumentMarginRate","ExchangeID",pQryInstrumentMarginRate.ExchangeID,dwTime);
            printString("pQryInstrumentMarginRate","InvestUnitID",pQryInstrumentMarginRate.InvestUnitID,dwTime);

            self.pQryInstrumentMarginRate2DB(pQryInstrumentMarginRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInstrumentMarginRate)
              with nogil:
                result = self._api.ReqQryInstrumentMarginRate(<CThostFtdcQryInstrumentMarginRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInstrumentMarginRate', exc_info=True)

        return result

    #请求查询合约手续费率
    def  ReqQryInstrumentCommissionRate(self, pQryInstrumentCommissionRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInstrumentCommissionRate","BrokerID",pQryInstrumentCommissionRate.BrokerID,dwTime);
            printString("pQryInstrumentCommissionRate","InvestorID",pQryInstrumentCommissionRate.InvestorID,dwTime);
            printString("pQryInstrumentCommissionRate","InstrumentID",pQryInstrumentCommissionRate.InstrumentID,dwTime);
            printString("pQryInstrumentCommissionRate","ExchangeID",pQryInstrumentCommissionRate.ExchangeID,dwTime);
            printString("pQryInstrumentCommissionRate","InvestUnitID",pQryInstrumentCommissionRate.InvestUnitID,dwTime);

            self.pQryInstrumentCommissionRate2DB(pQryInstrumentCommissionRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInstrumentCommissionRate)
              with nogil:
                result = self._api.ReqQryInstrumentCommissionRate(<CThostFtdcQryInstrumentCommissionRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInstrumentCommissionRate', exc_info=True)

        return result

    #请求查询交易所
    def  ReqQryExchange(self, pQryExchange, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryExchange","ExchangeID",pQryExchange.ExchangeID,dwTime);

            self.pQryExchange2DB(pQryExchange)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryExchange)
              with nogil:
                result = self._api.ReqQryExchange(<CThostFtdcQryExchangeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryExchange', exc_info=True)

        return result

    #请求查询产品
    def  ReqQryProduct(self, pQryProduct, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryProduct","ProductID",pQryProduct.ProductID,dwTime);
            printString("pQryProduct","ProductClass",pQryProduct.ProductClass,dwTime);
            printString("pQryProduct","ExchangeID",pQryProduct.ExchangeID,dwTime);

            self.pQryProduct2DB(pQryProduct)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryProduct)
              with nogil:
                result = self._api.ReqQryProduct(<CThostFtdcQryProductField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryProduct', exc_info=True)

        return result

    #请求查询合约
    def  ReqQryInstrument(self, pQryInstrument, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInstrument","InstrumentID",pQryInstrument.InstrumentID,dwTime);
            printString("pQryInstrument","ExchangeID",pQryInstrument.ExchangeID,dwTime);
            printString("pQryInstrument","ExchangeInstID",pQryInstrument.ExchangeInstID,dwTime);
            printString("pQryInstrument","ProductID",pQryInstrument.ProductID,dwTime);

            self.pQryInstrument2DB(pQryInstrument)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInstrument)
              with nogil:
                result = self._api.ReqQryInstrument(<CThostFtdcQryInstrumentField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInstrument', exc_info=True)

        return result

    #请求查询行情
    def  ReqQryDepthMarketData(self, pQryDepthMarketData, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryDepthMarketData","InstrumentID",pQryDepthMarketData.InstrumentID,dwTime);
            printString("pQryDepthMarketData","ExchangeID",pQryDepthMarketData.ExchangeID,dwTime);

            self.pQryDepthMarketData2DB(pQryDepthMarketData)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryDepthMarketData)
              with nogil:
                result = self._api.ReqQryDepthMarketData(<CThostFtdcQryDepthMarketDataField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryDepthMarketData', exc_info=True)

        return result

    #请求查询投资者结算结果
    def  ReqQrySettlementInfo(self, pQrySettlementInfo, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQrySettlementInfo","BrokerID",pQrySettlementInfo.BrokerID,dwTime);
            printString("pQrySettlementInfo","InvestorID",pQrySettlementInfo.InvestorID,dwTime);
            printString("pQrySettlementInfo","TradingDay",pQrySettlementInfo.TradingDay,dwTime);
            printString("pQrySettlementInfo","AccountID",pQrySettlementInfo.AccountID,dwTime);
            printString("pQrySettlementInfo","CurrencyID",pQrySettlementInfo.CurrencyID,dwTime);

            self.pQrySettlementInfo2DB(pQrySettlementInfo)

            if self._spi is not NULL:
              address = ctypes.addressof(pQrySettlementInfo)
              with nogil:
                result = self._api.ReqQrySettlementInfo(<CThostFtdcQrySettlementInfoField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQrySettlementInfo', exc_info=True)

        return result

    #请求查询转帐银行
    def  ReqQryTransferBank(self, pQryTransferBank, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTransferBank","BankID",pQryTransferBank.BankID,dwTime);
            printString("pQryTransferBank","BankBrchID",pQryTransferBank.BankBrchID,dwTime);

            self.pQryTransferBank2DB(pQryTransferBank)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTransferBank)
              with nogil:
                result = self._api.ReqQryTransferBank(<CThostFtdcQryTransferBankField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTransferBank', exc_info=True)

        return result

    #请求查询投资者持仓明细
    def  ReqQryInvestorPositionDetail(self, pQryInvestorPositionDetail, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestorPositionDetail","BrokerID",pQryInvestorPositionDetail.BrokerID,dwTime);
            printString("pQryInvestorPositionDetail","InvestorID",pQryInvestorPositionDetail.InvestorID,dwTime);
            printString("pQryInvestorPositionDetail","InstrumentID",pQryInvestorPositionDetail.InstrumentID,dwTime);
            printString("pQryInvestorPositionDetail","ExchangeID",pQryInvestorPositionDetail.ExchangeID,dwTime);
            printString("pQryInvestorPositionDetail","InvestUnitID",pQryInvestorPositionDetail.InvestUnitID,dwTime);

            self.pQryInvestorPositionDetail2DB(pQryInvestorPositionDetail)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestorPositionDetail)
              with nogil:
                result = self._api.ReqQryInvestorPositionDetail(<CThostFtdcQryInvestorPositionDetailField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestorPositionDetail', exc_info=True)

        return result

    #请求查询客户通知
    def  ReqQryNotice(self, pQryNotice, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryNotice","BrokerID",pQryNotice.BrokerID,dwTime);

            self.pQryNotice2DB(pQryNotice)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryNotice)
              with nogil:
                result = self._api.ReqQryNotice(<CThostFtdcQryNoticeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryNotice', exc_info=True)

        return result

    #请求查询结算信息确认
    def  ReqQrySettlementInfoConfirm(self, pQrySettlementInfoConfirm, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQrySettlementInfoConfirm","BrokerID",pQrySettlementInfoConfirm.BrokerID,dwTime);
            printString("pQrySettlementInfoConfirm","InvestorID",pQrySettlementInfoConfirm.InvestorID,dwTime);
            printString("pQrySettlementInfoConfirm","AccountID",pQrySettlementInfoConfirm.AccountID,dwTime);
            printString("pQrySettlementInfoConfirm","CurrencyID",pQrySettlementInfoConfirm.CurrencyID,dwTime);

            self.pQrySettlementInfoConfirm2DB(pQrySettlementInfoConfirm)

            if self._spi is not NULL:
              address = ctypes.addressof(pQrySettlementInfoConfirm)
              with nogil:
                result = self._api.ReqQrySettlementInfoConfirm(<CThostFtdcQrySettlementInfoConfirmField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQrySettlementInfoConfirm', exc_info=True)

        return result

    #请求查询投资者持仓明细
    def  ReqQryInvestorPositionCombineDetail(self, pQryInvestorPositionCombineDetail, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestorPositionCombineDetail","BrokerID",pQryInvestorPositionCombineDetail.BrokerID,dwTime);
            printString("pQryInvestorPositionCombineDetail","InvestorID",pQryInvestorPositionCombineDetail.InvestorID,dwTime);
            printString("pQryInvestorPositionCombineDetail","CombInstrumentID",pQryInvestorPositionCombineDetail.CombInstrumentID,dwTime);
            printString("pQryInvestorPositionCombineDetail","ExchangeID",pQryInvestorPositionCombineDetail.ExchangeID,dwTime);
            printString("pQryInvestorPositionCombineDetail","InvestUnitID",pQryInvestorPositionCombineDetail.InvestUnitID,dwTime);

            self.pQryInvestorPositionCombineDetail2DB(pQryInvestorPositionCombineDetail)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestorPositionCombineDetail)
              with nogil:
                result = self._api.ReqQryInvestorPositionCombineDetail(<CThostFtdcQryInvestorPositionCombineDetailField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestorPositionCombineDetail', exc_info=True)

        return result

    #请求查询保证金监管系统经纪公司资金账户密钥
    def  ReqQryCFMMCTradingAccountKey(self, pQryCFMMCTradingAccountKey, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryCFMMCTradingAccountKey","BrokerID",pQryCFMMCTradingAccountKey.BrokerID,dwTime);
            printString("pQryCFMMCTradingAccountKey","InvestorID",pQryCFMMCTradingAccountKey.InvestorID,dwTime);

            self.pQryCFMMCTradingAccountKey2DB(pQryCFMMCTradingAccountKey)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryCFMMCTradingAccountKey)
              with nogil:
                result = self._api.ReqQryCFMMCTradingAccountKey(<CThostFtdcQryCFMMCTradingAccountKeyField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryCFMMCTradingAccountKey', exc_info=True)

        return result

    #请求查询仓单折抵信息
    def  ReqQryEWarrantOffset(self, pQryEWarrantOffset, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryEWarrantOffset","BrokerID",pQryEWarrantOffset.BrokerID,dwTime);
            printString("pQryEWarrantOffset","InvestorID",pQryEWarrantOffset.InvestorID,dwTime);
            printString("pQryEWarrantOffset","ExchangeID",pQryEWarrantOffset.ExchangeID,dwTime);
            printString("pQryEWarrantOffset","InstrumentID",pQryEWarrantOffset.InstrumentID,dwTime);
            printString("pQryEWarrantOffset","InvestUnitID",pQryEWarrantOffset.InvestUnitID,dwTime);

            self.pQryEWarrantOffset2DB(pQryEWarrantOffset)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryEWarrantOffset)
              with nogil:
                result = self._api.ReqQryEWarrantOffset(<CThostFtdcQryEWarrantOffsetField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryEWarrantOffset', exc_info=True)

        return result

    #请求查询投资者品种/跨品种保证金
    def  ReqQryInvestorProductGroupMargin(self, pQryInvestorProductGroupMargin, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestorProductGroupMargin","BrokerID",pQryInvestorProductGroupMargin.BrokerID,dwTime);
            printString("pQryInvestorProductGroupMargin","InvestorID",pQryInvestorProductGroupMargin.InvestorID,dwTime);
            printString("pQryInvestorProductGroupMargin","ProductGroupID",pQryInvestorProductGroupMargin.ProductGroupID,dwTime);
            printString("pQryInvestorProductGroupMargin","HedgeFlag",pQryInvestorProductGroupMargin.HedgeFlag,dwTime);
            printString("pQryInvestorProductGroupMargin","ExchangeID",pQryInvestorProductGroupMargin.ExchangeID,dwTime);
            printString("pQryInvestorProductGroupMargin","InvestUnitID",pQryInvestorProductGroupMargin.InvestUnitID,dwTime);

            self.pQryInvestorProductGroupMargin2DB(pQryInvestorProductGroupMargin)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestorProductGroupMargin)
              with nogil:
                result = self._api.ReqQryInvestorProductGroupMargin(<CThostFtdcQryInvestorProductGroupMarginField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestorProductGroupMargin', exc_info=True)

        return result

    #请求查询交易所保证金率
    def  ReqQryExchangeMarginRate(self, pQryExchangeMarginRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryExchangeMarginRate","BrokerID",pQryExchangeMarginRate.BrokerID,dwTime);
            printString("pQryExchangeMarginRate","InstrumentID",pQryExchangeMarginRate.InstrumentID,dwTime);
            printString("pQryExchangeMarginRate","HedgeFlag",pQryExchangeMarginRate.HedgeFlag,dwTime);
            printString("pQryExchangeMarginRate","ExchangeID",pQryExchangeMarginRate.ExchangeID,dwTime);

            self.pQryExchangeMarginRate2DB(pQryExchangeMarginRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryExchangeMarginRate)
              with nogil:
                result = self._api.ReqQryExchangeMarginRate(<CThostFtdcQryExchangeMarginRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryExchangeMarginRate', exc_info=True)

        return result

    #请求查询交易所调整保证金率
    def  ReqQryExchangeMarginRateAdjust(self, pQryExchangeMarginRateAdjust, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryExchangeMarginRateAdjust","BrokerID",pQryExchangeMarginRateAdjust.BrokerID,dwTime);
            printString("pQryExchangeMarginRateAdjust","InstrumentID",pQryExchangeMarginRateAdjust.InstrumentID,dwTime);
            printString("pQryExchangeMarginRateAdjust","HedgeFlag",pQryExchangeMarginRateAdjust.HedgeFlag,dwTime);

            self.pQryExchangeMarginRateAdjust2DB(pQryExchangeMarginRateAdjust)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryExchangeMarginRateAdjust)
              with nogil:
                result = self._api.ReqQryExchangeMarginRateAdjust(<CThostFtdcQryExchangeMarginRateAdjustField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryExchangeMarginRateAdjust', exc_info=True)

        return result

    #请求查询汇率
    def  ReqQryExchangeRate(self, pQryExchangeRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryExchangeRate","BrokerID",pQryExchangeRate.BrokerID,dwTime);
            printString("pQryExchangeRate","FromCurrencyID",pQryExchangeRate.FromCurrencyID,dwTime);
            printString("pQryExchangeRate","ToCurrencyID",pQryExchangeRate.ToCurrencyID,dwTime);

            self.pQryExchangeRate2DB(pQryExchangeRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryExchangeRate)
              with nogil:
                result = self._api.ReqQryExchangeRate(<CThostFtdcQryExchangeRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryExchangeRate', exc_info=True)

        return result

    #请求查询二级代理操作员银期权限
    def  ReqQrySecAgentACIDMap(self, pQrySecAgentACIDMap, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQrySecAgentACIDMap","BrokerID",pQrySecAgentACIDMap.BrokerID,dwTime);
            printString("pQrySecAgentACIDMap","UserID",pQrySecAgentACIDMap.UserID,dwTime);
            printString("pQrySecAgentACIDMap","AccountID",pQrySecAgentACIDMap.AccountID,dwTime);
            printString("pQrySecAgentACIDMap","CurrencyID",pQrySecAgentACIDMap.CurrencyID,dwTime);

            self.pQrySecAgentACIDMap2DB(pQrySecAgentACIDMap)

            if self._spi is not NULL:
              address = ctypes.addressof(pQrySecAgentACIDMap)
              with nogil:
                result = self._api.ReqQrySecAgentACIDMap(<CThostFtdcQrySecAgentACIDMapField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQrySecAgentACIDMap', exc_info=True)

        return result

    #请求查询产品报价汇率
    def  ReqQryProductExchRate(self, pQryProductExchRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryProductExchRate","ProductID",pQryProductExchRate.ProductID,dwTime);
            printString("pQryProductExchRate","ExchangeID",pQryProductExchRate.ExchangeID,dwTime);

            self.pQryProductExchRate2DB(pQryProductExchRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryProductExchRate)
              with nogil:
                result = self._api.ReqQryProductExchRate(<CThostFtdcQryProductExchRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryProductExchRate', exc_info=True)

        return result

    #请求查询产品组
    def  ReqQryProductGroup(self, pQryProductGroup, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryProductGroup","ProductID",pQryProductGroup.ProductID,dwTime);
            printString("pQryProductGroup","ExchangeID",pQryProductGroup.ExchangeID,dwTime);

            self.pQryProductGroup2DB(pQryProductGroup)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryProductGroup)
              with nogil:
                result = self._api.ReqQryProductGroup(<CThostFtdcQryProductGroupField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryProductGroup', exc_info=True)

        return result

    #请求查询做市商合约手续费率
    def  ReqQryMMInstrumentCommissionRate(self, pQryMMInstrumentCommissionRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryMMInstrumentCommissionRate","BrokerID",pQryMMInstrumentCommissionRate.BrokerID,dwTime);
            printString("pQryMMInstrumentCommissionRate","InvestorID",pQryMMInstrumentCommissionRate.InvestorID,dwTime);
            printString("pQryMMInstrumentCommissionRate","InstrumentID",pQryMMInstrumentCommissionRate.InstrumentID,dwTime);

            self.pQryMMInstrumentCommissionRate2DB(pQryMMInstrumentCommissionRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryMMInstrumentCommissionRate)
              with nogil:
                result = self._api.ReqQryMMInstrumentCommissionRate(<CThostFtdcQryMMInstrumentCommissionRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryMMInstrumentCommissionRate', exc_info=True)

        return result

    #请求查询做市商期权合约手续费
    def  ReqQryMMOptionInstrCommRate(self, pQryMMOptionInstrCommRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryMMOptionInstrCommRate","BrokerID",pQryMMOptionInstrCommRate.BrokerID,dwTime);
            printString("pQryMMOptionInstrCommRate","InvestorID",pQryMMOptionInstrCommRate.InvestorID,dwTime);
            printString("pQryMMOptionInstrCommRate","InstrumentID",pQryMMOptionInstrCommRate.InstrumentID,dwTime);

            self.pQryMMOptionInstrCommRate2DB(pQryMMOptionInstrCommRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryMMOptionInstrCommRate)
              with nogil:
                result = self._api.ReqQryMMOptionInstrCommRate(<CThostFtdcQryMMOptionInstrCommRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryMMOptionInstrCommRate', exc_info=True)

        return result

    #请求查询报单手续费
    def  ReqQryInstrumentOrderCommRate(self, pQryInstrumentOrderCommRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInstrumentOrderCommRate","BrokerID",pQryInstrumentOrderCommRate.BrokerID,dwTime);
            printString("pQryInstrumentOrderCommRate","InvestorID",pQryInstrumentOrderCommRate.InvestorID,dwTime);
            printString("pQryInstrumentOrderCommRate","InstrumentID",pQryInstrumentOrderCommRate.InstrumentID,dwTime);

            self.pQryInstrumentOrderCommRate2DB(pQryInstrumentOrderCommRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInstrumentOrderCommRate)
              with nogil:
                result = self._api.ReqQryInstrumentOrderCommRate(<CThostFtdcQryInstrumentOrderCommRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInstrumentOrderCommRate', exc_info=True)

        return result

    #请求查询资金账户
    def  ReqQrySecAgentTradingAccount(self, pQryTradingAccount, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTradingAccount","BrokerID",pQryTradingAccount.BrokerID,dwTime);
            printString("pQryTradingAccount","InvestorID",pQryTradingAccount.InvestorID,dwTime);
            printString("pQryTradingAccount","CurrencyID",pQryTradingAccount.CurrencyID,dwTime);
            printString("pQryTradingAccount","BizType",pQryTradingAccount.BizType,dwTime);
            printString("pQryTradingAccount","AccountID",pQryTradingAccount.AccountID,dwTime);

            self.pQryTradingAccount2DB(pQryTradingAccount)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTradingAccount)
              with nogil:
                result = self._api.ReqQrySecAgentTradingAccount(<CThostFtdcQryTradingAccountField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQrySecAgentTradingAccount', exc_info=True)

        return result

    #请求查询二级代理商资金校验模式
    def  ReqQrySecAgentCheckMode(self, pQrySecAgentCheckMode, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQrySecAgentCheckMode","BrokerID",pQrySecAgentCheckMode.BrokerID,dwTime);
            printString("pQrySecAgentCheckMode","InvestorID",pQrySecAgentCheckMode.InvestorID,dwTime);

            self.pQrySecAgentCheckMode2DB(pQrySecAgentCheckMode)

            if self._spi is not NULL:
              address = ctypes.addressof(pQrySecAgentCheckMode)
              with nogil:
                result = self._api.ReqQrySecAgentCheckMode(<CThostFtdcQrySecAgentCheckModeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQrySecAgentCheckMode', exc_info=True)

        return result

    #请求查询期权交易成本
    def  ReqQryOptionInstrTradeCost(self, pQryOptionInstrTradeCost, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryOptionInstrTradeCost","BrokerID",pQryOptionInstrTradeCost.BrokerID,dwTime);
            printString("pQryOptionInstrTradeCost","InvestorID",pQryOptionInstrTradeCost.InvestorID,dwTime);
            printString("pQryOptionInstrTradeCost","InstrumentID",pQryOptionInstrTradeCost.InstrumentID,dwTime);
            printString("pQryOptionInstrTradeCost","HedgeFlag",pQryOptionInstrTradeCost.HedgeFlag,dwTime);
            printNumber("pQryOptionInstrTradeCost","InputPrice",pQryOptionInstrTradeCost.InputPrice,dwTime);
            printNumber("pQryOptionInstrTradeCost","UnderlyingPrice",pQryOptionInstrTradeCost.UnderlyingPrice,dwTime);
            printString("pQryOptionInstrTradeCost","ExchangeID",pQryOptionInstrTradeCost.ExchangeID,dwTime);
            printString("pQryOptionInstrTradeCost","InvestUnitID",pQryOptionInstrTradeCost.InvestUnitID,dwTime);

            self.pQryOptionInstrTradeCost2DB(pQryOptionInstrTradeCost)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryOptionInstrTradeCost)
              with nogil:
                result = self._api.ReqQryOptionInstrTradeCost(<CThostFtdcQryOptionInstrTradeCostField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryOptionInstrTradeCost', exc_info=True)

        return result

    #请求查询期权合约手续费
    def  ReqQryOptionInstrCommRate(self, pQryOptionInstrCommRate, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryOptionInstrCommRate","BrokerID",pQryOptionInstrCommRate.BrokerID,dwTime);
            printString("pQryOptionInstrCommRate","InvestorID",pQryOptionInstrCommRate.InvestorID,dwTime);
            printString("pQryOptionInstrCommRate","InstrumentID",pQryOptionInstrCommRate.InstrumentID,dwTime);
            printString("pQryOptionInstrCommRate","ExchangeID",pQryOptionInstrCommRate.ExchangeID,dwTime);
            printString("pQryOptionInstrCommRate","InvestUnitID",pQryOptionInstrCommRate.InvestUnitID,dwTime);

            self.pQryOptionInstrCommRate2DB(pQryOptionInstrCommRate)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryOptionInstrCommRate)
              with nogil:
                result = self._api.ReqQryOptionInstrCommRate(<CThostFtdcQryOptionInstrCommRateField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryOptionInstrCommRate', exc_info=True)

        return result

    #请求查询执行宣告
    def  ReqQryExecOrder(self, pQryExecOrder, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryExecOrder","BrokerID",pQryExecOrder.BrokerID,dwTime);
            printString("pQryExecOrder","InvestorID",pQryExecOrder.InvestorID,dwTime);
            printString("pQryExecOrder","InstrumentID",pQryExecOrder.InstrumentID,dwTime);
            printString("pQryExecOrder","ExchangeID",pQryExecOrder.ExchangeID,dwTime);
            printString("pQryExecOrder","ExecOrderSysID",pQryExecOrder.ExecOrderSysID,dwTime);
            printString("pQryExecOrder","InsertTimeStart",pQryExecOrder.InsertTimeStart,dwTime);
            printString("pQryExecOrder","InsertTimeEnd",pQryExecOrder.InsertTimeEnd,dwTime);

            self.pQryExecOrder2DB(pQryExecOrder)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryExecOrder)
              with nogil:
                result = self._api.ReqQryExecOrder(<CThostFtdcQryExecOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryExecOrder', exc_info=True)

        return result

    #请求查询询价
    def  ReqQryForQuote(self, pQryForQuote, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryForQuote","BrokerID",pQryForQuote.BrokerID,dwTime);
            printString("pQryForQuote","InvestorID",pQryForQuote.InvestorID,dwTime);
            printString("pQryForQuote","InstrumentID",pQryForQuote.InstrumentID,dwTime);
            printString("pQryForQuote","ExchangeID",pQryForQuote.ExchangeID,dwTime);
            printString("pQryForQuote","InsertTimeStart",pQryForQuote.InsertTimeStart,dwTime);
            printString("pQryForQuote","InsertTimeEnd",pQryForQuote.InsertTimeEnd,dwTime);
            printString("pQryForQuote","InvestUnitID",pQryForQuote.InvestUnitID,dwTime);

            self.pQryForQuote2DB(pQryForQuote)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryForQuote)
              with nogil:
                result = self._api.ReqQryForQuote(<CThostFtdcQryForQuoteField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryForQuote', exc_info=True)

        return result

    #请求查询报价
    def  ReqQryQuote(self, pQryQuote, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryQuote","BrokerID",pQryQuote.BrokerID,dwTime);
            printString("pQryQuote","InvestorID",pQryQuote.InvestorID,dwTime);
            printString("pQryQuote","InstrumentID",pQryQuote.InstrumentID,dwTime);
            printString("pQryQuote","ExchangeID",pQryQuote.ExchangeID,dwTime);
            printString("pQryQuote","QuoteSysID",pQryQuote.QuoteSysID,dwTime);
            printString("pQryQuote","InsertTimeStart",pQryQuote.InsertTimeStart,dwTime);
            printString("pQryQuote","InsertTimeEnd",pQryQuote.InsertTimeEnd,dwTime);
            printString("pQryQuote","InvestUnitID",pQryQuote.InvestUnitID,dwTime);

            self.pQryQuote2DB(pQryQuote)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryQuote)
              with nogil:
                result = self._api.ReqQryQuote(<CThostFtdcQryQuoteField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryQuote', exc_info=True)

        return result

    #请求查询期权自对冲
    def  ReqQryOptionSelfClose(self, pQryOptionSelfClose, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryOptionSelfClose","BrokerID",pQryOptionSelfClose.BrokerID,dwTime);
            printString("pQryOptionSelfClose","InvestorID",pQryOptionSelfClose.InvestorID,dwTime);
            printString("pQryOptionSelfClose","InstrumentID",pQryOptionSelfClose.InstrumentID,dwTime);
            printString("pQryOptionSelfClose","ExchangeID",pQryOptionSelfClose.ExchangeID,dwTime);
            printString("pQryOptionSelfClose","OptionSelfCloseSysID",pQryOptionSelfClose.OptionSelfCloseSysID,dwTime);
            printString("pQryOptionSelfClose","InsertTimeStart",pQryOptionSelfClose.InsertTimeStart,dwTime);
            printString("pQryOptionSelfClose","InsertTimeEnd",pQryOptionSelfClose.InsertTimeEnd,dwTime);

            self.pQryOptionSelfClose2DB(pQryOptionSelfClose)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryOptionSelfClose)
              with nogil:
                result = self._api.ReqQryOptionSelfClose(<CThostFtdcQryOptionSelfCloseField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryOptionSelfClose', exc_info=True)

        return result

    #请求查询投资单元
    def  ReqQryInvestUnit(self, pQryInvestUnit, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryInvestUnit","BrokerID",pQryInvestUnit.BrokerID,dwTime);
            printString("pQryInvestUnit","InvestorID",pQryInvestUnit.InvestorID,dwTime);
            printString("pQryInvestUnit","InvestUnitID",pQryInvestUnit.InvestUnitID,dwTime);

            self.pQryInvestUnit2DB(pQryInvestUnit)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryInvestUnit)
              with nogil:
                result = self._api.ReqQryInvestUnit(<CThostFtdcQryInvestUnitField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryInvestUnit', exc_info=True)

        return result

    #请求查询组合合约安全系数
    def  ReqQryCombInstrumentGuard(self, pQryCombInstrumentGuard, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryCombInstrumentGuard","BrokerID",pQryCombInstrumentGuard.BrokerID,dwTime);
            printString("pQryCombInstrumentGuard","InstrumentID",pQryCombInstrumentGuard.InstrumentID,dwTime);
            printString("pQryCombInstrumentGuard","ExchangeID",pQryCombInstrumentGuard.ExchangeID,dwTime);

            self.pQryCombInstrumentGuard2DB(pQryCombInstrumentGuard)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryCombInstrumentGuard)
              with nogil:
                result = self._api.ReqQryCombInstrumentGuard(<CThostFtdcQryCombInstrumentGuardField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryCombInstrumentGuard', exc_info=True)

        return result

    #请求查询申请组合
    def  ReqQryCombAction(self, pQryCombAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryCombAction","BrokerID",pQryCombAction.BrokerID,dwTime);
            printString("pQryCombAction","InvestorID",pQryCombAction.InvestorID,dwTime);
            printString("pQryCombAction","InstrumentID",pQryCombAction.InstrumentID,dwTime);
            printString("pQryCombAction","ExchangeID",pQryCombAction.ExchangeID,dwTime);
            printString("pQryCombAction","InvestUnitID",pQryCombAction.InvestUnitID,dwTime);

            self.pQryCombAction2DB(pQryCombAction)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryCombAction)
              with nogil:
                result = self._api.ReqQryCombAction(<CThostFtdcQryCombActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryCombAction', exc_info=True)

        return result

    #请求查询转帐流水
    def  ReqQryTransferSerial(self, pQryTransferSerial, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTransferSerial","BrokerID",pQryTransferSerial.BrokerID,dwTime);
            printString("pQryTransferSerial","AccountID",pQryTransferSerial.AccountID,dwTime);
            printString("pQryTransferSerial","BankID",pQryTransferSerial.BankID,dwTime);
            printString("pQryTransferSerial","CurrencyID",pQryTransferSerial.CurrencyID,dwTime);

            self.pQryTransferSerial2DB(pQryTransferSerial)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTransferSerial)
              with nogil:
                result = self._api.ReqQryTransferSerial(<CThostFtdcQryTransferSerialField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTransferSerial', exc_info=True)

        return result

    #请求查询银期签约关系
    def  ReqQryAccountregister(self, pQryAccountregister, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryAccountregister","BrokerID",pQryAccountregister.BrokerID,dwTime);
            printString("pQryAccountregister","AccountID",pQryAccountregister.AccountID,dwTime);
            printString("pQryAccountregister","BankID",pQryAccountregister.BankID,dwTime);
            printString("pQryAccountregister","BankBranchID",pQryAccountregister.BankBranchID,dwTime);
            printString("pQryAccountregister","CurrencyID",pQryAccountregister.CurrencyID,dwTime);

            self.pQryAccountregister2DB(pQryAccountregister)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryAccountregister)
              with nogil:
                result = self._api.ReqQryAccountregister(<CThostFtdcQryAccountregisterField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryAccountregister', exc_info=True)

        return result

    #请求查询签约银行
    def  ReqQryContractBank(self, pQryContractBank, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryContractBank","BrokerID",pQryContractBank.BrokerID,dwTime);
            printString("pQryContractBank","BankID",pQryContractBank.BankID,dwTime);
            printString("pQryContractBank","BankBrchID",pQryContractBank.BankBrchID,dwTime);

            self.pQryContractBank2DB(pQryContractBank)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryContractBank)
              with nogil:
                result = self._api.ReqQryContractBank(<CThostFtdcQryContractBankField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryContractBank', exc_info=True)

        return result

    #请求查询预埋单
    def  ReqQryParkedOrder(self, pQryParkedOrder, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryParkedOrder","BrokerID",pQryParkedOrder.BrokerID,dwTime);
            printString("pQryParkedOrder","InvestorID",pQryParkedOrder.InvestorID,dwTime);
            printString("pQryParkedOrder","InstrumentID",pQryParkedOrder.InstrumentID,dwTime);
            printString("pQryParkedOrder","ExchangeID",pQryParkedOrder.ExchangeID,dwTime);
            printString("pQryParkedOrder","InvestUnitID",pQryParkedOrder.InvestUnitID,dwTime);

            self.pQryParkedOrder2DB(pQryParkedOrder)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryParkedOrder)
              with nogil:
                result = self._api.ReqQryParkedOrder(<CThostFtdcQryParkedOrderField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryParkedOrder', exc_info=True)

        return result

    #请求查询预埋撤单
    def  ReqQryParkedOrderAction(self, pQryParkedOrderAction, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryParkedOrderAction","BrokerID",pQryParkedOrderAction.BrokerID,dwTime);
            printString("pQryParkedOrderAction","InvestorID",pQryParkedOrderAction.InvestorID,dwTime);
            printString("pQryParkedOrderAction","InstrumentID",pQryParkedOrderAction.InstrumentID,dwTime);
            printString("pQryParkedOrderAction","ExchangeID",pQryParkedOrderAction.ExchangeID,dwTime);
            printString("pQryParkedOrderAction","InvestUnitID",pQryParkedOrderAction.InvestUnitID,dwTime);

            self.pQryParkedOrderAction2DB(pQryParkedOrderAction)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryParkedOrderAction)
              with nogil:
                result = self._api.ReqQryParkedOrderAction(<CThostFtdcQryParkedOrderActionField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryParkedOrderAction', exc_info=True)

        return result

    #请求查询交易通知
    def  ReqQryTradingNotice(self, pQryTradingNotice, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryTradingNotice","BrokerID",pQryTradingNotice.BrokerID,dwTime);
            printString("pQryTradingNotice","InvestorID",pQryTradingNotice.InvestorID,dwTime);
            printString("pQryTradingNotice","InvestUnitID",pQryTradingNotice.InvestUnitID,dwTime);

            self.pQryTradingNotice2DB(pQryTradingNotice)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryTradingNotice)
              with nogil:
                result = self._api.ReqQryTradingNotice(<CThostFtdcQryTradingNoticeField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryTradingNotice', exc_info=True)

        return result

    #请求查询经纪公司交易参数
    def  ReqQryBrokerTradingParams(self, pQryBrokerTradingParams, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryBrokerTradingParams","BrokerID",pQryBrokerTradingParams.BrokerID,dwTime);
            printString("pQryBrokerTradingParams","InvestorID",pQryBrokerTradingParams.InvestorID,dwTime);
            printString("pQryBrokerTradingParams","CurrencyID",pQryBrokerTradingParams.CurrencyID,dwTime);
            printString("pQryBrokerTradingParams","AccountID",pQryBrokerTradingParams.AccountID,dwTime);

            self.pQryBrokerTradingParams2DB(pQryBrokerTradingParams)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryBrokerTradingParams)
              with nogil:
                result = self._api.ReqQryBrokerTradingParams(<CThostFtdcQryBrokerTradingParamsField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryBrokerTradingParams', exc_info=True)

        return result

    #请求查询经纪公司交易算法
    def  ReqQryBrokerTradingAlgos(self, pQryBrokerTradingAlgos, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQryBrokerTradingAlgos","BrokerID",pQryBrokerTradingAlgos.BrokerID,dwTime);
            printString("pQryBrokerTradingAlgos","ExchangeID",pQryBrokerTradingAlgos.ExchangeID,dwTime);
            printString("pQryBrokerTradingAlgos","InstrumentID",pQryBrokerTradingAlgos.InstrumentID,dwTime);

            self.pQryBrokerTradingAlgos2DB(pQryBrokerTradingAlgos)

            if self._spi is not NULL:
              address = ctypes.addressof(pQryBrokerTradingAlgos)
              with nogil:
                result = self._api.ReqQryBrokerTradingAlgos(<CThostFtdcQryBrokerTradingAlgosField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQryBrokerTradingAlgos', exc_info=True)

        return result

    #请求查询监控中心用户令牌
    def  ReqQueryCFMMCTradingAccountToken(self, pQueryCFMMCTradingAccountToken, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pQueryCFMMCTradingAccountToken","BrokerID",pQueryCFMMCTradingAccountToken.BrokerID,dwTime);
            printString("pQueryCFMMCTradingAccountToken","InvestorID",pQueryCFMMCTradingAccountToken.InvestorID,dwTime);
            printString("pQueryCFMMCTradingAccountToken","InvestUnitID",pQueryCFMMCTradingAccountToken.InvestUnitID,dwTime);

            self.pQueryCFMMCTradingAccountToken2DB(pQueryCFMMCTradingAccountToken)

            if self._spi is not NULL:
              address = ctypes.addressof(pQueryCFMMCTradingAccountToken)
              with nogil:
                result = self._api.ReqQueryCFMMCTradingAccountToken(<CThostFtdcQueryCFMMCTradingAccountTokenField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQueryCFMMCTradingAccountToken', exc_info=True)

        return result

    #期货发起银行资金转期货请求
    def  ReqFromBankToFutureByFuture(self, pReqTransfer, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pReqTransfer","TradeCode",pReqTransfer.TradeCode,dwTime);
            printString("pReqTransfer","BankID",pReqTransfer.BankID,dwTime);
            printString("pReqTransfer","BankBranchID",pReqTransfer.BankBranchID,dwTime);
            printString("pReqTransfer","BrokerID",pReqTransfer.BrokerID,dwTime);
            printString("pReqTransfer","BrokerBranchID",pReqTransfer.BrokerBranchID,dwTime);
            printString("pReqTransfer","TradeDate",pReqTransfer.TradeDate,dwTime);
            printString("pReqTransfer","TradeTime",pReqTransfer.TradeTime,dwTime);
            printString("pReqTransfer","BankSerial",pReqTransfer.BankSerial,dwTime);
            printString("pReqTransfer","TradingDay",pReqTransfer.TradingDay,dwTime);
            printNumber("pReqTransfer","PlateSerial",pReqTransfer.PlateSerial,dwTime);
            printString("pReqTransfer","LastFragment",pReqTransfer.LastFragment,dwTime);
            printNumber("pReqTransfer","SessionID",pReqTransfer.SessionID,dwTime);
            printString("pReqTransfer","CustomerName",pReqTransfer.CustomerName,dwTime);
            printString("pReqTransfer","IdCardType",pReqTransfer.IdCardType,dwTime);
            printString("pReqTransfer","IdentifiedCardNo",pReqTransfer.IdentifiedCardNo,dwTime);
            printString("pReqTransfer","CustType",pReqTransfer.CustType,dwTime);
            printString("pReqTransfer","BankAccount",pReqTransfer.BankAccount,dwTime);
            printString("pReqTransfer","BankPassWord",pReqTransfer.BankPassWord,dwTime);
            printString("pReqTransfer","AccountID",pReqTransfer.AccountID,dwTime);
            printString("pReqTransfer","Password",pReqTransfer.Password,dwTime);
            printNumber("pReqTransfer","InstallID",pReqTransfer.InstallID,dwTime);
            printNumber("pReqTransfer","FutureSerial",pReqTransfer.FutureSerial,dwTime);
            printString("pReqTransfer","UserID",pReqTransfer.UserID,dwTime);
            printString("pReqTransfer","VerifyCertNoFlag",pReqTransfer.VerifyCertNoFlag,dwTime);
            printString("pReqTransfer","CurrencyID",pReqTransfer.CurrencyID,dwTime);
            printNumber("pReqTransfer","TradeAmount",pReqTransfer.TradeAmount,dwTime);
            printNumber("pReqTransfer","FutureFetchAmount",pReqTransfer.FutureFetchAmount,dwTime);
            printString("pReqTransfer","FeePayFlag",pReqTransfer.FeePayFlag,dwTime);
            printNumber("pReqTransfer","CustFee",pReqTransfer.CustFee,dwTime);
            printNumber("pReqTransfer","BrokerFee",pReqTransfer.BrokerFee,dwTime);
            printString("pReqTransfer","Message",pReqTransfer.Message,dwTime);
            printString("pReqTransfer","Digest",pReqTransfer.Digest,dwTime);
            printString("pReqTransfer","BankAccType",pReqTransfer.BankAccType,dwTime);
            printString("pReqTransfer","DeviceID",pReqTransfer.DeviceID,dwTime);
            printString("pReqTransfer","BankSecuAccType",pReqTransfer.BankSecuAccType,dwTime);
            printString("pReqTransfer","BrokerIDByBank",pReqTransfer.BrokerIDByBank,dwTime);
            printString("pReqTransfer","BankSecuAcc",pReqTransfer.BankSecuAcc,dwTime);
            printString("pReqTransfer","BankPwdFlag",pReqTransfer.BankPwdFlag,dwTime);
            printString("pReqTransfer","SecuPwdFlag",pReqTransfer.SecuPwdFlag,dwTime);
            printString("pReqTransfer","OperNo",pReqTransfer.OperNo,dwTime);
            printNumber("pReqTransfer","RequestID",pReqTransfer.RequestID,dwTime);
            printNumber("pReqTransfer","TID",pReqTransfer.TID,dwTime);
            printString("pReqTransfer","TransferStatus",pReqTransfer.TransferStatus,dwTime);
            printString("pReqTransfer","LongCustomerName",pReqTransfer.LongCustomerName,dwTime);

            self.pReqTransfer2DB(pReqTransfer)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pReqTransfer)
                with nogil:
                  result = self._api.ReqFromBankToFutureByFuture(<CThostFtdcReqTransferField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqFromBankToFutureByFuture', exc_info=True)

        return result

    #期货发起期货资金转银行请求
    def  ReqFromFutureToBankByFuture(self, pReqTransfer, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pReqTransfer","TradeCode",pReqTransfer.TradeCode,dwTime);
            printString("pReqTransfer","BankID",pReqTransfer.BankID,dwTime);
            printString("pReqTransfer","BankBranchID",pReqTransfer.BankBranchID,dwTime);
            printString("pReqTransfer","BrokerID",pReqTransfer.BrokerID,dwTime);
            printString("pReqTransfer","BrokerBranchID",pReqTransfer.BrokerBranchID,dwTime);
            printString("pReqTransfer","TradeDate",pReqTransfer.TradeDate,dwTime);
            printString("pReqTransfer","TradeTime",pReqTransfer.TradeTime,dwTime);
            printString("pReqTransfer","BankSerial",pReqTransfer.BankSerial,dwTime);
            printString("pReqTransfer","TradingDay",pReqTransfer.TradingDay,dwTime);
            printNumber("pReqTransfer","PlateSerial",pReqTransfer.PlateSerial,dwTime);
            printString("pReqTransfer","LastFragment",pReqTransfer.LastFragment,dwTime);
            printNumber("pReqTransfer","SessionID",pReqTransfer.SessionID,dwTime);
            printString("pReqTransfer","CustomerName",pReqTransfer.CustomerName,dwTime);
            printString("pReqTransfer","IdCardType",pReqTransfer.IdCardType,dwTime);
            printString("pReqTransfer","IdentifiedCardNo",pReqTransfer.IdentifiedCardNo,dwTime);
            printString("pReqTransfer","CustType",pReqTransfer.CustType,dwTime);
            printString("pReqTransfer","BankAccount",pReqTransfer.BankAccount,dwTime);
            printString("pReqTransfer","BankPassWord",pReqTransfer.BankPassWord,dwTime);
            printString("pReqTransfer","AccountID",pReqTransfer.AccountID,dwTime);
            printString("pReqTransfer","Password",pReqTransfer.Password,dwTime);
            printNumber("pReqTransfer","InstallID",pReqTransfer.InstallID,dwTime);
            printNumber("pReqTransfer","FutureSerial",pReqTransfer.FutureSerial,dwTime);
            printString("pReqTransfer","UserID",pReqTransfer.UserID,dwTime);
            printString("pReqTransfer","VerifyCertNoFlag",pReqTransfer.VerifyCertNoFlag,dwTime);
            printString("pReqTransfer","CurrencyID",pReqTransfer.CurrencyID,dwTime);
            printNumber("pReqTransfer","TradeAmount",pReqTransfer.TradeAmount,dwTime);
            printNumber("pReqTransfer","FutureFetchAmount",pReqTransfer.FutureFetchAmount,dwTime);
            printString("pReqTransfer","FeePayFlag",pReqTransfer.FeePayFlag,dwTime);
            printNumber("pReqTransfer","CustFee",pReqTransfer.CustFee,dwTime);
            printNumber("pReqTransfer","BrokerFee",pReqTransfer.BrokerFee,dwTime);
            printString("pReqTransfer","Message",pReqTransfer.Message,dwTime);
            printString("pReqTransfer","Digest",pReqTransfer.Digest,dwTime);
            printString("pReqTransfer","BankAccType",pReqTransfer.BankAccType,dwTime);
            printString("pReqTransfer","DeviceID",pReqTransfer.DeviceID,dwTime);
            printString("pReqTransfer","BankSecuAccType",pReqTransfer.BankSecuAccType,dwTime);
            printString("pReqTransfer","BrokerIDByBank",pReqTransfer.BrokerIDByBank,dwTime);
            printString("pReqTransfer","BankSecuAcc",pReqTransfer.BankSecuAcc,dwTime);
            printString("pReqTransfer","BankPwdFlag",pReqTransfer.BankPwdFlag,dwTime);
            printString("pReqTransfer","SecuPwdFlag",pReqTransfer.SecuPwdFlag,dwTime);
            printString("pReqTransfer","OperNo",pReqTransfer.OperNo,dwTime);
            printNumber("pReqTransfer","RequestID",pReqTransfer.RequestID,dwTime);
            printNumber("pReqTransfer","TID",pReqTransfer.TID,dwTime);
            printString("pReqTransfer","TransferStatus",pReqTransfer.TransferStatus,dwTime);
            printString("pReqTransfer","LongCustomerName",pReqTransfer.LongCustomerName,dwTime);

            self.pReqTransfer2DB(pReqTransfer)


            if self.sim == 0:
              if self._spi is not NULL:
                address = ctypes.addressof(pReqTransfer)
                with nogil:
                  result = self._api.ReqFromFutureToBankByFuture(<CThostFtdcReqTransferField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqFromFutureToBankByFuture', exc_info=True)

        return result

    #期货发起查询银行余额请求
    def  ReqQueryBankAccountMoneyByFuture(self, pReqQueryAccount, int nRequestID):
        cdef int result = 0
        cdef size_t address = 0
        try:
            dwTime  = self.Inc_RequestID()
            funName = "%s.%s" % (self.__class__.__name__, sys._getframe().f_code.co_name)
            printString("Trader_call_stack","call->",funName,dwTime)
            printString("pReqQueryAccount","TradeCode",pReqQueryAccount.TradeCode,dwTime);
            printString("pReqQueryAccount","BankID",pReqQueryAccount.BankID,dwTime);
            printString("pReqQueryAccount","BankBranchID",pReqQueryAccount.BankBranchID,dwTime);
            printString("pReqQueryAccount","BrokerID",pReqQueryAccount.BrokerID,dwTime);
            printString("pReqQueryAccount","BrokerBranchID",pReqQueryAccount.BrokerBranchID,dwTime);
            printString("pReqQueryAccount","TradeDate",pReqQueryAccount.TradeDate,dwTime);
            printString("pReqQueryAccount","TradeTime",pReqQueryAccount.TradeTime,dwTime);
            printString("pReqQueryAccount","BankSerial",pReqQueryAccount.BankSerial,dwTime);
            printString("pReqQueryAccount","TradingDay",pReqQueryAccount.TradingDay,dwTime);
            printNumber("pReqQueryAccount","PlateSerial",pReqQueryAccount.PlateSerial,dwTime);
            printString("pReqQueryAccount","LastFragment",pReqQueryAccount.LastFragment,dwTime);
            printNumber("pReqQueryAccount","SessionID",pReqQueryAccount.SessionID,dwTime);
            printString("pReqQueryAccount","CustomerName",pReqQueryAccount.CustomerName,dwTime);
            printString("pReqQueryAccount","IdCardType",pReqQueryAccount.IdCardType,dwTime);
            printString("pReqQueryAccount","IdentifiedCardNo",pReqQueryAccount.IdentifiedCardNo,dwTime);
            printString("pReqQueryAccount","CustType",pReqQueryAccount.CustType,dwTime);
            printString("pReqQueryAccount","BankAccount",pReqQueryAccount.BankAccount,dwTime);
            printString("pReqQueryAccount","BankPassWord",pReqQueryAccount.BankPassWord,dwTime);
            printString("pReqQueryAccount","AccountID",pReqQueryAccount.AccountID,dwTime);
            printString("pReqQueryAccount","Password",pReqQueryAccount.Password,dwTime);
            printNumber("pReqQueryAccount","FutureSerial",pReqQueryAccount.FutureSerial,dwTime);
            printNumber("pReqQueryAccount","InstallID",pReqQueryAccount.InstallID,dwTime);
            printString("pReqQueryAccount","UserID",pReqQueryAccount.UserID,dwTime);
            printString("pReqQueryAccount","VerifyCertNoFlag",pReqQueryAccount.VerifyCertNoFlag,dwTime);
            printString("pReqQueryAccount","CurrencyID",pReqQueryAccount.CurrencyID,dwTime);
            printString("pReqQueryAccount","Digest",pReqQueryAccount.Digest,dwTime);
            printString("pReqQueryAccount","BankAccType",pReqQueryAccount.BankAccType,dwTime);
            printString("pReqQueryAccount","DeviceID",pReqQueryAccount.DeviceID,dwTime);
            printString("pReqQueryAccount","BankSecuAccType",pReqQueryAccount.BankSecuAccType,dwTime);
            printString("pReqQueryAccount","BrokerIDByBank",pReqQueryAccount.BrokerIDByBank,dwTime);
            printString("pReqQueryAccount","BankSecuAcc",pReqQueryAccount.BankSecuAcc,dwTime);
            printString("pReqQueryAccount","BankPwdFlag",pReqQueryAccount.BankPwdFlag,dwTime);
            printString("pReqQueryAccount","SecuPwdFlag",pReqQueryAccount.SecuPwdFlag,dwTime);
            printString("pReqQueryAccount","OperNo",pReqQueryAccount.OperNo,dwTime);
            printNumber("pReqQueryAccount","RequestID",pReqQueryAccount.RequestID,dwTime);
            printNumber("pReqQueryAccount","TID",pReqQueryAccount.TID,dwTime);
            printString("pReqQueryAccount","LongCustomerName",pReqQueryAccount.LongCustomerName,dwTime);

            self.pReqQueryAccount2DB(pReqQueryAccount)

            if self._spi is not NULL:
              address = ctypes.addressof(pReqQueryAccount)
              with nogil:
                result = self._api.ReqQueryBankAccountMoneyByFuture(<CThostFtdcReqQueryAccountField *> address, nRequestID)
            printString("Trader_call_stack","call-<",funName, dwTime)
        except Exception as err:
            myEnv.logger.error('ReqQueryBankAccountMoneyByFuture', exc_info=True)

        return result

    def  pReqAuthenticateField2DB(self, pReqAuthenticateField):
        l_BrokerID=pReqAuthenticateField.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pReqAuthenticateField.UserID.decode(encoding="gb18030", errors="ignore");
        l_UserProductInfo=pReqAuthenticateField.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_AuthCode=pReqAuthenticateField.AuthCode.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqAuthenticate(BrokerID,UserID,UserProductInfo,AuthCode)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_UserID,l_UserProductInfo,l_AuthCode)]
        self.SQL2DB(the_SQL,the_data)

    def  pReqUserLoginField2DB(self, pReqUserLoginField):
        l_TradingDay=pReqUserLoginField.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pReqUserLoginField.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pReqUserLoginField.UserID.decode(encoding="gb18030", errors="ignore");
        l_Password=pReqUserLoginField.Password.decode(encoding="gb18030", errors="ignore");
        l_UserProductInfo=pReqUserLoginField.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_InterfaceProductInfo=pReqUserLoginField.InterfaceProductInfo.decode(encoding="gb18030", errors="ignore");
        l_ProtocolInfo=pReqUserLoginField.ProtocolInfo.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pReqUserLoginField.MacAddress.decode(encoding="gb18030", errors="ignore");
        l_OneTimePassword=pReqUserLoginField.OneTimePassword.decode(encoding="gb18030", errors="ignore");
        l_ClientIPAddress=pReqUserLoginField.ClientIPAddress.decode(encoding="gb18030", errors="ignore");
        l_LoginRemark=pReqUserLoginField.LoginRemark.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqUserLogin(TradingDay,BrokerID,UserID,Password,UserProductInfo,InterfaceProductInfo,ProtocolInfo,MacAddress,OneTimePassword,ClientIPAddress,LoginRemark)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_BrokerID,l_UserID,l_Password,l_UserProductInfo,l_InterfaceProductInfo,l_ProtocolInfo,l_MacAddress,l_OneTimePassword,l_ClientIPAddress,l_LoginRemark)]
        self.SQL2DB(the_SQL,the_data)

    def  pUserLogout2DB(self, pUserLogout):
        l_BrokerID=pUserLogout.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pUserLogout.UserID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_UserLogout(BrokerID,UserID)VALUES(%s,%s)"
        the_data =[( l_BrokerID,l_UserID)]
        self.SQL2DB(the_SQL,the_data)

    def  pUserPasswordUpdate2DB(self, pUserPasswordUpdate):
        l_BrokerID=pUserPasswordUpdate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pUserPasswordUpdate.UserID.decode(encoding="gb18030", errors="ignore");
        l_OldPassword=pUserPasswordUpdate.OldPassword.decode(encoding="gb18030", errors="ignore");
        l_NewPassword=pUserPasswordUpdate.NewPassword.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_UserPasswordUpdate(BrokerID,UserID,OldPassword,NewPassword)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_UserID,l_OldPassword,l_NewPassword)]
        self.SQL2DB(the_SQL,the_data)

    def  pTradingAccountPasswordUpdate2DB(self, pTradingAccountPasswordUpdate):
        l_BrokerID=pTradingAccountPasswordUpdate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pTradingAccountPasswordUpdate.AccountID.decode(encoding="gb18030", errors="ignore");
        l_OldPassword=pTradingAccountPasswordUpdate.OldPassword.decode(encoding="gb18030", errors="ignore");
        l_NewPassword=pTradingAccountPasswordUpdate.NewPassword.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pTradingAccountPasswordUpdate.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_TradingAccountPasswordUpdate(BrokerID,AccountID,OldPassword,NewPassword,CurrencyID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_AccountID,l_OldPassword,l_NewPassword,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pReqUserLogin2DB(self, pReqUserLogin):
        l_TradingDay=pReqUserLogin.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pReqUserLogin.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pReqUserLogin.UserID.decode(encoding="gb18030", errors="ignore");
        l_Password=pReqUserLogin.Password.decode(encoding="gb18030", errors="ignore");
        l_UserProductInfo=pReqUserLogin.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_InterfaceProductInfo=pReqUserLogin.InterfaceProductInfo.decode(encoding="gb18030", errors="ignore");
        l_ProtocolInfo=pReqUserLogin.ProtocolInfo.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pReqUserLogin.MacAddress.decode(encoding="gb18030", errors="ignore");
        l_OneTimePassword=pReqUserLogin.OneTimePassword.decode(encoding="gb18030", errors="ignore");
        l_ClientIPAddress=pReqUserLogin.ClientIPAddress.decode(encoding="gb18030", errors="ignore");
        l_LoginRemark=pReqUserLogin.LoginRemark.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqUserLogin(TradingDay,BrokerID,UserID,Password,UserProductInfo,InterfaceProductInfo,ProtocolInfo,MacAddress,OneTimePassword,ClientIPAddress,LoginRemark)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_BrokerID,l_UserID,l_Password,l_UserProductInfo,l_InterfaceProductInfo,l_ProtocolInfo,l_MacAddress,l_OneTimePassword,l_ClientIPAddress,l_LoginRemark)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputOrder2DB(self, pInputOrder):
        l_BrokerID=pInputOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OrderRef=pInputOrder.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_OrderPriceType=pInputOrder.OrderPriceType.decode(encoding="gb18030", errors="ignore");
        l_Direction=pInputOrder.Direction.decode(encoding="gb18030", errors="ignore");
        l_CombOffsetFlag=pInputOrder.CombOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_CombHedgeFlag=pInputOrder.CombHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pInputOrder.LimitPrice
        l_VolumeTotalOriginal=pInputOrder.VolumeTotalOriginal
        l_TimeCondition=pInputOrder.TimeCondition.decode(encoding="gb18030", errors="ignore");
        l_GTDDate=pInputOrder.GTDDate.decode(encoding="gb18030", errors="ignore");
        l_VolumeCondition=pInputOrder.VolumeCondition.decode(encoding="gb18030", errors="ignore");
        l_MinVolume=pInputOrder.MinVolume
        l_ContingentCondition=pInputOrder.ContingentCondition.decode(encoding="gb18030", errors="ignore");
        l_StopPrice=pInputOrder.StopPrice
        l_ForceCloseReason=pInputOrder.ForceCloseReason.decode(encoding="gb18030", errors="ignore");
        l_IsAutoSuspend=pInputOrder.IsAutoSuspend
        l_BusinessUnit=pInputOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pInputOrder.RequestID
        l_UserForceClose=pInputOrder.UserForceClose
        l_IsSwapOrder=pInputOrder.IsSwapOrder
        l_ExchangeID=pInputOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pInputOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pInputOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pInputOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputOrder.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputOrder(BrokerID,InvestorID,InstrumentID,OrderRef,UserID,OrderPriceType,Direction,CombOffsetFlag,CombHedgeFlag,LimitPrice,VolumeTotalOriginal,TimeCondition,GTDDate,VolumeCondition,MinVolume,ContingentCondition,StopPrice,ForceCloseReason,IsAutoSuspend,BusinessUnit,RequestID,UserForceClose,IsSwapOrder,ExchangeID,InvestUnitID,AccountID,CurrencyID,ClientID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OrderRef,l_UserID,l_OrderPriceType,l_Direction,l_CombOffsetFlag,l_CombHedgeFlag,l_LimitPrice,l_VolumeTotalOriginal,l_TimeCondition,l_GTDDate,l_VolumeCondition,l_MinVolume,l_ContingentCondition,l_StopPrice,l_ForceCloseReason,l_IsAutoSuspend,l_BusinessUnit,l_RequestID,l_UserForceClose,l_IsSwapOrder,l_ExchangeID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_ClientID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pParkedOrder2DB(self, pParkedOrder):
        l_BrokerID=pParkedOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pParkedOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pParkedOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OrderRef=pParkedOrder.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pParkedOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_OrderPriceType=pParkedOrder.OrderPriceType.decode(encoding="gb18030", errors="ignore");
        l_Direction=pParkedOrder.Direction.decode(encoding="gb18030", errors="ignore");
        l_CombOffsetFlag=pParkedOrder.CombOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_CombHedgeFlag=pParkedOrder.CombHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pParkedOrder.LimitPrice
        l_VolumeTotalOriginal=pParkedOrder.VolumeTotalOriginal
        l_TimeCondition=pParkedOrder.TimeCondition.decode(encoding="gb18030", errors="ignore");
        l_GTDDate=pParkedOrder.GTDDate.decode(encoding="gb18030", errors="ignore");
        l_VolumeCondition=pParkedOrder.VolumeCondition.decode(encoding="gb18030", errors="ignore");
        l_MinVolume=pParkedOrder.MinVolume
        l_ContingentCondition=pParkedOrder.ContingentCondition.decode(encoding="gb18030", errors="ignore");
        l_StopPrice=pParkedOrder.StopPrice
        l_ForceCloseReason=pParkedOrder.ForceCloseReason.decode(encoding="gb18030", errors="ignore");
        l_IsAutoSuspend=pParkedOrder.IsAutoSuspend
        l_BusinessUnit=pParkedOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pParkedOrder.RequestID
        l_UserForceClose=pParkedOrder.UserForceClose
        l_ExchangeID=pParkedOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParkedOrderID=pParkedOrder.ParkedOrderID.decode(encoding="gb18030", errors="ignore");
        l_UserType=pParkedOrder.UserType.decode(encoding="gb18030", errors="ignore");
        l_Status=pParkedOrder.Status.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pParkedOrder.ErrorID
        l_ErrorMsg=pParkedOrder.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_IsSwapOrder=pParkedOrder.IsSwapOrder
        l_AccountID=pParkedOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pParkedOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pParkedOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pParkedOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pParkedOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pParkedOrder.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ParkedOrder(BrokerID,InvestorID,InstrumentID,OrderRef,UserID,OrderPriceType,Direction,CombOffsetFlag,CombHedgeFlag,LimitPrice,VolumeTotalOriginal,TimeCondition,GTDDate,VolumeCondition,MinVolume,ContingentCondition,StopPrice,ForceCloseReason,IsAutoSuspend,BusinessUnit,RequestID,UserForceClose,ExchangeID,ParkedOrderID,UserType,Status,ErrorID,ErrorMsg,IsSwapOrder,AccountID,CurrencyID,ClientID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OrderRef,l_UserID,l_OrderPriceType,l_Direction,l_CombOffsetFlag,l_CombHedgeFlag,l_LimitPrice,l_VolumeTotalOriginal,l_TimeCondition,l_GTDDate,l_VolumeCondition,l_MinVolume,l_ContingentCondition,l_StopPrice,l_ForceCloseReason,l_IsAutoSuspend,l_BusinessUnit,l_RequestID,l_UserForceClose,l_ExchangeID,l_ParkedOrderID,l_UserType,l_Status,l_ErrorID,l_ErrorMsg,l_IsSwapOrder,l_AccountID,l_CurrencyID,l_ClientID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pParkedOrderAction2DB(self, pParkedOrderAction):
        l_BrokerID=pParkedOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pParkedOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OrderActionRef=pParkedOrderAction.OrderActionRef
        l_OrderRef=pParkedOrderAction.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pParkedOrderAction.RequestID
        l_FrontID=pParkedOrderAction.FrontID
        l_SessionID=pParkedOrderAction.SessionID
        l_ExchangeID=pParkedOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OrderSysID=pParkedOrderAction.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pParkedOrderAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pParkedOrderAction.LimitPrice
        l_VolumeChange=pParkedOrderAction.VolumeChange
        l_UserID=pParkedOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pParkedOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ParkedOrderActionID=pParkedOrderAction.ParkedOrderActionID.decode(encoding="gb18030", errors="ignore");
        l_UserType=pParkedOrderAction.UserType.decode(encoding="gb18030", errors="ignore");
        l_Status=pParkedOrderAction.Status.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pParkedOrderAction.ErrorID
        l_ErrorMsg=pParkedOrderAction.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pParkedOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pParkedOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pParkedOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ParkedOrderAction(BrokerID,InvestorID,OrderActionRef,OrderRef,RequestID,FrontID,SessionID,ExchangeID,OrderSysID,ActionFlag,LimitPrice,VolumeChange,UserID,InstrumentID,ParkedOrderActionID,UserType,Status,ErrorID,ErrorMsg,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OrderActionRef,l_OrderRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_OrderSysID,l_ActionFlag,l_LimitPrice,l_VolumeChange,l_UserID,l_InstrumentID,l_ParkedOrderActionID,l_UserType,l_Status,l_ErrorID,l_ErrorMsg,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputOrderAction2DB(self, pInputOrderAction):
        l_BrokerID=pInputOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OrderActionRef=pInputOrderAction.OrderActionRef
        l_OrderRef=pInputOrderAction.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pInputOrderAction.RequestID
        l_FrontID=pInputOrderAction.FrontID
        l_SessionID=pInputOrderAction.SessionID
        l_ExchangeID=pInputOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OrderSysID=pInputOrderAction.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pInputOrderAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pInputOrderAction.LimitPrice
        l_VolumeChange=pInputOrderAction.VolumeChange
        l_UserID=pInputOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputOrderAction(BrokerID,InvestorID,OrderActionRef,OrderRef,RequestID,FrontID,SessionID,ExchangeID,OrderSysID,ActionFlag,LimitPrice,VolumeChange,UserID,InstrumentID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OrderActionRef,l_OrderRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_OrderSysID,l_ActionFlag,l_LimitPrice,l_VolumeChange,l_UserID,l_InstrumentID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pQueryMaxOrderVolume2DB(self, pQueryMaxOrderVolume):
        l_BrokerID=pQueryMaxOrderVolume.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQueryMaxOrderVolume.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQueryMaxOrderVolume.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_Direction=pQueryMaxOrderVolume.Direction.decode(encoding="gb18030", errors="ignore");
        l_OffsetFlag=pQueryMaxOrderVolume.OffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQueryMaxOrderVolume.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_MaxVolume=pQueryMaxOrderVolume.MaxVolume
        l_ExchangeID=pQueryMaxOrderVolume.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQueryMaxOrderVolume.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QueryMaxOrderVolume(BrokerID,InvestorID,InstrumentID,Direction,OffsetFlag,HedgeFlag,MaxVolume,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_Direction,l_OffsetFlag,l_HedgeFlag,l_MaxVolume,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pSettlementInfoConfirm2DB(self, pSettlementInfoConfirm):
        l_BrokerID=pSettlementInfoConfirm.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pSettlementInfoConfirm.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ConfirmDate=pSettlementInfoConfirm.ConfirmDate.decode(encoding="gb18030", errors="ignore");
        l_ConfirmTime=pSettlementInfoConfirm.ConfirmTime.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pSettlementInfoConfirm.SettlementID
        l_AccountID=pSettlementInfoConfirm.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pSettlementInfoConfirm.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_SettlementInfoConfirm(BrokerID,InvestorID,ConfirmDate,ConfirmTime,SettlementID,AccountID,CurrencyID)VALUES(%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ConfirmDate,l_ConfirmTime,l_SettlementID,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pRemoveParkedOrder2DB(self, pRemoveParkedOrder):
        l_BrokerID=pRemoveParkedOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pRemoveParkedOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ParkedOrderID=pRemoveParkedOrder.ParkedOrderID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pRemoveParkedOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RemoveParkedOrder(BrokerID,InvestorID,ParkedOrderID,InvestUnitID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ParkedOrderID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pRemoveParkedOrderAction2DB(self, pRemoveParkedOrderAction):
        l_BrokerID=pRemoveParkedOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pRemoveParkedOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ParkedOrderActionID=pRemoveParkedOrderAction.ParkedOrderActionID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pRemoveParkedOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RemoveParkedOrderAction(BrokerID,InvestorID,ParkedOrderActionID,InvestUnitID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ParkedOrderActionID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputExecOrder2DB(self, pInputExecOrder):
        l_BrokerID=pInputExecOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputExecOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputExecOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderRef=pInputExecOrder.ExecOrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputExecOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_Volume=pInputExecOrder.Volume
        l_RequestID=pInputExecOrder.RequestID
        l_BusinessUnit=pInputExecOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OffsetFlag=pInputExecOrder.OffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInputExecOrder.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionType=pInputExecOrder.ActionType.decode(encoding="gb18030", errors="ignore");
        l_PosiDirection=pInputExecOrder.PosiDirection.decode(encoding="gb18030", errors="ignore");
        l_ReservePositionFlag=pInputExecOrder.ReservePositionFlag.decode(encoding="gb18030", errors="ignore");
        l_CloseFlag=pInputExecOrder.CloseFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInputExecOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputExecOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pInputExecOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pInputExecOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pInputExecOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputExecOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputExecOrder.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputExecOrder(BrokerID,InvestorID,InstrumentID,ExecOrderRef,UserID,Volume,RequestID,BusinessUnit,OffsetFlag,HedgeFlag,ActionType,PosiDirection,ReservePositionFlag,CloseFlag,ExchangeID,InvestUnitID,AccountID,CurrencyID,ClientID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExecOrderRef,l_UserID,l_Volume,l_RequestID,l_BusinessUnit,l_OffsetFlag,l_HedgeFlag,l_ActionType,l_PosiDirection,l_ReservePositionFlag,l_CloseFlag,l_ExchangeID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_ClientID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputExecOrderAction2DB(self, pInputExecOrderAction):
        l_BrokerID=pInputExecOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputExecOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderActionRef=pInputExecOrderAction.ExecOrderActionRef
        l_ExecOrderRef=pInputExecOrderAction.ExecOrderRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pInputExecOrderAction.RequestID
        l_FrontID=pInputExecOrderAction.FrontID
        l_SessionID=pInputExecOrderAction.SessionID
        l_ExchangeID=pInputExecOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderSysID=pInputExecOrderAction.ExecOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pInputExecOrderAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputExecOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputExecOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputExecOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputExecOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputExecOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputExecOrderAction(BrokerID,InvestorID,ExecOrderActionRef,ExecOrderRef,RequestID,FrontID,SessionID,ExchangeID,ExecOrderSysID,ActionFlag,UserID,InstrumentID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ExecOrderActionRef,l_ExecOrderRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_ExecOrderSysID,l_ActionFlag,l_UserID,l_InstrumentID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputForQuote2DB(self, pInputForQuote):
        l_BrokerID=pInputForQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputForQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputForQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteRef=pInputForQuote.ForQuoteRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputForQuote.UserID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInputForQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputForQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputForQuote.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputForQuote.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputForQuote(BrokerID,InvestorID,InstrumentID,ForQuoteRef,UserID,ExchangeID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ForQuoteRef,l_UserID,l_ExchangeID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputQuote2DB(self, pInputQuote):
        l_BrokerID=pInputQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_QuoteRef=pInputQuote.QuoteRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputQuote.UserID.decode(encoding="gb18030", errors="ignore");
        l_AskPrice=pInputQuote.AskPrice
        l_BidPrice=pInputQuote.BidPrice
        l_AskVolume=pInputQuote.AskVolume
        l_BidVolume=pInputQuote.BidVolume
        l_RequestID=pInputQuote.RequestID
        l_BusinessUnit=pInputQuote.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_AskOffsetFlag=pInputQuote.AskOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_BidOffsetFlag=pInputQuote.BidOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_AskHedgeFlag=pInputQuote.AskHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_BidHedgeFlag=pInputQuote.BidHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_AskOrderRef=pInputQuote.AskOrderRef.decode(encoding="gb18030", errors="ignore");
        l_BidOrderRef=pInputQuote.BidOrderRef.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteSysID=pInputQuote.ForQuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInputQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pInputQuote.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputQuote.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputQuote.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputQuote(BrokerID,InvestorID,InstrumentID,QuoteRef,UserID,AskPrice,BidPrice,AskVolume,BidVolume,RequestID,BusinessUnit,AskOffsetFlag,BidOffsetFlag,AskHedgeFlag,BidHedgeFlag,AskOrderRef,BidOrderRef,ForQuoteSysID,ExchangeID,InvestUnitID,ClientID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_QuoteRef,l_UserID,l_AskPrice,l_BidPrice,l_AskVolume,l_BidVolume,l_RequestID,l_BusinessUnit,l_AskOffsetFlag,l_BidOffsetFlag,l_AskHedgeFlag,l_BidHedgeFlag,l_AskOrderRef,l_BidOrderRef,l_ForQuoteSysID,l_ExchangeID,l_InvestUnitID,l_ClientID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputQuoteAction2DB(self, pInputQuoteAction):
        l_BrokerID=pInputQuoteAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputQuoteAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_QuoteActionRef=pInputQuoteAction.QuoteActionRef
        l_QuoteRef=pInputQuoteAction.QuoteRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pInputQuoteAction.RequestID
        l_FrontID=pInputQuoteAction.FrontID
        l_SessionID=pInputQuoteAction.SessionID
        l_ExchangeID=pInputQuoteAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_QuoteSysID=pInputQuoteAction.QuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pInputQuoteAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputQuoteAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputQuoteAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputQuoteAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pInputQuoteAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputQuoteAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputQuoteAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputQuoteAction(BrokerID,InvestorID,QuoteActionRef,QuoteRef,RequestID,FrontID,SessionID,ExchangeID,QuoteSysID,ActionFlag,UserID,InstrumentID,InvestUnitID,ClientID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_QuoteActionRef,l_QuoteRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_QuoteSysID,l_ActionFlag,l_UserID,l_InstrumentID,l_InvestUnitID,l_ClientID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputBatchOrderAction2DB(self, pInputBatchOrderAction):
        l_BrokerID=pInputBatchOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputBatchOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OrderActionRef=pInputBatchOrderAction.OrderActionRef
        l_RequestID=pInputBatchOrderAction.RequestID
        l_FrontID=pInputBatchOrderAction.FrontID
        l_SessionID=pInputBatchOrderAction.SessionID
        l_ExchangeID=pInputBatchOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputBatchOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputBatchOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputBatchOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputBatchOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputBatchOrderAction(BrokerID,InvestorID,OrderActionRef,RequestID,FrontID,SessionID,ExchangeID,UserID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OrderActionRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_UserID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputOptionSelfClose2DB(self, pInputOptionSelfClose):
        l_BrokerID=pInputOptionSelfClose.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputOptionSelfClose.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputOptionSelfClose.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseRef=pInputOptionSelfClose.OptionSelfCloseRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputOptionSelfClose.UserID.decode(encoding="gb18030", errors="ignore");
        l_Volume=pInputOptionSelfClose.Volume
        l_RequestID=pInputOptionSelfClose.RequestID
        l_BusinessUnit=pInputOptionSelfClose.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInputOptionSelfClose.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_OptSelfCloseFlag=pInputOptionSelfClose.OptSelfCloseFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInputOptionSelfClose.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputOptionSelfClose.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pInputOptionSelfClose.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pInputOptionSelfClose.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pInputOptionSelfClose.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputOptionSelfClose.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputOptionSelfClose.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputOptionSelfClose(BrokerID,InvestorID,InstrumentID,OptionSelfCloseRef,UserID,Volume,RequestID,BusinessUnit,HedgeFlag,OptSelfCloseFlag,ExchangeID,InvestUnitID,AccountID,CurrencyID,ClientID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OptionSelfCloseRef,l_UserID,l_Volume,l_RequestID,l_BusinessUnit,l_HedgeFlag,l_OptSelfCloseFlag,l_ExchangeID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_ClientID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputOptionSelfCloseAction2DB(self, pInputOptionSelfCloseAction):
        l_BrokerID=pInputOptionSelfCloseAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputOptionSelfCloseAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseActionRef=pInputOptionSelfCloseAction.OptionSelfCloseActionRef
        l_OptionSelfCloseRef=pInputOptionSelfCloseAction.OptionSelfCloseRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pInputOptionSelfCloseAction.RequestID
        l_FrontID=pInputOptionSelfCloseAction.FrontID
        l_SessionID=pInputOptionSelfCloseAction.SessionID
        l_ExchangeID=pInputOptionSelfCloseAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseSysID=pInputOptionSelfCloseAction.OptionSelfCloseSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pInputOptionSelfCloseAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputOptionSelfCloseAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputOptionSelfCloseAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputOptionSelfCloseAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputOptionSelfCloseAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputOptionSelfCloseAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputOptionSelfCloseAction(BrokerID,InvestorID,OptionSelfCloseActionRef,OptionSelfCloseRef,RequestID,FrontID,SessionID,ExchangeID,OptionSelfCloseSysID,ActionFlag,UserID,InstrumentID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OptionSelfCloseActionRef,l_OptionSelfCloseRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_OptionSelfCloseSysID,l_ActionFlag,l_UserID,l_InstrumentID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInputCombAction2DB(self, pInputCombAction):
        l_BrokerID=pInputCombAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInputCombAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInputCombAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_CombActionRef=pInputCombAction.CombActionRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pInputCombAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_Direction=pInputCombAction.Direction.decode(encoding="gb18030", errors="ignore");
        l_Volume=pInputCombAction.Volume
        l_CombDirection=pInputCombAction.CombDirection.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInputCombAction.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInputCombAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pInputCombAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pInputCombAction.MacAddress.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInputCombAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InputCombAction(BrokerID,InvestorID,InstrumentID,CombActionRef,UserID,Direction,Volume,CombDirection,HedgeFlag,ExchangeID,IPAddress,MacAddress,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_CombActionRef,l_UserID,l_Direction,l_Volume,l_CombDirection,l_HedgeFlag,l_ExchangeID,l_IPAddress,l_MacAddress,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryOrder2DB(self, pQryOrder):
        l_BrokerID=pQryOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OrderSysID=pQryOrder.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeStart=pQryOrder.InsertTimeStart.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeEnd=pQryOrder.InsertTimeEnd.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryOrder(BrokerID,InvestorID,InstrumentID,ExchangeID,OrderSysID,InsertTimeStart,InsertTimeEnd,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_OrderSysID,l_InsertTimeStart,l_InsertTimeEnd,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTrade2DB(self, pQryTrade):
        l_BrokerID=pQryTrade.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryTrade.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryTrade.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryTrade.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_TradeID=pQryTrade.TradeID.decode(encoding="gb18030", errors="ignore");
        l_TradeTimeStart=pQryTrade.TradeTimeStart.decode(encoding="gb18030", errors="ignore");
        l_TradeTimeEnd=pQryTrade.TradeTimeEnd.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryTrade.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTrade(BrokerID,InvestorID,InstrumentID,ExchangeID,TradeID,TradeTimeStart,TradeTimeEnd,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_TradeID,l_TradeTimeStart,l_TradeTimeEnd,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestorPosition2DB(self, pQryInvestorPosition):
        l_BrokerID=pQryInvestorPosition.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestorPosition.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryInvestorPosition.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInvestorPosition.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInvestorPosition.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestorPosition(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTradingAccount2DB(self, pQryTradingAccount):
        l_BrokerID=pQryTradingAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryTradingAccount.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQryTradingAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_BizType=pQryTradingAccount.BizType.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQryTradingAccount.AccountID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTradingAccount(BrokerID,InvestorID,CurrencyID,BizType,AccountID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_CurrencyID,l_BizType,l_AccountID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestor2DB(self, pQryInvestor):
        l_BrokerID=pQryInvestor.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestor.InvestorID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestor(BrokerID,InvestorID)VALUES(%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTradingCode2DB(self, pQryTradingCode):
        l_BrokerID=pQryTradingCode.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryTradingCode.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryTradingCode.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pQryTradingCode.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ClientIDType=pQryTradingCode.ClientIDType.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryTradingCode.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTradingCode(BrokerID,InvestorID,ExchangeID,ClientID,ClientIDType,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ExchangeID,l_ClientID,l_ClientIDType,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInstrumentMarginRate2DB(self, pQryInstrumentMarginRate):
        l_BrokerID=pQryInstrumentMarginRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInstrumentMarginRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryInstrumentMarginRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQryInstrumentMarginRate.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInstrumentMarginRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInstrumentMarginRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInstrumentMarginRate(BrokerID,InvestorID,InstrumentID,HedgeFlag,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_HedgeFlag,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInstrumentCommissionRate2DB(self, pQryInstrumentCommissionRate):
        l_BrokerID=pQryInstrumentCommissionRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInstrumentCommissionRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryInstrumentCommissionRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInstrumentCommissionRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInstrumentCommissionRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInstrumentCommissionRate(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryExchange2DB(self, pQryExchange):
        l_ExchangeID=pQryExchange.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryExchange(ExchangeID)VALUES(%s)"
        the_data =[( l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryProduct2DB(self, pQryProduct):
        l_ProductID=pQryProduct.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ProductClass=pQryProduct.ProductClass.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryProduct.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryProduct(ProductID,ProductClass,ExchangeID)VALUES(%s,%s,%s)"
        the_data =[( l_ProductID,l_ProductClass,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInstrument2DB(self, pQryInstrument):
        l_InstrumentID=pQryInstrument.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInstrument.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pQryInstrument.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_ProductID=pQryInstrument.ProductID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInstrument(InstrumentID,ExchangeID,ExchangeInstID,ProductID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_ExchangeID,l_ExchangeInstID,l_ProductID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryDepthMarketData2DB(self, pQryDepthMarketData):
        l_InstrumentID=pQryDepthMarketData.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryDepthMarketData.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryDepthMarketData(InstrumentID,ExchangeID)VALUES(%s,%s)"
        the_data =[( l_InstrumentID,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQrySettlementInfo2DB(self, pQrySettlementInfo):
        l_BrokerID=pQrySettlementInfo.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQrySettlementInfo.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pQrySettlementInfo.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQrySettlementInfo.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQrySettlementInfo.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QrySettlementInfo(BrokerID,InvestorID,TradingDay,AccountID,CurrencyID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_TradingDay,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTransferBank2DB(self, pQryTransferBank):
        l_BankID=pQryTransferBank.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBrchID=pQryTransferBank.BankBrchID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTransferBank(BankID,BankBrchID)VALUES(%s,%s)"
        the_data =[( l_BankID,l_BankBrchID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestorPositionDetail2DB(self, pQryInvestorPositionDetail):
        l_BrokerID=pQryInvestorPositionDetail.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestorPositionDetail.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryInvestorPositionDetail.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInvestorPositionDetail.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInvestorPositionDetail.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestorPositionDetail(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryNotice2DB(self, pQryNotice):
        l_BrokerID=pQryNotice.BrokerID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryNotice(BrokerID)VALUES(%s)"
        the_data =[( l_BrokerID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQrySettlementInfoConfirm2DB(self, pQrySettlementInfoConfirm):
        l_BrokerID=pQrySettlementInfoConfirm.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQrySettlementInfoConfirm.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQrySettlementInfoConfirm.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQrySettlementInfoConfirm.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QrySettlementInfoConfirm(BrokerID,InvestorID,AccountID,CurrencyID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestorPositionCombineDetail2DB(self, pQryInvestorPositionCombineDetail):
        l_BrokerID=pQryInvestorPositionCombineDetail.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestorPositionCombineDetail.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_CombInstrumentID=pQryInvestorPositionCombineDetail.CombInstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInvestorPositionCombineDetail.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInvestorPositionCombineDetail.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestorPositionCombineDetail(BrokerID,InvestorID,CombInstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_CombInstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryCFMMCTradingAccountKey2DB(self, pQryCFMMCTradingAccountKey):
        l_BrokerID=pQryCFMMCTradingAccountKey.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryCFMMCTradingAccountKey.InvestorID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryCFMMCTradingAccountKey(BrokerID,InvestorID)VALUES(%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryEWarrantOffset2DB(self, pQryEWarrantOffset):
        l_BrokerID=pQryEWarrantOffset.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryEWarrantOffset.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryEWarrantOffset.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryEWarrantOffset.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryEWarrantOffset.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryEWarrantOffset(BrokerID,InvestorID,ExchangeID,InstrumentID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ExchangeID,l_InstrumentID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestorProductGroupMargin2DB(self, pQryInvestorProductGroupMargin):
        l_BrokerID=pQryInvestorProductGroupMargin.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestorProductGroupMargin.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ProductGroupID=pQryInvestorProductGroupMargin.ProductGroupID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQryInvestorProductGroupMargin.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryInvestorProductGroupMargin.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInvestorProductGroupMargin.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestorProductGroupMargin(BrokerID,InvestorID,ProductGroupID,HedgeFlag,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ProductGroupID,l_HedgeFlag,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryExchangeMarginRate2DB(self, pQryExchangeMarginRate):
        l_BrokerID=pQryExchangeMarginRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryExchangeMarginRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQryExchangeMarginRate.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryExchangeMarginRate.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryExchangeMarginRate(BrokerID,InstrumentID,HedgeFlag,ExchangeID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_HedgeFlag,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryExchangeMarginRateAdjust2DB(self, pQryExchangeMarginRateAdjust):
        l_BrokerID=pQryExchangeMarginRateAdjust.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryExchangeMarginRateAdjust.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQryExchangeMarginRateAdjust.HedgeFlag.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryExchangeMarginRateAdjust(BrokerID,InstrumentID,HedgeFlag)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_HedgeFlag)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryExchangeRate2DB(self, pQryExchangeRate):
        l_BrokerID=pQryExchangeRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_FromCurrencyID=pQryExchangeRate.FromCurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ToCurrencyID=pQryExchangeRate.ToCurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryExchangeRate(BrokerID,FromCurrencyID,ToCurrencyID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_FromCurrencyID,l_ToCurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQrySecAgentACIDMap2DB(self, pQrySecAgentACIDMap):
        l_BrokerID=pQrySecAgentACIDMap.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pQrySecAgentACIDMap.UserID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQrySecAgentACIDMap.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQrySecAgentACIDMap.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QrySecAgentACIDMap(BrokerID,UserID,AccountID,CurrencyID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_UserID,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryProductExchRate2DB(self, pQryProductExchRate):
        l_ProductID=pQryProductExchRate.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryProductExchRate.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryProductExchRate(ProductID,ExchangeID)VALUES(%s,%s)"
        the_data =[( l_ProductID,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryProductGroup2DB(self, pQryProductGroup):
        l_ProductID=pQryProductGroup.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryProductGroup.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryProductGroup(ProductID,ExchangeID)VALUES(%s,%s)"
        the_data =[( l_ProductID,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryMMInstrumentCommissionRate2DB(self, pQryMMInstrumentCommissionRate):
        l_BrokerID=pQryMMInstrumentCommissionRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryMMInstrumentCommissionRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryMMInstrumentCommissionRate.InstrumentID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryMMInstrumentCommissionRate(BrokerID,InvestorID,InstrumentID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryMMOptionInstrCommRate2DB(self, pQryMMOptionInstrCommRate):
        l_BrokerID=pQryMMOptionInstrCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryMMOptionInstrCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryMMOptionInstrCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryMMOptionInstrCommRate(BrokerID,InvestorID,InstrumentID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInstrumentOrderCommRate2DB(self, pQryInstrumentOrderCommRate):
        l_BrokerID=pQryInstrumentOrderCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInstrumentOrderCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryInstrumentOrderCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInstrumentOrderCommRate(BrokerID,InvestorID,InstrumentID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQrySecAgentCheckMode2DB(self, pQrySecAgentCheckMode):
        l_BrokerID=pQrySecAgentCheckMode.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQrySecAgentCheckMode.InvestorID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QrySecAgentCheckMode(BrokerID,InvestorID)VALUES(%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryOptionInstrTradeCost2DB(self, pQryOptionInstrTradeCost):
        l_BrokerID=pQryOptionInstrTradeCost.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryOptionInstrTradeCost.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryOptionInstrTradeCost.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pQryOptionInstrTradeCost.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_InputPrice=pQryOptionInstrTradeCost.InputPrice
        l_UnderlyingPrice=pQryOptionInstrTradeCost.UnderlyingPrice
        l_ExchangeID=pQryOptionInstrTradeCost.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryOptionInstrTradeCost.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryOptionInstrTradeCost(BrokerID,InvestorID,InstrumentID,HedgeFlag,InputPrice,UnderlyingPrice,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_HedgeFlag,l_InputPrice,l_UnderlyingPrice,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryOptionInstrCommRate2DB(self, pQryOptionInstrCommRate):
        l_BrokerID=pQryOptionInstrCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryOptionInstrCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryOptionInstrCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryOptionInstrCommRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryOptionInstrCommRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryOptionInstrCommRate(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryExecOrder2DB(self, pQryExecOrder):
        l_BrokerID=pQryExecOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryExecOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryExecOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryExecOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderSysID=pQryExecOrder.ExecOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeStart=pQryExecOrder.InsertTimeStart.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeEnd=pQryExecOrder.InsertTimeEnd.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryExecOrder(BrokerID,InvestorID,InstrumentID,ExchangeID,ExecOrderSysID,InsertTimeStart,InsertTimeEnd)VALUES(%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_ExecOrderSysID,l_InsertTimeStart,l_InsertTimeEnd)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryForQuote2DB(self, pQryForQuote):
        l_BrokerID=pQryForQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryForQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryForQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryForQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeStart=pQryForQuote.InsertTimeStart.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeEnd=pQryForQuote.InsertTimeEnd.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryForQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryForQuote(BrokerID,InvestorID,InstrumentID,ExchangeID,InsertTimeStart,InsertTimeEnd,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InsertTimeStart,l_InsertTimeEnd,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryQuote2DB(self, pQryQuote):
        l_BrokerID=pQryQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_QuoteSysID=pQryQuote.QuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeStart=pQryQuote.InsertTimeStart.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeEnd=pQryQuote.InsertTimeEnd.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryQuote(BrokerID,InvestorID,InstrumentID,ExchangeID,QuoteSysID,InsertTimeStart,InsertTimeEnd,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_QuoteSysID,l_InsertTimeStart,l_InsertTimeEnd,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryOptionSelfClose2DB(self, pQryOptionSelfClose):
        l_BrokerID=pQryOptionSelfClose.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryOptionSelfClose.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryOptionSelfClose.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryOptionSelfClose.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseSysID=pQryOptionSelfClose.OptionSelfCloseSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeStart=pQryOptionSelfClose.InsertTimeStart.decode(encoding="gb18030", errors="ignore");
        l_InsertTimeEnd=pQryOptionSelfClose.InsertTimeEnd.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryOptionSelfClose(BrokerID,InvestorID,InstrumentID,ExchangeID,OptionSelfCloseSysID,InsertTimeStart,InsertTimeEnd)VALUES(%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_OptionSelfCloseSysID,l_InsertTimeStart,l_InsertTimeEnd)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryInvestUnit2DB(self, pQryInvestUnit):
        l_BrokerID=pQryInvestUnit.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryInvestUnit.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryInvestUnit.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryInvestUnit(BrokerID,InvestorID,InvestUnitID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryCombInstrumentGuard2DB(self, pQryCombInstrumentGuard):
        l_BrokerID=pQryCombInstrumentGuard.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryCombInstrumentGuard.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryCombInstrumentGuard.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryCombInstrumentGuard(BrokerID,InstrumentID,ExchangeID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryCombAction2DB(self, pQryCombAction):
        l_BrokerID=pQryCombAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryCombAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryCombAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryCombAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryCombAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryCombAction(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTransferSerial2DB(self, pQryTransferSerial):
        l_BrokerID=pQryTransferSerial.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQryTransferSerial.AccountID.decode(encoding="gb18030", errors="ignore");
        l_BankID=pQryTransferSerial.BankID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQryTransferSerial.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTransferSerial(BrokerID,AccountID,BankID,CurrencyID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_AccountID,l_BankID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryAccountregister2DB(self, pQryAccountregister):
        l_BrokerID=pQryAccountregister.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQryAccountregister.AccountID.decode(encoding="gb18030", errors="ignore");
        l_BankID=pQryAccountregister.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pQryAccountregister.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQryAccountregister.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryAccountregister(BrokerID,AccountID,BankID,BankBranchID,CurrencyID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_AccountID,l_BankID,l_BankBranchID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryContractBank2DB(self, pQryContractBank):
        l_BrokerID=pQryContractBank.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BankID=pQryContractBank.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBrchID=pQryContractBank.BankBrchID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryContractBank(BrokerID,BankID,BankBrchID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_BankID,l_BankBrchID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryParkedOrder2DB(self, pQryParkedOrder):
        l_BrokerID=pQryParkedOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryParkedOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryParkedOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryParkedOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryParkedOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryParkedOrder(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryParkedOrderAction2DB(self, pQryParkedOrderAction):
        l_BrokerID=pQryParkedOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryParkedOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryParkedOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryParkedOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryParkedOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryParkedOrderAction(BrokerID,InvestorID,InstrumentID,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryTradingNotice2DB(self, pQryTradingNotice):
        l_BrokerID=pQryTradingNotice.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryTradingNotice.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQryTradingNotice.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryTradingNotice(BrokerID,InvestorID,InvestUnitID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryBrokerTradingParams2DB(self, pQryBrokerTradingParams):
        l_BrokerID=pQryBrokerTradingParams.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQryBrokerTradingParams.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQryBrokerTradingParams.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQryBrokerTradingParams.AccountID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryBrokerTradingParams(BrokerID,InvestorID,CurrencyID,AccountID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_CurrencyID,l_AccountID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQryBrokerTradingAlgos2DB(self, pQryBrokerTradingAlgos):
        l_BrokerID=pQryBrokerTradingAlgos.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQryBrokerTradingAlgos.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQryBrokerTradingAlgos.InstrumentID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QryBrokerTradingAlgos(BrokerID,ExchangeID,InstrumentID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_ExchangeID,l_InstrumentID)]
        self.SQL2DB(the_SQL,the_data)

    def  pQueryCFMMCTradingAccountToken2DB(self, pQueryCFMMCTradingAccountToken):
        l_BrokerID=pQueryCFMMCTradingAccountToken.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQueryCFMMCTradingAccountToken.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQueryCFMMCTradingAccountToken.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QueryCFMMCTradingAccountToken(BrokerID,InvestorID,InvestUnitID)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pReqTransfer2DB(self, pReqTransfer):
        l_TradeCode=pReqTransfer.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pReqTransfer.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pReqTransfer.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pReqTransfer.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pReqTransfer.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pReqTransfer.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pReqTransfer.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pReqTransfer.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pReqTransfer.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pReqTransfer.PlateSerial
        l_LastFragment=pReqTransfer.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pReqTransfer.SessionID
        l_CustomerName=pReqTransfer.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pReqTransfer.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pReqTransfer.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pReqTransfer.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pReqTransfer.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pReqTransfer.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pReqTransfer.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pReqTransfer.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pReqTransfer.InstallID
        l_FutureSerial=pReqTransfer.FutureSerial
        l_UserID=pReqTransfer.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pReqTransfer.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pReqTransfer.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_TradeAmount=pReqTransfer.TradeAmount
        l_FutureFetchAmount=pReqTransfer.FutureFetchAmount
        l_FeePayFlag=pReqTransfer.FeePayFlag.decode(encoding="gb18030", errors="ignore");
        l_CustFee=pReqTransfer.CustFee
        l_BrokerFee=pReqTransfer.BrokerFee
        l_Message=pReqTransfer.Message.decode(encoding="gb18030", errors="ignore");
        l_Digest=pReqTransfer.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pReqTransfer.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pReqTransfer.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pReqTransfer.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pReqTransfer.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pReqTransfer.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pReqTransfer.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pReqTransfer.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pReqTransfer.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pReqTransfer.RequestID
        l_TID=pReqTransfer.TID
        l_TransferStatus=pReqTransfer.TransferStatus.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pReqTransfer.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqTransfer(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,InstallID,FutureSerial,UserID,VerifyCertNoFlag,CurrencyID,TradeAmount,FutureFetchAmount,FeePayFlag,CustFee,BrokerFee,Message,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,TransferStatus,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_FutureSerial,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_TradeAmount,l_FutureFetchAmount,l_FeePayFlag,l_CustFee,l_BrokerFee,l_Message,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_TransferStatus,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pReqQueryAccount2DB(self, pReqQueryAccount):
        l_TradeCode=pReqQueryAccount.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pReqQueryAccount.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pReqQueryAccount.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pReqQueryAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pReqQueryAccount.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pReqQueryAccount.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pReqQueryAccount.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pReqQueryAccount.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pReqQueryAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pReqQueryAccount.PlateSerial
        l_LastFragment=pReqQueryAccount.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pReqQueryAccount.SessionID
        l_CustomerName=pReqQueryAccount.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pReqQueryAccount.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pReqQueryAccount.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pReqQueryAccount.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pReqQueryAccount.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pReqQueryAccount.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pReqQueryAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pReqQueryAccount.Password.decode(encoding="gb18030", errors="ignore");
        l_FutureSerial=pReqQueryAccount.FutureSerial
        l_InstallID=pReqQueryAccount.InstallID
        l_UserID=pReqQueryAccount.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pReqQueryAccount.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pReqQueryAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_Digest=pReqQueryAccount.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pReqQueryAccount.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pReqQueryAccount.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pReqQueryAccount.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pReqQueryAccount.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pReqQueryAccount.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pReqQueryAccount.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pReqQueryAccount.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pReqQueryAccount.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pReqQueryAccount.RequestID
        l_TID=pReqQueryAccount.TID
        l_LongCustomerName=pReqQueryAccount.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqQueryAccount(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,FutureSerial,InstallID,UserID,VerifyCertNoFlag,CurrencyID,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_FutureSerial,l_InstallID,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pRspAuthenticateField2DB(self, pRspAuthenticateField):
        l_BrokerID=pRspAuthenticateField.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pRspAuthenticateField.UserID.decode(encoding="gb18030", errors="ignore");
        l_UserProductInfo=pRspAuthenticateField.UserProductInfo.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RspAuthenticate(BrokerID,UserID,UserProductInfo)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_UserID,l_UserProductInfo)]
        self.SQL2DB(the_SQL,the_data)

    def  pRspUserLogin2DB(self, pRspUserLogin):
        l_TradingDay=pRspUserLogin.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_LoginTime=pRspUserLogin.LoginTime.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pRspUserLogin.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pRspUserLogin.UserID.decode(encoding="gb18030", errors="ignore");
        l_SystemName=pRspUserLogin.SystemName.decode(encoding="gb18030", errors="ignore");
        l_FrontID=pRspUserLogin.FrontID
        l_SessionID=pRspUserLogin.SessionID
        l_MaxOrderRef=pRspUserLogin.MaxOrderRef.decode(encoding="gb18030", errors="ignore");
        l_SHFETime=pRspUserLogin.SHFETime.decode(encoding="gb18030", errors="ignore");
        l_DCETime=pRspUserLogin.DCETime.decode(encoding="gb18030", errors="ignore");
        l_CZCETime=pRspUserLogin.CZCETime.decode(encoding="gb18030", errors="ignore");
        l_FFEXTime=pRspUserLogin.FFEXTime.decode(encoding="gb18030", errors="ignore");
        l_INETime=pRspUserLogin.INETime.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RspUserLogin(TradingDay,LoginTime,BrokerID,UserID,SystemName,FrontID,SessionID,MaxOrderRef,SHFETime,DCETime,CZCETime,FFEXTime,INETime)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_LoginTime,l_BrokerID,l_UserID,l_SystemName,l_FrontID,l_SessionID,l_MaxOrderRef,l_SHFETime,l_DCETime,l_CZCETime,l_FFEXTime,l_INETime)]
        self.SQL2DB(the_SQL,the_data)

    def  pOrder2DB(self, pOrder):
        l_BrokerID=pOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OrderRef=pOrder.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_OrderPriceType=pOrder.OrderPriceType.decode(encoding="gb18030", errors="ignore");
        l_Direction=pOrder.Direction.decode(encoding="gb18030", errors="ignore");
        l_CombOffsetFlag=pOrder.CombOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_CombHedgeFlag=pOrder.CombHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pOrder.LimitPrice
        l_VolumeTotalOriginal=pOrder.VolumeTotalOriginal
        l_TimeCondition=pOrder.TimeCondition.decode(encoding="gb18030", errors="ignore");
        l_GTDDate=pOrder.GTDDate.decode(encoding="gb18030", errors="ignore");
        l_VolumeCondition=pOrder.VolumeCondition.decode(encoding="gb18030", errors="ignore");
        l_MinVolume=pOrder.MinVolume
        l_ContingentCondition=pOrder.ContingentCondition.decode(encoding="gb18030", errors="ignore");
        l_StopPrice=pOrder.StopPrice
        l_ForceCloseReason=pOrder.ForceCloseReason.decode(encoding="gb18030", errors="ignore");
        l_IsAutoSuspend=pOrder.IsAutoSuspend
        l_BusinessUnit=pOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pOrder.RequestID
        l_OrderLocalID=pOrder.OrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pOrder.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pOrder.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pOrder.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pOrder.InstallID
        l_OrderSubmitStatus=pOrder.OrderSubmitStatus.decode(encoding="gb18030", errors="ignore");
        l_NotifySequence=pOrder.NotifySequence
        l_TradingDay=pOrder.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pOrder.SettlementID
        l_OrderSysID=pOrder.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_OrderSource=pOrder.OrderSource.decode(encoding="gb18030", errors="ignore");
        l_OrderStatus=pOrder.OrderStatus.decode(encoding="gb18030", errors="ignore");
        l_OrderType=pOrder.OrderType.decode(encoding="gb18030", errors="ignore");
        l_VolumeTraded=pOrder.VolumeTraded
        l_VolumeTotal=pOrder.VolumeTotal
        l_InsertDate=pOrder.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pOrder.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_ActiveTime=pOrder.ActiveTime.decode(encoding="gb18030", errors="ignore");
        l_SuspendTime=pOrder.SuspendTime.decode(encoding="gb18030", errors="ignore");
        l_UpdateTime=pOrder.UpdateTime.decode(encoding="gb18030", errors="ignore");
        l_CancelTime=pOrder.CancelTime.decode(encoding="gb18030", errors="ignore");
        l_ActiveTraderID=pOrder.ActiveTraderID.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pOrder.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pOrder.SequenceNo
        l_FrontID=pOrder.FrontID
        l_SessionID=pOrder.SessionID
        l_UserProductInfo=pOrder.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pOrder.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_UserForceClose=pOrder.UserForceClose
        l_ActiveUserID=pOrder.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerOrderSeq=pOrder.BrokerOrderSeq
        l_RelativeOrderSysID=pOrder.RelativeOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ZCETotalTradedVolume=pOrder.ZCETotalTradedVolume
        l_IsSwapOrder=pOrder.IsSwapOrder
        l_BranchID=pOrder.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pOrder.MacAddress.decode(encoding="gb18030", errors="ignore");



        '''
        ///全部成交
        #define THOST_FTDC_OST_AllTraded '0'
        ///部分成交还在队列中
        #define THOST_FTDC_OST_PartTradedQueueing '1'
        ///部分成交不在队列中
        #define THOST_FTDC_OST_PartTradedNotQueueing '2'
        ///未成交还在队列中
        #define THOST_FTDC_OST_NoTradeQueueing '3'
        ///未成交不在队列中
        #define THOST_FTDC_OST_NoTradeNotQueueing '4'
        ///撤单
        #define THOST_FTDC_OST_Canceled '5'
        ///未知
        #define THOST_FTDC_OST_Unknown 'a'
        ///尚未触发
        #define THOST_FTDC_OST_NotTouched 'b'
        ///已触发
        #define THOST_FTDC_OST_Touched 'c'
        '''
        #内存中只记录非 0和5的报单通知，为撤单使用 
        l_order={}
        l_order["BrokerID"]               = l_BrokerID
        l_order["InvestorID"]             = l_InvestorID
        l_order["InstrumentID"]           = l_InstrumentID
        l_order["OrderRef"]               = l_OrderRef
        l_order["UserID"]                 = l_UserID
        l_order["OrderPriceType"]         = l_OrderPriceType
        l_order["Direction"]              = l_Direction
        l_order["CombOffsetFlag"]         = l_CombOffsetFlag
        l_order["CombHedgeFlag"]          = l_CombHedgeFlag
        l_order["LimitPrice"]             = l_LimitPrice
        l_order["VolumeTotalOriginal"]    = l_VolumeTotalOriginal
        l_order["TimeCondition"]          = l_TimeCondition
        l_order["GTDDate"]                = l_GTDDate
        l_order["VolumeCondition"]        = l_VolumeCondition
        l_order["MinVolume"]              = l_MinVolume
        l_order["ContingentCondition"]    = l_ContingentCondition
        l_order["StopPrice"]              = l_StopPrice
        l_order["ForceCloseReason"]       = l_ForceCloseReason
        l_order["IsAutoSuspend"]          = l_IsAutoSuspend
        l_order["BusinessUnit"]           = l_BusinessUnit
        l_order["RequestID"]              = l_RequestID
        l_order["OrderLocalID"]           = l_OrderLocalID
        l_order["ExchangeID"]             = l_ExchangeID
        l_order["ParticipantID"]          = l_ParticipantID
        l_order["ClientID"]               = l_ClientID
        l_order["ExchangeInstID"]         = l_ExchangeInstID
        l_order["TraderID"]               = l_TraderID
        l_order["InstallID"]              = l_InstallID
        l_order["OrderSubmitStatus"]      = l_OrderSubmitStatus
        l_order["NotifySequence"]         = l_NotifySequence
        l_order["TradingDay"]             = l_TradingDay
        l_order["SettlementID"]           = l_SettlementID
        l_order["OrderSysID"]             = l_OrderSysID
        l_order["OrderSource"]            = l_OrderSource
        l_order["OrderStatus"]            = l_OrderStatus
        l_order["OrderType"]              = l_OrderType
        l_order["VolumeTraded"]           = l_VolumeTraded
        l_order["VolumeTotal"]            = l_VolumeTotal
        l_order["InsertDate"]             = l_InsertDate
        l_order["InsertTime"]             = l_InsertTime
        l_order["ActiveTime"]             = l_ActiveTime
        l_order["SuspendTime"]            = l_SuspendTime
        l_order["UpdateTime"]             = l_UpdateTime
        l_order["CancelTime"]             = l_CancelTime
        l_order["ActiveTraderID"]         = l_ActiveTraderID
        l_order["ClearingPartID"]         = l_ClearingPartID
        l_order["SequenceNo"]             = l_SequenceNo
        l_order["FrontID"]                = l_FrontID
        l_order["SessionID"]              = l_SessionID
        l_order["UserProductInfo"]        = l_UserProductInfo
        l_order["StatusMsg"]              = l_StatusMsg
        l_order["UserForceClose"]         = l_UserForceClose
        l_order["ActiveUserID"]           = l_ActiveUserID
        l_order["BrokerOrderSeq"]         = l_BrokerOrderSeq
        l_order["RelativeOrderSysID"]     = l_RelativeOrderSysID
        l_order["ZCETotalTradedVolume"]   = l_ZCETotalTradedVolume
        l_order["IsSwapOrder"]            = l_IsSwapOrder
        l_order["BranchID"]               = l_BranchID
        l_order["InvestUnitID"]           = l_InvestUnitID
        l_order["AccountID"]              = l_AccountID
        l_order["CurrencyID"]             = l_CurrencyID
        l_order["IPAddress"]              = l_IPAddress
        l_order["MacAddress"]             = l_MacAddress

        if l_OrderStatus not in ['a']:
          l_order_list= self.__instrument_rtn_order_dict.get(l_InstrumentID)
          if l_order_list is None:
            l_order_list=[l_order]
            self.__instrument_rtn_order_dict[l_InstrumentID]=l_order_list;
          else:
            #找到就更新
            found=False
            for it_order in l_order_list:
              if it_order["OrderSysID"] == l_OrderSysID and it_order["ExchangeID"] == l_ExchangeID and len(l_OrderSysID) > 0:
                found=True
                it_order["BrokerID"]               = l_BrokerID
                it_order["InvestorID"]             = l_InvestorID
                it_order["InstrumentID"]           = l_InstrumentID
                it_order["OrderRef"]               = l_OrderRef
                it_order["UserID"]                 = l_UserID
                it_order["OrderPriceType"]         = l_OrderPriceType
                it_order["Direction"]              = l_Direction
                it_order["CombOffsetFlag"]         = l_CombOffsetFlag
                it_order["CombHedgeFlag"]          = l_CombHedgeFlag
                it_order["LimitPrice"]             = l_LimitPrice
                it_order["VolumeTotalOriginal"]    = l_VolumeTotalOriginal
                it_order["TimeCondition"]          = l_TimeCondition
                it_order["GTDDate"]                = l_GTDDate
                it_order["VolumeCondition"]        = l_VolumeCondition
                it_order["MinVolume"]              = l_MinVolume
                it_order["ContingentCondition"]    = l_ContingentCondition
                it_order["StopPrice"]              = l_StopPrice
                it_order["ForceCloseReason"]       = l_ForceCloseReason
                it_order["IsAutoSuspend"]          = l_IsAutoSuspend
                it_order["BusinessUnit"]           = l_BusinessUnit
                it_order["RequestID"]              = l_RequestID
                it_order["OrderLocalID"]           = l_OrderLocalID
                it_order["ExchangeID"]             = l_ExchangeID
                it_order["ParticipantID"]          = l_ParticipantID
                it_order["ClientID"]               = l_ClientID
                it_order["ExchangeInstID"]         = l_ExchangeInstID
                it_order["TraderID"]               = l_TraderID
                it_order["InstallID"]              = l_InstallID
                it_order["OrderSubmitStatus"]      = l_OrderSubmitStatus
                it_order["NotifySequence"]         = l_NotifySequence
                it_order["TradingDay"]             = l_TradingDay
                it_order["SettlementID"]           = l_SettlementID
                it_order["OrderSysID"]             = l_OrderSysID
                it_order["OrderSource"]            = l_OrderSource
                it_order["OrderStatus"]            = l_OrderStatus
                it_order["OrderType"]              = l_OrderType
                it_order["VolumeTraded"]           = l_VolumeTraded
                it_order["VolumeTotal"]            = l_VolumeTotal
                it_order["InsertDate"]             = l_InsertDate
                it_order["InsertTime"]             = l_InsertTime
                it_order["ActiveTime"]             = l_ActiveTime
                it_order["SuspendTime"]            = l_SuspendTime
                it_order["UpdateTime"]             = l_UpdateTime
                it_order["CancelTime"]             = l_CancelTime
                it_order["ActiveTraderID"]         = l_ActiveTraderID
                it_order["ClearingPartID"]         = l_ClearingPartID
                it_order["SequenceNo"]             = l_SequenceNo
                it_order["FrontID"]                = l_FrontID
                it_order["SessionID"]              = l_SessionID
                it_order["UserProductInfo"]        = l_UserProductInfo
                it_order["StatusMsg"]              = l_StatusMsg
                it_order["UserForceClose"]         = l_UserForceClose
                it_order["ActiveUserID"]           = l_ActiveUserID
                it_order["BrokerOrderSeq"]         = l_BrokerOrderSeq
                it_order["RelativeOrderSysID"]     = l_RelativeOrderSysID
                it_order["ZCETotalTradedVolume"]   = l_ZCETotalTradedVolume
                it_order["IsSwapOrder"]            = l_IsSwapOrder
                it_order["BranchID"]               = l_BranchID
                it_order["InvestUnitID"]           = l_InvestUnitID
                it_order["AccountID"]              = l_AccountID
                it_order["CurrencyID"]             = l_CurrencyID
                it_order["IPAddress"]              = l_IPAddress
                it_order["MacAddress"]             = l_MacAddress
            if found == False:
              l_order_list.append(l_order)

        the_SQL  ="INSERT INTO T_Order(BrokerID,InvestorID,InstrumentID,OrderRef,UserID,OrderPriceType,Direction,CombOffsetFlag,CombHedgeFlag,LimitPrice,VolumeTotalOriginal,TimeCondition,GTDDate,VolumeCondition,MinVolume,ContingentCondition,StopPrice,ForceCloseReason,IsAutoSuspend,BusinessUnit,RequestID,OrderLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,OrderSubmitStatus,NotifySequence,TradingDay,SettlementID,OrderSysID,OrderSource,OrderStatus,OrderType,VolumeTraded,VolumeTotal,InsertDate,InsertTime,ActiveTime,SuspendTime,UpdateTime,CancelTime,ActiveTraderID,ClearingPartID,SequenceNo,FrontID,SessionID,UserProductInfo,StatusMsg,UserForceClose,ActiveUserID,BrokerOrderSeq,RelativeOrderSysID,ZCETotalTradedVolume,IsSwapOrder,BranchID,InvestUnitID,AccountID,CurrencyID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OrderRef,l_UserID,l_OrderPriceType,l_Direction,l_CombOffsetFlag,l_CombHedgeFlag,l_LimitPrice,l_VolumeTotalOriginal,l_TimeCondition,l_GTDDate,l_VolumeCondition,l_MinVolume,l_ContingentCondition,l_StopPrice,l_ForceCloseReason,l_IsAutoSuspend,l_BusinessUnit,l_RequestID,l_OrderLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_OrderSubmitStatus,l_NotifySequence,l_TradingDay,l_SettlementID,l_OrderSysID,l_OrderSource,l_OrderStatus,l_OrderType,l_VolumeTraded,l_VolumeTotal,l_InsertDate,l_InsertTime,l_ActiveTime,l_SuspendTime,l_UpdateTime,l_CancelTime,l_ActiveTraderID,l_ClearingPartID,l_SequenceNo,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_UserForceClose,l_ActiveUserID,l_BrokerOrderSeq,l_RelativeOrderSysID,l_ZCETotalTradedVolume,l_IsSwapOrder,l_BranchID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pTrade2DB(self, pTrade):
        l_BrokerID=pTrade.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pTrade.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pTrade.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OrderRef=pTrade.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pTrade.UserID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pTrade.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_TradeID=pTrade.TradeID.decode(encoding="gb18030", errors="ignore");
        l_Direction=pTrade.Direction.decode(encoding="gb18030", errors="ignore");
        l_OrderSysID=pTrade.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pTrade.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pTrade.ClientID.decode(encoding="gb18030", errors="ignore");
        l_TradingRole=pTrade.TradingRole.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pTrade.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_OffsetFlag=pTrade.OffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pTrade.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_Price=pTrade.Price
        l_Volume=pTrade.Volume
        l_TradeDate=pTrade.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pTrade.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_TradeType=pTrade.TradeType.decode(encoding="gb18030", errors="ignore");
        l_PriceSource=pTrade.PriceSource.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pTrade.TraderID.decode(encoding="gb18030", errors="ignore");
        l_OrderLocalID=pTrade.OrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pTrade.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pTrade.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pTrade.SequenceNo
        l_TradingDay=pTrade.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pTrade.SettlementID
        l_BrokerOrderSeq=pTrade.BrokerOrderSeq
        l_TradeSource=pTrade.TradeSource.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pTrade.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Trade(BrokerID,InvestorID,InstrumentID,OrderRef,UserID,ExchangeID,TradeID,Direction,OrderSysID,ParticipantID,ClientID,TradingRole,ExchangeInstID,OffsetFlag,HedgeFlag,Price,Volume,TradeDate,TradeTime,TradeType,PriceSource,TraderID,OrderLocalID,ClearingPartID,BusinessUnit,SequenceNo,TradingDay,SettlementID,BrokerOrderSeq,TradeSource,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OrderRef,l_UserID,l_ExchangeID,l_TradeID,l_Direction,l_OrderSysID,l_ParticipantID,l_ClientID,l_TradingRole,l_ExchangeInstID,l_OffsetFlag,l_HedgeFlag,l_Price,l_Volume,l_TradeDate,l_TradeTime,l_TradeType,l_PriceSource,l_TraderID,l_OrderLocalID,l_ClearingPartID,l_BusinessUnit,l_SequenceNo,l_TradingDay,l_SettlementID,l_BrokerOrderSeq,l_TradeSource,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

        try:
          #更新这个合约的报单及仓位信息 
          l_pQryPos = py_ApiStructure.QryInvestorPositionField(InvestorID=self.investor_id,InstrumentID=l_InstrumentID)
          l_retVal = -1
          while l_retVal != 0:
             time.sleep(1)
             l_retVal = self.ReqQryInvestorPosition(pQryInvestorPosition=l_pQryPos)

        except Exception as err:
          myEnv.logger.error('成交引起的仓位信息发生更新', exc_info=True)

    def  pInvestorPosition2DB(self, pInvestorPosition):
        l_InstrumentID=pInvestorPosition.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInvestorPosition.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInvestorPosition.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_PosiDirection=pInvestorPosition.PosiDirection.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInvestorPosition.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_PositionDate=pInvestorPosition.PositionDate.decode(encoding="gb18030", errors="ignore");
        l_YdPosition=pInvestorPosition.YdPosition
        l_Position=pInvestorPosition.Position
        l_LongFrozen=pInvestorPosition.LongFrozen
        l_ShortFrozen=pInvestorPosition.ShortFrozen
        l_LongFrozenAmount=pInvestorPosition.LongFrozenAmount
        l_ShortFrozenAmount=pInvestorPosition.ShortFrozenAmount
        l_OpenVolume=pInvestorPosition.OpenVolume
        l_CloseVolume=pInvestorPosition.CloseVolume
        l_OpenAmount=pInvestorPosition.OpenAmount
        l_CloseAmount=pInvestorPosition.CloseAmount
        l_PositionCost=pInvestorPosition.PositionCost
        l_PreMargin=pInvestorPosition.PreMargin
        l_UseMargin=pInvestorPosition.UseMargin
        l_FrozenMargin=pInvestorPosition.FrozenMargin
        l_FrozenCash=pInvestorPosition.FrozenCash
        l_FrozenCommission=pInvestorPosition.FrozenCommission
        l_CashIn=pInvestorPosition.CashIn
        l_Commission=pInvestorPosition.Commission
        l_CloseProfit=pInvestorPosition.CloseProfit
        l_PositionProfit=pInvestorPosition.PositionProfit
        l_PreSettlementPrice=pInvestorPosition.PreSettlementPrice
        l_SettlementPrice=pInvestorPosition.SettlementPrice
        l_TradingDay=pInvestorPosition.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pInvestorPosition.SettlementID
        l_OpenCost=pInvestorPosition.OpenCost
        l_ExchangeMargin=pInvestorPosition.ExchangeMargin
        l_CombPosition=pInvestorPosition.CombPosition
        l_CombLongFrozen=pInvestorPosition.CombLongFrozen
        l_CombShortFrozen=pInvestorPosition.CombShortFrozen
        l_CloseProfitByDate=pInvestorPosition.CloseProfitByDate
        l_CloseProfitByTrade=pInvestorPosition.CloseProfitByTrade
        l_TodayPosition=pInvestorPosition.TodayPosition
        l_MarginRateByMoney=pInvestorPosition.MarginRateByMoney
        l_MarginRateByVolume=pInvestorPosition.MarginRateByVolume
        l_StrikeFrozen=pInvestorPosition.StrikeFrozen
        l_StrikeFrozenAmount=pInvestorPosition.StrikeFrozenAmount
        l_AbandonFrozen=pInvestorPosition.AbandonFrozen
        l_ExchangeID=pInvestorPosition.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_YdStrikeFrozen=pInvestorPosition.YdStrikeFrozen
        l_InvestUnitID=pInvestorPosition.InvestUnitID.decode(encoding="gb18030", errors="ignore");


        l_pos={}
        l_pos["InstrumentID"]              = l_InstrumentID
        l_pos["BrokerID"]                  = l_BrokerID
        l_pos["InvestorID"]                = l_InvestorID
        l_pos["PosiDirection"]             = l_PosiDirection
        l_pos["HedgeFlag"]                 = l_HedgeFlag
        l_pos["PositionDate"]              = l_PositionDate
        l_pos["YdPosition"]                = l_YdPosition
        l_pos["Position"]                  = l_Position
        l_pos["LongFrozen"]                = l_LongFrozen
        l_pos["ShortFrozen"]               = l_ShortFrozen
        l_pos["LongFrozenAmount"]          = l_LongFrozenAmount
        l_pos["ShortFrozenAmount"]         = l_ShortFrozenAmount
        l_pos["OpenVolume"]                = l_OpenVolume
        l_pos["CloseVolume"]               = l_CloseVolume
        l_pos["OpenAmount"]                = l_OpenAmount
        l_pos["CloseAmount"]               = l_CloseAmount
        l_pos["PositionCost"]              = l_PositionCost
        l_pos["PreMargin"]                 = l_PreMargin
        l_pos["UseMargin"]                 = l_UseMargin
        l_pos["FrozenMargin"]              = l_FrozenMargin
        l_pos["FrozenCash"]                = l_FrozenCash
        l_pos["FrozenCommission"]          = l_FrozenCommission
        l_pos["CashIn"]                    = l_CashIn
        l_pos["Commission"]                = l_Commission
        l_pos["CloseProfit"]               = l_CloseProfit
        l_pos["PositionProfit"]            = l_PositionProfit
        l_pos["PreSettlementPrice"]        = l_PreSettlementPrice
        l_pos["SettlementPrice"]           = l_SettlementPrice
        l_pos["TradingDay"]                = l_TradingDay
        l_pos["SettlementID"]              = l_SettlementID
        l_pos["OpenCost"]                  = l_OpenCost
        l_pos["ExchangeMargin"]            = l_ExchangeMargin
        l_pos["CombPosition"]              = l_CombPosition
        l_pos["CombLongFrozen"]            = l_CombLongFrozen
        l_pos["CombShortFrozen"]           = l_CombShortFrozen
        l_pos["CloseProfitByDate"]         = l_CloseProfitByDate
        l_pos["CloseProfitByTrade"]        = l_CloseProfitByTrade
        l_pos["TodayPosition"]             = l_TodayPosition
        l_pos["MarginRateByMoney"]         = l_MarginRateByMoney
        l_pos["MarginRateByVolume"]        = l_MarginRateByVolume
        l_pos["StrikeFrozen"]              = l_StrikeFrozen
        l_pos["StrikeFrozenAmount"]        = l_StrikeFrozenAmount
        l_pos["AbandonFrozen"]             = l_AbandonFrozen
        l_pos["ExchangeID"]                = l_ExchangeID
        l_pos["YdStrikeFrozen"]            = l_YdStrikeFrozen
        l_pos["InvestUnitID"]              = l_InvestUnitID

        '''
        PositionProfit：期权没有持仓盈亏，为0。
        Position：表示当前持仓数量
        TodayPosition：表示今新开仓
        YdPosition：表示昨日收盘时持仓数量（≠ 当前的昨仓数量，静态，日间不随着开平仓而变化）
        当前的昨仓数量 = ∑Position -∑TodayPosition
        '''
        l_position_list= self.__instrument_position_dict.get(l_InstrumentID)
        if l_position_list is None:
          l_position_list=[l_pos]
          self.__instrument_position_dict[l_InstrumentID]=l_position_list
        else:
          #找到就更新
          found=False
          for it_pos in l_position_list: 
            if it_pos["InstrumentID"] == l_InstrumentID and it_pos["PosiDirection"] == l_PosiDirection:
              found=True
              it_pos["InstrumentID"]              = l_InstrumentID
              it_pos["BrokerID"]                  = l_BrokerID
              it_pos["InvestorID"]                = l_InvestorID
              it_pos["PosiDirection"]             = l_PosiDirection
              it_pos["HedgeFlag"]                 = l_HedgeFlag
              it_pos["PositionDate"]              = l_PositionDate
              it_pos["YdPosition"]                = l_YdPosition
              it_pos["Position"]                  = l_Position
              it_pos["LongFrozen"]                = l_LongFrozen
              it_pos["ShortFrozen"]               = l_ShortFrozen
              it_pos["LongFrozenAmount"]          = l_LongFrozenAmount
              it_pos["ShortFrozenAmount"]         = l_ShortFrozenAmount
              it_pos["OpenVolume"]                = l_OpenVolume
              it_pos["CloseVolume"]               = l_CloseVolume
              it_pos["OpenAmount"]                = l_OpenAmount
              it_pos["CloseAmount"]               = l_CloseAmount
              it_pos["PositionCost"]              = l_PositionCost
              it_pos["PreMargin"]                 = l_PreMargin
              it_pos["UseMargin"]                 = l_UseMargin
              it_pos["FrozenMargin"]              = l_FrozenMargin
              it_pos["FrozenCash"]                = l_FrozenCash
              it_pos["FrozenCommission"]          = l_FrozenCommission
              it_pos["CashIn"]                    = l_CashIn
              it_pos["Commission"]                = l_Commission
              it_pos["CloseProfit"]               = l_CloseProfit
              it_pos["PositionProfit"]            = l_PositionProfit
              it_pos["PreSettlementPrice"]        = l_PreSettlementPrice
              it_pos["SettlementPrice"]           = l_SettlementPrice
              it_pos["TradingDay"]                = l_TradingDay
              it_pos["SettlementID"]              = l_SettlementID
              it_pos["OpenCost"]                  = l_OpenCost
              it_pos["ExchangeMargin"]            = l_ExchangeMargin
              it_pos["CombPosition"]              = l_CombPosition
              it_pos["CombLongFrozen"]            = l_CombLongFrozen
              it_pos["CombShortFrozen"]           = l_CombShortFrozen
              it_pos["CloseProfitByDate"]         = l_CloseProfitByDate
              it_pos["CloseProfitByTrade"]        = l_CloseProfitByTrade
              it_pos["TodayPosition"]             = l_TodayPosition
              it_pos["MarginRateByMoney"]         = l_MarginRateByMoney
              it_pos["MarginRateByVolume"]        = l_MarginRateByVolume
              it_pos["StrikeFrozen"]              = l_StrikeFrozen
              it_pos["StrikeFrozenAmount"]        = l_StrikeFrozenAmount
              it_pos["AbandonFrozen"]             = l_AbandonFrozen
              it_pos["ExchangeID"]                = l_ExchangeID
              it_pos["YdStrikeFrozen"]            = l_YdStrikeFrozen
              it_pos["InvestUnitID"]              = l_InvestUnitID
              
          if found == False:
            l_position_list.append(l_pos)

        the_SQL  ="INSERT INTO T_InvestorPosition(InstrumentID,BrokerID,InvestorID,PosiDirection,HedgeFlag,PositionDate,YdPosition,Position,LongFrozen,ShortFrozen,LongFrozenAmount,ShortFrozenAmount,OpenVolume,CloseVolume,OpenAmount,CloseAmount,PositionCost,PreMargin,UseMargin,FrozenMargin,FrozenCash,FrozenCommission,CashIn,Commission,CloseProfit,PositionProfit,PreSettlementPrice,SettlementPrice,TradingDay,SettlementID,OpenCost,ExchangeMargin,CombPosition,CombLongFrozen,CombShortFrozen,CloseProfitByDate,CloseProfitByTrade,TodayPosition,MarginRateByMoney,MarginRateByVolume,StrikeFrozen,StrikeFrozenAmount,AbandonFrozen,ExchangeID,YdStrikeFrozen,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_BrokerID,l_InvestorID,l_PosiDirection,l_HedgeFlag,l_PositionDate,l_YdPosition,l_Position,l_LongFrozen,l_ShortFrozen,l_LongFrozenAmount,l_ShortFrozenAmount,l_OpenVolume,l_CloseVolume,l_OpenAmount,l_CloseAmount,l_PositionCost,l_PreMargin,l_UseMargin,l_FrozenMargin,l_FrozenCash,l_FrozenCommission,l_CashIn,l_Commission,l_CloseProfit,l_PositionProfit,l_PreSettlementPrice,l_SettlementPrice,l_TradingDay,l_SettlementID,l_OpenCost,l_ExchangeMargin,l_CombPosition,l_CombLongFrozen,l_CombShortFrozen,l_CloseProfitByDate,l_CloseProfitByTrade,l_TodayPosition,l_MarginRateByMoney,l_MarginRateByVolume,l_StrikeFrozen,l_StrikeFrozenAmount,l_AbandonFrozen,l_ExchangeID,l_YdStrikeFrozen,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pTradingAccount2DB(self, pTradingAccount):
        l_BrokerID=pTradingAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pTradingAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_PreMortgage=pTradingAccount.PreMortgage
        l_PreCredit=pTradingAccount.PreCredit
        l_PreDeposit=pTradingAccount.PreDeposit
        l_PreBalance=pTradingAccount.PreBalance
        l_PreMargin=pTradingAccount.PreMargin
        l_InterestBase=pTradingAccount.InterestBase
        l_Interest=pTradingAccount.Interest
        l_Deposit=pTradingAccount.Deposit
        l_Withdraw=pTradingAccount.Withdraw
        l_FrozenMargin=pTradingAccount.FrozenMargin
        l_FrozenCash=pTradingAccount.FrozenCash
        l_FrozenCommission=pTradingAccount.FrozenCommission
        l_CurrMargin=pTradingAccount.CurrMargin
        l_CashIn=pTradingAccount.CashIn
        l_Commission=pTradingAccount.Commission
        l_CloseProfit=pTradingAccount.CloseProfit
        l_PositionProfit=pTradingAccount.PositionProfit
        l_Balance=pTradingAccount.Balance
        l_Available=pTradingAccount.Available
        l_WithdrawQuota=pTradingAccount.WithdrawQuota
        l_Reserve=pTradingAccount.Reserve
        l_TradingDay=pTradingAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pTradingAccount.SettlementID
        l_Credit=pTradingAccount.Credit
        l_Mortgage=pTradingAccount.Mortgage
        l_ExchangeMargin=pTradingAccount.ExchangeMargin
        l_DeliveryMargin=pTradingAccount.DeliveryMargin
        l_ExchangeDeliveryMargin=pTradingAccount.ExchangeDeliveryMargin
        l_ReserveBalance=pTradingAccount.ReserveBalance
        l_CurrencyID=pTradingAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_PreFundMortgageIn=pTradingAccount.PreFundMortgageIn
        l_PreFundMortgageOut=pTradingAccount.PreFundMortgageOut
        l_FundMortgageIn=pTradingAccount.FundMortgageIn
        l_FundMortgageOut=pTradingAccount.FundMortgageOut
        l_FundMortgageAvailable=pTradingAccount.FundMortgageAvailable
        l_MortgageableFund=pTradingAccount.MortgageableFund
        l_SpecProductMargin=pTradingAccount.SpecProductMargin
        l_SpecProductFrozenMargin=pTradingAccount.SpecProductFrozenMargin
        l_SpecProductCommission=pTradingAccount.SpecProductCommission
        l_SpecProductFrozenCommission=pTradingAccount.SpecProductFrozenCommission
        l_SpecProductPositionProfit=pTradingAccount.SpecProductPositionProfit
        l_SpecProductCloseProfit=pTradingAccount.SpecProductCloseProfit
        l_SpecProductPositionProfitByAlg=pTradingAccount.SpecProductPositionProfitByAlg
        l_SpecProductExchangeMargin=pTradingAccount.SpecProductExchangeMargin
        l_BizType=pTradingAccount.BizType.decode(encoding="gb18030", errors="ignore");
        l_FrozenSwap=pTradingAccount.FrozenSwap
        l_RemainSwap=pTradingAccount.RemainSwap

        the_SQL  ="INSERT INTO T_TradingAccount(BrokerID,AccountID,PreMortgage,PreCredit,PreDeposit,PreBalance,PreMargin,InterestBase,Interest,Deposit,Withdraw,FrozenMargin,FrozenCash,FrozenCommission,CurrMargin,CashIn,Commission,CloseProfit,PositionProfit,Balance,Available,WithdrawQuota,Reserve,TradingDay,SettlementID,Credit,Mortgage,ExchangeMargin,DeliveryMargin,ExchangeDeliveryMargin,ReserveBalance,CurrencyID,PreFundMortgageIn,PreFundMortgageOut,FundMortgageIn,FundMortgageOut,FundMortgageAvailable,MortgageableFund,SpecProductMargin,SpecProductFrozenMargin,SpecProductCommission,SpecProductFrozenCommission,SpecProductPositionProfit,SpecProductCloseProfit,SpecProductPositionProfitByAlg,SpecProductExchangeMargin,BizType,FrozenSwap,RemainSwap)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_AccountID,l_PreMortgage,l_PreCredit,l_PreDeposit,l_PreBalance,l_PreMargin,l_InterestBase,l_Interest,l_Deposit,l_Withdraw,l_FrozenMargin,l_FrozenCash,l_FrozenCommission,l_CurrMargin,l_CashIn,l_Commission,l_CloseProfit,l_PositionProfit,l_Balance,l_Available,l_WithdrawQuota,l_Reserve,l_TradingDay,l_SettlementID,l_Credit,l_Mortgage,l_ExchangeMargin,l_DeliveryMargin,l_ExchangeDeliveryMargin,l_ReserveBalance,l_CurrencyID,l_PreFundMortgageIn,l_PreFundMortgageOut,l_FundMortgageIn,l_FundMortgageOut,l_FundMortgageAvailable,l_MortgageableFund,l_SpecProductMargin,l_SpecProductFrozenMargin,l_SpecProductCommission,l_SpecProductFrozenCommission,l_SpecProductPositionProfit,l_SpecProductCloseProfit,l_SpecProductPositionProfitByAlg,l_SpecProductExchangeMargin,l_BizType,l_FrozenSwap,l_RemainSwap)]
        self.SQL2DB(the_SQL,the_data)

    def  pInvestor2DB(self, pInvestor):
        l_InvestorID=pInvestor.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInvestor.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorGroupID=pInvestor.InvestorGroupID.decode(encoding="gb18030", errors="ignore");
        l_InvestorName=pInvestor.InvestorName.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardType=pInvestor.IdentifiedCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pInvestor.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_IsActive=pInvestor.IsActive
        l_Telephone=pInvestor.Telephone.decode(encoding="gb18030", errors="ignore");
        l_Address=pInvestor.Address.decode(encoding="gb18030", errors="ignore");
        l_OpenDate=pInvestor.OpenDate.decode(encoding="gb18030", errors="ignore");
        l_Mobile=pInvestor.Mobile.decode(encoding="gb18030", errors="ignore");
        l_CommModelID=pInvestor.CommModelID.decode(encoding="gb18030", errors="ignore");
        l_MarginModelID=pInvestor.MarginModelID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Investor(InvestorID,BrokerID,InvestorGroupID,InvestorName,IdentifiedCardType,IdentifiedCardNo,IsActive,Telephone,Address,OpenDate,Mobile,CommModelID,MarginModelID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InvestorID,l_BrokerID,l_InvestorGroupID,l_InvestorName,l_IdentifiedCardType,l_IdentifiedCardNo,l_IsActive,l_Telephone,l_Address,l_OpenDate,l_Mobile,l_CommModelID,l_MarginModelID)]
        self.SQL2DB(the_SQL,the_data)

    def  pTradingCode2DB(self, pTradingCode):
        l_InvestorID=pTradingCode.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pTradingCode.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pTradingCode.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pTradingCode.ClientID.decode(encoding="gb18030", errors="ignore");
        l_IsActive=pTradingCode.IsActive
        l_ClientIDType=pTradingCode.ClientIDType.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pTradingCode.BranchID.decode(encoding="gb18030", errors="ignore");
        l_BizType=pTradingCode.BizType.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pTradingCode.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_TradingCode(InvestorID,BrokerID,ExchangeID,ClientID,IsActive,ClientIDType,BranchID,BizType,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InvestorID,l_BrokerID,l_ExchangeID,l_ClientID,l_IsActive,l_ClientIDType,l_BranchID,l_BizType,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pInstrumentMarginRate2DB(self, pInstrumentMarginRate):
        l_InstrumentID=pInstrumentMarginRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pInstrumentMarginRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInstrumentMarginRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInstrumentMarginRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInstrumentMarginRate.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LongMarginRatioByMoney=pInstrumentMarginRate.LongMarginRatioByMoney
        l_LongMarginRatioByVolume=pInstrumentMarginRate.LongMarginRatioByVolume
        l_ShortMarginRatioByMoney=pInstrumentMarginRate.ShortMarginRatioByMoney
        l_ShortMarginRatioByVolume=pInstrumentMarginRate.ShortMarginRatioByVolume
        l_IsRelative=pInstrumentMarginRate.IsRelative
        l_ExchangeID=pInstrumentMarginRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInstrumentMarginRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InstrumentMarginRate(InstrumentID,InvestorRange,BrokerID,InvestorID,HedgeFlag,LongMarginRatioByMoney,LongMarginRatioByVolume,ShortMarginRatioByMoney,ShortMarginRatioByVolume,IsRelative,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_HedgeFlag,l_LongMarginRatioByMoney,l_LongMarginRatioByVolume,l_ShortMarginRatioByMoney,l_ShortMarginRatioByVolume,l_IsRelative,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pInstrumentCommissionRate2DB(self, pInstrumentCommissionRate):
        l_InstrumentID=pInstrumentCommissionRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pInstrumentCommissionRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInstrumentCommissionRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInstrumentCommissionRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OpenRatioByMoney=pInstrumentCommissionRate.OpenRatioByMoney
        l_OpenRatioByVolume=pInstrumentCommissionRate.OpenRatioByVolume
        l_CloseRatioByMoney=pInstrumentCommissionRate.CloseRatioByMoney
        l_CloseRatioByVolume=pInstrumentCommissionRate.CloseRatioByVolume
        l_CloseTodayRatioByMoney=pInstrumentCommissionRate.CloseTodayRatioByMoney
        l_CloseTodayRatioByVolume=pInstrumentCommissionRate.CloseTodayRatioByVolume
        l_ExchangeID=pInstrumentCommissionRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_BizType=pInstrumentCommissionRate.BizType.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInstrumentCommissionRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InstrumentCommissionRate(InstrumentID,InvestorRange,BrokerID,InvestorID,OpenRatioByMoney,OpenRatioByVolume,CloseRatioByMoney,CloseRatioByVolume,CloseTodayRatioByMoney,CloseTodayRatioByVolume,ExchangeID,BizType,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_OpenRatioByMoney,l_OpenRatioByVolume,l_CloseRatioByMoney,l_CloseRatioByVolume,l_CloseTodayRatioByMoney,l_CloseTodayRatioByVolume,l_ExchangeID,l_BizType,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pExchange2DB(self, pExchange):
        l_ExchangeID=pExchange.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeName=pExchange.ExchangeName.decode(encoding="gb18030", errors="ignore");
        l_ExchangeProperty=pExchange.ExchangeProperty.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Exchange(ExchangeID,ExchangeName,ExchangeProperty)VALUES(%s,%s,%s)"
        the_data =[( l_ExchangeID,l_ExchangeName,l_ExchangeProperty)]
        self.SQL2DB(the_SQL,the_data)

    def  pProduct2DB(self, pProduct):
        l_ProductID=pProduct.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ProductName=pProduct.ProductName.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pProduct.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ProductClass=pProduct.ProductClass.decode(encoding="gb18030", errors="ignore");
        l_VolumeMultiple=pProduct.VolumeMultiple
        l_PriceTick=pProduct.PriceTick
        l_MaxMarketOrderVolume=pProduct.MaxMarketOrderVolume
        l_MinMarketOrderVolume=pProduct.MinMarketOrderVolume
        l_MaxLimitOrderVolume=pProduct.MaxLimitOrderVolume
        l_MinLimitOrderVolume=pProduct.MinLimitOrderVolume
        l_PositionType=pProduct.PositionType.decode(encoding="gb18030", errors="ignore");
        l_PositionDateType=pProduct.PositionDateType.decode(encoding="gb18030", errors="ignore");
        l_CloseDealType=pProduct.CloseDealType.decode(encoding="gb18030", errors="ignore");
        l_TradeCurrencyID=pProduct.TradeCurrencyID.decode(encoding="gb18030", errors="ignore");
        l_MortgageFundUseRange=pProduct.MortgageFundUseRange.decode(encoding="gb18030", errors="ignore");
        l_ExchangeProductID=pProduct.ExchangeProductID.decode(encoding="gb18030", errors="ignore");
        l_UnderlyingMultiple=pProduct.UnderlyingMultiple

        the_SQL  ="INSERT INTO T_Product(ProductID,ProductName,ExchangeID,ProductClass,VolumeMultiple,PriceTick,MaxMarketOrderVolume,MinMarketOrderVolume,MaxLimitOrderVolume,MinLimitOrderVolume,PositionType,PositionDateType,CloseDealType,TradeCurrencyID,MortgageFundUseRange,ExchangeProductID,UnderlyingMultiple)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_ProductID,l_ProductName,l_ExchangeID,l_ProductClass,l_VolumeMultiple,l_PriceTick,l_MaxMarketOrderVolume,l_MinMarketOrderVolume,l_MaxLimitOrderVolume,l_MinLimitOrderVolume,l_PositionType,l_PositionDateType,l_CloseDealType,l_TradeCurrencyID,l_MortgageFundUseRange,l_ExchangeProductID,l_UnderlyingMultiple)]
        self.SQL2DB(the_SQL,the_data)




    def  pInstrument2DB(self, pInstrument):

        l_InstrumentID=pInstrument.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInstrument.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentName=pInstrument.InstrumentName.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pInstrument.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_ProductID=pInstrument.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ProductClass=pInstrument.ProductClass.decode(encoding="gb18030", errors="ignore");
        l_DeliveryYear=pInstrument.DeliveryYear
        l_DeliveryMonth=pInstrument.DeliveryMonth
        l_MaxMarketOrderVolume=pInstrument.MaxMarketOrderVolume
        l_MinMarketOrderVolume=pInstrument.MinMarketOrderVolume
        l_MaxLimitOrderVolume=pInstrument.MaxLimitOrderVolume
        l_MinLimitOrderVolume=pInstrument.MinLimitOrderVolume
        l_VolumeMultiple=pInstrument.VolumeMultiple
        l_PriceTick=pInstrument.PriceTick
        l_CreateDate=pInstrument.CreateDate.decode(encoding="gb18030", errors="ignore");
        l_OpenDate=pInstrument.OpenDate.decode(encoding="gb18030", errors="ignore");
        l_ExpireDate=pInstrument.ExpireDate.decode(encoding="gb18030", errors="ignore");
        l_StartDelivDate=pInstrument.StartDelivDate.decode(encoding="gb18030", errors="ignore");
        l_EndDelivDate=pInstrument.EndDelivDate.decode(encoding="gb18030", errors="ignore");
        l_InstLifePhase=pInstrument.InstLifePhase.decode(encoding="gb18030", errors="ignore");
        l_IsTrading=pInstrument.IsTrading
        l_PositionType=pInstrument.PositionType.decode(encoding="gb18030", errors="ignore");
        l_PositionDateType=pInstrument.PositionDateType.decode(encoding="gb18030", errors="ignore");
        l_LongMarginRatio=pInstrument.LongMarginRatio
        l_ShortMarginRatio=pInstrument.ShortMarginRatio
        l_MaxMarginSideAlgorithm=pInstrument.MaxMarginSideAlgorithm.decode(encoding="gb18030", errors="ignore");
        l_UnderlyingInstrID=pInstrument.UnderlyingInstrID.decode(encoding="gb18030", errors="ignore");
        l_StrikePrice=pInstrument.StrikePrice
        l_OptionsType=pInstrument.OptionsType.decode(encoding="gb18030", errors="ignore");
        l_UnderlyingMultiple=pInstrument.UnderlyingMultiple
        l_CombinationType=pInstrument.CombinationType.decode(encoding="gb18030", errors="ignore");

        InstrumentAttr={}
        InstrumentAttr = self.__instrument_attr_dict.get(l_InstrumentID)
        if InstrumentAttr is None:
          InstrumentAttr = self.InitFactor()
            
        #InstrumentAttr["InstrumentID"]              = l_InstrumentID
        InstrumentAttr["ExchangeID"]                = l_ExchangeID
        InstrumentAttr["InstrumentName"]            = l_InstrumentName
        InstrumentAttr["ExchangeInstID"]            = l_ExchangeInstID
        InstrumentAttr["ProductID"]                 = l_ProductID
        InstrumentAttr["ProductClass"]              = l_ProductClass
        InstrumentAttr["DeliveryYear"]              = l_DeliveryYear
        InstrumentAttr["DeliveryMonth"]             = l_DeliveryMonth
        InstrumentAttr["MaxMarketOrderVolume"]      = l_MaxMarketOrderVolume
        InstrumentAttr["MinMarketOrderVolume"]      = l_MinMarketOrderVolume
        InstrumentAttr["MaxLimitOrderVolume"]       = l_MaxLimitOrderVolume
        InstrumentAttr["MinLimitOrderVolume"]       = l_MinLimitOrderVolume
        InstrumentAttr["VolumeMultiple"]            = l_VolumeMultiple
        InstrumentAttr["PriceTick"]                 = l_PriceTick
        InstrumentAttr["CreateDate"]                = l_CreateDate
        InstrumentAttr["OpenDate"]                  = l_OpenDate
        InstrumentAttr["ExpireDate"]                = l_ExpireDate
        InstrumentAttr["StartDelivDate"]            = l_StartDelivDate
        InstrumentAttr["EndDelivDate"]              = l_EndDelivDate
        InstrumentAttr["InstLifePhase"]             = l_InstLifePhase
        InstrumentAttr["IsTrading"]                 = l_IsTrading
        InstrumentAttr["PositionType"]              = l_PositionType
        InstrumentAttr["PositionDateType"]          = l_PositionDateType
        InstrumentAttr["LongMarginRatio"]           = l_LongMarginRatio
        InstrumentAttr["ShortMarginRatio"]          = l_ShortMarginRatio
        InstrumentAttr["MaxMarginSideAlgorithm"]    = l_MaxMarginSideAlgorithm
        InstrumentAttr["UnderlyingInstrID"]         = l_UnderlyingInstrID
        InstrumentAttr["StrikePrice"]               = l_StrikePrice
        InstrumentAttr["OptionsType"]               = l_OptionsType
        InstrumentAttr["UnderlyingMultiple"]        = l_UnderlyingMultiple
        InstrumentAttr["CombinationType"]           = l_CombinationType
        self.__instrument_attr_dict[l_InstrumentID] = InstrumentAttr


        the_SQL  ="INSERT INTO T_Instrument(InstrumentID,ExchangeID,InstrumentName,ExchangeInstID,ProductID,ProductClass,DeliveryYear,DeliveryMonth,MaxMarketOrderVolume,MinMarketOrderVolume,MaxLimitOrderVolume,MinLimitOrderVolume,VolumeMultiple,PriceTick,CreateDate,OpenDate,ExpireDate,StartDelivDate,EndDelivDate,InstLifePhase,IsTrading,PositionType,PositionDateType,LongMarginRatio,ShortMarginRatio,MaxMarginSideAlgorithm,UnderlyingInstrID,StrikePrice,OptionsType,UnderlyingMultiple,CombinationType)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_ExchangeID,l_InstrumentName,l_ExchangeInstID,l_ProductID,l_ProductClass,l_DeliveryYear,l_DeliveryMonth,l_MaxMarketOrderVolume,l_MinMarketOrderVolume,l_MaxLimitOrderVolume,l_MinLimitOrderVolume,l_VolumeMultiple,l_PriceTick,l_CreateDate,l_OpenDate,l_ExpireDate,l_StartDelivDate,l_EndDelivDate,l_InstLifePhase,l_IsTrading,l_PositionType,l_PositionDateType,l_LongMarginRatio,l_ShortMarginRatio,l_MaxMarginSideAlgorithm,l_UnderlyingInstrID,l_StrikePrice,l_OptionsType,l_UnderlyingMultiple,l_CombinationType)]
        self.SQL2DB(the_SQL,the_data)

    def  pDepthMarketData2DB(self, pDepthMarketData):
        l_TradingDay=pDepthMarketData.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pDepthMarketData.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pDepthMarketData.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pDepthMarketData.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_LastPrice=pDepthMarketData.LastPrice
        l_PreSettlementPrice=pDepthMarketData.PreSettlementPrice
        l_PreClosePrice=pDepthMarketData.PreClosePrice
        l_PreOpenInterest=pDepthMarketData.PreOpenInterest
        l_OpenPrice=pDepthMarketData.OpenPrice
        l_HighestPrice=pDepthMarketData.HighestPrice
        l_LowestPrice=pDepthMarketData.LowestPrice
        l_Volume=pDepthMarketData.Volume
        l_Turnover=pDepthMarketData.Turnover
        l_OpenInterest=pDepthMarketData.OpenInterest
        l_ClosePrice=pDepthMarketData.ClosePrice
        l_SettlementPrice=pDepthMarketData.SettlementPrice
        l_UpperLimitPrice=pDepthMarketData.UpperLimitPrice
        l_LowerLimitPrice=pDepthMarketData.LowerLimitPrice
        l_PreDelta=pDepthMarketData.PreDelta
        l_CurrDelta=pDepthMarketData.CurrDelta
        l_UpdateTime=pDepthMarketData.UpdateTime.decode(encoding="gb18030", errors="ignore");
        l_UpdateMillisec=pDepthMarketData.UpdateMillisec
        l_BidPrice1=pDepthMarketData.BidPrice1
        l_BidVolume1=pDepthMarketData.BidVolume1
        l_AskPrice1=pDepthMarketData.AskPrice1
        l_AskVolume1=pDepthMarketData.AskVolume1
        l_BidPrice2=pDepthMarketData.BidPrice2
        l_BidVolume2=pDepthMarketData.BidVolume2
        l_AskPrice2=pDepthMarketData.AskPrice2
        l_AskVolume2=pDepthMarketData.AskVolume2
        l_BidPrice3=pDepthMarketData.BidPrice3
        l_BidVolume3=pDepthMarketData.BidVolume3
        l_AskPrice3=pDepthMarketData.AskPrice3
        l_AskVolume3=pDepthMarketData.AskVolume3
        l_BidPrice4=pDepthMarketData.BidPrice4
        l_BidVolume4=pDepthMarketData.BidVolume4
        l_AskPrice4=pDepthMarketData.AskPrice4
        l_AskVolume4=pDepthMarketData.AskVolume4
        l_BidPrice5=pDepthMarketData.BidPrice5
        l_BidVolume5=pDepthMarketData.BidVolume5
        l_AskPrice5=pDepthMarketData.AskPrice5
        l_AskVolume5=pDepthMarketData.AskVolume5
        l_AveragePrice=pDepthMarketData.AveragePrice
        l_ActionDay=pDepthMarketData.ActionDay.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_DepthMarketData(TradingDay,InstrumentID,ExchangeID,ExchangeInstID,LastPrice,PreSettlementPrice,PreClosePrice,PreOpenInterest,OpenPrice,HighestPrice,LowestPrice,Volume,Turnover,OpenInterest,ClosePrice,SettlementPrice,UpperLimitPrice,LowerLimitPrice,PreDelta,CurrDelta,UpdateTime,UpdateMillisec,BidPrice1,BidVolume1,AskPrice1,AskVolume1,BidPrice2,BidVolume2,AskPrice2,AskVolume2,BidPrice3,BidVolume3,AskPrice3,AskVolume3,BidPrice4,BidVolume4,AskPrice4,AskVolume4,BidPrice5,BidVolume5,AskPrice5,AskVolume5,AveragePrice,ActionDay)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_InstrumentID,l_ExchangeID,l_ExchangeInstID,l_LastPrice,l_PreSettlementPrice,l_PreClosePrice,l_PreOpenInterest,l_OpenPrice,l_HighestPrice,l_LowestPrice,l_Volume,l_Turnover,l_OpenInterest,l_ClosePrice,l_SettlementPrice,l_UpperLimitPrice,l_LowerLimitPrice,l_PreDelta,l_CurrDelta,l_UpdateTime,l_UpdateMillisec,l_BidPrice1,l_BidVolume1,l_AskPrice1,l_AskVolume1,l_BidPrice2,l_BidVolume2,l_AskPrice2,l_AskVolume2,l_BidPrice3,l_BidVolume3,l_AskPrice3,l_AskVolume3,l_BidPrice4,l_BidVolume4,l_AskPrice4,l_AskVolume4,l_BidPrice5,l_BidVolume5,l_AskPrice5,l_AskVolume5,l_AveragePrice,l_ActionDay)]
        self.SQL2DB(the_SQL,the_data)

    def  pSettlementInfo2DB(self, pSettlementInfo):

        l_TradingDay=pSettlementInfo.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pSettlementInfo.SettlementID
        l_BrokerID=pSettlementInfo.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pSettlementInfo.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pSettlementInfo.SequenceNo
        l_Content=pSettlementInfo.Content.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pSettlementInfo.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pSettlementInfo.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_SettlementInfo(TradingDay,SettlementID,BrokerID,InvestorID,SequenceNo,Content,AccountID,CurrencyID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_SettlementID,l_BrokerID,l_InvestorID,l_SequenceNo,l_Content,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pTransferBank2DB(self, pTransferBank):
        l_BankID=pTransferBank.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBrchID=pTransferBank.BankBrchID.decode(encoding="gb18030", errors="ignore");
        l_BankName=pTransferBank.BankName.decode(encoding="gb18030", errors="ignore");
        l_IsActive=pTransferBank.IsActive

        the_SQL  ="INSERT INTO T_TransferBank(BankID,BankBrchID,BankName,IsActive)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BankID,l_BankBrchID,l_BankName,l_IsActive)]
        self.SQL2DB(the_SQL,the_data)

    def  pInvestorPositionDetail2DB(self, pInvestorPositionDetail):
        l_InstrumentID=pInvestorPositionDetail.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInvestorPositionDetail.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInvestorPositionDetail.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInvestorPositionDetail.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_Direction=pInvestorPositionDetail.Direction.decode(encoding="gb18030", errors="ignore");
        l_OpenDate=pInvestorPositionDetail.OpenDate.decode(encoding="gb18030", errors="ignore");
        l_TradeID=pInvestorPositionDetail.TradeID.decode(encoding="gb18030", errors="ignore");
        l_Volume=pInvestorPositionDetail.Volume
        l_OpenPrice=pInvestorPositionDetail.OpenPrice
        l_TradingDay=pInvestorPositionDetail.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pInvestorPositionDetail.SettlementID
        l_TradeType=pInvestorPositionDetail.TradeType.decode(encoding="gb18030", errors="ignore");
        l_CombInstrumentID=pInvestorPositionDetail.CombInstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInvestorPositionDetail.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_CloseProfitByDate=pInvestorPositionDetail.CloseProfitByDate
        l_CloseProfitByTrade=pInvestorPositionDetail.CloseProfitByTrade
        l_PositionProfitByDate=pInvestorPositionDetail.PositionProfitByDate
        l_PositionProfitByTrade=pInvestorPositionDetail.PositionProfitByTrade
        l_Margin=pInvestorPositionDetail.Margin
        l_ExchMargin=pInvestorPositionDetail.ExchMargin
        l_MarginRateByMoney=pInvestorPositionDetail.MarginRateByMoney
        l_MarginRateByVolume=pInvestorPositionDetail.MarginRateByVolume
        l_LastSettlementPrice=pInvestorPositionDetail.LastSettlementPrice
        l_SettlementPrice=pInvestorPositionDetail.SettlementPrice
        l_CloseVolume=pInvestorPositionDetail.CloseVolume
        l_CloseAmount=pInvestorPositionDetail.CloseAmount
        l_InvestUnitID=pInvestorPositionDetail.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InvestorPositionDetail(InstrumentID,BrokerID,InvestorID,HedgeFlag,Direction,OpenDate,TradeID,Volume,OpenPrice,TradingDay,SettlementID,TradeType,CombInstrumentID,ExchangeID,CloseProfitByDate,CloseProfitByTrade,PositionProfitByDate,PositionProfitByTrade,Margin,ExchMargin,MarginRateByMoney,MarginRateByVolume,LastSettlementPrice,SettlementPrice,CloseVolume,CloseAmount,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_BrokerID,l_InvestorID,l_HedgeFlag,l_Direction,l_OpenDate,l_TradeID,l_Volume,l_OpenPrice,l_TradingDay,l_SettlementID,l_TradeType,l_CombInstrumentID,l_ExchangeID,l_CloseProfitByDate,l_CloseProfitByTrade,l_PositionProfitByDate,l_PositionProfitByTrade,l_Margin,l_ExchMargin,l_MarginRateByMoney,l_MarginRateByVolume,l_LastSettlementPrice,l_SettlementPrice,l_CloseVolume,l_CloseAmount,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pNotice2DB(self, pNotice):
        l_BrokerID=pNotice.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_Content=pNotice.Content.decode(encoding="gb18030", errors="ignore");
        l_SequenceLabel=pNotice.SequenceLabel.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Notice(BrokerID,Content,SequenceLabel)VALUES(%s,%s,%s)"
        the_data =[( l_BrokerID,l_Content,l_SequenceLabel)]
        self.SQL2DB(the_SQL,the_data)

    def  pInvestorPositionCombineDetail2DB(self, pInvestorPositionCombineDetail):
        l_TradingDay=pInvestorPositionCombineDetail.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_OpenDate=pInvestorPositionCombineDetail.OpenDate.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInvestorPositionCombineDetail.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pInvestorPositionCombineDetail.SettlementID
        l_BrokerID=pInvestorPositionCombineDetail.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInvestorPositionCombineDetail.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ComTradeID=pInvestorPositionCombineDetail.ComTradeID.decode(encoding="gb18030", errors="ignore");
        l_TradeID=pInvestorPositionCombineDetail.TradeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInvestorPositionCombineDetail.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInvestorPositionCombineDetail.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_Direction=pInvestorPositionCombineDetail.Direction.decode(encoding="gb18030", errors="ignore");
        l_TotalAmt=pInvestorPositionCombineDetail.TotalAmt
        l_Margin=pInvestorPositionCombineDetail.Margin
        l_ExchMargin=pInvestorPositionCombineDetail.ExchMargin
        l_MarginRateByMoney=pInvestorPositionCombineDetail.MarginRateByMoney
        l_MarginRateByVolume=pInvestorPositionCombineDetail.MarginRateByVolume
        l_LegID=pInvestorPositionCombineDetail.LegID
        l_LegMultiple=pInvestorPositionCombineDetail.LegMultiple
        l_CombInstrumentID=pInvestorPositionCombineDetail.CombInstrumentID.decode(encoding="gb18030", errors="ignore");
        l_TradeGroupID=pInvestorPositionCombineDetail.TradeGroupID
        l_InvestUnitID=pInvestorPositionCombineDetail.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InvestorPositionCombineDetail(TradingDay,OpenDate,ExchangeID,SettlementID,BrokerID,InvestorID,ComTradeID,TradeID,InstrumentID,HedgeFlag,Direction,TotalAmt,Margin,ExchMargin,MarginRateByMoney,MarginRateByVolume,LegID,LegMultiple,CombInstrumentID,TradeGroupID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_OpenDate,l_ExchangeID,l_SettlementID,l_BrokerID,l_InvestorID,l_ComTradeID,l_TradeID,l_InstrumentID,l_HedgeFlag,l_Direction,l_TotalAmt,l_Margin,l_ExchMargin,l_MarginRateByMoney,l_MarginRateByVolume,l_LegID,l_LegMultiple,l_CombInstrumentID,l_TradeGroupID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pCFMMCTradingAccountKey2DB(self, pCFMMCTradingAccountKey):
        l_BrokerID=pCFMMCTradingAccountKey.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pCFMMCTradingAccountKey.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pCFMMCTradingAccountKey.AccountID.decode(encoding="gb18030", errors="ignore");
        l_KeyID=pCFMMCTradingAccountKey.KeyID
        l_CurrentKey=pCFMMCTradingAccountKey.CurrentKey.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_CFMMCTradingAccountKey(BrokerID,ParticipantID,AccountID,KeyID,CurrentKey)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_ParticipantID,l_AccountID,l_KeyID,l_CurrentKey)]
        self.SQL2DB(the_SQL,the_data)

    def  pEWarrantOffset2DB(self, pEWarrantOffset):
        l_TradingDay=pEWarrantOffset.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pEWarrantOffset.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pEWarrantOffset.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pEWarrantOffset.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pEWarrantOffset.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_Direction=pEWarrantOffset.Direction.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pEWarrantOffset.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_Volume=pEWarrantOffset.Volume
        l_InvestUnitID=pEWarrantOffset.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_EWarrantOffset(TradingDay,BrokerID,InvestorID,ExchangeID,InstrumentID,Direction,HedgeFlag,Volume,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_BrokerID,l_InvestorID,l_ExchangeID,l_InstrumentID,l_Direction,l_HedgeFlag,l_Volume,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pInvestorProductGroupMargin2DB(self, pInvestorProductGroupMargin):
        l_ProductGroupID=pInvestorProductGroupMargin.ProductGroupID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInvestorProductGroupMargin.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInvestorProductGroupMargin.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pInvestorProductGroupMargin.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pInvestorProductGroupMargin.SettlementID
        l_FrozenMargin=pInvestorProductGroupMargin.FrozenMargin
        l_LongFrozenMargin=pInvestorProductGroupMargin.LongFrozenMargin
        l_ShortFrozenMargin=pInvestorProductGroupMargin.ShortFrozenMargin
        l_UseMargin=pInvestorProductGroupMargin.UseMargin
        l_LongUseMargin=pInvestorProductGroupMargin.LongUseMargin
        l_ShortUseMargin=pInvestorProductGroupMargin.ShortUseMargin
        l_ExchMargin=pInvestorProductGroupMargin.ExchMargin
        l_LongExchMargin=pInvestorProductGroupMargin.LongExchMargin
        l_ShortExchMargin=pInvestorProductGroupMargin.ShortExchMargin
        l_CloseProfit=pInvestorProductGroupMargin.CloseProfit
        l_FrozenCommission=pInvestorProductGroupMargin.FrozenCommission
        l_Commission=pInvestorProductGroupMargin.Commission
        l_FrozenCash=pInvestorProductGroupMargin.FrozenCash
        l_CashIn=pInvestorProductGroupMargin.CashIn
        l_PositionProfit=pInvestorProductGroupMargin.PositionProfit
        l_OffsetAmount=pInvestorProductGroupMargin.OffsetAmount
        l_LongOffsetAmount=pInvestorProductGroupMargin.LongOffsetAmount
        l_ShortOffsetAmount=pInvestorProductGroupMargin.ShortOffsetAmount
        l_ExchOffsetAmount=pInvestorProductGroupMargin.ExchOffsetAmount
        l_LongExchOffsetAmount=pInvestorProductGroupMargin.LongExchOffsetAmount
        l_ShortExchOffsetAmount=pInvestorProductGroupMargin.ShortExchOffsetAmount
        l_HedgeFlag=pInvestorProductGroupMargin.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pInvestorProductGroupMargin.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInvestorProductGroupMargin.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InvestorProductGroupMargin(ProductGroupID,BrokerID,InvestorID,TradingDay,SettlementID,FrozenMargin,LongFrozenMargin,ShortFrozenMargin,UseMargin,LongUseMargin,ShortUseMargin,ExchMargin,LongExchMargin,ShortExchMargin,CloseProfit,FrozenCommission,Commission,FrozenCash,CashIn,PositionProfit,OffsetAmount,LongOffsetAmount,ShortOffsetAmount,ExchOffsetAmount,LongExchOffsetAmount,ShortExchOffsetAmount,HedgeFlag,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_ProductGroupID,l_BrokerID,l_InvestorID,l_TradingDay,l_SettlementID,l_FrozenMargin,l_LongFrozenMargin,l_ShortFrozenMargin,l_UseMargin,l_LongUseMargin,l_ShortUseMargin,l_ExchMargin,l_LongExchMargin,l_ShortExchMargin,l_CloseProfit,l_FrozenCommission,l_Commission,l_FrozenCash,l_CashIn,l_PositionProfit,l_OffsetAmount,l_LongOffsetAmount,l_ShortOffsetAmount,l_ExchOffsetAmount,l_LongExchOffsetAmount,l_ShortExchOffsetAmount,l_HedgeFlag,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pExchangeMarginRate2DB(self, pExchangeMarginRate):
        l_BrokerID=pExchangeMarginRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pExchangeMarginRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pExchangeMarginRate.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LongMarginRatioByMoney=pExchangeMarginRate.LongMarginRatioByMoney
        l_LongMarginRatioByVolume=pExchangeMarginRate.LongMarginRatioByVolume
        l_ShortMarginRatioByMoney=pExchangeMarginRate.ShortMarginRatioByMoney
        l_ShortMarginRatioByVolume=pExchangeMarginRate.ShortMarginRatioByVolume
        l_ExchangeID=pExchangeMarginRate.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ExchangeMarginRate(BrokerID,InstrumentID,HedgeFlag,LongMarginRatioByMoney,LongMarginRatioByVolume,ShortMarginRatioByMoney,ShortMarginRatioByVolume,ExchangeID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_HedgeFlag,l_LongMarginRatioByMoney,l_LongMarginRatioByVolume,l_ShortMarginRatioByMoney,l_ShortMarginRatioByVolume,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pExchangeMarginRateAdjust2DB(self, pExchangeMarginRateAdjust):
        l_BrokerID=pExchangeMarginRateAdjust.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pExchangeMarginRateAdjust.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pExchangeMarginRateAdjust.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LongMarginRatioByMoney=pExchangeMarginRateAdjust.LongMarginRatioByMoney
        l_LongMarginRatioByVolume=pExchangeMarginRateAdjust.LongMarginRatioByVolume
        l_ShortMarginRatioByMoney=pExchangeMarginRateAdjust.ShortMarginRatioByMoney
        l_ShortMarginRatioByVolume=pExchangeMarginRateAdjust.ShortMarginRatioByVolume
        l_ExchLongMarginRatioByMoney=pExchangeMarginRateAdjust.ExchLongMarginRatioByMoney
        l_ExchLongMarginRatioByVolume=pExchangeMarginRateAdjust.ExchLongMarginRatioByVolume
        l_ExchShortMarginRatioByMoney=pExchangeMarginRateAdjust.ExchShortMarginRatioByMoney
        l_ExchShortMarginRatioByVolume=pExchangeMarginRateAdjust.ExchShortMarginRatioByVolume
        l_NoLongMarginRatioByMoney=pExchangeMarginRateAdjust.NoLongMarginRatioByMoney
        l_NoLongMarginRatioByVolume=pExchangeMarginRateAdjust.NoLongMarginRatioByVolume
        l_NoShortMarginRatioByMoney=pExchangeMarginRateAdjust.NoShortMarginRatioByMoney
        l_NoShortMarginRatioByVolume=pExchangeMarginRateAdjust.NoShortMarginRatioByVolume

        the_SQL  ="INSERT INTO T_ExchangeMarginRateAdjust(BrokerID,InstrumentID,HedgeFlag,LongMarginRatioByMoney,LongMarginRatioByVolume,ShortMarginRatioByMoney,ShortMarginRatioByVolume,ExchLongMarginRatioByMoney,ExchLongMarginRatioByVolume,ExchShortMarginRatioByMoney,ExchShortMarginRatioByVolume,NoLongMarginRatioByMoney,NoLongMarginRatioByVolume,NoShortMarginRatioByMoney,NoShortMarginRatioByVolume)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_HedgeFlag,l_LongMarginRatioByMoney,l_LongMarginRatioByVolume,l_ShortMarginRatioByMoney,l_ShortMarginRatioByVolume,l_ExchLongMarginRatioByMoney,l_ExchLongMarginRatioByVolume,l_ExchShortMarginRatioByMoney,l_ExchShortMarginRatioByVolume,l_NoLongMarginRatioByMoney,l_NoLongMarginRatioByVolume,l_NoShortMarginRatioByMoney,l_NoShortMarginRatioByVolume)]
        self.SQL2DB(the_SQL,the_data)

    def  pExchangeRate2DB(self, pExchangeRate):
        l_BrokerID=pExchangeRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_FromCurrencyID=pExchangeRate.FromCurrencyID.decode(encoding="gb18030", errors="ignore");
        l_FromCurrencyUnit=pExchangeRate.FromCurrencyUnit
        l_ToCurrencyID=pExchangeRate.ToCurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeRate=pExchangeRate.ExchangeRate

        the_SQL  ="INSERT INTO T_ExchangeRate(BrokerID,FromCurrencyID,FromCurrencyUnit,ToCurrencyID,ExchangeRate)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_FromCurrencyID,l_FromCurrencyUnit,l_ToCurrencyID,l_ExchangeRate)]
        self.SQL2DB(the_SQL,the_data)

    def  pSecAgentACIDMap2DB(self, pSecAgentACIDMap):
        l_BrokerID=pSecAgentACIDMap.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_UserID=pSecAgentACIDMap.UserID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pSecAgentACIDMap.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pSecAgentACIDMap.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_BrokerSecAgentID=pSecAgentACIDMap.BrokerSecAgentID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_SecAgentACIDMap(BrokerID,UserID,AccountID,CurrencyID,BrokerSecAgentID)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_UserID,l_AccountID,l_CurrencyID,l_BrokerSecAgentID)]
        self.SQL2DB(the_SQL,the_data)

    def  pProductExchRate2DB(self, pProductExchRate):
        l_ProductID=pProductExchRate.ProductID.decode(encoding="gb18030", errors="ignore");
        l_QuoteCurrencyID=pProductExchRate.QuoteCurrencyID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeRate=pProductExchRate.ExchangeRate
        l_ExchangeID=pProductExchRate.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ProductExchRate(ProductID,QuoteCurrencyID,ExchangeRate,ExchangeID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_ProductID,l_QuoteCurrencyID,l_ExchangeRate,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pProductGroup2DB(self, pProductGroup):
        l_ProductID=pProductGroup.ProductID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pProductGroup.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ProductGroupID=pProductGroup.ProductGroupID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ProductGroup(ProductID,ExchangeID,ProductGroupID)VALUES(%s,%s,%s)"
        the_data =[( l_ProductID,l_ExchangeID,l_ProductGroupID)]
        self.SQL2DB(the_SQL,the_data)

    def  pMMInstrumentCommissionRate2DB(self, pMMInstrumentCommissionRate):
        l_InstrumentID=pMMInstrumentCommissionRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pMMInstrumentCommissionRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pMMInstrumentCommissionRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pMMInstrumentCommissionRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OpenRatioByMoney=pMMInstrumentCommissionRate.OpenRatioByMoney
        l_OpenRatioByVolume=pMMInstrumentCommissionRate.OpenRatioByVolume
        l_CloseRatioByMoney=pMMInstrumentCommissionRate.CloseRatioByMoney
        l_CloseRatioByVolume=pMMInstrumentCommissionRate.CloseRatioByVolume
        l_CloseTodayRatioByMoney=pMMInstrumentCommissionRate.CloseTodayRatioByMoney
        l_CloseTodayRatioByVolume=pMMInstrumentCommissionRate.CloseTodayRatioByVolume

        the_SQL  ="INSERT INTO T_MMInstrumentCommissionRate(InstrumentID,InvestorRange,BrokerID,InvestorID,OpenRatioByMoney,OpenRatioByVolume,CloseRatioByMoney,CloseRatioByVolume,CloseTodayRatioByMoney,CloseTodayRatioByVolume)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_OpenRatioByMoney,l_OpenRatioByVolume,l_CloseRatioByMoney,l_CloseRatioByVolume,l_CloseTodayRatioByMoney,l_CloseTodayRatioByVolume)]
        self.SQL2DB(the_SQL,the_data)

    def  pMMOptionInstrCommRate2DB(self, pMMOptionInstrCommRate):
        l_InstrumentID=pMMOptionInstrCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pMMOptionInstrCommRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pMMOptionInstrCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pMMOptionInstrCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OpenRatioByMoney=pMMOptionInstrCommRate.OpenRatioByMoney
        l_OpenRatioByVolume=pMMOptionInstrCommRate.OpenRatioByVolume
        l_CloseRatioByMoney=pMMOptionInstrCommRate.CloseRatioByMoney
        l_CloseRatioByVolume=pMMOptionInstrCommRate.CloseRatioByVolume
        l_CloseTodayRatioByMoney=pMMOptionInstrCommRate.CloseTodayRatioByMoney
        l_CloseTodayRatioByVolume=pMMOptionInstrCommRate.CloseTodayRatioByVolume
        l_StrikeRatioByMoney=pMMOptionInstrCommRate.StrikeRatioByMoney
        l_StrikeRatioByVolume=pMMOptionInstrCommRate.StrikeRatioByVolume

        the_SQL  ="INSERT INTO T_MMOptionInstrCommRate(InstrumentID,InvestorRange,BrokerID,InvestorID,OpenRatioByMoney,OpenRatioByVolume,CloseRatioByMoney,CloseRatioByVolume,CloseTodayRatioByMoney,CloseTodayRatioByVolume,StrikeRatioByMoney,StrikeRatioByVolume)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_OpenRatioByMoney,l_OpenRatioByVolume,l_CloseRatioByMoney,l_CloseRatioByVolume,l_CloseTodayRatioByMoney,l_CloseTodayRatioByVolume,l_StrikeRatioByMoney,l_StrikeRatioByVolume)]
        self.SQL2DB(the_SQL,the_data)

    def  pInstrumentOrderCommRate2DB(self, pInstrumentOrderCommRate):
        l_InstrumentID=pInstrumentOrderCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pInstrumentOrderCommRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pInstrumentOrderCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInstrumentOrderCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pInstrumentOrderCommRate.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_OrderCommByVolume=pInstrumentOrderCommRate.OrderCommByVolume
        l_OrderActionCommByVolume=pInstrumentOrderCommRate.OrderActionCommByVolume
        l_ExchangeID=pInstrumentOrderCommRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInstrumentOrderCommRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InstrumentOrderCommRate(InstrumentID,InvestorRange,BrokerID,InvestorID,HedgeFlag,OrderCommByVolume,OrderActionCommByVolume,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_HedgeFlag,l_OrderCommByVolume,l_OrderActionCommByVolume,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pSecAgentCheckMode2DB(self, pSecAgentCheckMode):
        l_InvestorID=pSecAgentCheckMode.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pSecAgentCheckMode.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pSecAgentCheckMode.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_BrokerSecAgentID=pSecAgentCheckMode.BrokerSecAgentID.decode(encoding="gb18030", errors="ignore");
        l_CheckSelfAccount=pSecAgentCheckMode.CheckSelfAccount

        the_SQL  ="INSERT INTO T_SecAgentCheckMode(InvestorID,BrokerID,CurrencyID,BrokerSecAgentID,CheckSelfAccount)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_InvestorID,l_BrokerID,l_CurrencyID,l_BrokerSecAgentID,l_CheckSelfAccount)]
        self.SQL2DB(the_SQL,the_data)

    def  pOptionInstrTradeCost2DB(self, pOptionInstrTradeCost):
        l_BrokerID=pOptionInstrTradeCost.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOptionInstrTradeCost.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pOptionInstrTradeCost.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pOptionInstrTradeCost.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_FixedMargin=pOptionInstrTradeCost.FixedMargin
        l_MiniMargin=pOptionInstrTradeCost.MiniMargin
        l_Royalty=pOptionInstrTradeCost.Royalty
        l_ExchFixedMargin=pOptionInstrTradeCost.ExchFixedMargin
        l_ExchMiniMargin=pOptionInstrTradeCost.ExchMiniMargin
        l_ExchangeID=pOptionInstrTradeCost.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOptionInstrTradeCost.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OptionInstrTradeCost(BrokerID,InvestorID,InstrumentID,HedgeFlag,FixedMargin,MiniMargin,Royalty,ExchFixedMargin,ExchMiniMargin,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_HedgeFlag,l_FixedMargin,l_MiniMargin,l_Royalty,l_ExchFixedMargin,l_ExchMiniMargin,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pOptionInstrCommRate2DB(self, pOptionInstrCommRate):
        l_InstrumentID=pOptionInstrCommRate.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pOptionInstrCommRate.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pOptionInstrCommRate.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOptionInstrCommRate.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OpenRatioByMoney=pOptionInstrCommRate.OpenRatioByMoney
        l_OpenRatioByVolume=pOptionInstrCommRate.OpenRatioByVolume
        l_CloseRatioByMoney=pOptionInstrCommRate.CloseRatioByMoney
        l_CloseRatioByVolume=pOptionInstrCommRate.CloseRatioByVolume
        l_CloseTodayRatioByMoney=pOptionInstrCommRate.CloseTodayRatioByMoney
        l_CloseTodayRatioByVolume=pOptionInstrCommRate.CloseTodayRatioByVolume
        l_StrikeRatioByMoney=pOptionInstrCommRate.StrikeRatioByMoney
        l_StrikeRatioByVolume=pOptionInstrCommRate.StrikeRatioByVolume
        l_ExchangeID=pOptionInstrCommRate.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOptionInstrCommRate.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OptionInstrCommRate(InstrumentID,InvestorRange,BrokerID,InvestorID,OpenRatioByMoney,OpenRatioByVolume,CloseRatioByMoney,CloseRatioByVolume,CloseTodayRatioByMoney,CloseTodayRatioByVolume,StrikeRatioByMoney,StrikeRatioByVolume,ExchangeID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_InstrumentID,l_InvestorRange,l_BrokerID,l_InvestorID,l_OpenRatioByMoney,l_OpenRatioByVolume,l_CloseRatioByMoney,l_CloseRatioByVolume,l_CloseTodayRatioByMoney,l_CloseTodayRatioByVolume,l_StrikeRatioByMoney,l_StrikeRatioByVolume,l_ExchangeID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pExecOrder2DB(self, pExecOrder):
        l_BrokerID=pExecOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pExecOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pExecOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderRef=pExecOrder.ExecOrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pExecOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_Volume=pExecOrder.Volume
        l_RequestID=pExecOrder.RequestID
        l_BusinessUnit=pExecOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OffsetFlag=pExecOrder.OffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pExecOrder.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionType=pExecOrder.ActionType.decode(encoding="gb18030", errors="ignore");
        l_PosiDirection=pExecOrder.PosiDirection.decode(encoding="gb18030", errors="ignore");
        l_ReservePositionFlag=pExecOrder.ReservePositionFlag.decode(encoding="gb18030", errors="ignore");
        l_CloseFlag=pExecOrder.CloseFlag.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderLocalID=pExecOrder.ExecOrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pExecOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pExecOrder.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pExecOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pExecOrder.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pExecOrder.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pExecOrder.InstallID
        l_OrderSubmitStatus=pExecOrder.OrderSubmitStatus.decode(encoding="gb18030", errors="ignore");
        l_NotifySequence=pExecOrder.NotifySequence
        l_TradingDay=pExecOrder.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pExecOrder.SettlementID
        l_ExecOrderSysID=pExecOrder.ExecOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertDate=pExecOrder.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pExecOrder.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_CancelTime=pExecOrder.CancelTime.decode(encoding="gb18030", errors="ignore");
        l_ExecResult=pExecOrder.ExecResult.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pExecOrder.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pExecOrder.SequenceNo
        l_FrontID=pExecOrder.FrontID
        l_SessionID=pExecOrder.SessionID
        l_UserProductInfo=pExecOrder.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pExecOrder.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_ActiveUserID=pExecOrder.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerExecOrderSeq=pExecOrder.BrokerExecOrderSeq
        l_BranchID=pExecOrder.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pExecOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pExecOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pExecOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pExecOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pExecOrder.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ExecOrder(BrokerID,InvestorID,InstrumentID,ExecOrderRef,UserID,Volume,RequestID,BusinessUnit,OffsetFlag,HedgeFlag,ActionType,PosiDirection,ReservePositionFlag,CloseFlag,ExecOrderLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,OrderSubmitStatus,NotifySequence,TradingDay,SettlementID,ExecOrderSysID,InsertDate,InsertTime,CancelTime,ExecResult,ClearingPartID,SequenceNo,FrontID,SessionID,UserProductInfo,StatusMsg,ActiveUserID,BrokerExecOrderSeq,BranchID,InvestUnitID,AccountID,CurrencyID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ExecOrderRef,l_UserID,l_Volume,l_RequestID,l_BusinessUnit,l_OffsetFlag,l_HedgeFlag,l_ActionType,l_PosiDirection,l_ReservePositionFlag,l_CloseFlag,l_ExecOrderLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_OrderSubmitStatus,l_NotifySequence,l_TradingDay,l_SettlementID,l_ExecOrderSysID,l_InsertDate,l_InsertTime,l_CancelTime,l_ExecResult,l_ClearingPartID,l_SequenceNo,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_ActiveUserID,l_BrokerExecOrderSeq,l_BranchID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pForQuote2DB(self, pForQuote):
        l_BrokerID=pForQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pForQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pForQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteRef=pForQuote.ForQuoteRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pForQuote.UserID.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteLocalID=pForQuote.ForQuoteLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pForQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pForQuote.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pForQuote.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pForQuote.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pForQuote.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pForQuote.InstallID
        l_InsertDate=pForQuote.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pForQuote.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteStatus=pForQuote.ForQuoteStatus.decode(encoding="gb18030", errors="ignore");
        l_FrontID=pForQuote.FrontID
        l_SessionID=pForQuote.SessionID
        l_StatusMsg=pForQuote.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_ActiveUserID=pForQuote.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerForQutoSeq=pForQuote.BrokerForQutoSeq
        l_InvestUnitID=pForQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pForQuote.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pForQuote.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ForQuote(BrokerID,InvestorID,InstrumentID,ForQuoteRef,UserID,ForQuoteLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,InsertDate,InsertTime,ForQuoteStatus,FrontID,SessionID,StatusMsg,ActiveUserID,BrokerForQutoSeq,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_ForQuoteRef,l_UserID,l_ForQuoteLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_InsertDate,l_InsertTime,l_ForQuoteStatus,l_FrontID,l_SessionID,l_StatusMsg,l_ActiveUserID,l_BrokerForQutoSeq,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pQuote2DB(self, pQuote):
        l_BrokerID=pQuote.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQuote.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQuote.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_QuoteRef=pQuote.QuoteRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pQuote.UserID.decode(encoding="gb18030", errors="ignore");
        l_AskPrice=pQuote.AskPrice
        l_BidPrice=pQuote.BidPrice
        l_AskVolume=pQuote.AskVolume
        l_BidVolume=pQuote.BidVolume
        l_RequestID=pQuote.RequestID
        l_BusinessUnit=pQuote.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_AskOffsetFlag=pQuote.AskOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_BidOffsetFlag=pQuote.BidOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_AskHedgeFlag=pQuote.AskHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_BidHedgeFlag=pQuote.BidHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_QuoteLocalID=pQuote.QuoteLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pQuote.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pQuote.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pQuote.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pQuote.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pQuote.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pQuote.InstallID
        l_NotifySequence=pQuote.NotifySequence
        l_OrderSubmitStatus=pQuote.OrderSubmitStatus.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pQuote.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pQuote.SettlementID
        l_QuoteSysID=pQuote.QuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertDate=pQuote.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pQuote.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_CancelTime=pQuote.CancelTime.decode(encoding="gb18030", errors="ignore");
        l_QuoteStatus=pQuote.QuoteStatus.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pQuote.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pQuote.SequenceNo
        l_AskOrderSysID=pQuote.AskOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_BidOrderSysID=pQuote.BidOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_FrontID=pQuote.FrontID
        l_SessionID=pQuote.SessionID
        l_UserProductInfo=pQuote.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pQuote.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_ActiveUserID=pQuote.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerQuoteSeq=pQuote.BrokerQuoteSeq
        l_AskOrderRef=pQuote.AskOrderRef.decode(encoding="gb18030", errors="ignore");
        l_BidOrderRef=pQuote.BidOrderRef.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteSysID=pQuote.ForQuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pQuote.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQuote.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pQuote.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pQuote.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pQuote.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pQuote.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Quote(BrokerID,InvestorID,InstrumentID,QuoteRef,UserID,AskPrice,BidPrice,AskVolume,BidVolume,RequestID,BusinessUnit,AskOffsetFlag,BidOffsetFlag,AskHedgeFlag,BidHedgeFlag,QuoteLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,NotifySequence,OrderSubmitStatus,TradingDay,SettlementID,QuoteSysID,InsertDate,InsertTime,CancelTime,QuoteStatus,ClearingPartID,SequenceNo,AskOrderSysID,BidOrderSysID,FrontID,SessionID,UserProductInfo,StatusMsg,ActiveUserID,BrokerQuoteSeq,AskOrderRef,BidOrderRef,ForQuoteSysID,BranchID,InvestUnitID,AccountID,CurrencyID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_QuoteRef,l_UserID,l_AskPrice,l_BidPrice,l_AskVolume,l_BidVolume,l_RequestID,l_BusinessUnit,l_AskOffsetFlag,l_BidOffsetFlag,l_AskHedgeFlag,l_BidHedgeFlag,l_QuoteLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_NotifySequence,l_OrderSubmitStatus,l_TradingDay,l_SettlementID,l_QuoteSysID,l_InsertDate,l_InsertTime,l_CancelTime,l_QuoteStatus,l_ClearingPartID,l_SequenceNo,l_AskOrderSysID,l_BidOrderSysID,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_ActiveUserID,l_BrokerQuoteSeq,l_AskOrderRef,l_BidOrderRef,l_ForQuoteSysID,l_BranchID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pOptionSelfClose2DB(self, pOptionSelfClose):
        l_BrokerID=pOptionSelfClose.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOptionSelfClose.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pOptionSelfClose.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseRef=pOptionSelfClose.OptionSelfCloseRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pOptionSelfClose.UserID.decode(encoding="gb18030", errors="ignore");
        l_Volume=pOptionSelfClose.Volume
        l_RequestID=pOptionSelfClose.RequestID
        l_BusinessUnit=pOptionSelfClose.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pOptionSelfClose.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_OptSelfCloseFlag=pOptionSelfClose.OptSelfCloseFlag.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseLocalID=pOptionSelfClose.OptionSelfCloseLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pOptionSelfClose.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pOptionSelfClose.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pOptionSelfClose.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pOptionSelfClose.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pOptionSelfClose.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pOptionSelfClose.InstallID
        l_OrderSubmitStatus=pOptionSelfClose.OrderSubmitStatus.decode(encoding="gb18030", errors="ignore");
        l_NotifySequence=pOptionSelfClose.NotifySequence
        l_TradingDay=pOptionSelfClose.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pOptionSelfClose.SettlementID
        l_OptionSelfCloseSysID=pOptionSelfClose.OptionSelfCloseSysID.decode(encoding="gb18030", errors="ignore");
        l_InsertDate=pOptionSelfClose.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pOptionSelfClose.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_CancelTime=pOptionSelfClose.CancelTime.decode(encoding="gb18030", errors="ignore");
        l_ExecResult=pOptionSelfClose.ExecResult.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pOptionSelfClose.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pOptionSelfClose.SequenceNo
        l_FrontID=pOptionSelfClose.FrontID
        l_SessionID=pOptionSelfClose.SessionID
        l_UserProductInfo=pOptionSelfClose.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pOptionSelfClose.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_ActiveUserID=pOptionSelfClose.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerOptionSelfCloseSeq=pOptionSelfClose.BrokerOptionSelfCloseSeq
        l_BranchID=pOptionSelfClose.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOptionSelfClose.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pOptionSelfClose.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pOptionSelfClose.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pOptionSelfClose.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pOptionSelfClose.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OptionSelfClose(BrokerID,InvestorID,InstrumentID,OptionSelfCloseRef,UserID,Volume,RequestID,BusinessUnit,HedgeFlag,OptSelfCloseFlag,OptionSelfCloseLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,OrderSubmitStatus,NotifySequence,TradingDay,SettlementID,OptionSelfCloseSysID,InsertDate,InsertTime,CancelTime,ExecResult,ClearingPartID,SequenceNo,FrontID,SessionID,UserProductInfo,StatusMsg,ActiveUserID,BrokerOptionSelfCloseSeq,BranchID,InvestUnitID,AccountID,CurrencyID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OptionSelfCloseRef,l_UserID,l_Volume,l_RequestID,l_BusinessUnit,l_HedgeFlag,l_OptSelfCloseFlag,l_OptionSelfCloseLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_OrderSubmitStatus,l_NotifySequence,l_TradingDay,l_SettlementID,l_OptionSelfCloseSysID,l_InsertDate,l_InsertTime,l_CancelTime,l_ExecResult,l_ClearingPartID,l_SequenceNo,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_ActiveUserID,l_BrokerOptionSelfCloseSeq,l_BranchID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInvestUnit2DB(self, pInvestUnit):
        l_BrokerID=pInvestUnit.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pInvestUnit.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pInvestUnit.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_InvestorUnitName=pInvestUnit.InvestorUnitName.decode(encoding="gb18030", errors="ignore");
        l_InvestorGroupID=pInvestUnit.InvestorGroupID.decode(encoding="gb18030", errors="ignore");
        l_CommModelID=pInvestUnit.CommModelID.decode(encoding="gb18030", errors="ignore");
        l_MarginModelID=pInvestUnit.MarginModelID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pInvestUnit.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pInvestUnit.CurrencyID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InvestUnit(BrokerID,InvestorID,InvestUnitID,InvestorUnitName,InvestorGroupID,CommModelID,MarginModelID,AccountID,CurrencyID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InvestUnitID,l_InvestorUnitName,l_InvestorGroupID,l_CommModelID,l_MarginModelID,l_AccountID,l_CurrencyID)]
        self.SQL2DB(the_SQL,the_data)

    def  pCombInstrumentGuard2DB(self, pCombInstrumentGuard):
        l_BrokerID=pCombInstrumentGuard.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pCombInstrumentGuard.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_GuarantRatio=pCombInstrumentGuard.GuarantRatio
        l_ExchangeID=pCombInstrumentGuard.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_CombInstrumentGuard(BrokerID,InstrumentID,GuarantRatio,ExchangeID)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InstrumentID,l_GuarantRatio,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pCombAction2DB(self, pCombAction):
        l_BrokerID=pCombAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pCombAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pCombAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_CombActionRef=pCombAction.CombActionRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pCombAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_Direction=pCombAction.Direction.decode(encoding="gb18030", errors="ignore");
        l_Volume=pCombAction.Volume
        l_CombDirection=pCombAction.CombDirection.decode(encoding="gb18030", errors="ignore");
        l_HedgeFlag=pCombAction.HedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionLocalID=pCombAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pCombAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pCombAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pCombAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pCombAction.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pCombAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pCombAction.InstallID
        l_ActionStatus=pCombAction.ActionStatus.decode(encoding="gb18030", errors="ignore");
        l_NotifySequence=pCombAction.NotifySequence
        l_TradingDay=pCombAction.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pCombAction.SettlementID
        l_SequenceNo=pCombAction.SequenceNo
        l_FrontID=pCombAction.FrontID
        l_SessionID=pCombAction.SessionID
        l_UserProductInfo=pCombAction.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pCombAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pCombAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pCombAction.MacAddress.decode(encoding="gb18030", errors="ignore");
        l_ComTradeID=pCombAction.ComTradeID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pCombAction.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pCombAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_CombAction(BrokerID,InvestorID,InstrumentID,CombActionRef,UserID,Direction,Volume,CombDirection,HedgeFlag,ActionLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,ActionStatus,NotifySequence,TradingDay,SettlementID,SequenceNo,FrontID,SessionID,UserProductInfo,StatusMsg,IPAddress,MacAddress,ComTradeID,BranchID,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_CombActionRef,l_UserID,l_Direction,l_Volume,l_CombDirection,l_HedgeFlag,l_ActionLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_ActionStatus,l_NotifySequence,l_TradingDay,l_SettlementID,l_SequenceNo,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_IPAddress,l_MacAddress,l_ComTradeID,l_BranchID,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pTransferSerial2DB(self, pTransferSerial):
        l_PlateSerial=pTransferSerial.PlateSerial
        l_TradeDate=pTransferSerial.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pTransferSerial.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pTransferSerial.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_TradeCode=pTransferSerial.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pTransferSerial.SessionID
        l_BankID=pTransferSerial.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pTransferSerial.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pTransferSerial.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pTransferSerial.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pTransferSerial.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pTransferSerial.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pTransferSerial.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_FutureAccType=pTransferSerial.FutureAccType.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pTransferSerial.AccountID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pTransferSerial.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_FutureSerial=pTransferSerial.FutureSerial
        l_IdCardType=pTransferSerial.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pTransferSerial.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pTransferSerial.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_TradeAmount=pTransferSerial.TradeAmount
        l_CustFee=pTransferSerial.CustFee
        l_BrokerFee=pTransferSerial.BrokerFee
        l_AvailabilityFlag=pTransferSerial.AvailabilityFlag.decode(encoding="gb18030", errors="ignore");
        l_OperatorCode=pTransferSerial.OperatorCode.decode(encoding="gb18030", errors="ignore");
        l_BankNewAccount=pTransferSerial.BankNewAccount.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pTransferSerial.ErrorID
        l_ErrorMsg=pTransferSerial.ErrorMsg.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_TransferSerial(PlateSerial,TradeDate,TradingDay,TradeTime,TradeCode,SessionID,BankID,BankBranchID,BankAccType,BankAccount,BankSerial,BrokerID,BrokerBranchID,FutureAccType,AccountID,InvestorID,FutureSerial,IdCardType,IdentifiedCardNo,CurrencyID,TradeAmount,CustFee,BrokerFee,AvailabilityFlag,OperatorCode,BankNewAccount,ErrorID,ErrorMsg)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_PlateSerial,l_TradeDate,l_TradingDay,l_TradeTime,l_TradeCode,l_SessionID,l_BankID,l_BankBranchID,l_BankAccType,l_BankAccount,l_BankSerial,l_BrokerID,l_BrokerBranchID,l_FutureAccType,l_AccountID,l_InvestorID,l_FutureSerial,l_IdCardType,l_IdentifiedCardNo,l_CurrencyID,l_TradeAmount,l_CustFee,l_BrokerFee,l_AvailabilityFlag,l_OperatorCode,l_BankNewAccount,l_ErrorID,l_ErrorMsg)]
        self.SQL2DB(the_SQL,the_data)

    def  pAccountregister2DB(self, pAccountregister):
        l_TradeDay=pAccountregister.TradeDay.decode(encoding="gb18030", errors="ignore");
        l_BankID=pAccountregister.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pAccountregister.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pAccountregister.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pAccountregister.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pAccountregister.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pAccountregister.AccountID.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pAccountregister.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pAccountregister.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustomerName=pAccountregister.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pAccountregister.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_OpenOrDestroy=pAccountregister.OpenOrDestroy.decode(encoding="gb18030", errors="ignore");
        l_RegDate=pAccountregister.RegDate.decode(encoding="gb18030", errors="ignore");
        l_OutDate=pAccountregister.OutDate.decode(encoding="gb18030", errors="ignore");
        l_TID=pAccountregister.TID
        l_CustType=pAccountregister.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pAccountregister.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pAccountregister.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Accountregister(TradeDay,BankID,BankBranchID,BankAccount,BrokerID,BrokerBranchID,AccountID,IdCardType,IdentifiedCardNo,CustomerName,CurrencyID,OpenOrDestroy,RegDate,OutDate,TID,CustType,BankAccType,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeDay,l_BankID,l_BankBranchID,l_BankAccount,l_BrokerID,l_BrokerBranchID,l_AccountID,l_IdCardType,l_IdentifiedCardNo,l_CustomerName,l_CurrencyID,l_OpenOrDestroy,l_RegDate,l_OutDate,l_TID,l_CustType,l_BankAccType,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pRspInfo2DB(self, pRspInfo):
        if pRspInfo is None:
            return

        l_ErrorID=pRspInfo.ErrorID
        l_ErrorMsg=pRspInfo.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        if l_ErrorID ==0:
            return

        the_SQL  ="INSERT INTO T_RspInfo(ErrorID,ErrorMsg)VALUES(%s,%s)"
        the_data =[( l_ErrorID,l_ErrorMsg)]
        self.SQL2DB(the_SQL,the_data)

    def  pOrderAction2DB(self, pOrderAction):
        l_BrokerID=pOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OrderActionRef=pOrderAction.OrderActionRef
        l_OrderRef=pOrderAction.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pOrderAction.RequestID
        l_FrontID=pOrderAction.FrontID
        l_SessionID=pOrderAction.SessionID
        l_ExchangeID=pOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OrderSysID=pOrderAction.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pOrderAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pOrderAction.LimitPrice
        l_VolumeChange=pOrderAction.VolumeChange
        l_ActionDate=pOrderAction.ActionDate.decode(encoding="gb18030", errors="ignore");
        l_ActionTime=pOrderAction.ActionTime.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pOrderAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pOrderAction.InstallID
        l_OrderLocalID=pOrderAction.OrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ActionLocalID=pOrderAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pOrderAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pOrderAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pOrderAction.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OrderActionStatus=pOrderAction.OrderActionStatus.decode(encoding="gb18030", errors="ignore");
        l_UserID=pOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pOrderAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pOrderAction.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OrderAction(BrokerID,InvestorID,OrderActionRef,OrderRef,RequestID,FrontID,SessionID,ExchangeID,OrderSysID,ActionFlag,LimitPrice,VolumeChange,ActionDate,ActionTime,TraderID,InstallID,OrderLocalID,ActionLocalID,ParticipantID,ClientID,BusinessUnit,OrderActionStatus,UserID,StatusMsg,InstrumentID,BranchID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OrderActionRef,l_OrderRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_OrderSysID,l_ActionFlag,l_LimitPrice,l_VolumeChange,l_ActionDate,l_ActionTime,l_TraderID,l_InstallID,l_OrderLocalID,l_ActionLocalID,l_ParticipantID,l_ClientID,l_BusinessUnit,l_OrderActionStatus,l_UserID,l_StatusMsg,l_InstrumentID,l_BranchID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pInstrumentStatus2DB(self, pInstrumentStatus):
        l_ExchangeID=pInstrumentStatus.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pInstrumentStatus.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_SettlementGroupID=pInstrumentStatus.SettlementGroupID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pInstrumentStatus.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentStatus=pInstrumentStatus.InstrumentStatus.decode(encoding="gb18030", errors="ignore");
        l_TradingSegmentSN=pInstrumentStatus.TradingSegmentSN
        l_EnterTime=pInstrumentStatus.EnterTime.decode(encoding="gb18030", errors="ignore");
        l_EnterReason=pInstrumentStatus.EnterReason.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_InstrumentStatus(ExchangeID,ExchangeInstID,SettlementGroupID,InstrumentID,InstrumentStatus,TradingSegmentSN,EnterTime,EnterReason)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_ExchangeID,l_ExchangeInstID,l_SettlementGroupID,l_InstrumentID,l_InstrumentStatus,l_TradingSegmentSN,l_EnterTime,l_EnterReason)]
        self.SQL2DB(the_SQL,the_data)

    def  pBulletin2DB(self, pBulletin):
        l_ExchangeID=pBulletin.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pBulletin.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_BulletinID=pBulletin.BulletinID
        l_SequenceNo=pBulletin.SequenceNo
        l_NewsType=pBulletin.NewsType.decode(encoding="gb18030", errors="ignore");
        l_NewsUrgency=pBulletin.NewsUrgency.decode(encoding="gb18030", errors="ignore");
        l_SendTime=pBulletin.SendTime.decode(encoding="gb18030", errors="ignore");
        l_Abstract=pBulletin.Abstract.decode(encoding="gb18030", errors="ignore");
        l_ComeFrom=pBulletin.ComeFrom.decode(encoding="gb18030", errors="ignore");
        l_Content=pBulletin.Content.decode(encoding="gb18030", errors="ignore");
        l_URLLink=pBulletin.URLLink.decode(encoding="gb18030", errors="ignore");
        l_MarketID=pBulletin.MarketID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_Bulletin(ExchangeID,TradingDay,BulletinID,SequenceNo,NewsType,NewsUrgency,SendTime,Abstract,ComeFrom,Content,URLLink,MarketID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_ExchangeID,l_TradingDay,l_BulletinID,l_SequenceNo,l_NewsType,l_NewsUrgency,l_SendTime,l_Abstract,l_ComeFrom,l_Content,l_URLLink,l_MarketID)]
        self.SQL2DB(the_SQL,the_data)

    def  pTradingNoticeInfo2DB(self, pTradingNoticeInfo):
        l_BrokerID=pTradingNoticeInfo.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pTradingNoticeInfo.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_SendTime=pTradingNoticeInfo.SendTime.decode(encoding="gb18030", errors="ignore");
        l_FieldContent=pTradingNoticeInfo.FieldContent.decode(encoding="gb18030", errors="ignore");
        l_SequenceSeries=pTradingNoticeInfo.SequenceSeries
        l_SequenceNo=pTradingNoticeInfo.SequenceNo
        l_InvestUnitID=pTradingNoticeInfo.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_TradingNoticeInfo(BrokerID,InvestorID,SendTime,FieldContent,SequenceSeries,SequenceNo,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_SendTime,l_FieldContent,l_SequenceSeries,l_SequenceNo,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pErrorConditionalOrder2DB(self, pErrorConditionalOrder):
        l_BrokerID=pErrorConditionalOrder.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pErrorConditionalOrder.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pErrorConditionalOrder.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_OrderRef=pErrorConditionalOrder.OrderRef.decode(encoding="gb18030", errors="ignore");
        l_UserID=pErrorConditionalOrder.UserID.decode(encoding="gb18030", errors="ignore");
        l_OrderPriceType=pErrorConditionalOrder.OrderPriceType.decode(encoding="gb18030", errors="ignore");
        l_Direction=pErrorConditionalOrder.Direction.decode(encoding="gb18030", errors="ignore");
        l_CombOffsetFlag=pErrorConditionalOrder.CombOffsetFlag.decode(encoding="gb18030", errors="ignore");
        l_CombHedgeFlag=pErrorConditionalOrder.CombHedgeFlag.decode(encoding="gb18030", errors="ignore");
        l_LimitPrice=pErrorConditionalOrder.LimitPrice
        l_VolumeTotalOriginal=pErrorConditionalOrder.VolumeTotalOriginal
        l_TimeCondition=pErrorConditionalOrder.TimeCondition.decode(encoding="gb18030", errors="ignore");
        l_GTDDate=pErrorConditionalOrder.GTDDate.decode(encoding="gb18030", errors="ignore");
        l_VolumeCondition=pErrorConditionalOrder.VolumeCondition.decode(encoding="gb18030", errors="ignore");
        l_MinVolume=pErrorConditionalOrder.MinVolume
        l_ContingentCondition=pErrorConditionalOrder.ContingentCondition.decode(encoding="gb18030", errors="ignore");
        l_StopPrice=pErrorConditionalOrder.StopPrice
        l_ForceCloseReason=pErrorConditionalOrder.ForceCloseReason.decode(encoding="gb18030", errors="ignore");
        l_IsAutoSuspend=pErrorConditionalOrder.IsAutoSuspend
        l_BusinessUnit=pErrorConditionalOrder.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pErrorConditionalOrder.RequestID
        l_OrderLocalID=pErrorConditionalOrder.OrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pErrorConditionalOrder.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pErrorConditionalOrder.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pErrorConditionalOrder.ClientID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeInstID=pErrorConditionalOrder.ExchangeInstID.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pErrorConditionalOrder.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pErrorConditionalOrder.InstallID
        l_OrderSubmitStatus=pErrorConditionalOrder.OrderSubmitStatus.decode(encoding="gb18030", errors="ignore");
        l_NotifySequence=pErrorConditionalOrder.NotifySequence
        l_TradingDay=pErrorConditionalOrder.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_SettlementID=pErrorConditionalOrder.SettlementID
        l_OrderSysID=pErrorConditionalOrder.OrderSysID.decode(encoding="gb18030", errors="ignore");
        l_OrderSource=pErrorConditionalOrder.OrderSource.decode(encoding="gb18030", errors="ignore");
        l_OrderStatus=pErrorConditionalOrder.OrderStatus.decode(encoding="gb18030", errors="ignore");
        l_OrderType=pErrorConditionalOrder.OrderType.decode(encoding="gb18030", errors="ignore");
        l_VolumeTraded=pErrorConditionalOrder.VolumeTraded
        l_VolumeTotal=pErrorConditionalOrder.VolumeTotal
        l_InsertDate=pErrorConditionalOrder.InsertDate.decode(encoding="gb18030", errors="ignore");
        l_InsertTime=pErrorConditionalOrder.InsertTime.decode(encoding="gb18030", errors="ignore");
        l_ActiveTime=pErrorConditionalOrder.ActiveTime.decode(encoding="gb18030", errors="ignore");
        l_SuspendTime=pErrorConditionalOrder.SuspendTime.decode(encoding="gb18030", errors="ignore");
        l_UpdateTime=pErrorConditionalOrder.UpdateTime.decode(encoding="gb18030", errors="ignore");
        l_CancelTime=pErrorConditionalOrder.CancelTime.decode(encoding="gb18030", errors="ignore");
        l_ActiveTraderID=pErrorConditionalOrder.ActiveTraderID.decode(encoding="gb18030", errors="ignore");
        l_ClearingPartID=pErrorConditionalOrder.ClearingPartID.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pErrorConditionalOrder.SequenceNo
        l_FrontID=pErrorConditionalOrder.FrontID
        l_SessionID=pErrorConditionalOrder.SessionID
        l_UserProductInfo=pErrorConditionalOrder.UserProductInfo.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pErrorConditionalOrder.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_UserForceClose=pErrorConditionalOrder.UserForceClose
        l_ActiveUserID=pErrorConditionalOrder.ActiveUserID.decode(encoding="gb18030", errors="ignore");
        l_BrokerOrderSeq=pErrorConditionalOrder.BrokerOrderSeq
        l_RelativeOrderSysID=pErrorConditionalOrder.RelativeOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ZCETotalTradedVolume=pErrorConditionalOrder.ZCETotalTradedVolume
        l_ErrorID=pErrorConditionalOrder.ErrorID
        l_ErrorMsg=pErrorConditionalOrder.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_IsSwapOrder=pErrorConditionalOrder.IsSwapOrder
        l_BranchID=pErrorConditionalOrder.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pErrorConditionalOrder.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pErrorConditionalOrder.AccountID.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pErrorConditionalOrder.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pErrorConditionalOrder.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pErrorConditionalOrder.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ErrorConditionalOrder(BrokerID,InvestorID,InstrumentID,OrderRef,UserID,OrderPriceType,Direction,CombOffsetFlag,CombHedgeFlag,LimitPrice,VolumeTotalOriginal,TimeCondition,GTDDate,VolumeCondition,MinVolume,ContingentCondition,StopPrice,ForceCloseReason,IsAutoSuspend,BusinessUnit,RequestID,OrderLocalID,ExchangeID,ParticipantID,ClientID,ExchangeInstID,TraderID,InstallID,OrderSubmitStatus,NotifySequence,TradingDay,SettlementID,OrderSysID,OrderSource,OrderStatus,OrderType,VolumeTraded,VolumeTotal,InsertDate,InsertTime,ActiveTime,SuspendTime,UpdateTime,CancelTime,ActiveTraderID,ClearingPartID,SequenceNo,FrontID,SessionID,UserProductInfo,StatusMsg,UserForceClose,ActiveUserID,BrokerOrderSeq,RelativeOrderSysID,ZCETotalTradedVolume,ErrorID,ErrorMsg,IsSwapOrder,BranchID,InvestUnitID,AccountID,CurrencyID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_InstrumentID,l_OrderRef,l_UserID,l_OrderPriceType,l_Direction,l_CombOffsetFlag,l_CombHedgeFlag,l_LimitPrice,l_VolumeTotalOriginal,l_TimeCondition,l_GTDDate,l_VolumeCondition,l_MinVolume,l_ContingentCondition,l_StopPrice,l_ForceCloseReason,l_IsAutoSuspend,l_BusinessUnit,l_RequestID,l_OrderLocalID,l_ExchangeID,l_ParticipantID,l_ClientID,l_ExchangeInstID,l_TraderID,l_InstallID,l_OrderSubmitStatus,l_NotifySequence,l_TradingDay,l_SettlementID,l_OrderSysID,l_OrderSource,l_OrderStatus,l_OrderType,l_VolumeTraded,l_VolumeTotal,l_InsertDate,l_InsertTime,l_ActiveTime,l_SuspendTime,l_UpdateTime,l_CancelTime,l_ActiveTraderID,l_ClearingPartID,l_SequenceNo,l_FrontID,l_SessionID,l_UserProductInfo,l_StatusMsg,l_UserForceClose,l_ActiveUserID,l_BrokerOrderSeq,l_RelativeOrderSysID,l_ZCETotalTradedVolume,l_ErrorID,l_ErrorMsg,l_IsSwapOrder,l_BranchID,l_InvestUnitID,l_AccountID,l_CurrencyID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pExecOrderAction2DB(self, pExecOrderAction):
        l_BrokerID=pExecOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pExecOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderActionRef=pExecOrderAction.ExecOrderActionRef
        l_ExecOrderRef=pExecOrderAction.ExecOrderRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pExecOrderAction.RequestID
        l_FrontID=pExecOrderAction.FrontID
        l_SessionID=pExecOrderAction.SessionID
        l_ExchangeID=pExecOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ExecOrderSysID=pExecOrderAction.ExecOrderSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pExecOrderAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionDate=pExecOrderAction.ActionDate.decode(encoding="gb18030", errors="ignore");
        l_ActionTime=pExecOrderAction.ActionTime.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pExecOrderAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pExecOrderAction.InstallID
        l_ExecOrderLocalID=pExecOrderAction.ExecOrderLocalID.decode(encoding="gb18030", errors="ignore");
        l_ActionLocalID=pExecOrderAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pExecOrderAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pExecOrderAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pExecOrderAction.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OrderActionStatus=pExecOrderAction.OrderActionStatus.decode(encoding="gb18030", errors="ignore");
        l_UserID=pExecOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_ActionType=pExecOrderAction.ActionType.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pExecOrderAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pExecOrderAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pExecOrderAction.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pExecOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pExecOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pExecOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ExecOrderAction(BrokerID,InvestorID,ExecOrderActionRef,ExecOrderRef,RequestID,FrontID,SessionID,ExchangeID,ExecOrderSysID,ActionFlag,ActionDate,ActionTime,TraderID,InstallID,ExecOrderLocalID,ActionLocalID,ParticipantID,ClientID,BusinessUnit,OrderActionStatus,UserID,ActionType,StatusMsg,InstrumentID,BranchID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_ExecOrderActionRef,l_ExecOrderRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_ExecOrderSysID,l_ActionFlag,l_ActionDate,l_ActionTime,l_TraderID,l_InstallID,l_ExecOrderLocalID,l_ActionLocalID,l_ParticipantID,l_ClientID,l_BusinessUnit,l_OrderActionStatus,l_UserID,l_ActionType,l_StatusMsg,l_InstrumentID,l_BranchID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pQuoteAction2DB(self, pQuoteAction):
        l_BrokerID=pQuoteAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pQuoteAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_QuoteActionRef=pQuoteAction.QuoteActionRef
        l_QuoteRef=pQuoteAction.QuoteRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pQuoteAction.RequestID
        l_FrontID=pQuoteAction.FrontID
        l_SessionID=pQuoteAction.SessionID
        l_ExchangeID=pQuoteAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_QuoteSysID=pQuoteAction.QuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pQuoteAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionDate=pQuoteAction.ActionDate.decode(encoding="gb18030", errors="ignore");
        l_ActionTime=pQuoteAction.ActionTime.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pQuoteAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pQuoteAction.InstallID
        l_QuoteLocalID=pQuoteAction.QuoteLocalID.decode(encoding="gb18030", errors="ignore");
        l_ActionLocalID=pQuoteAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pQuoteAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pQuoteAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pQuoteAction.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OrderActionStatus=pQuoteAction.OrderActionStatus.decode(encoding="gb18030", errors="ignore");
        l_UserID=pQuoteAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pQuoteAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pQuoteAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pQuoteAction.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pQuoteAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pQuoteAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pQuoteAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_QuoteAction(BrokerID,InvestorID,QuoteActionRef,QuoteRef,RequestID,FrontID,SessionID,ExchangeID,QuoteSysID,ActionFlag,ActionDate,ActionTime,TraderID,InstallID,QuoteLocalID,ActionLocalID,ParticipantID,ClientID,BusinessUnit,OrderActionStatus,UserID,StatusMsg,InstrumentID,BranchID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_QuoteActionRef,l_QuoteRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_QuoteSysID,l_ActionFlag,l_ActionDate,l_ActionTime,l_TraderID,l_InstallID,l_QuoteLocalID,l_ActionLocalID,l_ParticipantID,l_ClientID,l_BusinessUnit,l_OrderActionStatus,l_UserID,l_StatusMsg,l_InstrumentID,l_BranchID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pForQuoteRsp2DB(self, pForQuoteRsp):
        l_TradingDay=pForQuoteRsp.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pForQuoteRsp.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteSysID=pForQuoteRsp.ForQuoteSysID.decode(encoding="gb18030", errors="ignore");
        l_ForQuoteTime=pForQuoteRsp.ForQuoteTime.decode(encoding="gb18030", errors="ignore");
        l_ActionDay=pForQuoteRsp.ActionDay.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pForQuoteRsp.ExchangeID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ForQuoteRsp(TradingDay,InstrumentID,ForQuoteSysID,ForQuoteTime,ActionDay,ExchangeID)VALUES(%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradingDay,l_InstrumentID,l_ForQuoteSysID,l_ForQuoteTime,l_ActionDay,l_ExchangeID)]
        self.SQL2DB(the_SQL,the_data)

    def  pCFMMCTradingAccountToken2DB(self, pCFMMCTradingAccountToken):
        l_BrokerID=pCFMMCTradingAccountToken.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pCFMMCTradingAccountToken.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pCFMMCTradingAccountToken.AccountID.decode(encoding="gb18030", errors="ignore");
        l_KeyID=pCFMMCTradingAccountToken.KeyID
        l_Token=pCFMMCTradingAccountToken.Token.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_CFMMCTradingAccountToken(BrokerID,ParticipantID,AccountID,KeyID,Token)VALUES(%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_ParticipantID,l_AccountID,l_KeyID,l_Token)]
        self.SQL2DB(the_SQL,the_data)

    def  pBatchOrderAction2DB(self, pBatchOrderAction):
        l_BrokerID=pBatchOrderAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pBatchOrderAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OrderActionRef=pBatchOrderAction.OrderActionRef
        l_RequestID=pBatchOrderAction.RequestID
        l_FrontID=pBatchOrderAction.FrontID
        l_SessionID=pBatchOrderAction.SessionID
        l_ExchangeID=pBatchOrderAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_ActionDate=pBatchOrderAction.ActionDate.decode(encoding="gb18030", errors="ignore");
        l_ActionTime=pBatchOrderAction.ActionTime.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pBatchOrderAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pBatchOrderAction.InstallID
        l_ActionLocalID=pBatchOrderAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pBatchOrderAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pBatchOrderAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pBatchOrderAction.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OrderActionStatus=pBatchOrderAction.OrderActionStatus.decode(encoding="gb18030", errors="ignore");
        l_UserID=pBatchOrderAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pBatchOrderAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pBatchOrderAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pBatchOrderAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pBatchOrderAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_BatchOrderAction(BrokerID,InvestorID,OrderActionRef,RequestID,FrontID,SessionID,ExchangeID,ActionDate,ActionTime,TraderID,InstallID,ActionLocalID,ParticipantID,ClientID,BusinessUnit,OrderActionStatus,UserID,StatusMsg,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OrderActionRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_ActionDate,l_ActionTime,l_TraderID,l_InstallID,l_ActionLocalID,l_ParticipantID,l_ClientID,l_BusinessUnit,l_OrderActionStatus,l_UserID,l_StatusMsg,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pOptionSelfCloseAction2DB(self, pOptionSelfCloseAction):
        l_BrokerID=pOptionSelfCloseAction.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pOptionSelfCloseAction.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseActionRef=pOptionSelfCloseAction.OptionSelfCloseActionRef
        l_OptionSelfCloseRef=pOptionSelfCloseAction.OptionSelfCloseRef.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pOptionSelfCloseAction.RequestID
        l_FrontID=pOptionSelfCloseAction.FrontID
        l_SessionID=pOptionSelfCloseAction.SessionID
        l_ExchangeID=pOptionSelfCloseAction.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_OptionSelfCloseSysID=pOptionSelfCloseAction.OptionSelfCloseSysID.decode(encoding="gb18030", errors="ignore");
        l_ActionFlag=pOptionSelfCloseAction.ActionFlag.decode(encoding="gb18030", errors="ignore");
        l_ActionDate=pOptionSelfCloseAction.ActionDate.decode(encoding="gb18030", errors="ignore");
        l_ActionTime=pOptionSelfCloseAction.ActionTime.decode(encoding="gb18030", errors="ignore");
        l_TraderID=pOptionSelfCloseAction.TraderID.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pOptionSelfCloseAction.InstallID
        l_OptionSelfCloseLocalID=pOptionSelfCloseAction.OptionSelfCloseLocalID.decode(encoding="gb18030", errors="ignore");
        l_ActionLocalID=pOptionSelfCloseAction.ActionLocalID.decode(encoding="gb18030", errors="ignore");
        l_ParticipantID=pOptionSelfCloseAction.ParticipantID.decode(encoding="gb18030", errors="ignore");
        l_ClientID=pOptionSelfCloseAction.ClientID.decode(encoding="gb18030", errors="ignore");
        l_BusinessUnit=pOptionSelfCloseAction.BusinessUnit.decode(encoding="gb18030", errors="ignore");
        l_OrderActionStatus=pOptionSelfCloseAction.OrderActionStatus.decode(encoding="gb18030", errors="ignore");
        l_UserID=pOptionSelfCloseAction.UserID.decode(encoding="gb18030", errors="ignore");
        l_StatusMsg=pOptionSelfCloseAction.StatusMsg.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pOptionSelfCloseAction.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_BranchID=pOptionSelfCloseAction.BranchID.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pOptionSelfCloseAction.InvestUnitID.decode(encoding="gb18030", errors="ignore");
        l_IPAddress=pOptionSelfCloseAction.IPAddress.decode(encoding="gb18030", errors="ignore");
        l_MacAddress=pOptionSelfCloseAction.MacAddress.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OptionSelfCloseAction(BrokerID,InvestorID,OptionSelfCloseActionRef,OptionSelfCloseRef,RequestID,FrontID,SessionID,ExchangeID,OptionSelfCloseSysID,ActionFlag,ActionDate,ActionTime,TraderID,InstallID,OptionSelfCloseLocalID,ActionLocalID,ParticipantID,ClientID,BusinessUnit,OrderActionStatus,UserID,StatusMsg,InstrumentID,BranchID,InvestUnitID,IPAddress,MacAddress)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_OptionSelfCloseActionRef,l_OptionSelfCloseRef,l_RequestID,l_FrontID,l_SessionID,l_ExchangeID,l_OptionSelfCloseSysID,l_ActionFlag,l_ActionDate,l_ActionTime,l_TraderID,l_InstallID,l_OptionSelfCloseLocalID,l_ActionLocalID,l_ParticipantID,l_ClientID,l_BusinessUnit,l_OrderActionStatus,l_UserID,l_StatusMsg,l_InstrumentID,l_BranchID,l_InvestUnitID,l_IPAddress,l_MacAddress)]
        self.SQL2DB(the_SQL,the_data)

    def  pContractBank2DB(self, pContractBank):
        l_BrokerID=pContractBank.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BankID=pContractBank.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBrchID=pContractBank.BankBrchID.decode(encoding="gb18030", errors="ignore");
        l_BankName=pContractBank.BankName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ContractBank(BrokerID,BankID,BankBrchID,BankName)VALUES(%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_BankID,l_BankBrchID,l_BankName)]
        self.SQL2DB(the_SQL,the_data)

    def  pTradingNotice2DB(self, pTradingNotice):
        l_BrokerID=pTradingNotice.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorRange=pTradingNotice.InvestorRange.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pTradingNotice.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_SequenceSeries=pTradingNotice.SequenceSeries
        l_UserID=pTradingNotice.UserID.decode(encoding="gb18030", errors="ignore");
        l_SendTime=pTradingNotice.SendTime.decode(encoding="gb18030", errors="ignore");
        l_SequenceNo=pTradingNotice.SequenceNo
        l_FieldContent=pTradingNotice.FieldContent.decode(encoding="gb18030", errors="ignore");
        l_InvestUnitID=pTradingNotice.InvestUnitID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_TradingNotice(BrokerID,InvestorRange,InvestorID,SequenceSeries,UserID,SendTime,SequenceNo,FieldContent,InvestUnitID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorRange,l_InvestorID,l_SequenceSeries,l_UserID,l_SendTime,l_SequenceNo,l_FieldContent,l_InvestUnitID)]
        self.SQL2DB(the_SQL,the_data)

    def  pBrokerTradingParams2DB(self, pBrokerTradingParams):
        l_BrokerID=pBrokerTradingParams.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_InvestorID=pBrokerTradingParams.InvestorID.decode(encoding="gb18030", errors="ignore");
        l_MarginPriceType=pBrokerTradingParams.MarginPriceType.decode(encoding="gb18030", errors="ignore");
        l_Algorithm=pBrokerTradingParams.Algorithm.decode(encoding="gb18030", errors="ignore");
        l_AvailIncludeCloseProfit=pBrokerTradingParams.AvailIncludeCloseProfit.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pBrokerTradingParams.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_OptionRoyaltyPriceType=pBrokerTradingParams.OptionRoyaltyPriceType.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pBrokerTradingParams.AccountID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_BrokerTradingParams(BrokerID,InvestorID,MarginPriceType,Algorithm,AvailIncludeCloseProfit,CurrencyID,OptionRoyaltyPriceType,AccountID)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_InvestorID,l_MarginPriceType,l_Algorithm,l_AvailIncludeCloseProfit,l_CurrencyID,l_OptionRoyaltyPriceType,l_AccountID)]
        self.SQL2DB(the_SQL,the_data)

    def  pBrokerTradingAlgos2DB(self, pBrokerTradingAlgos):
        l_BrokerID=pBrokerTradingAlgos.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_ExchangeID=pBrokerTradingAlgos.ExchangeID.decode(encoding="gb18030", errors="ignore");
        l_InstrumentID=pBrokerTradingAlgos.InstrumentID.decode(encoding="gb18030", errors="ignore");
        l_HandlePositionAlgoID=pBrokerTradingAlgos.HandlePositionAlgoID.decode(encoding="gb18030", errors="ignore");
        l_FindMarginRateAlgoID=pBrokerTradingAlgos.FindMarginRateAlgoID.decode(encoding="gb18030", errors="ignore");
        l_HandleTradingAccountAlgoID=pBrokerTradingAlgos.HandleTradingAccountAlgoID.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_BrokerTradingAlgos(BrokerID,ExchangeID,InstrumentID,HandlePositionAlgoID,FindMarginRateAlgoID,HandleTradingAccountAlgoID)VALUES(%s,%s,%s,%s,%s,%s)"
        the_data =[( l_BrokerID,l_ExchangeID,l_InstrumentID,l_HandlePositionAlgoID,l_FindMarginRateAlgoID,l_HandleTradingAccountAlgoID)]
        self.SQL2DB(the_SQL,the_data)

    def  pRspTransfer2DB(self, pRspTransfer):
        l_TradeCode=pRspTransfer.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pRspTransfer.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pRspTransfer.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pRspTransfer.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pRspTransfer.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pRspTransfer.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pRspTransfer.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pRspTransfer.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pRspTransfer.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pRspTransfer.PlateSerial
        l_LastFragment=pRspTransfer.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pRspTransfer.SessionID
        l_CustomerName=pRspTransfer.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pRspTransfer.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pRspTransfer.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pRspTransfer.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pRspTransfer.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pRspTransfer.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pRspTransfer.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pRspTransfer.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pRspTransfer.InstallID
        l_FutureSerial=pRspTransfer.FutureSerial
        l_UserID=pRspTransfer.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pRspTransfer.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pRspTransfer.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_TradeAmount=pRspTransfer.TradeAmount
        l_FutureFetchAmount=pRspTransfer.FutureFetchAmount
        l_FeePayFlag=pRspTransfer.FeePayFlag.decode(encoding="gb18030", errors="ignore");
        l_CustFee=pRspTransfer.CustFee
        l_BrokerFee=pRspTransfer.BrokerFee
        l_Message=pRspTransfer.Message.decode(encoding="gb18030", errors="ignore");
        l_Digest=pRspTransfer.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pRspTransfer.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pRspTransfer.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pRspTransfer.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pRspTransfer.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pRspTransfer.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pRspTransfer.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pRspTransfer.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pRspTransfer.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pRspTransfer.RequestID
        l_TID=pRspTransfer.TID
        l_TransferStatus=pRspTransfer.TransferStatus.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pRspTransfer.ErrorID
        l_ErrorMsg=pRspTransfer.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pRspTransfer.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RspTransfer(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,InstallID,FutureSerial,UserID,VerifyCertNoFlag,CurrencyID,TradeAmount,FutureFetchAmount,FeePayFlag,CustFee,BrokerFee,Message,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,TransferStatus,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_FutureSerial,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_TradeAmount,l_FutureFetchAmount,l_FeePayFlag,l_CustFee,l_BrokerFee,l_Message,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_TransferStatus,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pRspRepeal2DB(self, pRspRepeal):
        l_RepealTimeInterval=pRspRepeal.RepealTimeInterval
        l_RepealedTimes=pRspRepeal.RepealedTimes
        l_BankRepealFlag=pRspRepeal.BankRepealFlag.decode(encoding="gb18030", errors="ignore");
        l_BrokerRepealFlag=pRspRepeal.BrokerRepealFlag.decode(encoding="gb18030", errors="ignore");
        l_PlateRepealSerial=pRspRepeal.PlateRepealSerial
        l_BankRepealSerial=pRspRepeal.BankRepealSerial.decode(encoding="gb18030", errors="ignore");
        l_FutureRepealSerial=pRspRepeal.FutureRepealSerial
        l_TradeCode=pRspRepeal.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pRspRepeal.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pRspRepeal.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pRspRepeal.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pRspRepeal.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pRspRepeal.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pRspRepeal.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pRspRepeal.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pRspRepeal.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pRspRepeal.PlateSerial
        l_LastFragment=pRspRepeal.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pRspRepeal.SessionID
        l_CustomerName=pRspRepeal.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pRspRepeal.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pRspRepeal.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pRspRepeal.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pRspRepeal.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pRspRepeal.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pRspRepeal.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pRspRepeal.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pRspRepeal.InstallID
        l_FutureSerial=pRspRepeal.FutureSerial
        l_UserID=pRspRepeal.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pRspRepeal.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pRspRepeal.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_TradeAmount=pRspRepeal.TradeAmount
        l_FutureFetchAmount=pRspRepeal.FutureFetchAmount
        l_FeePayFlag=pRspRepeal.FeePayFlag.decode(encoding="gb18030", errors="ignore");
        l_CustFee=pRspRepeal.CustFee
        l_BrokerFee=pRspRepeal.BrokerFee
        l_Message=pRspRepeal.Message.decode(encoding="gb18030", errors="ignore");
        l_Digest=pRspRepeal.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pRspRepeal.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pRspRepeal.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pRspRepeal.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pRspRepeal.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pRspRepeal.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pRspRepeal.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pRspRepeal.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pRspRepeal.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pRspRepeal.RequestID
        l_TID=pRspRepeal.TID
        l_TransferStatus=pRspRepeal.TransferStatus.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pRspRepeal.ErrorID
        l_ErrorMsg=pRspRepeal.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pRspRepeal.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_RspRepeal(RepealTimeInterval,RepealedTimes,BankRepealFlag,BrokerRepealFlag,PlateRepealSerial,BankRepealSerial,FutureRepealSerial,TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,InstallID,FutureSerial,UserID,VerifyCertNoFlag,CurrencyID,TradeAmount,FutureFetchAmount,FeePayFlag,CustFee,BrokerFee,Message,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,TransferStatus,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_RepealTimeInterval,l_RepealedTimes,l_BankRepealFlag,l_BrokerRepealFlag,l_PlateRepealSerial,l_BankRepealSerial,l_FutureRepealSerial,l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_FutureSerial,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_TradeAmount,l_FutureFetchAmount,l_FeePayFlag,l_CustFee,l_BrokerFee,l_Message,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_TransferStatus,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)


    def  pNotifyQueryAccount2DB(self, pNotifyQueryAccount):
        l_TradeCode=pNotifyQueryAccount.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pNotifyQueryAccount.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pNotifyQueryAccount.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pNotifyQueryAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pNotifyQueryAccount.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pNotifyQueryAccount.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pNotifyQueryAccount.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pNotifyQueryAccount.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pNotifyQueryAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pNotifyQueryAccount.PlateSerial
        l_LastFragment=pNotifyQueryAccount.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pNotifyQueryAccount.SessionID
        l_CustomerName=pNotifyQueryAccount.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pNotifyQueryAccount.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pNotifyQueryAccount.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pNotifyQueryAccount.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pNotifyQueryAccount.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pNotifyQueryAccount.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pNotifyQueryAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pNotifyQueryAccount.Password.decode(encoding="gb18030", errors="ignore");
        l_FutureSerial=pNotifyQueryAccount.FutureSerial
        l_InstallID=pNotifyQueryAccount.InstallID
        l_UserID=pNotifyQueryAccount.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pNotifyQueryAccount.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pNotifyQueryAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_Digest=pNotifyQueryAccount.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pNotifyQueryAccount.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pNotifyQueryAccount.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pNotifyQueryAccount.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pNotifyQueryAccount.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pNotifyQueryAccount.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pNotifyQueryAccount.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pNotifyQueryAccount.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pNotifyQueryAccount.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pNotifyQueryAccount.RequestID
        l_TID=pNotifyQueryAccount.TID
        l_BankUseAmount=pNotifyQueryAccount.BankUseAmount
        l_BankFetchAmount=pNotifyQueryAccount.BankFetchAmount
        l_ErrorID=pNotifyQueryAccount.ErrorID
        l_ErrorMsg=pNotifyQueryAccount.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pNotifyQueryAccount.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_NotifyQueryAccount(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,FutureSerial,InstallID,UserID,VerifyCertNoFlag,CurrencyID,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,BankUseAmount,BankFetchAmount,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_FutureSerial,l_InstallID,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_BankUseAmount,l_BankFetchAmount,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)


    def  pReqRepeal2DB(self, pReqRepeal):
        l_RepealTimeInterval=pReqRepeal.RepealTimeInterval
        l_RepealedTimes=pReqRepeal.RepealedTimes
        l_BankRepealFlag=pReqRepeal.BankRepealFlag.decode(encoding="gb18030", errors="ignore");
        l_BrokerRepealFlag=pReqRepeal.BrokerRepealFlag.decode(encoding="gb18030", errors="ignore");
        l_PlateRepealSerial=pReqRepeal.PlateRepealSerial
        l_BankRepealSerial=pReqRepeal.BankRepealSerial.decode(encoding="gb18030", errors="ignore");
        l_FutureRepealSerial=pReqRepeal.FutureRepealSerial
        l_TradeCode=pReqRepeal.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pReqRepeal.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pReqRepeal.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pReqRepeal.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pReqRepeal.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pReqRepeal.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pReqRepeal.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pReqRepeal.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pReqRepeal.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pReqRepeal.PlateSerial
        l_LastFragment=pReqRepeal.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pReqRepeal.SessionID
        l_CustomerName=pReqRepeal.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pReqRepeal.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pReqRepeal.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_CustType=pReqRepeal.CustType.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pReqRepeal.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pReqRepeal.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pReqRepeal.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pReqRepeal.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pReqRepeal.InstallID
        l_FutureSerial=pReqRepeal.FutureSerial
        l_UserID=pReqRepeal.UserID.decode(encoding="gb18030", errors="ignore");
        l_VerifyCertNoFlag=pReqRepeal.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pReqRepeal.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_TradeAmount=pReqRepeal.TradeAmount
        l_FutureFetchAmount=pReqRepeal.FutureFetchAmount
        l_FeePayFlag=pReqRepeal.FeePayFlag.decode(encoding="gb18030", errors="ignore");
        l_CustFee=pReqRepeal.CustFee
        l_BrokerFee=pReqRepeal.BrokerFee
        l_Message=pReqRepeal.Message.decode(encoding="gb18030", errors="ignore");
        l_Digest=pReqRepeal.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pReqRepeal.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pReqRepeal.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pReqRepeal.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pReqRepeal.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pReqRepeal.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pReqRepeal.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pReqRepeal.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pReqRepeal.OperNo.decode(encoding="gb18030", errors="ignore");
        l_RequestID=pReqRepeal.RequestID
        l_TID=pReqRepeal.TID
        l_TransferStatus=pReqRepeal.TransferStatus.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pReqRepeal.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ReqRepeal(RepealTimeInterval,RepealedTimes,BankRepealFlag,BrokerRepealFlag,PlateRepealSerial,BankRepealSerial,FutureRepealSerial,TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,CustType,BankAccount,BankPassWord,AccountID,Password,InstallID,FutureSerial,UserID,VerifyCertNoFlag,CurrencyID,TradeAmount,FutureFetchAmount,FeePayFlag,CustFee,BrokerFee,Message,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,RequestID,TID,TransferStatus,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_RepealTimeInterval,l_RepealedTimes,l_BankRepealFlag,l_BrokerRepealFlag,l_PlateRepealSerial,l_BankRepealSerial,l_FutureRepealSerial,l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_CustType,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_FutureSerial,l_UserID,l_VerifyCertNoFlag,l_CurrencyID,l_TradeAmount,l_FutureFetchAmount,l_FeePayFlag,l_CustFee,l_BrokerFee,l_Message,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_RequestID,l_TID,l_TransferStatus,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pOpenAccount2DB(self, pOpenAccount):
        l_TradeCode=pOpenAccount.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pOpenAccount.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pOpenAccount.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pOpenAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pOpenAccount.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pOpenAccount.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pOpenAccount.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pOpenAccount.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pOpenAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pOpenAccount.PlateSerial
        l_LastFragment=pOpenAccount.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pOpenAccount.SessionID
        l_CustomerName=pOpenAccount.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pOpenAccount.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pOpenAccount.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_Gender=pOpenAccount.Gender.decode(encoding="gb18030", errors="ignore");
        l_CountryCode=pOpenAccount.CountryCode.decode(encoding="gb18030", errors="ignore");
        l_CustType=pOpenAccount.CustType.decode(encoding="gb18030", errors="ignore");
        l_Address=pOpenAccount.Address.decode(encoding="gb18030", errors="ignore");
        l_ZipCode=pOpenAccount.ZipCode.decode(encoding="gb18030", errors="ignore");
        l_Telephone=pOpenAccount.Telephone.decode(encoding="gb18030", errors="ignore");
        l_MobilePhone=pOpenAccount.MobilePhone.decode(encoding="gb18030", errors="ignore");
        l_Fax=pOpenAccount.Fax.decode(encoding="gb18030", errors="ignore");
        l_EMail=pOpenAccount.EMail.decode(encoding="gb18030", errors="ignore");
        l_MoneyAccountStatus=pOpenAccount.MoneyAccountStatus.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pOpenAccount.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pOpenAccount.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pOpenAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pOpenAccount.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pOpenAccount.InstallID
        l_VerifyCertNoFlag=pOpenAccount.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pOpenAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_CashExchangeCode=pOpenAccount.CashExchangeCode.decode(encoding="gb18030", errors="ignore");
        l_Digest=pOpenAccount.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pOpenAccount.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pOpenAccount.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pOpenAccount.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pOpenAccount.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pOpenAccount.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pOpenAccount.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pOpenAccount.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pOpenAccount.OperNo.decode(encoding="gb18030", errors="ignore");
        l_TID=pOpenAccount.TID
        l_UserID=pOpenAccount.UserID.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pOpenAccount.ErrorID
        l_ErrorMsg=pOpenAccount.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pOpenAccount.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_OpenAccount(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,Gender,CountryCode,CustType,Address,ZipCode,Telephone,MobilePhone,Fax,EMail,MoneyAccountStatus,BankAccount,BankPassWord,AccountID,Password,InstallID,VerifyCertNoFlag,CurrencyID,CashExchangeCode,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,TID,UserID,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_Gender,l_CountryCode,l_CustType,l_Address,l_ZipCode,l_Telephone,l_MobilePhone,l_Fax,l_EMail,l_MoneyAccountStatus,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_VerifyCertNoFlag,l_CurrencyID,l_CashExchangeCode,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_TID,l_UserID,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pCancelAccount2DB(self, pCancelAccount):
        l_TradeCode=pCancelAccount.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pCancelAccount.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pCancelAccount.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pCancelAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pCancelAccount.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pCancelAccount.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pCancelAccount.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pCancelAccount.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pCancelAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pCancelAccount.PlateSerial
        l_LastFragment=pCancelAccount.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pCancelAccount.SessionID
        l_CustomerName=pCancelAccount.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pCancelAccount.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pCancelAccount.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_Gender=pCancelAccount.Gender.decode(encoding="gb18030", errors="ignore");
        l_CountryCode=pCancelAccount.CountryCode.decode(encoding="gb18030", errors="ignore");
        l_CustType=pCancelAccount.CustType.decode(encoding="gb18030", errors="ignore");
        l_Address=pCancelAccount.Address.decode(encoding="gb18030", errors="ignore");
        l_ZipCode=pCancelAccount.ZipCode.decode(encoding="gb18030", errors="ignore");
        l_Telephone=pCancelAccount.Telephone.decode(encoding="gb18030", errors="ignore");
        l_MobilePhone=pCancelAccount.MobilePhone.decode(encoding="gb18030", errors="ignore");
        l_Fax=pCancelAccount.Fax.decode(encoding="gb18030", errors="ignore");
        l_EMail=pCancelAccount.EMail.decode(encoding="gb18030", errors="ignore");
        l_MoneyAccountStatus=pCancelAccount.MoneyAccountStatus.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pCancelAccount.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pCancelAccount.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pCancelAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pCancelAccount.Password.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pCancelAccount.InstallID
        l_VerifyCertNoFlag=pCancelAccount.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pCancelAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_CashExchangeCode=pCancelAccount.CashExchangeCode.decode(encoding="gb18030", errors="ignore");
        l_Digest=pCancelAccount.Digest.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pCancelAccount.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_DeviceID=pCancelAccount.DeviceID.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAccType=pCancelAccount.BankSecuAccType.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pCancelAccount.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankSecuAcc=pCancelAccount.BankSecuAcc.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pCancelAccount.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pCancelAccount.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_OperNo=pCancelAccount.OperNo.decode(encoding="gb18030", errors="ignore");
        l_TID=pCancelAccount.TID
        l_UserID=pCancelAccount.UserID.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pCancelAccount.ErrorID
        l_ErrorMsg=pCancelAccount.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pCancelAccount.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_CancelAccount(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,Gender,CountryCode,CustType,Address,ZipCode,Telephone,MobilePhone,Fax,EMail,MoneyAccountStatus,BankAccount,BankPassWord,AccountID,Password,InstallID,VerifyCertNoFlag,CurrencyID,CashExchangeCode,Digest,BankAccType,DeviceID,BankSecuAccType,BrokerIDByBank,BankSecuAcc,BankPwdFlag,SecuPwdFlag,OperNo,TID,UserID,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_Gender,l_CountryCode,l_CustType,l_Address,l_ZipCode,l_Telephone,l_MobilePhone,l_Fax,l_EMail,l_MoneyAccountStatus,l_BankAccount,l_BankPassWord,l_AccountID,l_Password,l_InstallID,l_VerifyCertNoFlag,l_CurrencyID,l_CashExchangeCode,l_Digest,l_BankAccType,l_DeviceID,l_BankSecuAccType,l_BrokerIDByBank,l_BankSecuAcc,l_BankPwdFlag,l_SecuPwdFlag,l_OperNo,l_TID,l_UserID,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

    def  pChangeAccount2DB(self, pChangeAccount):
        l_TradeCode=pChangeAccount.TradeCode.decode(encoding="gb18030", errors="ignore");
        l_BankID=pChangeAccount.BankID.decode(encoding="gb18030", errors="ignore");
        l_BankBranchID=pChangeAccount.BankBranchID.decode(encoding="gb18030", errors="ignore");
        l_BrokerID=pChangeAccount.BrokerID.decode(encoding="gb18030", errors="ignore");
        l_BrokerBranchID=pChangeAccount.BrokerBranchID.decode(encoding="gb18030", errors="ignore");
        l_TradeDate=pChangeAccount.TradeDate.decode(encoding="gb18030", errors="ignore");
        l_TradeTime=pChangeAccount.TradeTime.decode(encoding="gb18030", errors="ignore");
        l_BankSerial=pChangeAccount.BankSerial.decode(encoding="gb18030", errors="ignore");
        l_TradingDay=pChangeAccount.TradingDay.decode(encoding="gb18030", errors="ignore");
        l_PlateSerial=pChangeAccount.PlateSerial
        l_LastFragment=pChangeAccount.LastFragment.decode(encoding="gb18030", errors="ignore");
        l_SessionID=pChangeAccount.SessionID
        l_CustomerName=pChangeAccount.CustomerName.decode(encoding="gb18030", errors="ignore");
        l_IdCardType=pChangeAccount.IdCardType.decode(encoding="gb18030", errors="ignore");
        l_IdentifiedCardNo=pChangeAccount.IdentifiedCardNo.decode(encoding="gb18030", errors="ignore");
        l_Gender=pChangeAccount.Gender.decode(encoding="gb18030", errors="ignore");
        l_CountryCode=pChangeAccount.CountryCode.decode(encoding="gb18030", errors="ignore");
        l_CustType=pChangeAccount.CustType.decode(encoding="gb18030", errors="ignore");
        l_Address=pChangeAccount.Address.decode(encoding="gb18030", errors="ignore");
        l_ZipCode=pChangeAccount.ZipCode.decode(encoding="gb18030", errors="ignore");
        l_Telephone=pChangeAccount.Telephone.decode(encoding="gb18030", errors="ignore");
        l_MobilePhone=pChangeAccount.MobilePhone.decode(encoding="gb18030", errors="ignore");
        l_Fax=pChangeAccount.Fax.decode(encoding="gb18030", errors="ignore");
        l_EMail=pChangeAccount.EMail.decode(encoding="gb18030", errors="ignore");
        l_MoneyAccountStatus=pChangeAccount.MoneyAccountStatus.decode(encoding="gb18030", errors="ignore");
        l_BankAccount=pChangeAccount.BankAccount.decode(encoding="gb18030", errors="ignore");
        l_BankPassWord=pChangeAccount.BankPassWord.decode(encoding="gb18030", errors="ignore");
        l_NewBankAccount=pChangeAccount.NewBankAccount.decode(encoding="gb18030", errors="ignore");
        l_NewBankPassWord=pChangeAccount.NewBankPassWord.decode(encoding="gb18030", errors="ignore");
        l_AccountID=pChangeAccount.AccountID.decode(encoding="gb18030", errors="ignore");
        l_Password=pChangeAccount.Password.decode(encoding="gb18030", errors="ignore");
        l_BankAccType=pChangeAccount.BankAccType.decode(encoding="gb18030", errors="ignore");
        l_InstallID=pChangeAccount.InstallID
        l_VerifyCertNoFlag=pChangeAccount.VerifyCertNoFlag.decode(encoding="gb18030", errors="ignore");
        l_CurrencyID=pChangeAccount.CurrencyID.decode(encoding="gb18030", errors="ignore");
        l_BrokerIDByBank=pChangeAccount.BrokerIDByBank.decode(encoding="gb18030", errors="ignore");
        l_BankPwdFlag=pChangeAccount.BankPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_SecuPwdFlag=pChangeAccount.SecuPwdFlag.decode(encoding="gb18030", errors="ignore");
        l_TID=pChangeAccount.TID
        l_Digest=pChangeAccount.Digest.decode(encoding="gb18030", errors="ignore");
        l_ErrorID=pChangeAccount.ErrorID
        l_ErrorMsg=pChangeAccount.ErrorMsg.decode(encoding="gb18030", errors="ignore");
        l_LongCustomerName=pChangeAccount.LongCustomerName.decode(encoding="gb18030", errors="ignore");

        the_SQL  ="INSERT INTO T_ChangeAccount(TradeCode,BankID,BankBranchID,BrokerID,BrokerBranchID,TradeDate,TradeTime,BankSerial,TradingDay,PlateSerial,LastFragment,SessionID,CustomerName,IdCardType,IdentifiedCardNo,Gender,CountryCode,CustType,Address,ZipCode,Telephone,MobilePhone,Fax,EMail,MoneyAccountStatus,BankAccount,BankPassWord,NewBankAccount,NewBankPassWord,AccountID,Password,BankAccType,InstallID,VerifyCertNoFlag,CurrencyID,BrokerIDByBank,BankPwdFlag,SecuPwdFlag,TID,Digest,ErrorID,ErrorMsg,LongCustomerName)VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        the_data =[( l_TradeCode,l_BankID,l_BankBranchID,l_BrokerID,l_BrokerBranchID,l_TradeDate,l_TradeTime,l_BankSerial,l_TradingDay,l_PlateSerial,l_LastFragment,l_SessionID,l_CustomerName,l_IdCardType,l_IdentifiedCardNo,l_Gender,l_CountryCode,l_CustType,l_Address,l_ZipCode,l_Telephone,l_MobilePhone,l_Fax,l_EMail,l_MoneyAccountStatus,l_BankAccount,l_BankPassWord,l_NewBankAccount,l_NewBankPassWord,l_AccountID,l_Password,l_BankAccType,l_InstallID,l_VerifyCertNoFlag,l_CurrencyID,l_BrokerIDByBank,l_BankPwdFlag,l_SecuPwdFlag,l_TID,l_Digest,l_ErrorID,l_ErrorMsg,l_LongCustomerName)]
        self.SQL2DB(the_SQL,the_data)

"""
当客户端与交易后台建立起通信连接时（还未登录前），该方法被调用。
"""
cdef extern int   TraderSpi_OnFrontConnected(self) except -1:
    try:
        self.OnFrontConnected()
    except Exception as err:
        myEnv.logger.error('OnFrontConnected', exc_info=True)

    return 0

"""
当客户端与交易后台通信连接断开时，该方法被调用。当发生这个情况后，API会自动重新连接，客户端可不做处理。
///@param nReason 错误原因
///        0x1001 网络读失败
///        0x1002 网络写失败
///        0x2001 接收心跳超时
///        0x2002 发送心跳失败
///        0x2003 收到错误报文
"""
cdef extern int   TraderSpi_OnFrontDisconnected(self
        , int nReason) except -1:
    try:
        self.OnFrontDisconnected(nReason)
    except Exception as err:
        myEnv.logger.error('OnFrontDisconnected', exc_info=True)

    return 0

"""
心跳超时警告。当长时间未收到报文时，该方法被调用。
///@param nTimeLapse 距离上次接收报文的时间
"""
cdef extern int   TraderSpi_OnHeartBeatWarning(self
        , int nTimeLapse) except -1:
    try:
        self.OnHeartBeatWarning(nTimeLapse)
    except Exception as err:
        myEnv.logger.error('OnHeartBeatWarning', exc_info=True)

    return 0

"""
客户端认证响应
"""
cdef extern int   TraderSpi_OnRspAuthenticate(self
        , CThostFtdcRspAuthenticateField *pRspAuthenticateField
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pRspAuthenticateField == NULL:
            return -1
        self.pRspAuthenticateField2DB(None if pRspAuthenticateField is NULL else py_ApiStructure.RspAuthenticateField.from_address(<size_t> pRspAuthenticateField))
        self.OnRspAuthenticate(None if pRspAuthenticateField is NULL else py_ApiStructure.RspAuthenticateField.from_address(<size_t> pRspAuthenticateField)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspAuthenticate', exc_info=True)

    return 0

"""
登录请求响应
"""
cdef extern int   TraderSpi_OnRspUserLogin(self
        , CThostFtdcRspUserLoginField *pRspUserLogin
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pRspUserLogin == NULL:
            return -1
        self.pRspUserLogin2DB(None if pRspUserLogin is NULL else py_ApiStructure.RspUserLoginField.from_address(<size_t> pRspUserLogin))
        self.OnRspUserLogin(None if pRspUserLogin is NULL else py_ApiStructure.RspUserLoginField.from_address(<size_t> pRspUserLogin)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspUserLogin', exc_info=True)

    return 0

"""
登出请求响应
"""
cdef extern int   TraderSpi_OnRspUserLogout(self
        , CThostFtdcUserLogoutField *pUserLogout
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pUserLogout == NULL:
            return -1
        self.pUserLogout2DB(None if pUserLogout is NULL else py_ApiStructure.UserLogoutField.from_address(<size_t> pUserLogout))
        self.OnRspUserLogout(None if pUserLogout is NULL else py_ApiStructure.UserLogoutField.from_address(<size_t> pUserLogout)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspUserLogout', exc_info=True)

    return 0

"""
用户口令更新请求响应
"""
cdef extern int   TraderSpi_OnRspUserPasswordUpdate(self
        , CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pUserPasswordUpdate == NULL:
            return -1
        self.pUserPasswordUpdate2DB(None if pUserPasswordUpdate is NULL else py_ApiStructure.UserPasswordUpdateField.from_address(<size_t> pUserPasswordUpdate))
        self.OnRspUserPasswordUpdate(None if pUserPasswordUpdate is NULL else py_ApiStructure.UserPasswordUpdateField.from_address(<size_t> pUserPasswordUpdate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspUserPasswordUpdate', exc_info=True)

    return 0

"""
资金账户口令更新请求响应
"""
cdef extern int   TraderSpi_OnRspTradingAccountPasswordUpdate(self
        , CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTradingAccountPasswordUpdate == NULL:
            return -1
        self.pTradingAccountPasswordUpdate2DB(None if pTradingAccountPasswordUpdate is NULL else py_ApiStructure.TradingAccountPasswordUpdateField.from_address(<size_t> pTradingAccountPasswordUpdate))
        self.OnRspTradingAccountPasswordUpdate(None if pTradingAccountPasswordUpdate is NULL else py_ApiStructure.TradingAccountPasswordUpdateField.from_address(<size_t> pTradingAccountPasswordUpdate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspTradingAccountPasswordUpdate', exc_info=True)

    return 0

"""
报单录入请求响应
"""
cdef extern int   TraderSpi_OnRspOrderInsert(self
        , CThostFtdcInputOrderField *pInputOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputOrder == NULL:
            return -1
        self.pInputOrder2DB(None if pInputOrder is NULL else py_ApiStructure.InputOrderField.from_address(<size_t> pInputOrder))
        self.OnRspOrderInsert(None if pInputOrder is NULL else py_ApiStructure.InputOrderField.from_address(<size_t> pInputOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspOrderInsert', exc_info=True)

    return 0

"""
预埋单录入请求响应
"""
cdef extern int   TraderSpi_OnRspParkedOrderInsert(self
        , CThostFtdcParkedOrderField *pParkedOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pParkedOrder == NULL:
            return -1
        self.pParkedOrder2DB(None if pParkedOrder is NULL else py_ApiStructure.ParkedOrderField.from_address(<size_t> pParkedOrder))
        self.OnRspParkedOrderInsert(None if pParkedOrder is NULL else py_ApiStructure.ParkedOrderField.from_address(<size_t> pParkedOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspParkedOrderInsert', exc_info=True)

    return 0

"""
预埋撤单录入请求响应
"""
cdef extern int   TraderSpi_OnRspParkedOrderAction(self
        , CThostFtdcParkedOrderActionField *pParkedOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pParkedOrderAction == NULL:
            return -1
        self.pParkedOrderAction2DB(None if pParkedOrderAction is NULL else py_ApiStructure.ParkedOrderActionField.from_address(<size_t> pParkedOrderAction))
        self.OnRspParkedOrderAction(None if pParkedOrderAction is NULL else py_ApiStructure.ParkedOrderActionField.from_address(<size_t> pParkedOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspParkedOrderAction', exc_info=True)

    return 0

"""
报单操作请求响应
"""
cdef extern int   TraderSpi_OnRspOrderAction(self
        , CThostFtdcInputOrderActionField *pInputOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputOrderAction == NULL:
            return -1
        self.pInputOrderAction2DB(None if pInputOrderAction is NULL else py_ApiStructure.InputOrderActionField.from_address(<size_t> pInputOrderAction))
        self.OnRspOrderAction(None if pInputOrderAction is NULL else py_ApiStructure.InputOrderActionField.from_address(<size_t> pInputOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspOrderAction', exc_info=True)

    return 0

"""
查询最大报单数量响应
"""
cdef extern int   TraderSpi_OnRspQueryMaxOrderVolume(self
        , CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pQueryMaxOrderVolume == NULL:
            return -1
        self.pQueryMaxOrderVolume2DB(None if pQueryMaxOrderVolume is NULL else py_ApiStructure.QueryMaxOrderVolumeField.from_address(<size_t> pQueryMaxOrderVolume))
        self.OnRspQueryMaxOrderVolume(None if pQueryMaxOrderVolume is NULL else py_ApiStructure.QueryMaxOrderVolumeField.from_address(<size_t> pQueryMaxOrderVolume)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQueryMaxOrderVolume', exc_info=True)

    return 0

"""
投资者结算结果确认响应
"""
cdef extern int   TraderSpi_OnRspSettlementInfoConfirm(self
        , CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pSettlementInfoConfirm == NULL:
            return -1
        self.pSettlementInfoConfirm2DB(None if pSettlementInfoConfirm is NULL else py_ApiStructure.SettlementInfoConfirmField.from_address(<size_t> pSettlementInfoConfirm))
        self.OnRspSettlementInfoConfirm(None if pSettlementInfoConfirm is NULL else py_ApiStructure.SettlementInfoConfirmField.from_address(<size_t> pSettlementInfoConfirm)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspSettlementInfoConfirm', exc_info=True)

    return 0

"""
删除预埋单响应
"""
cdef extern int   TraderSpi_OnRspRemoveParkedOrder(self
        , CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pRemoveParkedOrder == NULL:
            return -1
        self.pRemoveParkedOrder2DB(None if pRemoveParkedOrder is NULL else py_ApiStructure.RemoveParkedOrderField.from_address(<size_t> pRemoveParkedOrder))
        self.OnRspRemoveParkedOrder(None if pRemoveParkedOrder is NULL else py_ApiStructure.RemoveParkedOrderField.from_address(<size_t> pRemoveParkedOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspRemoveParkedOrder', exc_info=True)

    return 0

"""
删除预埋撤单响应
"""
cdef extern int   TraderSpi_OnRspRemoveParkedOrderAction(self
        , CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pRemoveParkedOrderAction == NULL:
            return -1
        self.pRemoveParkedOrderAction2DB(None if pRemoveParkedOrderAction is NULL else py_ApiStructure.RemoveParkedOrderActionField.from_address(<size_t> pRemoveParkedOrderAction))
        self.OnRspRemoveParkedOrderAction(None if pRemoveParkedOrderAction is NULL else py_ApiStructure.RemoveParkedOrderActionField.from_address(<size_t> pRemoveParkedOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspRemoveParkedOrderAction', exc_info=True)

    return 0

"""
执行宣告录入请求响应
"""
cdef extern int   TraderSpi_OnRspExecOrderInsert(self
        , CThostFtdcInputExecOrderField *pInputExecOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputExecOrder == NULL:
            return -1
        self.pInputExecOrder2DB(None if pInputExecOrder is NULL else py_ApiStructure.InputExecOrderField.from_address(<size_t> pInputExecOrder))
        self.OnRspExecOrderInsert(None if pInputExecOrder is NULL else py_ApiStructure.InputExecOrderField.from_address(<size_t> pInputExecOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspExecOrderInsert', exc_info=True)

    return 0

"""
执行宣告操作请求响应
"""
cdef extern int   TraderSpi_OnRspExecOrderAction(self
        , CThostFtdcInputExecOrderActionField *pInputExecOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputExecOrderAction == NULL:
            return -1
        self.pInputExecOrderAction2DB(None if pInputExecOrderAction is NULL else py_ApiStructure.InputExecOrderActionField.from_address(<size_t> pInputExecOrderAction))
        self.OnRspExecOrderAction(None if pInputExecOrderAction is NULL else py_ApiStructure.InputExecOrderActionField.from_address(<size_t> pInputExecOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspExecOrderAction', exc_info=True)

    return 0

"""
询价录入请求响应
"""
cdef extern int   TraderSpi_OnRspForQuoteInsert(self
        , CThostFtdcInputForQuoteField *pInputForQuote
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputForQuote == NULL:
            return -1
        self.pInputForQuote2DB(None if pInputForQuote is NULL else py_ApiStructure.InputForQuoteField.from_address(<size_t> pInputForQuote))
        self.OnRspForQuoteInsert(None if pInputForQuote is NULL else py_ApiStructure.InputForQuoteField.from_address(<size_t> pInputForQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspForQuoteInsert', exc_info=True)

    return 0

"""
报价录入请求响应
"""
cdef extern int   TraderSpi_OnRspQuoteInsert(self
        , CThostFtdcInputQuoteField *pInputQuote
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputQuote == NULL:
            return -1
        self.pInputQuote2DB(None if pInputQuote is NULL else py_ApiStructure.InputQuoteField.from_address(<size_t> pInputQuote))
        self.OnRspQuoteInsert(None if pInputQuote is NULL else py_ApiStructure.InputQuoteField.from_address(<size_t> pInputQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQuoteInsert', exc_info=True)

    return 0

"""
报价操作请求响应
"""
cdef extern int   TraderSpi_OnRspQuoteAction(self
        , CThostFtdcInputQuoteActionField *pInputQuoteAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputQuoteAction == NULL:
            return -1
        self.pInputQuoteAction2DB(None if pInputQuoteAction is NULL else py_ApiStructure.InputQuoteActionField.from_address(<size_t> pInputQuoteAction))
        self.OnRspQuoteAction(None if pInputQuoteAction is NULL else py_ApiStructure.InputQuoteActionField.from_address(<size_t> pInputQuoteAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQuoteAction', exc_info=True)

    return 0

"""
批量报单操作请求响应
"""
cdef extern int   TraderSpi_OnRspBatchOrderAction(self
        , CThostFtdcInputBatchOrderActionField *pInputBatchOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputBatchOrderAction == NULL:
            return -1
        self.pInputBatchOrderAction2DB(None if pInputBatchOrderAction is NULL else py_ApiStructure.InputBatchOrderActionField.from_address(<size_t> pInputBatchOrderAction))
        self.OnRspBatchOrderAction(None if pInputBatchOrderAction is NULL else py_ApiStructure.InputBatchOrderActionField.from_address(<size_t> pInputBatchOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspBatchOrderAction', exc_info=True)

    return 0

"""
期权自对冲录入请求响应
"""
cdef extern int   TraderSpi_OnRspOptionSelfCloseInsert(self
        , CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputOptionSelfClose == NULL:
            return -1
        self.pInputOptionSelfClose2DB(None if pInputOptionSelfClose is NULL else py_ApiStructure.InputOptionSelfCloseField.from_address(<size_t> pInputOptionSelfClose))
        self.OnRspOptionSelfCloseInsert(None if pInputOptionSelfClose is NULL else py_ApiStructure.InputOptionSelfCloseField.from_address(<size_t> pInputOptionSelfClose)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspOptionSelfCloseInsert', exc_info=True)

    return 0

"""
期权自对冲操作请求响应
"""
cdef extern int   TraderSpi_OnRspOptionSelfCloseAction(self
        , CThostFtdcInputOptionSelfCloseActionField *pInputOptionSelfCloseAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputOptionSelfCloseAction == NULL:
            return -1
        self.pInputOptionSelfCloseAction2DB(None if pInputOptionSelfCloseAction is NULL else py_ApiStructure.InputOptionSelfCloseActionField.from_address(<size_t> pInputOptionSelfCloseAction))
        self.OnRspOptionSelfCloseAction(None if pInputOptionSelfCloseAction is NULL else py_ApiStructure.InputOptionSelfCloseActionField.from_address(<size_t> pInputOptionSelfCloseAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspOptionSelfCloseAction', exc_info=True)

    return 0

"""
申请组合录入请求响应
"""
cdef extern int   TraderSpi_OnRspCombActionInsert(self
        , CThostFtdcInputCombActionField *pInputCombAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInputCombAction == NULL:
            return -1
        self.pInputCombAction2DB(None if pInputCombAction is NULL else py_ApiStructure.InputCombActionField.from_address(<size_t> pInputCombAction))
        self.OnRspCombActionInsert(None if pInputCombAction is NULL else py_ApiStructure.InputCombActionField.from_address(<size_t> pInputCombAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspCombActionInsert', exc_info=True)

    return 0

"""
请求查询报单响应
"""
cdef extern int   TraderSpi_OnRspQryOrder(self
        , CThostFtdcOrderField *pOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pOrder == NULL:
            return -1
        self.pOrder2DB(None if pOrder is NULL else py_ApiStructure.OrderField.from_address(<size_t> pOrder))
        self.OnRspQryOrder(None if pOrder is NULL else py_ApiStructure.OrderField.from_address(<size_t> pOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast) 
        
    except Exception as err:
        myEnv.logger.error('OnRspQryOrder', exc_info=True)

    return 0

"""
请求查询成交响应
"""
cdef extern int   TraderSpi_OnRspQryTrade(self
        , CThostFtdcTradeField *pTrade
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTrade == NULL:
            return -1
        self.pTrade2DB(None if pTrade is NULL else py_ApiStructure.TradeField.from_address(<size_t> pTrade))
        self.OnRspQryTrade(None if pTrade is NULL else py_ApiStructure.TradeField.from_address(<size_t> pTrade)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTrade', exc_info=True)

    return 0

"""
请求查询投资者持仓响应
"""
cdef extern int   TraderSpi_OnRspQryInvestorPosition(self
        , CThostFtdcInvestorPositionField *pInvestorPosition
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestorPosition == NULL:
            return -1
        self.pInvestorPosition2DB(None if pInvestorPosition is NULL else py_ApiStructure.InvestorPositionField.from_address(<size_t> pInvestorPosition))
        self.OnRspQryInvestorPosition(None if pInvestorPosition is NULL else py_ApiStructure.InvestorPositionField.from_address(<size_t> pInvestorPosition)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestorPosition', exc_info=True)

    return 0

"""
请求查询资金账户响应
"""
cdef extern int   TraderSpi_OnRspQryTradingAccount(self
        , CThostFtdcTradingAccountField *pTradingAccount
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTradingAccount == NULL:
            return -1
        self.pTradingAccount2DB(None if pTradingAccount is NULL else py_ApiStructure.TradingAccountField.from_address(<size_t> pTradingAccount))
        self.OnRspQryTradingAccount(None if pTradingAccount is NULL else py_ApiStructure.TradingAccountField.from_address(<size_t> pTradingAccount)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTradingAccount', exc_info=True)

    return 0

"""
请求查询投资者响应
"""
cdef extern int   TraderSpi_OnRspQryInvestor(self
        , CThostFtdcInvestorField *pInvestor
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestor == NULL:
            return -1
        self.pInvestor2DB(None if pInvestor is NULL else py_ApiStructure.InvestorField.from_address(<size_t> pInvestor))
        self.OnRspQryInvestor(None if pInvestor is NULL else py_ApiStructure.InvestorField.from_address(<size_t> pInvestor)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestor', exc_info=True)

    return 0

"""
请求查询交易编码响应
"""
cdef extern int   TraderSpi_OnRspQryTradingCode(self
        , CThostFtdcTradingCodeField *pTradingCode
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTradingCode == NULL:
            return -1
        self.pTradingCode2DB(None if pTradingCode is NULL else py_ApiStructure.TradingCodeField.from_address(<size_t> pTradingCode))
        self.OnRspQryTradingCode(None if pTradingCode is NULL else py_ApiStructure.TradingCodeField.from_address(<size_t> pTradingCode)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTradingCode', exc_info=True)

    return 0

"""
请求查询合约保证金率响应
"""
cdef extern int   TraderSpi_OnRspQryInstrumentMarginRate(self
        , CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInstrumentMarginRate == NULL:
            return -1
        self.pInstrumentMarginRate2DB(None if pInstrumentMarginRate is NULL else py_ApiStructure.InstrumentMarginRateField.from_address(<size_t> pInstrumentMarginRate))
        self.OnRspQryInstrumentMarginRate(None if pInstrumentMarginRate is NULL else py_ApiStructure.InstrumentMarginRateField.from_address(<size_t> pInstrumentMarginRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInstrumentMarginRate', exc_info=True)

    return 0

"""
请求查询合约手续费率响应
"""
cdef extern int   TraderSpi_OnRspQryInstrumentCommissionRate(self
        , CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInstrumentCommissionRate == NULL:
            return -1
        self.pInstrumentCommissionRate2DB(None if pInstrumentCommissionRate is NULL else py_ApiStructure.InstrumentCommissionRateField.from_address(<size_t> pInstrumentCommissionRate))
        self.OnRspQryInstrumentCommissionRate(None if pInstrumentCommissionRate is NULL else py_ApiStructure.InstrumentCommissionRateField.from_address(<size_t> pInstrumentCommissionRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInstrumentCommissionRate', exc_info=True)

    return 0

"""
请求查询交易所响应
"""
cdef extern int   TraderSpi_OnRspQryExchange(self
        , CThostFtdcExchangeField *pExchange
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pExchange == NULL:
            return -1
        self.pExchange2DB(None if pExchange is NULL else py_ApiStructure.ExchangeField.from_address(<size_t> pExchange))
        self.OnRspQryExchange(None if pExchange is NULL else py_ApiStructure.ExchangeField.from_address(<size_t> pExchange)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryExchange', exc_info=True)

    return 0

"""
请求查询产品响应
"""
cdef extern int   TraderSpi_OnRspQryProduct(self
        , CThostFtdcProductField *pProduct
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pProduct == NULL:
            return -1
        self.pProduct2DB(None if pProduct is NULL else py_ApiStructure.ProductField.from_address(<size_t> pProduct))
        self.OnRspQryProduct(None if pProduct is NULL else py_ApiStructure.ProductField.from_address(<size_t> pProduct)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryProduct', exc_info=True)

    return 0

"""
请求查询合约响应
"""
cdef extern int   TraderSpi_OnRspQryInstrument(self
        , CThostFtdcInstrumentField *pInstrument
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInstrument == NULL:
            return -1
        self.pInstrument2DB(None if pInstrument is NULL else py_ApiStructure.InstrumentField.from_address(<size_t> pInstrument))
        self.OnRspQryInstrument(None if pInstrument is NULL else py_ApiStructure.InstrumentField.from_address(<size_t> pInstrument)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInstrument', exc_info=True)

    return 0

"""
请求查询行情响应
"""
cdef extern int   TraderSpi_OnRspQryDepthMarketData(self
        , CThostFtdcDepthMarketDataField *pDepthMarketData
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pDepthMarketData == NULL:
            return -1
        self.pDepthMarketData2DB(None if pDepthMarketData is NULL else py_ApiStructure.DepthMarketDataField.from_address(<size_t> pDepthMarketData))
        self.OnRspQryDepthMarketData(None if pDepthMarketData is NULL else py_ApiStructure.DepthMarketDataField.from_address(<size_t> pDepthMarketData)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryDepthMarketData', exc_info=True)

    return 0

"""
请求查询投资者结算结果响应
"""
cdef extern int   TraderSpi_OnRspQrySettlementInfo(self
        , CThostFtdcSettlementInfoField *pSettlementInfo
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pSettlementInfo == NULL:
            return -1
        self.pSettlementInfo2DB(None if pSettlementInfo is NULL else py_ApiStructure.SettlementInfoField.from_address(<size_t> pSettlementInfo))
        self.OnRspQrySettlementInfo(None if pSettlementInfo is NULL else py_ApiStructure.SettlementInfoField.from_address(<size_t> pSettlementInfo)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQrySettlementInfo', exc_info=True)

    return 0

"""
请求查询转帐银行响应
"""
cdef extern int   TraderSpi_OnRspQryTransferBank(self
        , CThostFtdcTransferBankField *pTransferBank
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTransferBank == NULL:
            return -1
        self.pTransferBank2DB(None if pTransferBank is NULL else py_ApiStructure.TransferBankField.from_address(<size_t> pTransferBank))
        self.OnRspQryTransferBank(None if pTransferBank is NULL else py_ApiStructure.TransferBankField.from_address(<size_t> pTransferBank)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTransferBank', exc_info=True)

    return 0

"""
请求查询投资者持仓明细响应
"""
cdef extern int   TraderSpi_OnRspQryInvestorPositionDetail(self
        , CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestorPositionDetail == NULL:
            return -1
        self.pInvestorPositionDetail2DB(None if pInvestorPositionDetail is NULL else py_ApiStructure.InvestorPositionDetailField.from_address(<size_t> pInvestorPositionDetail))
        self.OnRspQryInvestorPositionDetail(None if pInvestorPositionDetail is NULL else py_ApiStructure.InvestorPositionDetailField.from_address(<size_t> pInvestorPositionDetail)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestorPositionDetail', exc_info=True)

    return 0

"""
请求查询客户通知响应
"""
cdef extern int   TraderSpi_OnRspQryNotice(self
        , CThostFtdcNoticeField *pNotice
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pNotice == NULL:
            return -1
        self.pNotice2DB(None if pNotice is NULL else py_ApiStructure.NoticeField.from_address(<size_t> pNotice))
        self.OnRspQryNotice(None if pNotice is NULL else py_ApiStructure.NoticeField.from_address(<size_t> pNotice)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryNotice', exc_info=True)

    return 0

"""
请求查询结算信息确认响应
"""
cdef extern int   TraderSpi_OnRspQrySettlementInfoConfirm(self
        , CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pSettlementInfoConfirm == NULL:
            return -1
        self.pSettlementInfoConfirm2DB(None if pSettlementInfoConfirm is NULL else py_ApiStructure.SettlementInfoConfirmField.from_address(<size_t> pSettlementInfoConfirm))
        self.OnRspQrySettlementInfoConfirm(None if pSettlementInfoConfirm is NULL else py_ApiStructure.SettlementInfoConfirmField.from_address(<size_t> pSettlementInfoConfirm)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQrySettlementInfoConfirm', exc_info=True)

    return 0

"""
请求查询投资者持仓明细响应
"""
cdef extern int   TraderSpi_OnRspQryInvestorPositionCombineDetail(self
        , CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestorPositionCombineDetail == NULL:
            return -1
        self.pInvestorPositionCombineDetail2DB(None if pInvestorPositionCombineDetail is NULL else py_ApiStructure.InvestorPositionCombineDetailField.from_address(<size_t> pInvestorPositionCombineDetail))
        self.OnRspQryInvestorPositionCombineDetail(None if pInvestorPositionCombineDetail is NULL else py_ApiStructure.InvestorPositionCombineDetailField.from_address(<size_t> pInvestorPositionCombineDetail)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestorPositionCombineDetail', exc_info=True)

    return 0

"""
查询保证金监管系统经纪公司资金账户密钥响应
"""
cdef extern int   TraderSpi_OnRspQryCFMMCTradingAccountKey(self
        , CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pCFMMCTradingAccountKey == NULL:
            return -1
        self.pCFMMCTradingAccountKey2DB(None if pCFMMCTradingAccountKey is NULL else py_ApiStructure.CFMMCTradingAccountKeyField.from_address(<size_t> pCFMMCTradingAccountKey))
        self.OnRspQryCFMMCTradingAccountKey(None if pCFMMCTradingAccountKey is NULL else py_ApiStructure.CFMMCTradingAccountKeyField.from_address(<size_t> pCFMMCTradingAccountKey)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryCFMMCTradingAccountKey', exc_info=True)

    return 0

"""
请求查询仓单折抵信息响应
"""
cdef extern int   TraderSpi_OnRspQryEWarrantOffset(self
        , CThostFtdcEWarrantOffsetField *pEWarrantOffset
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pEWarrantOffset == NULL:
            return -1
        self.pEWarrantOffset2DB(None if pEWarrantOffset is NULL else py_ApiStructure.EWarrantOffsetField.from_address(<size_t> pEWarrantOffset))
        self.OnRspQryEWarrantOffset(None if pEWarrantOffset is NULL else py_ApiStructure.EWarrantOffsetField.from_address(<size_t> pEWarrantOffset)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryEWarrantOffset', exc_info=True)

    return 0

"""
请求查询投资者品种/跨品种保证金响应
"""
cdef extern int   TraderSpi_OnRspQryInvestorProductGroupMargin(self
        , CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestorProductGroupMargin == NULL:
            return -1
        self.pInvestorProductGroupMargin2DB(None if pInvestorProductGroupMargin is NULL else py_ApiStructure.InvestorProductGroupMarginField.from_address(<size_t> pInvestorProductGroupMargin))
        self.OnRspQryInvestorProductGroupMargin(None if pInvestorProductGroupMargin is NULL else py_ApiStructure.InvestorProductGroupMarginField.from_address(<size_t> pInvestorProductGroupMargin)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestorProductGroupMargin', exc_info=True)

    return 0

"""
请求查询交易所保证金率响应
"""
cdef extern int   TraderSpi_OnRspQryExchangeMarginRate(self
        , CThostFtdcExchangeMarginRateField *pExchangeMarginRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pExchangeMarginRate == NULL:
            return -1
        self.pExchangeMarginRate2DB(None if pExchangeMarginRate is NULL else py_ApiStructure.ExchangeMarginRateField.from_address(<size_t> pExchangeMarginRate))
        self.OnRspQryExchangeMarginRate(None if pExchangeMarginRate is NULL else py_ApiStructure.ExchangeMarginRateField.from_address(<size_t> pExchangeMarginRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryExchangeMarginRate', exc_info=True)

    return 0

"""
请求查询交易所调整保证金率响应
"""
cdef extern int   TraderSpi_OnRspQryExchangeMarginRateAdjust(self
        , CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pExchangeMarginRateAdjust == NULL:
            return -1
        self.pExchangeMarginRateAdjust2DB(None if pExchangeMarginRateAdjust is NULL else py_ApiStructure.ExchangeMarginRateAdjustField.from_address(<size_t> pExchangeMarginRateAdjust))
        self.OnRspQryExchangeMarginRateAdjust(None if pExchangeMarginRateAdjust is NULL else py_ApiStructure.ExchangeMarginRateAdjustField.from_address(<size_t> pExchangeMarginRateAdjust)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryExchangeMarginRateAdjust', exc_info=True)

    return 0

"""
请求查询汇率响应
"""
cdef extern int   TraderSpi_OnRspQryExchangeRate(self
        , CThostFtdcExchangeRateField *pExchangeRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pExchangeRate == NULL:
            return -1
        self.pExchangeRate2DB(None if pExchangeRate is NULL else py_ApiStructure.ExchangeRateField.from_address(<size_t> pExchangeRate))
        self.OnRspQryExchangeRate(None if pExchangeRate is NULL else py_ApiStructure.ExchangeRateField.from_address(<size_t> pExchangeRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryExchangeRate', exc_info=True)

    return 0

"""
请求查询二级代理操作员银期权限响应
"""
cdef extern int   TraderSpi_OnRspQrySecAgentACIDMap(self
        , CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pSecAgentACIDMap == NULL:
            return -1
        self.pSecAgentACIDMap2DB(None if pSecAgentACIDMap is NULL else py_ApiStructure.SecAgentACIDMapField.from_address(<size_t> pSecAgentACIDMap))
        self.OnRspQrySecAgentACIDMap(None if pSecAgentACIDMap is NULL else py_ApiStructure.SecAgentACIDMapField.from_address(<size_t> pSecAgentACIDMap)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQrySecAgentACIDMap', exc_info=True)

    return 0

"""
请求查询产品报价汇率
"""
cdef extern int   TraderSpi_OnRspQryProductExchRate(self
        , CThostFtdcProductExchRateField *pProductExchRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pProductExchRate == NULL:
            return -1
        self.pProductExchRate2DB(None if pProductExchRate is NULL else py_ApiStructure.ProductExchRateField.from_address(<size_t> pProductExchRate))
        self.OnRspQryProductExchRate(None if pProductExchRate is NULL else py_ApiStructure.ProductExchRateField.from_address(<size_t> pProductExchRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryProductExchRate', exc_info=True)

    return 0

"""
请求查询产品组
"""
cdef extern int   TraderSpi_OnRspQryProductGroup(self
        , CThostFtdcProductGroupField *pProductGroup
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pProductGroup == NULL:
            return -1
        self.pProductGroup2DB(None if pProductGroup is NULL else py_ApiStructure.ProductGroupField.from_address(<size_t> pProductGroup))
        self.OnRspQryProductGroup(None if pProductGroup is NULL else py_ApiStructure.ProductGroupField.from_address(<size_t> pProductGroup)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryProductGroup', exc_info=True)

    return 0

"""
请求查询做市商合约手续费率响应
"""
cdef extern int   TraderSpi_OnRspQryMMInstrumentCommissionRate(self
        , CThostFtdcMMInstrumentCommissionRateField *pMMInstrumentCommissionRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pMMInstrumentCommissionRate == NULL:
            return -1
        self.pMMInstrumentCommissionRate2DB(None if pMMInstrumentCommissionRate is NULL else py_ApiStructure.MMInstrumentCommissionRateField.from_address(<size_t> pMMInstrumentCommissionRate))
        self.OnRspQryMMInstrumentCommissionRate(None if pMMInstrumentCommissionRate is NULL else py_ApiStructure.MMInstrumentCommissionRateField.from_address(<size_t> pMMInstrumentCommissionRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryMMInstrumentCommissionRate', exc_info=True)

    return 0

"""
请求查询做市商期权合约手续费响应
"""
cdef extern int   TraderSpi_OnRspQryMMOptionInstrCommRate(self
        , CThostFtdcMMOptionInstrCommRateField *pMMOptionInstrCommRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pMMOptionInstrCommRate == NULL:
            return -1
        self.pMMOptionInstrCommRate2DB(None if pMMOptionInstrCommRate is NULL else py_ApiStructure.MMOptionInstrCommRateField.from_address(<size_t> pMMOptionInstrCommRate))
        self.OnRspQryMMOptionInstrCommRate(None if pMMOptionInstrCommRate is NULL else py_ApiStructure.MMOptionInstrCommRateField.from_address(<size_t> pMMOptionInstrCommRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryMMOptionInstrCommRate', exc_info=True)

    return 0

"""
请求查询报单手续费响应
"""
cdef extern int   TraderSpi_OnRspQryInstrumentOrderCommRate(self
        , CThostFtdcInstrumentOrderCommRateField *pInstrumentOrderCommRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInstrumentOrderCommRate == NULL:
            return -1
        self.pInstrumentOrderCommRate2DB(None if pInstrumentOrderCommRate is NULL else py_ApiStructure.InstrumentOrderCommRateField.from_address(<size_t> pInstrumentOrderCommRate))
        self.OnRspQryInstrumentOrderCommRate(None if pInstrumentOrderCommRate is NULL else py_ApiStructure.InstrumentOrderCommRateField.from_address(<size_t> pInstrumentOrderCommRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInstrumentOrderCommRate', exc_info=True)

    return 0

"""
请求查询资金账户响应
"""
cdef extern int   TraderSpi_OnRspQrySecAgentTradingAccount(self
        , CThostFtdcTradingAccountField *pTradingAccount
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTradingAccount == NULL:
            return -1
        self.pTradingAccount2DB(None if pTradingAccount is NULL else py_ApiStructure.TradingAccountField.from_address(<size_t> pTradingAccount))
        self.OnRspQrySecAgentTradingAccount(None if pTradingAccount is NULL else py_ApiStructure.TradingAccountField.from_address(<size_t> pTradingAccount)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQrySecAgentTradingAccount', exc_info=True)

    return 0

"""
请求查询二级代理商资金校验模式响应
"""
cdef extern int   TraderSpi_OnRspQrySecAgentCheckMode(self
        , CThostFtdcSecAgentCheckModeField *pSecAgentCheckMode
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pSecAgentCheckMode == NULL:
            return -1
        self.pSecAgentCheckMode2DB(None if pSecAgentCheckMode is NULL else py_ApiStructure.SecAgentCheckModeField.from_address(<size_t> pSecAgentCheckMode))
        self.OnRspQrySecAgentCheckMode(None if pSecAgentCheckMode is NULL else py_ApiStructure.SecAgentCheckModeField.from_address(<size_t> pSecAgentCheckMode)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQrySecAgentCheckMode', exc_info=True)

    return 0

"""
请求查询期权交易成本响应
"""
cdef extern int   TraderSpi_OnRspQryOptionInstrTradeCost(self
        , CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pOptionInstrTradeCost == NULL:
            return -1
        self.pOptionInstrTradeCost2DB(None if pOptionInstrTradeCost is NULL else py_ApiStructure.OptionInstrTradeCostField.from_address(<size_t> pOptionInstrTradeCost))
        self.OnRspQryOptionInstrTradeCost(None if pOptionInstrTradeCost is NULL else py_ApiStructure.OptionInstrTradeCostField.from_address(<size_t> pOptionInstrTradeCost)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryOptionInstrTradeCost', exc_info=True)

    return 0

"""
请求查询期权合约手续费响应
"""
cdef extern int   TraderSpi_OnRspQryOptionInstrCommRate(self
        , CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pOptionInstrCommRate == NULL:
            return -1
        self.pOptionInstrCommRate2DB(None if pOptionInstrCommRate is NULL else py_ApiStructure.OptionInstrCommRateField.from_address(<size_t> pOptionInstrCommRate))
        self.OnRspQryOptionInstrCommRate(None if pOptionInstrCommRate is NULL else py_ApiStructure.OptionInstrCommRateField.from_address(<size_t> pOptionInstrCommRate)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryOptionInstrCommRate', exc_info=True)

    return 0

"""
请求查询执行宣告响应
"""
cdef extern int   TraderSpi_OnRspQryExecOrder(self
        , CThostFtdcExecOrderField *pExecOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pExecOrder == NULL:
            return -1
        self.pExecOrder2DB(None if pExecOrder is NULL else py_ApiStructure.ExecOrderField.from_address(<size_t> pExecOrder))
        self.OnRspQryExecOrder(None if pExecOrder is NULL else py_ApiStructure.ExecOrderField.from_address(<size_t> pExecOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryExecOrder', exc_info=True)

    return 0

"""
请求查询询价响应
"""
cdef extern int   TraderSpi_OnRspQryForQuote(self
        , CThostFtdcForQuoteField *pForQuote
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pForQuote == NULL:
            return -1
        self.pForQuote2DB(None if pForQuote is NULL else py_ApiStructure.ForQuoteField.from_address(<size_t> pForQuote))
        self.OnRspQryForQuote(None if pForQuote is NULL else py_ApiStructure.ForQuoteField.from_address(<size_t> pForQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryForQuote', exc_info=True)

    return 0

"""
请求查询报价响应
"""
cdef extern int   TraderSpi_OnRspQryQuote(self
        , CThostFtdcQuoteField *pQuote
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pQuote == NULL:
            return -1
        self.pQuote2DB(None if pQuote is NULL else py_ApiStructure.QuoteField.from_address(<size_t> pQuote))
        self.OnRspQryQuote(None if pQuote is NULL else py_ApiStructure.QuoteField.from_address(<size_t> pQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryQuote', exc_info=True)

    return 0

"""
请求查询期权自对冲响应
"""
cdef extern int   TraderSpi_OnRspQryOptionSelfClose(self
        , CThostFtdcOptionSelfCloseField *pOptionSelfClose
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pOptionSelfClose == NULL:
            return -1
        self.pOptionSelfClose2DB(None if pOptionSelfClose is NULL else py_ApiStructure.OptionSelfCloseField.from_address(<size_t> pOptionSelfClose))
        self.OnRspQryOptionSelfClose(None if pOptionSelfClose is NULL else py_ApiStructure.OptionSelfCloseField.from_address(<size_t> pOptionSelfClose)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryOptionSelfClose', exc_info=True)

    return 0

"""
请求查询投资单元响应
"""
cdef extern int   TraderSpi_OnRspQryInvestUnit(self
        , CThostFtdcInvestUnitField *pInvestUnit
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pInvestUnit == NULL:
            return -1
        self.pInvestUnit2DB(None if pInvestUnit is NULL else py_ApiStructure.InvestUnitField.from_address(<size_t> pInvestUnit))
        self.OnRspQryInvestUnit(None if pInvestUnit is NULL else py_ApiStructure.InvestUnitField.from_address(<size_t> pInvestUnit)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryInvestUnit', exc_info=True)

    return 0

"""
请求查询组合合约安全系数响应
"""
cdef extern int   TraderSpi_OnRspQryCombInstrumentGuard(self
        , CThostFtdcCombInstrumentGuardField *pCombInstrumentGuard
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pCombInstrumentGuard == NULL:
            return -1
        self.pCombInstrumentGuard2DB(None if pCombInstrumentGuard is NULL else py_ApiStructure.CombInstrumentGuardField.from_address(<size_t> pCombInstrumentGuard))
        self.OnRspQryCombInstrumentGuard(None if pCombInstrumentGuard is NULL else py_ApiStructure.CombInstrumentGuardField.from_address(<size_t> pCombInstrumentGuard)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryCombInstrumentGuard', exc_info=True)

    return 0

"""
请求查询申请组合响应
"""
cdef extern int   TraderSpi_OnRspQryCombAction(self
        , CThostFtdcCombActionField *pCombAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pCombAction == NULL:
            return -1
        self.pCombAction2DB(None if pCombAction is NULL else py_ApiStructure.CombActionField.from_address(<size_t> pCombAction))
        self.OnRspQryCombAction(None if pCombAction is NULL else py_ApiStructure.CombActionField.from_address(<size_t> pCombAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryCombAction', exc_info=True)

    return 0

"""
请求查询转帐流水响应
"""
cdef extern int   TraderSpi_OnRspQryTransferSerial(self
        , CThostFtdcTransferSerialField *pTransferSerial
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTransferSerial == NULL:
            return -1
        self.pTransferSerial2DB(None if pTransferSerial is NULL else py_ApiStructure.TransferSerialField.from_address(<size_t> pTransferSerial))
        self.OnRspQryTransferSerial(None if pTransferSerial is NULL else py_ApiStructure.TransferSerialField.from_address(<size_t> pTransferSerial)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTransferSerial', exc_info=True)

    return 0

"""
请求查询银期签约关系响应
"""
cdef extern int   TraderSpi_OnRspQryAccountregister(self
        , CThostFtdcAccountregisterField *pAccountregister
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pAccountregister == NULL:
            return -1
        self.pAccountregister2DB(None if pAccountregister is NULL else py_ApiStructure.AccountregisterField.from_address(<size_t> pAccountregister))
        self.OnRspQryAccountregister(None if pAccountregister is NULL else py_ApiStructure.AccountregisterField.from_address(<size_t> pAccountregister)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryAccountregister', exc_info=True)

    return 0

"""
错误应答
"""
cdef extern int   TraderSpi_OnRspError(self
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pRspInfo == NULL:
            return -1
        self.pRspInfo2DB(None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
        self.OnRspError(None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspError', exc_info=True)

    return 0

"""
报单通知
"""
cdef extern int   TraderSpi_OnRtnOrder(self
        , CThostFtdcOrderField *pOrder) except -1:
    try:
        if pOrder == NULL:
            return -1
        self.pOrder2DB(None if pOrder is NULL else py_ApiStructure.OrderField.from_address(<size_t> pOrder))
        self.OnRtnOrder(None if pOrder is NULL else py_ApiStructure.OrderField.from_address(<size_t> pOrder))
    except Exception as err:
        myEnv.logger.error('OnRtnOrder', exc_info=True)

    return 0

"""
成交通知
"""
cdef extern int   TraderSpi_OnRtnTrade(self
        , CThostFtdcTradeField *pTrade) except -1:
    try:
        if pTrade == NULL:
            return -1
        self.OnRtnTrade(None if pTrade is NULL else py_ApiStructure.TradeField.from_address(<size_t> pTrade))
        self.pTrade2DB(None  if pTrade is NULL else py_ApiStructure.TradeField.from_address(<size_t> pTrade))

    except Exception as err:
        myEnv.logger.error('OnRtnTrade', exc_info=True)

    return 0

"""
报单录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnOrderInsert(self
        , CThostFtdcInputOrderField *pInputOrder
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputOrder == NULL:
            return -1
        self.pInputOrder2DB(None if pInputOrder is NULL else py_ApiStructure.InputOrderField.from_address(<size_t> pInputOrder))
        self.OnErrRtnOrderInsert(None if pInputOrder is NULL else py_ApiStructure.InputOrderField.from_address(<size_t> pInputOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnOrderInsert', exc_info=True)

    return 0

"""
报单操作错误回报
"""
cdef extern int   TraderSpi_OnErrRtnOrderAction(self
        , CThostFtdcOrderActionField *pOrderAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pOrderAction == NULL:
            return -1
        self.pOrderAction2DB(None if pOrderAction is NULL else py_ApiStructure.OrderActionField.from_address(<size_t> pOrderAction))
        self.OnErrRtnOrderAction(None if pOrderAction is NULL else py_ApiStructure.OrderActionField.from_address(<size_t> pOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnOrderAction', exc_info=True)

    return 0

"""
合约交易状态通知
"""
cdef extern int   TraderSpi_OnRtnInstrumentStatus(self
        , CThostFtdcInstrumentStatusField *pInstrumentStatus) except -1:
    try:
        if pInstrumentStatus == NULL:
            return -1
        self.pInstrumentStatus2DB(None if pInstrumentStatus is NULL else py_ApiStructure.InstrumentStatusField.from_address(<size_t> pInstrumentStatus))
        self.OnRtnInstrumentStatus(None if pInstrumentStatus is NULL else py_ApiStructure.InstrumentStatusField.from_address(<size_t> pInstrumentStatus))
    except Exception as err:
        myEnv.logger.error('OnRtnInstrumentStatus', exc_info=True)

    return 0

"""
交易所公告通知
"""
cdef extern int   TraderSpi_OnRtnBulletin(self
        , CThostFtdcBulletinField *pBulletin) except -1:
    try:
        if pBulletin == NULL:
            return -1
        self.pBulletin2DB(None if pBulletin is NULL else py_ApiStructure.BulletinField.from_address(<size_t> pBulletin))
        self.OnRtnBulletin(None if pBulletin is NULL else py_ApiStructure.BulletinField.from_address(<size_t> pBulletin))
    except Exception as err:
        myEnv.logger.error('OnRtnBulletin', exc_info=True)

    return 0

"""
交易通知
"""
cdef extern int   TraderSpi_OnRtnTradingNotice(self
        , CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) except -1:
    try:
        if pTradingNoticeInfo == NULL:
            return -1
        self.pTradingNoticeInfo2DB(None if pTradingNoticeInfo is NULL else py_ApiStructure.TradingNoticeInfoField.from_address(<size_t> pTradingNoticeInfo))
        self.OnRtnTradingNotice(None if pTradingNoticeInfo is NULL else py_ApiStructure.TradingNoticeInfoField.from_address(<size_t> pTradingNoticeInfo))
    except Exception as err:
        myEnv.logger.error('OnRtnTradingNotice', exc_info=True)

    return 0

"""
提示条件单校验错误
"""
cdef extern int   TraderSpi_OnRtnErrorConditionalOrder(self
        , CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) except -1:
    try:
        if pErrorConditionalOrder == NULL:
            return -1
        self.pErrorConditionalOrder2DB(None if pErrorConditionalOrder is NULL else py_ApiStructure.ErrorConditionalOrderField.from_address(<size_t> pErrorConditionalOrder))
        self.OnRtnErrorConditionalOrder(None if pErrorConditionalOrder is NULL else py_ApiStructure.ErrorConditionalOrderField.from_address(<size_t> pErrorConditionalOrder))
    except Exception as err:
        myEnv.logger.error('OnRtnErrorConditionalOrder', exc_info=True)

    return 0

"""
执行宣告通知
"""
cdef extern int   TraderSpi_OnRtnExecOrder(self
        , CThostFtdcExecOrderField *pExecOrder) except -1:
    try:
        if pExecOrder == NULL:
            return -1
        self.pExecOrder2DB(None if pExecOrder is NULL else py_ApiStructure.ExecOrderField.from_address(<size_t> pExecOrder))
        self.OnRtnExecOrder(None if pExecOrder is NULL else py_ApiStructure.ExecOrderField.from_address(<size_t> pExecOrder))
    except Exception as err:
        myEnv.logger.error('OnRtnExecOrder', exc_info=True)

    return 0

"""
执行宣告录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnExecOrderInsert(self
        , CThostFtdcInputExecOrderField *pInputExecOrder
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputExecOrder == NULL:
            return -1
        self.pInputExecOrder2DB(None if pInputExecOrder is NULL else py_ApiStructure.InputExecOrderField.from_address(<size_t> pInputExecOrder))
        self.OnErrRtnExecOrderInsert(None if pInputExecOrder is NULL else py_ApiStructure.InputExecOrderField.from_address(<size_t> pInputExecOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnExecOrderInsert', exc_info=True)

    return 0

"""
执行宣告操作错误回报
"""
cdef extern int   TraderSpi_OnErrRtnExecOrderAction(self
        , CThostFtdcExecOrderActionField *pExecOrderAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pExecOrderAction == NULL:
            return -1
        self.pExecOrderAction2DB(None if pExecOrderAction is NULL else py_ApiStructure.ExecOrderActionField.from_address(<size_t> pExecOrderAction))
        self.OnErrRtnExecOrderAction(None if pExecOrderAction is NULL else py_ApiStructure.ExecOrderActionField.from_address(<size_t> pExecOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnExecOrderAction', exc_info=True)

    return 0

"""
询价录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnForQuoteInsert(self
        , CThostFtdcInputForQuoteField *pInputForQuote
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputForQuote == NULL:
            return -1
        self.pInputForQuote2DB(None if pInputForQuote is NULL else py_ApiStructure.InputForQuoteField.from_address(<size_t> pInputForQuote))
        self.OnErrRtnForQuoteInsert(None if pInputForQuote is NULL else py_ApiStructure.InputForQuoteField.from_address(<size_t> pInputForQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnForQuoteInsert', exc_info=True)

    return 0

"""
报价通知
"""
cdef extern int   TraderSpi_OnRtnQuote(self
        , CThostFtdcQuoteField *pQuote) except -1:
    try:
        if pQuote == NULL:
            return -1
        self.pQuote2DB(None if pQuote is NULL else py_ApiStructure.QuoteField.from_address(<size_t> pQuote))
        self.OnRtnQuote(None if pQuote is NULL else py_ApiStructure.QuoteField.from_address(<size_t> pQuote))
    except Exception as err:
        myEnv.logger.error('OnRtnQuote', exc_info=True)

    return 0

"""
报价录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnQuoteInsert(self
        , CThostFtdcInputQuoteField *pInputQuote
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputQuote == NULL:
            return -1
        self.pInputQuote2DB(None if pInputQuote is NULL else py_ApiStructure.InputQuoteField.from_address(<size_t> pInputQuote))
        self.OnErrRtnQuoteInsert(None if pInputQuote is NULL else py_ApiStructure.InputQuoteField.from_address(<size_t> pInputQuote)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnQuoteInsert', exc_info=True)

    return 0

"""
报价操作错误回报
"""
cdef extern int   TraderSpi_OnErrRtnQuoteAction(self
        , CThostFtdcQuoteActionField *pQuoteAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pQuoteAction == NULL:
            return -1
        self.pQuoteAction2DB(None if pQuoteAction is NULL else py_ApiStructure.QuoteActionField.from_address(<size_t> pQuoteAction))
        self.OnErrRtnQuoteAction(None if pQuoteAction is NULL else py_ApiStructure.QuoteActionField.from_address(<size_t> pQuoteAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnQuoteAction', exc_info=True)

    return 0

"""
询价通知
"""
cdef extern int   TraderSpi_OnRtnForQuoteRsp(self
        , CThostFtdcForQuoteRspField *pForQuoteRsp) except -1:
    try:
        if pForQuoteRsp == NULL:
            return -1
        self.pForQuoteRsp2DB(None if pForQuoteRsp is NULL else py_ApiStructure.ForQuoteRspField.from_address(<size_t> pForQuoteRsp))
        self.OnRtnForQuoteRsp(None if pForQuoteRsp is NULL else py_ApiStructure.ForQuoteRspField.from_address(<size_t> pForQuoteRsp))
    except Exception as err:
        myEnv.logger.error('OnRtnForQuoteRsp', exc_info=True)

    return 0

"""
保证金监控中心用户令牌
"""
cdef extern int   TraderSpi_OnRtnCFMMCTradingAccountToken(self
        , CThostFtdcCFMMCTradingAccountTokenField *pCFMMCTradingAccountToken) except -1:
    try:
        if pCFMMCTradingAccountToken == NULL:
            return -1
        self.pCFMMCTradingAccountToken2DB(None if pCFMMCTradingAccountToken is NULL else py_ApiStructure.CFMMCTradingAccountTokenField.from_address(<size_t> pCFMMCTradingAccountToken))
        self.OnRtnCFMMCTradingAccountToken(None if pCFMMCTradingAccountToken is NULL else py_ApiStructure.CFMMCTradingAccountTokenField.from_address(<size_t> pCFMMCTradingAccountToken))
    except Exception as err:
        myEnv.logger.error('OnRtnCFMMCTradingAccountToken', exc_info=True)

    return 0

"""
批量报单操作错误回报
"""
cdef extern int   TraderSpi_OnErrRtnBatchOrderAction(self
        , CThostFtdcBatchOrderActionField *pBatchOrderAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pBatchOrderAction == NULL:
            return -1
        self.pBatchOrderAction2DB(None if pBatchOrderAction is NULL else py_ApiStructure.BatchOrderActionField.from_address(<size_t> pBatchOrderAction))
        self.OnErrRtnBatchOrderAction(None if pBatchOrderAction is NULL else py_ApiStructure.BatchOrderActionField.from_address(<size_t> pBatchOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnBatchOrderAction', exc_info=True)

    return 0

"""
期权自对冲通知
"""
cdef extern int   TraderSpi_OnRtnOptionSelfClose(self
        , CThostFtdcOptionSelfCloseField *pOptionSelfClose) except -1:
    try:
        if pOptionSelfClose == NULL:
            return -1
        self.pOptionSelfClose2DB(None if pOptionSelfClose is NULL else py_ApiStructure.OptionSelfCloseField.from_address(<size_t> pOptionSelfClose))
        self.OnRtnOptionSelfClose(None if pOptionSelfClose is NULL else py_ApiStructure.OptionSelfCloseField.from_address(<size_t> pOptionSelfClose))
    except Exception as err:
        myEnv.logger.error('OnRtnOptionSelfClose', exc_info=True)

    return 0

"""
期权自对冲录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnOptionSelfCloseInsert(self
        , CThostFtdcInputOptionSelfCloseField *pInputOptionSelfClose
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputOptionSelfClose == NULL:
            return -1
        self.pInputOptionSelfClose2DB(None if pInputOptionSelfClose is NULL else py_ApiStructure.InputOptionSelfCloseField.from_address(<size_t> pInputOptionSelfClose))
        self.OnErrRtnOptionSelfCloseInsert(None if pInputOptionSelfClose is NULL else py_ApiStructure.InputOptionSelfCloseField.from_address(<size_t> pInputOptionSelfClose)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnOptionSelfCloseInsert', exc_info=True)

    return 0

"""
期权自对冲操作错误回报
"""
cdef extern int   TraderSpi_OnErrRtnOptionSelfCloseAction(self
        , CThostFtdcOptionSelfCloseActionField *pOptionSelfCloseAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pOptionSelfCloseAction == NULL:
            return -1
        self.pOptionSelfCloseAction2DB(None if pOptionSelfCloseAction is NULL else py_ApiStructure.OptionSelfCloseActionField.from_address(<size_t> pOptionSelfCloseAction))
        self.OnErrRtnOptionSelfCloseAction(None if pOptionSelfCloseAction is NULL else py_ApiStructure.OptionSelfCloseActionField.from_address(<size_t> pOptionSelfCloseAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnOptionSelfCloseAction', exc_info=True)

    return 0

"""
申请组合通知
"""
cdef extern int   TraderSpi_OnRtnCombAction(self
        , CThostFtdcCombActionField *pCombAction) except -1:
    try:
        if pCombAction == NULL:
            return -1
        self.pCombAction2DB(None if pCombAction is NULL else py_ApiStructure.CombActionField.from_address(<size_t> pCombAction))
        self.OnRtnCombAction(None if pCombAction is NULL else py_ApiStructure.CombActionField.from_address(<size_t> pCombAction))
    except Exception as err:
        myEnv.logger.error('OnRtnCombAction', exc_info=True)

    return 0

"""
申请组合录入错误回报
"""
cdef extern int   TraderSpi_OnErrRtnCombActionInsert(self
        , CThostFtdcInputCombActionField *pInputCombAction
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pInputCombAction == NULL:
            return -1
        self.pInputCombAction2DB(None if pInputCombAction is NULL else py_ApiStructure.InputCombActionField.from_address(<size_t> pInputCombAction))
        self.OnErrRtnCombActionInsert(None if pInputCombAction is NULL else py_ApiStructure.InputCombActionField.from_address(<size_t> pInputCombAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnCombActionInsert', exc_info=True)

    return 0

"""
请求查询签约银行响应
"""
cdef extern int   TraderSpi_OnRspQryContractBank(self
        , CThostFtdcContractBankField *pContractBank
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pContractBank == NULL:
            return -1
        self.pContractBank2DB(None if pContractBank is NULL else py_ApiStructure.ContractBankField.from_address(<size_t> pContractBank))
        self.OnRspQryContractBank(None if pContractBank is NULL else py_ApiStructure.ContractBankField.from_address(<size_t> pContractBank)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryContractBank', exc_info=True)

    return 0

"""
请求查询预埋单响应
"""
cdef extern int   TraderSpi_OnRspQryParkedOrder(self
        , CThostFtdcParkedOrderField *pParkedOrder
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pParkedOrder == NULL:
            return -1
        self.pParkedOrder2DB(None if pParkedOrder is NULL else py_ApiStructure.ParkedOrderField.from_address(<size_t> pParkedOrder))
        self.OnRspQryParkedOrder(None if pParkedOrder is NULL else py_ApiStructure.ParkedOrderField.from_address(<size_t> pParkedOrder)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryParkedOrder', exc_info=True)

    return 0

"""
请求查询预埋撤单响应
"""
cdef extern int   TraderSpi_OnRspQryParkedOrderAction(self
        , CThostFtdcParkedOrderActionField *pParkedOrderAction
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pParkedOrderAction == NULL:
            return -1
        self.pParkedOrderAction2DB(None if pParkedOrderAction is NULL else py_ApiStructure.ParkedOrderActionField.from_address(<size_t> pParkedOrderAction))
        self.OnRspQryParkedOrderAction(None if pParkedOrderAction is NULL else py_ApiStructure.ParkedOrderActionField.from_address(<size_t> pParkedOrderAction)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryParkedOrderAction', exc_info=True)

    return 0

"""
请求查询交易通知响应
"""
cdef extern int   TraderSpi_OnRspQryTradingNotice(self
        , CThostFtdcTradingNoticeField *pTradingNotice
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pTradingNotice == NULL:
            return -1
        self.pTradingNotice2DB(None if pTradingNotice is NULL else py_ApiStructure.TradingNoticeField.from_address(<size_t> pTradingNotice))
        self.OnRspQryTradingNotice(None if pTradingNotice is NULL else py_ApiStructure.TradingNoticeField.from_address(<size_t> pTradingNotice)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryTradingNotice', exc_info=True)

    return 0

"""
请求查询经纪公司交易参数响应
"""
cdef extern int   TraderSpi_OnRspQryBrokerTradingParams(self
        , CThostFtdcBrokerTradingParamsField *pBrokerTradingParams
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pBrokerTradingParams == NULL:
            return -1
        self.pBrokerTradingParams2DB(None if pBrokerTradingParams is NULL else py_ApiStructure.BrokerTradingParamsField.from_address(<size_t> pBrokerTradingParams))
        self.OnRspQryBrokerTradingParams(None if pBrokerTradingParams is NULL else py_ApiStructure.BrokerTradingParamsField.from_address(<size_t> pBrokerTradingParams)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryBrokerTradingParams', exc_info=True)

    return 0

"""
请求查询经纪公司交易算法响应
"""
cdef extern int   TraderSpi_OnRspQryBrokerTradingAlgos(self
        , CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pBrokerTradingAlgos == NULL:
            return -1
        self.pBrokerTradingAlgos2DB(None if pBrokerTradingAlgos is NULL else py_ApiStructure.BrokerTradingAlgosField.from_address(<size_t> pBrokerTradingAlgos))
        self.OnRspQryBrokerTradingAlgos(None if pBrokerTradingAlgos is NULL else py_ApiStructure.BrokerTradingAlgosField.from_address(<size_t> pBrokerTradingAlgos)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQryBrokerTradingAlgos', exc_info=True)

    return 0

"""
请求查询监控中心用户令牌
"""
cdef extern int   TraderSpi_OnRspQueryCFMMCTradingAccountToken(self
        , CThostFtdcQueryCFMMCTradingAccountTokenField *pQueryCFMMCTradingAccountToken
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pQueryCFMMCTradingAccountToken == NULL:
            return -1
        self.pQueryCFMMCTradingAccountToken2DB(None if pQueryCFMMCTradingAccountToken is NULL else py_ApiStructure.QueryCFMMCTradingAccountTokenField.from_address(<size_t> pQueryCFMMCTradingAccountToken))
        self.OnRspQueryCFMMCTradingAccountToken(None if pQueryCFMMCTradingAccountToken is NULL else py_ApiStructure.QueryCFMMCTradingAccountTokenField.from_address(<size_t> pQueryCFMMCTradingAccountToken)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQueryCFMMCTradingAccountToken', exc_info=True)

    return 0

"""
银行发起银行资金转期货通知
"""
cdef extern int   TraderSpi_OnRtnFromBankToFutureByBank(self
        , CThostFtdcRspTransferField *pRspTransfer) except -1:
    try:
        if pRspTransfer == NULL:
            return -1
        self.pRspTransfer2DB(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
        self.OnRtnFromBankToFutureByBank(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
    except Exception as err:
        myEnv.logger.error('OnRtnFromBankToFutureByBank', exc_info=True)

    return 0

"""
银行发起期货资金转银行通知
"""
cdef extern int   TraderSpi_OnRtnFromFutureToBankByBank(self
        , CThostFtdcRspTransferField *pRspTransfer) except -1:
    try:
        if pRspTransfer == NULL:
            return -1
        self.pRspTransfer2DB(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
        self.OnRtnFromFutureToBankByBank(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
    except Exception as err:
        myEnv.logger.error('OnRtnFromFutureToBankByBank', exc_info=True)

    return 0

"""
银行发起冲正银行转期货通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromBankToFutureByBank(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromBankToFutureByBank(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromBankToFutureByBank', exc_info=True)

    return 0

"""
银行发起冲正期货转银行通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromFutureToBankByBank(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromFutureToBankByBank(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromFutureToBankByBank', exc_info=True)

    return 0

"""
期货发起银行资金转期货通知
"""
cdef extern int   TraderSpi_OnRtnFromBankToFutureByFuture(self
        , CThostFtdcRspTransferField *pRspTransfer) except -1:
    try:
        if pRspTransfer == NULL:
            return -1
        self.pRspTransfer2DB(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
        self.OnRtnFromBankToFutureByFuture(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
    except Exception as err:
        myEnv.logger.error('OnRtnFromBankToFutureByFuture', exc_info=True)

    return 0

"""
期货发起期货资金转银行通知
"""
cdef extern int   TraderSpi_OnRtnFromFutureToBankByFuture(self
        , CThostFtdcRspTransferField *pRspTransfer) except -1:
    try:
        if pRspTransfer == NULL:
            return -1
        self.pRspTransfer2DB(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
        self.OnRtnFromFutureToBankByFuture(None if pRspTransfer is NULL else py_ApiStructure.RspTransferField.from_address(<size_t> pRspTransfer))
    except Exception as err:
        myEnv.logger.error('OnRtnFromFutureToBankByFuture', exc_info=True)

    return 0

"""
系统运行时期货端手工发起冲正银行转期货请求，银行处理完毕后报盘发回的通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromBankToFutureByFutureManual(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromBankToFutureByFutureManual(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromBankToFutureByFutureManual', exc_info=True)

    return 0

"""
系统运行时期货端手工发起冲正期货转银行请求，银行处理完毕后报盘发回的通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromFutureToBankByFutureManual(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromFutureToBankByFutureManual(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromFutureToBankByFutureManual', exc_info=True)

    return 0

"""
期货发起查询银行余额通知
"""
cdef extern int   TraderSpi_OnRtnQueryBankBalanceByFuture(self
        , CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) except -1:
    try:
        if pNotifyQueryAccount == NULL:
            return -1
        self.pNotifyQueryAccount2DB(None if pNotifyQueryAccount is NULL else py_ApiStructure.NotifyQueryAccountField.from_address(<size_t> pNotifyQueryAccount))
        self.OnRtnQueryBankBalanceByFuture(None if pNotifyQueryAccount is NULL else py_ApiStructure.NotifyQueryAccountField.from_address(<size_t> pNotifyQueryAccount))
    except Exception as err:
        myEnv.logger.error('OnRtnQueryBankBalanceByFuture', exc_info=True)

    return 0

"""
期货发起银行资金转期货错误回报
"""
cdef extern int   TraderSpi_OnErrRtnBankToFutureByFuture(self
        , CThostFtdcReqTransferField *pReqTransfer
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pReqTransfer == NULL:
            return -1
        self.pReqTransfer2DB(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer))
        self.OnErrRtnBankToFutureByFuture(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnBankToFutureByFuture', exc_info=True)

    return 0

"""
期货发起期货资金转银行错误回报
"""
cdef extern int   TraderSpi_OnErrRtnFutureToBankByFuture(self
        , CThostFtdcReqTransferField *pReqTransfer
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pReqTransfer == NULL:
            return -1
        self.pReqTransfer2DB(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer))
        self.OnErrRtnFutureToBankByFuture(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnFutureToBankByFuture', exc_info=True)

    return 0

"""
系统运行时期货端手工发起冲正银行转期货错误回报
"""
cdef extern int   TraderSpi_OnErrRtnRepealBankToFutureByFutureManual(self
        , CThostFtdcReqRepealField *pReqRepeal
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pReqRepeal == NULL:
            return -1
        self.pReqRepeal2DB(None if pReqRepeal is NULL else py_ApiStructure.ReqRepealField.from_address(<size_t> pReqRepeal))
        self.OnErrRtnRepealBankToFutureByFutureManual(None if pReqRepeal is NULL else py_ApiStructure.ReqRepealField.from_address(<size_t> pReqRepeal)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnRepealBankToFutureByFutureManual', exc_info=True)

    return 0

"""
系统运行时期货端手工发起冲正期货转银行错误回报
"""
cdef extern int   TraderSpi_OnErrRtnRepealFutureToBankByFutureManual(self
        , CThostFtdcReqRepealField *pReqRepeal
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pReqRepeal == NULL:
            return -1
        self.pReqRepeal2DB(None if pReqRepeal is NULL else py_ApiStructure.ReqRepealField.from_address(<size_t> pReqRepeal))
        self.OnErrRtnRepealFutureToBankByFutureManual(None if pReqRepeal is NULL else py_ApiStructure.ReqRepealField.from_address(<size_t> pReqRepeal)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnRepealFutureToBankByFutureManual', exc_info=True)

    return 0

"""
期货发起查询银行余额错误回报
"""
cdef extern int   TraderSpi_OnErrRtnQueryBankBalanceByFuture(self
        , CThostFtdcReqQueryAccountField *pReqQueryAccount
        , CThostFtdcRspInfoField *pRspInfo) except -1:
    try:
        if pReqQueryAccount == NULL:
            return -1
        self.pReqQueryAccount2DB(None if pReqQueryAccount is NULL else py_ApiStructure.ReqQueryAccountField.from_address(<size_t> pReqQueryAccount))
        self.OnErrRtnQueryBankBalanceByFuture(None if pReqQueryAccount is NULL else py_ApiStructure.ReqQueryAccountField.from_address(<size_t> pReqQueryAccount)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo))
    except Exception as err:
        myEnv.logger.error('OnErrRtnQueryBankBalanceByFuture', exc_info=True)

    return 0

"""
期货发起冲正银行转期货请求，银行处理完毕后报盘发回的通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromBankToFutureByFuture(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromBankToFutureByFuture(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromBankToFutureByFuture', exc_info=True)

    return 0

"""
期货发起冲正期货转银行请求，银行处理完毕后报盘发回的通知
"""
cdef extern int   TraderSpi_OnRtnRepealFromFutureToBankByFuture(self
        , CThostFtdcRspRepealField *pRspRepeal) except -1:
    try:
        if pRspRepeal == NULL:
            return -1
        self.pRspRepeal2DB(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
        self.OnRtnRepealFromFutureToBankByFuture(None if pRspRepeal is NULL else py_ApiStructure.RspRepealField.from_address(<size_t> pRspRepeal))
    except Exception as err:
        myEnv.logger.error('OnRtnRepealFromFutureToBankByFuture', exc_info=True)

    return 0

"""
期货发起银行资金转期货应答
"""
cdef extern int   TraderSpi_OnRspFromBankToFutureByFuture(self
        , CThostFtdcReqTransferField *pReqTransfer
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pReqTransfer == NULL:
            return -1
        self.pReqTransfer2DB(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer))
        self.OnRspFromBankToFutureByFuture(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspFromBankToFutureByFuture', exc_info=True)

    return 0

"""
期货发起期货资金转银行应答
"""
cdef extern int   TraderSpi_OnRspFromFutureToBankByFuture(self
        , CThostFtdcReqTransferField *pReqTransfer
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pReqTransfer == NULL:
            return -1
        self.pReqTransfer2DB(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer))
        self.OnRspFromFutureToBankByFuture(None if pReqTransfer is NULL else py_ApiStructure.ReqTransferField.from_address(<size_t> pReqTransfer)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspFromFutureToBankByFuture', exc_info=True)

    return 0

"""
期货发起查询银行余额应答
"""
cdef extern int   TraderSpi_OnRspQueryBankAccountMoneyByFuture(self
        , CThostFtdcReqQueryAccountField *pReqQueryAccount
        , CThostFtdcRspInfoField *pRspInfo
        , int nRequestID
        , cbool bIsLast) except -1:
    try:
        if pReqQueryAccount == NULL:
            return -1
        self.pReqQueryAccount2DB(None if pReqQueryAccount is NULL else py_ApiStructure.ReqQueryAccountField.from_address(<size_t> pReqQueryAccount))
        self.OnRspQueryBankAccountMoneyByFuture(None if pReqQueryAccount is NULL else py_ApiStructure.ReqQueryAccountField.from_address(<size_t> pReqQueryAccount)
        ,None if pRspInfo is NULL else py_ApiStructure.RspInfoField.from_address(<size_t> pRspInfo)
        ,nRequestID
        ,bIsLast)
    except Exception as err:
        myEnv.logger.error('OnRspQueryBankAccountMoneyByFuture', exc_info=True)

    return 0

"""
银行发起银期开户通知
"""
cdef extern int   TraderSpi_OnRtnOpenAccountByBank(self
        , CThostFtdcOpenAccountField *pOpenAccount) except -1:
    try:
        if pOpenAccount == NULL:
            return -1
        self.pOpenAccount2DB(None if pOpenAccount is NULL else py_ApiStructure.OpenAccountField.from_address(<size_t> pOpenAccount))
        self.OnRtnOpenAccountByBank(None if pOpenAccount is NULL else py_ApiStructure.OpenAccountField.from_address(<size_t> pOpenAccount))
    except Exception as err:
        myEnv.logger.error('OnRtnOpenAccountByBank', exc_info=True)

    return 0

"""
银行发起银期销户通知
"""
cdef extern int   TraderSpi_OnRtnCancelAccountByBank(self
        , CThostFtdcCancelAccountField *pCancelAccount) except -1:
    try:
        if pCancelAccount == NULL:
            return -1
        self.pCancelAccount2DB(None if pCancelAccount is NULL else py_ApiStructure.CancelAccountField.from_address(<size_t> pCancelAccount))
        self.OnRtnCancelAccountByBank(None if pCancelAccount is NULL else py_ApiStructure.CancelAccountField.from_address(<size_t> pCancelAccount))
    except Exception as err:
        myEnv.logger.error('OnRtnCancelAccountByBank', exc_info=True)

    return 0

"""
银行发起变更银行账号通知
"""
cdef extern int   TraderSpi_OnRtnChangeAccountByBank(self
        , CThostFtdcChangeAccountField *pChangeAccount) except -1:
    try:
        if pChangeAccount == NULL:
            return -1
        self.pChangeAccount2DB(None if pChangeAccount is NULL else py_ApiStructure.ChangeAccountField.from_address(<size_t> pChangeAccount))
        self.OnRtnChangeAccountByBank(None if pChangeAccount is NULL else py_ApiStructure.ChangeAccountField.from_address(<size_t> pChangeAccount))
    except Exception as err:
        myEnv.logger.error('OnRtnChangeAccountByBank', exc_info=True)

    return 0
