code: def context_setting(self):
          
          if self.unlock_password == "":
              raise Exception("请先配置交易解锁密码! password: {}".format(
                  self.unlock_password))
  
          quote_ctx = ft.OpenQuoteContext(
              host=self.api_svr_ip, port=self.api_svr_port)
  
          if 'HK.' in self.stock:
              trade_ctx = ft.OpenHKTradeContext(
                  host=self.api_svr_ip, port=self.api_svr_port)
  
              if self.trade_env == ft.TrdEnv.REAL:
                  ret_code, ret_data = trade_ctx.unlock_trade(
                      self.unlock_password)
                  if ret_code == ft.RET_OK:
                      print('解锁交易成功!')
                  else:
                      raise Exception("请求交易解锁失败: {}".format(ret_data))
              else:
                  print('解锁交易成功!')
          elif 'US.' in self.stock:
              if self.trade_env != 0:
                  raise Exception("美股交易接口不支持仿真环境 trade_env: {}".format(
                      self.trade_env))
              trade_ctx = ft.OpenUSTradeContext(
                  host=self.api_svr_ip, port=self.api_svr_port)
          else:
              raise Exception("stock输入错误 stock: {}".format(self.stock))
  
          return quote_ctx, trade_ctx
docs: API trading and quote context setting
          :returns: trade context, quote context