/* generated by handle_module_api */
use std::{
    cell::Cell,
    ffi::{CStr, CString},
    os::raw::c_char,
    path::Path,
    ptr::null_mut,
};

use libloading::Library;

use crate::v1alpha1::bindings::*;
use crate::v1alpha1::traderspi::*;    

pub struct TraderApi {
    pub api_ptr: *mut CThostFtdcTraderApi,
    pub spi_ptr: Cell<* mut CThostFtdcTraderSpiExt>,
    pub dynlib: Option<Library>,          
}

unsafe impl Sync for TraderApi {}
unsafe impl Send for TraderApi {}

impl TraderApi {
        /// 删除接口对象本身
    ///@remark 不再使用本接口对象时,调用该函数删除接口对象
    pub fn release(&self) {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_Release)(self.api_ptr)
        }
    }
    
    /// 初始化
    ///@remark 初始化运行环境,只有调用后,接口才开始工作
    pub fn init(&self) {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_Init)(self.api_ptr)
        }
    }
    
    /// 等待接口线程结束运行
    ///@return 线程退出代码
    pub fn join(&self) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_Join)(self.api_ptr)
        }
    }
    
    /// 获取当前交易日
    ///@retrun 获取到的交易日
    ///@remark 只有登录成功后,才能得到正确的交易日
    pub fn get_trading_day(&self) -> String {
        unsafe {
            let cstr_ptr = ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_GetTradingDay)(self.api_ptr);
            let c_str = CStr::from_ptr(cstr_ptr);
            c_str.to_string_lossy().to_string()
        }
    }
    
    /// 注册前置机网络地址
    ///@param pszFrontAddress：前置机网络地址。
    ///@remark 网络地址的格式为：“protocol://ipaddress:port”，如：”tcp://127.0.0.1:17001”。
    ///@remark “tcp”代表传输协议，“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
    pub fn register_front(&self, psz_front_address: &str) {
        unsafe {
            let psz_front_address = CString::new(psz_front_address).unwrap();
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_RegisterFront)(self.api_ptr, psz_front_address.as_ptr() as *mut i8)
        }
    }
    
    /// 注册名字服务器网络地址
    ///@param pszNsAddress：名字服务器网络地址。
    ///@remark 网络地址的格式为：“protocol://ipaddress:port”，如：”tcp://127.0.0.1:12001”。
    ///@remark “tcp”代表传输协议，“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
    ///@remark RegisterNameServer优先于RegisterFront
    pub fn register_name_server(&self, psz_ns_address: &str) {
        unsafe {
            let psz_ns_address = CString::new(psz_ns_address).unwrap();
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_RegisterNameServer)(self.api_ptr, psz_ns_address.as_ptr() as *mut i8)
        }
    }
    
    /// 注册名字服务器用户信息
    ///@param pFensUserInfo：用户信息。
    pub fn register_fens_user_info(&self, p_fens_user_info: &mut CThostFtdcFensUserInfoField) {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_RegisterFensUserInfo)(self.api_ptr, p_fens_user_info as *mut CThostFtdcFensUserInfoField)
        }
    }
    
    /// 注册回调接口
    ///@param pSpi 派生自回调接口类的实例
    pub fn register_spi(&self, p_spi: *mut dyn TraderSpi) {
        let spi_ptr = Box::into_raw(Box::new(CThostFtdcTraderSpiExt::new(p_spi)));
        let last_spi_ptr = self.spi_ptr.get();
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_RegisterSpi)(self.api_ptr, spi_ptr as _)
        }
        self.spi_ptr.set(spi_ptr);
        if !last_spi_ptr.is_null() {
            unsafe {
                let _ = Box::from_raw(last_spi_ptr); // 释放动态分配的内存
            }
        }
    }
    
    /// 订阅私有流。
    ///@param nResumeType 私有流重传方式
    ///         THOST_TERT_RESTART:从本交易日开始重传
    ///         THOST_TERT_RESUME:从上次收到的续传
    ///         THOST_TERT_QUICK:只传送登录后私有流的内容
    ///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。
    pub fn subscribe_private_topic(&self, n_resume_type: THOST_TE_RESUME_TYPE) {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_SubscribePrivateTopic)(self.api_ptr, n_resume_type)
        }
    }
    
    /// 订阅公共流。
    ///@param nResumeType 公共流重传方式
    ///         THOST_TERT_RESTART:从本交易日开始重传
    ///         THOST_TERT_RESUME:从上次收到的续传
    ///         THOST_TERT_QUICK:只传送登录后公共流的内容
    ///         THOST_TERT_NONE:取消订阅公共流
    ///@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。
    pub fn subscribe_public_topic(&self, n_resume_type: THOST_TE_RESUME_TYPE) {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_SubscribePublicTopic)(self.api_ptr, n_resume_type)
        }
    }
    
    /// 客户端认证请求
    pub fn req_authenticate(&self, p_req_authenticate_field: &mut CThostFtdcReqAuthenticateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqAuthenticate)(self.api_ptr, p_req_authenticate_field as *mut CThostFtdcReqAuthenticateField, n_request_id)
        }
    }
    
    /// 注册用户终端信息，用于中继服务器多连接模式
    /// 需要在终端认证成功后，用户登录前调用该接口
    pub fn register_user_system_info(&self, p_user_system_info: &mut CThostFtdcUserSystemInfoField) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_RegisterUserSystemInfo)(self.api_ptr, p_user_system_info as *mut CThostFtdcUserSystemInfoField)
        }
    }
    
    /// 上报用户终端信息，用于中继服务器操作员登录模式
    /// 操作员登录后，可以多次调用该接口上报客户信息
    pub fn submit_user_system_info(&self, p_user_system_info: &mut CThostFtdcUserSystemInfoField) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_SubmitUserSystemInfo)(self.api_ptr, p_user_system_info as *mut CThostFtdcUserSystemInfoField)
        }
    }
    
    /// 用户登录请求
    pub fn req_user_login(&self, p_req_user_login_field: &mut CThostFtdcReqUserLoginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserLogin)(self.api_ptr, p_req_user_login_field as *mut CThostFtdcReqUserLoginField, n_request_id)
        }
    }
    
    /// 登出请求
    pub fn req_user_logout(&self, p_user_logout: &mut CThostFtdcUserLogoutField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserLogout)(self.api_ptr, p_user_logout as *mut CThostFtdcUserLogoutField, n_request_id)
        }
    }
    
    /// 用户口令更新请求
    pub fn req_user_password_update(&self, p_user_password_update: &mut CThostFtdcUserPasswordUpdateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserPasswordUpdate)(self.api_ptr, p_user_password_update as *mut CThostFtdcUserPasswordUpdateField, n_request_id)
        }
    }
    
    /// 资金账户口令更新请求
    pub fn req_trading_account_password_update(&self, p_trading_account_password_update: &mut CThostFtdcTradingAccountPasswordUpdateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqTradingAccountPasswordUpdate)(self.api_ptr, p_trading_account_password_update as *mut CThostFtdcTradingAccountPasswordUpdateField, n_request_id)
        }
    }
    
    /// 查询用户当前支持的认证模式
    pub fn req_user_auth_method(&self, p_req_user_auth_method: &mut CThostFtdcReqUserAuthMethodField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserAuthMethod)(self.api_ptr, p_req_user_auth_method as *mut CThostFtdcReqUserAuthMethodField, n_request_id)
        }
    }
    
    /// 用户发出获取图形验证码请求
    pub fn req_gen_user_captcha(&self, p_req_gen_user_captcha: &mut CThostFtdcReqGenUserCaptchaField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqGenUserCaptcha)(self.api_ptr, p_req_gen_user_captcha as *mut CThostFtdcReqGenUserCaptchaField, n_request_id)
        }
    }
    
    /// 用户发出获取短信验证码请求
    pub fn req_gen_user_text(&self, p_req_gen_user_text: &mut CThostFtdcReqGenUserTextField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqGenUserText)(self.api_ptr, p_req_gen_user_text as *mut CThostFtdcReqGenUserTextField, n_request_id)
        }
    }
    
    /// 用户发出带有图片验证码的登陆请求
    pub fn req_user_login_with_captcha(&self, p_req_user_login_with_captcha: &mut CThostFtdcReqUserLoginWithCaptchaField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserLoginWithCaptcha)(self.api_ptr, p_req_user_login_with_captcha as *mut CThostFtdcReqUserLoginWithCaptchaField, n_request_id)
        }
    }
    
    /// 用户发出带有短信验证码的登陆请求
    pub fn req_user_login_with_text(&self, p_req_user_login_with_text: &mut CThostFtdcReqUserLoginWithTextField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserLoginWithText)(self.api_ptr, p_req_user_login_with_text as *mut CThostFtdcReqUserLoginWithTextField, n_request_id)
        }
    }
    
    /// 用户发出带有动态口令的登陆请求
    pub fn req_user_login_with_otp(&self, p_req_user_login_with_otp: &mut CThostFtdcReqUserLoginWithOTPField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqUserLoginWithOTP)(self.api_ptr, p_req_user_login_with_otp as *mut CThostFtdcReqUserLoginWithOTPField, n_request_id)
        }
    }
    
    /// 报单录入请求
    pub fn req_order_insert(&self, p_input_order: &mut CThostFtdcInputOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqOrderInsert)(self.api_ptr, p_input_order as *mut CThostFtdcInputOrderField, n_request_id)
        }
    }
    
    /// 预埋单录入请求
    pub fn req_parked_order_insert(&self, p_parked_order: &mut CThostFtdcParkedOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqParkedOrderInsert)(self.api_ptr, p_parked_order as *mut CThostFtdcParkedOrderField, n_request_id)
        }
    }
    
    /// 预埋撤单录入请求
    pub fn req_parked_order_action(&self, p_parked_order_action: &mut CThostFtdcParkedOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqParkedOrderAction)(self.api_ptr, p_parked_order_action as *mut CThostFtdcParkedOrderActionField, n_request_id)
        }
    }
    
    /// 报单操作请求
    pub fn req_order_action(&self, p_input_order_action: &mut CThostFtdcInputOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqOrderAction)(self.api_ptr, p_input_order_action as *mut CThostFtdcInputOrderActionField, n_request_id)
        }
    }
    
    /// 查询最大报单数量请求
    pub fn req_qry_max_order_volume(&self, p_qry_max_order_volume: &mut CThostFtdcQryMaxOrderVolumeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryMaxOrderVolume)(self.api_ptr, p_qry_max_order_volume as *mut CThostFtdcQryMaxOrderVolumeField, n_request_id)
        }
    }
    
    /// 投资者结算结果确认
    pub fn req_settlement_info_confirm(&self, p_settlement_info_confirm: &mut CThostFtdcSettlementInfoConfirmField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqSettlementInfoConfirm)(self.api_ptr, p_settlement_info_confirm as *mut CThostFtdcSettlementInfoConfirmField, n_request_id)
        }
    }
    
    /// 请求删除预埋单
    pub fn req_remove_parked_order(&self, p_remove_parked_order: &mut CThostFtdcRemoveParkedOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqRemoveParkedOrder)(self.api_ptr, p_remove_parked_order as *mut CThostFtdcRemoveParkedOrderField, n_request_id)
        }
    }
    
    /// 请求删除预埋撤单
    pub fn req_remove_parked_order_action(&self, p_remove_parked_order_action: &mut CThostFtdcRemoveParkedOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqRemoveParkedOrderAction)(self.api_ptr, p_remove_parked_order_action as *mut CThostFtdcRemoveParkedOrderActionField, n_request_id)
        }
    }
    
    /// 执行宣告录入请求
    pub fn req_exec_order_insert(&self, p_input_exec_order: &mut CThostFtdcInputExecOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqExecOrderInsert)(self.api_ptr, p_input_exec_order as *mut CThostFtdcInputExecOrderField, n_request_id)
        }
    }
    
    /// 执行宣告操作请求
    pub fn req_exec_order_action(&self, p_input_exec_order_action: &mut CThostFtdcInputExecOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqExecOrderAction)(self.api_ptr, p_input_exec_order_action as *mut CThostFtdcInputExecOrderActionField, n_request_id)
        }
    }
    
    /// 询价录入请求
    pub fn req_for_quote_insert(&self, p_input_for_quote: &mut CThostFtdcInputForQuoteField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqForQuoteInsert)(self.api_ptr, p_input_for_quote as *mut CThostFtdcInputForQuoteField, n_request_id)
        }
    }
    
    /// 报价录入请求
    pub fn req_quote_insert(&self, p_input_quote: &mut CThostFtdcInputQuoteField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQuoteInsert)(self.api_ptr, p_input_quote as *mut CThostFtdcInputQuoteField, n_request_id)
        }
    }
    
    /// 报价操作请求
    pub fn req_quote_action(&self, p_input_quote_action: &mut CThostFtdcInputQuoteActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQuoteAction)(self.api_ptr, p_input_quote_action as *mut CThostFtdcInputQuoteActionField, n_request_id)
        }
    }
    
    /// 批量报单操作请求
    pub fn req_batch_order_action(&self, p_input_batch_order_action: &mut CThostFtdcInputBatchOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqBatchOrderAction)(self.api_ptr, p_input_batch_order_action as *mut CThostFtdcInputBatchOrderActionField, n_request_id)
        }
    }
    
    /// 期权自对冲录入请求
    pub fn req_option_self_close_insert(&self, p_input_option_self_close: &mut CThostFtdcInputOptionSelfCloseField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqOptionSelfCloseInsert)(self.api_ptr, p_input_option_self_close as *mut CThostFtdcInputOptionSelfCloseField, n_request_id)
        }
    }
    
    /// 期权自对冲操作请求
    pub fn req_option_self_close_action(&self, p_input_option_self_close_action: &mut CThostFtdcInputOptionSelfCloseActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqOptionSelfCloseAction)(self.api_ptr, p_input_option_self_close_action as *mut CThostFtdcInputOptionSelfCloseActionField, n_request_id)
        }
    }
    
    /// 申请组合录入请求
    pub fn req_comb_action_insert(&self, p_input_comb_action: &mut CThostFtdcInputCombActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqCombActionInsert)(self.api_ptr, p_input_comb_action as *mut CThostFtdcInputCombActionField, n_request_id)
        }
    }
    
    /// 请求查询报单
    pub fn req_qry_order(&self, p_qry_order: &mut CThostFtdcQryOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryOrder)(self.api_ptr, p_qry_order as *mut CThostFtdcQryOrderField, n_request_id)
        }
    }
    
    /// 请求查询成交
    pub fn req_qry_trade(&self, p_qry_trade: &mut CThostFtdcQryTradeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTrade)(self.api_ptr, p_qry_trade as *mut CThostFtdcQryTradeField, n_request_id)
        }
    }
    
    /// 请求查询投资者持仓
    pub fn req_qry_investor_position(&self, p_qry_investor_position: &mut CThostFtdcQryInvestorPositionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorPosition)(self.api_ptr, p_qry_investor_position as *mut CThostFtdcQryInvestorPositionField, n_request_id)
        }
    }
    
    /// 请求查询资金账户
    pub fn req_qry_trading_account(&self, p_qry_trading_account: &mut CThostFtdcQryTradingAccountField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTradingAccount)(self.api_ptr, p_qry_trading_account as *mut CThostFtdcQryTradingAccountField, n_request_id)
        }
    }
    
    /// 请求查询投资者
    pub fn req_qry_investor(&self, p_qry_investor: &mut CThostFtdcQryInvestorField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestor)(self.api_ptr, p_qry_investor as *mut CThostFtdcQryInvestorField, n_request_id)
        }
    }
    
    /// 请求查询交易编码
    pub fn req_qry_trading_code(&self, p_qry_trading_code: &mut CThostFtdcQryTradingCodeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTradingCode)(self.api_ptr, p_qry_trading_code as *mut CThostFtdcQryTradingCodeField, n_request_id)
        }
    }
    
    /// 请求查询合约保证金率
    pub fn req_qry_instrument_margin_rate(&self, p_qry_instrument_margin_rate: &mut CThostFtdcQryInstrumentMarginRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInstrumentMarginRate)(self.api_ptr, p_qry_instrument_margin_rate as *mut CThostFtdcQryInstrumentMarginRateField, n_request_id)
        }
    }
    
    /// 请求查询合约手续费率
    pub fn req_qry_instrument_commission_rate(&self, p_qry_instrument_commission_rate: &mut CThostFtdcQryInstrumentCommissionRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInstrumentCommissionRate)(self.api_ptr, p_qry_instrument_commission_rate as *mut CThostFtdcQryInstrumentCommissionRateField, n_request_id)
        }
    }
    
    /// 请求查询交易所
    pub fn req_qry_exchange(&self, p_qry_exchange: &mut CThostFtdcQryExchangeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryExchange)(self.api_ptr, p_qry_exchange as *mut CThostFtdcQryExchangeField, n_request_id)
        }
    }
    
    /// 请求查询产品
    pub fn req_qry_product(&self, p_qry_product: &mut CThostFtdcQryProductField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryProduct)(self.api_ptr, p_qry_product as *mut CThostFtdcQryProductField, n_request_id)
        }
    }
    
    /// 请求查询合约
    pub fn req_qry_instrument(&self, p_qry_instrument: &mut CThostFtdcQryInstrumentField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInstrument)(self.api_ptr, p_qry_instrument as *mut CThostFtdcQryInstrumentField, n_request_id)
        }
    }
    
    /// 请求查询行情
    pub fn req_qry_depth_market_data(&self, p_qry_depth_market_data: &mut CThostFtdcQryDepthMarketDataField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryDepthMarketData)(self.api_ptr, p_qry_depth_market_data as *mut CThostFtdcQryDepthMarketDataField, n_request_id)
        }
    }
    
    /// 请求查询交易员报盘机
    pub fn req_qry_trader_offer(&self, p_qry_trader_offer: &mut CThostFtdcQryTraderOfferField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTraderOffer)(self.api_ptr, p_qry_trader_offer as *mut CThostFtdcQryTraderOfferField, n_request_id)
        }
    }
    
    /// 请求查询投资者结算结果
    pub fn req_qry_settlement_info(&self, p_qry_settlement_info: &mut CThostFtdcQrySettlementInfoField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySettlementInfo)(self.api_ptr, p_qry_settlement_info as *mut CThostFtdcQrySettlementInfoField, n_request_id)
        }
    }
    
    /// 请求查询转帐银行
    pub fn req_qry_transfer_bank(&self, p_qry_transfer_bank: &mut CThostFtdcQryTransferBankField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTransferBank)(self.api_ptr, p_qry_transfer_bank as *mut CThostFtdcQryTransferBankField, n_request_id)
        }
    }
    
    /// 请求查询投资者持仓明细
    pub fn req_qry_investor_position_detail(&self, p_qry_investor_position_detail: &mut CThostFtdcQryInvestorPositionDetailField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorPositionDetail)(self.api_ptr, p_qry_investor_position_detail as *mut CThostFtdcQryInvestorPositionDetailField, n_request_id)
        }
    }
    
    /// 请求查询客户通知
    pub fn req_qry_notice(&self, p_qry_notice: &mut CThostFtdcQryNoticeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryNotice)(self.api_ptr, p_qry_notice as *mut CThostFtdcQryNoticeField, n_request_id)
        }
    }
    
    /// 请求查询结算信息确认
    pub fn req_qry_settlement_info_confirm(&self, p_qry_settlement_info_confirm: &mut CThostFtdcQrySettlementInfoConfirmField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySettlementInfoConfirm)(self.api_ptr, p_qry_settlement_info_confirm as *mut CThostFtdcQrySettlementInfoConfirmField, n_request_id)
        }
    }
    
    /// 请求查询投资者持仓明细
    pub fn req_qry_investor_position_combine_detail(&self, p_qry_investor_position_combine_detail: &mut CThostFtdcQryInvestorPositionCombineDetailField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorPositionCombineDetail)(self.api_ptr, p_qry_investor_position_combine_detail as *mut CThostFtdcQryInvestorPositionCombineDetailField, n_request_id)
        }
    }
    
    /// 请求查询保证金监管系统经纪公司资金账户密钥
    pub fn req_qry_cfmmc_trading_account_key(&self, p_qry_cfmmc_trading_account_key: &mut CThostFtdcQryCFMMCTradingAccountKeyField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryCFMMCTradingAccountKey)(self.api_ptr, p_qry_cfmmc_trading_account_key as *mut CThostFtdcQryCFMMCTradingAccountKeyField, n_request_id)
        }
    }
    
    /// 请求查询仓单折抵信息
    pub fn req_qry_e_warrant_offset(&self, p_qry_e_warrant_offset: &mut CThostFtdcQryEWarrantOffsetField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryEWarrantOffset)(self.api_ptr, p_qry_e_warrant_offset as *mut CThostFtdcQryEWarrantOffsetField, n_request_id)
        }
    }
    
    /// 请求查询投资者品种/跨品种保证金
    pub fn req_qry_investor_product_group_margin(&self, p_qry_investor_product_group_margin: &mut CThostFtdcQryInvestorProductGroupMarginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorProductGroupMargin)(self.api_ptr, p_qry_investor_product_group_margin as *mut CThostFtdcQryInvestorProductGroupMarginField, n_request_id)
        }
    }
    
    /// 请求查询交易所保证金率
    pub fn req_qry_exchange_margin_rate(&self, p_qry_exchange_margin_rate: &mut CThostFtdcQryExchangeMarginRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryExchangeMarginRate)(self.api_ptr, p_qry_exchange_margin_rate as *mut CThostFtdcQryExchangeMarginRateField, n_request_id)
        }
    }
    
    /// 请求查询交易所调整保证金率
    pub fn req_qry_exchange_margin_rate_adjust(&self, p_qry_exchange_margin_rate_adjust: &mut CThostFtdcQryExchangeMarginRateAdjustField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryExchangeMarginRateAdjust)(self.api_ptr, p_qry_exchange_margin_rate_adjust as *mut CThostFtdcQryExchangeMarginRateAdjustField, n_request_id)
        }
    }
    
    /// 请求查询汇率
    pub fn req_qry_exchange_rate(&self, p_qry_exchange_rate: &mut CThostFtdcQryExchangeRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryExchangeRate)(self.api_ptr, p_qry_exchange_rate as *mut CThostFtdcQryExchangeRateField, n_request_id)
        }
    }
    
    /// 请求查询二级代理操作员银期权限
    pub fn req_qry_sec_agent_acid_map(&self, p_qry_sec_agent_acid_map: &mut CThostFtdcQrySecAgentACIDMapField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySecAgentACIDMap)(self.api_ptr, p_qry_sec_agent_acid_map as *mut CThostFtdcQrySecAgentACIDMapField, n_request_id)
        }
    }
    
    /// 请求查询产品报价汇率
    pub fn req_qry_product_exch_rate(&self, p_qry_product_exch_rate: &mut CThostFtdcQryProductExchRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryProductExchRate)(self.api_ptr, p_qry_product_exch_rate as *mut CThostFtdcQryProductExchRateField, n_request_id)
        }
    }
    
    /// 请求查询产品组
    pub fn req_qry_product_group(&self, p_qry_product_group: &mut CThostFtdcQryProductGroupField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryProductGroup)(self.api_ptr, p_qry_product_group as *mut CThostFtdcQryProductGroupField, n_request_id)
        }
    }
    
    /// 请求查询做市商合约手续费率
    pub fn req_qry_mm_instrument_commission_rate(&self, p_qry_mm_instrument_commission_rate: &mut CThostFtdcQryMMInstrumentCommissionRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryMMInstrumentCommissionRate)(self.api_ptr, p_qry_mm_instrument_commission_rate as *mut CThostFtdcQryMMInstrumentCommissionRateField, n_request_id)
        }
    }
    
    /// 请求查询做市商期权合约手续费
    pub fn req_qry_mm_option_instr_comm_rate(&self, p_qry_mm_option_instr_comm_rate: &mut CThostFtdcQryMMOptionInstrCommRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryMMOptionInstrCommRate)(self.api_ptr, p_qry_mm_option_instr_comm_rate as *mut CThostFtdcQryMMOptionInstrCommRateField, n_request_id)
        }
    }
    
    /// 请求查询报单手续费
    pub fn req_qry_instrument_order_comm_rate(&self, p_qry_instrument_order_comm_rate: &mut CThostFtdcQryInstrumentOrderCommRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInstrumentOrderCommRate)(self.api_ptr, p_qry_instrument_order_comm_rate as *mut CThostFtdcQryInstrumentOrderCommRateField, n_request_id)
        }
    }
    
    /// 请求查询资金账户
    pub fn req_qry_sec_agent_trading_account(&self, p_qry_trading_account: &mut CThostFtdcQryTradingAccountField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySecAgentTradingAccount)(self.api_ptr, p_qry_trading_account as *mut CThostFtdcQryTradingAccountField, n_request_id)
        }
    }
    
    /// 请求查询二级代理商资金校验模式
    pub fn req_qry_sec_agent_check_mode(&self, p_qry_sec_agent_check_mode: &mut CThostFtdcQrySecAgentCheckModeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySecAgentCheckMode)(self.api_ptr, p_qry_sec_agent_check_mode as *mut CThostFtdcQrySecAgentCheckModeField, n_request_id)
        }
    }
    
    /// 请求查询二级代理商信息
    pub fn req_qry_sec_agent_trade_info(&self, p_qry_sec_agent_trade_info: &mut CThostFtdcQrySecAgentTradeInfoField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySecAgentTradeInfo)(self.api_ptr, p_qry_sec_agent_trade_info as *mut CThostFtdcQrySecAgentTradeInfoField, n_request_id)
        }
    }
    
    /// 请求查询期权交易成本
    pub fn req_qry_option_instr_trade_cost(&self, p_qry_option_instr_trade_cost: &mut CThostFtdcQryOptionInstrTradeCostField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryOptionInstrTradeCost)(self.api_ptr, p_qry_option_instr_trade_cost as *mut CThostFtdcQryOptionInstrTradeCostField, n_request_id)
        }
    }
    
    /// 请求查询期权合约手续费
    pub fn req_qry_option_instr_comm_rate(&self, p_qry_option_instr_comm_rate: &mut CThostFtdcQryOptionInstrCommRateField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryOptionInstrCommRate)(self.api_ptr, p_qry_option_instr_comm_rate as *mut CThostFtdcQryOptionInstrCommRateField, n_request_id)
        }
    }
    
    /// 请求查询执行宣告
    pub fn req_qry_exec_order(&self, p_qry_exec_order: &mut CThostFtdcQryExecOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryExecOrder)(self.api_ptr, p_qry_exec_order as *mut CThostFtdcQryExecOrderField, n_request_id)
        }
    }
    
    /// 请求查询询价
    pub fn req_qry_for_quote(&self, p_qry_for_quote: &mut CThostFtdcQryForQuoteField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryForQuote)(self.api_ptr, p_qry_for_quote as *mut CThostFtdcQryForQuoteField, n_request_id)
        }
    }
    
    /// 请求查询报价
    pub fn req_qry_quote(&self, p_qry_quote: &mut CThostFtdcQryQuoteField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryQuote)(self.api_ptr, p_qry_quote as *mut CThostFtdcQryQuoteField, n_request_id)
        }
    }
    
    /// 请求查询期权自对冲
    pub fn req_qry_option_self_close(&self, p_qry_option_self_close: &mut CThostFtdcQryOptionSelfCloseField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryOptionSelfClose)(self.api_ptr, p_qry_option_self_close as *mut CThostFtdcQryOptionSelfCloseField, n_request_id)
        }
    }
    
    /// 请求查询投资单元
    pub fn req_qry_invest_unit(&self, p_qry_invest_unit: &mut CThostFtdcQryInvestUnitField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestUnit)(self.api_ptr, p_qry_invest_unit as *mut CThostFtdcQryInvestUnitField, n_request_id)
        }
    }
    
    /// 请求查询组合合约安全系数
    pub fn req_qry_comb_instrument_guard(&self, p_qry_comb_instrument_guard: &mut CThostFtdcQryCombInstrumentGuardField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryCombInstrumentGuard)(self.api_ptr, p_qry_comb_instrument_guard as *mut CThostFtdcQryCombInstrumentGuardField, n_request_id)
        }
    }
    
    /// 请求查询申请组合
    pub fn req_qry_comb_action(&self, p_qry_comb_action: &mut CThostFtdcQryCombActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryCombAction)(self.api_ptr, p_qry_comb_action as *mut CThostFtdcQryCombActionField, n_request_id)
        }
    }
    
    /// 请求查询转帐流水
    pub fn req_qry_transfer_serial(&self, p_qry_transfer_serial: &mut CThostFtdcQryTransferSerialField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTransferSerial)(self.api_ptr, p_qry_transfer_serial as *mut CThostFtdcQryTransferSerialField, n_request_id)
        }
    }
    
    /// 请求查询银期签约关系
    pub fn req_qry_accountregister(&self, p_qry_accountregister: &mut CThostFtdcQryAccountregisterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryAccountregister)(self.api_ptr, p_qry_accountregister as *mut CThostFtdcQryAccountregisterField, n_request_id)
        }
    }
    
    /// 请求查询签约银行
    pub fn req_qry_contract_bank(&self, p_qry_contract_bank: &mut CThostFtdcQryContractBankField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryContractBank)(self.api_ptr, p_qry_contract_bank as *mut CThostFtdcQryContractBankField, n_request_id)
        }
    }
    
    /// 请求查询预埋单
    pub fn req_qry_parked_order(&self, p_qry_parked_order: &mut CThostFtdcQryParkedOrderField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryParkedOrder)(self.api_ptr, p_qry_parked_order as *mut CThostFtdcQryParkedOrderField, n_request_id)
        }
    }
    
    /// 请求查询预埋撤单
    pub fn req_qry_parked_order_action(&self, p_qry_parked_order_action: &mut CThostFtdcQryParkedOrderActionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryParkedOrderAction)(self.api_ptr, p_qry_parked_order_action as *mut CThostFtdcQryParkedOrderActionField, n_request_id)
        }
    }
    
    /// 请求查询交易通知
    pub fn req_qry_trading_notice(&self, p_qry_trading_notice: &mut CThostFtdcQryTradingNoticeField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryTradingNotice)(self.api_ptr, p_qry_trading_notice as *mut CThostFtdcQryTradingNoticeField, n_request_id)
        }
    }
    
    /// 请求查询经纪公司交易参数
    pub fn req_qry_broker_trading_params(&self, p_qry_broker_trading_params: &mut CThostFtdcQryBrokerTradingParamsField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryBrokerTradingParams)(self.api_ptr, p_qry_broker_trading_params as *mut CThostFtdcQryBrokerTradingParamsField, n_request_id)
        }
    }
    
    /// 请求查询经纪公司交易算法
    pub fn req_qry_broker_trading_algos(&self, p_qry_broker_trading_algos: &mut CThostFtdcQryBrokerTradingAlgosField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryBrokerTradingAlgos)(self.api_ptr, p_qry_broker_trading_algos as *mut CThostFtdcQryBrokerTradingAlgosField, n_request_id)
        }
    }
    
    /// 请求查询监控中心用户令牌
    pub fn req_query_cfmmc_trading_account_token(&self, p_query_cfmmc_trading_account_token: &mut CThostFtdcQueryCFMMCTradingAccountTokenField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQueryCFMMCTradingAccountToken)(self.api_ptr, p_query_cfmmc_trading_account_token as *mut CThostFtdcQueryCFMMCTradingAccountTokenField, n_request_id)
        }
    }
    
    /// 期货发起银行资金转期货请求
    pub fn req_from_bank_to_future_by_future(&self, p_req_transfer: &mut CThostFtdcReqTransferField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqFromBankToFutureByFuture)(self.api_ptr, p_req_transfer as *mut CThostFtdcReqTransferField, n_request_id)
        }
    }
    
    /// 期货发起期货资金转银行请求
    pub fn req_from_future_to_bank_by_future(&self, p_req_transfer: &mut CThostFtdcReqTransferField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqFromFutureToBankByFuture)(self.api_ptr, p_req_transfer as *mut CThostFtdcReqTransferField, n_request_id)
        }
    }
    
    /// 期货发起查询银行余额请求
    pub fn req_query_bank_account_money_by_future(&self, p_req_query_account: &mut CThostFtdcReqQueryAccountField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQueryBankAccountMoneyByFuture)(self.api_ptr, p_req_query_account as *mut CThostFtdcReqQueryAccountField, n_request_id)
        }
    }
    
    /// 请求查询分类合约
    pub fn req_qry_classified_instrument(&self, p_qry_classified_instrument: &mut CThostFtdcQryClassifiedInstrumentField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryClassifiedInstrument)(self.api_ptr, p_qry_classified_instrument as *mut CThostFtdcQryClassifiedInstrumentField, n_request_id)
        }
    }
    
    /// 请求组合优惠比例
    pub fn req_qry_comb_promotion_param(&self, p_qry_comb_promotion_param: &mut CThostFtdcQryCombPromotionParamField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryCombPromotionParam)(self.api_ptr, p_qry_comb_promotion_param as *mut CThostFtdcQryCombPromotionParamField, n_request_id)
        }
    }
    
    /// 投资者风险结算持仓查询
    pub fn req_qry_risk_settle_invst_position(&self, p_qry_risk_settle_invst_position: &mut CThostFtdcQryRiskSettleInvstPositionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRiskSettleInvstPosition)(self.api_ptr, p_qry_risk_settle_invst_position as *mut CThostFtdcQryRiskSettleInvstPositionField, n_request_id)
        }
    }
    
    /// 风险结算产品查询
    pub fn req_qry_risk_settle_product_status(&self, p_qry_risk_settle_product_status: &mut CThostFtdcQryRiskSettleProductStatusField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRiskSettleProductStatus)(self.api_ptr, p_qry_risk_settle_product_status as *mut CThostFtdcQryRiskSettleProductStatusField, n_request_id)
        }
    }
    
    /// SPBM期货合约参数查询
    pub fn req_qry_spbm_future_parameter(&self, p_qry_spbm_future_parameter: &mut CThostFtdcQrySPBMFutureParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMFutureParameter)(self.api_ptr, p_qry_spbm_future_parameter as *mut CThostFtdcQrySPBMFutureParameterField, n_request_id)
        }
    }
    
    /// SPBM期权合约参数查询
    pub fn req_qry_spbm_option_parameter(&self, p_qry_spbm_option_parameter: &mut CThostFtdcQrySPBMOptionParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMOptionParameter)(self.api_ptr, p_qry_spbm_option_parameter as *mut CThostFtdcQrySPBMOptionParameterField, n_request_id)
        }
    }
    
    /// SPBM品种内对锁仓折扣参数查询
    pub fn req_qry_spbm_intra_parameter(&self, p_qry_spbm_intra_parameter: &mut CThostFtdcQrySPBMIntraParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMIntraParameter)(self.api_ptr, p_qry_spbm_intra_parameter as *mut CThostFtdcQrySPBMIntraParameterField, n_request_id)
        }
    }
    
    /// SPBM跨品种抵扣参数查询
    pub fn req_qry_spbm_inter_parameter(&self, p_qry_spbm_inter_parameter: &mut CThostFtdcQrySPBMInterParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMInterParameter)(self.api_ptr, p_qry_spbm_inter_parameter as *mut CThostFtdcQrySPBMInterParameterField, n_request_id)
        }
    }
    
    /// SPBM组合保证金套餐查询
    pub fn req_qry_spbm_portf_definition(&self, p_qry_spbm_portf_definition: &mut CThostFtdcQrySPBMPortfDefinitionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMPortfDefinition)(self.api_ptr, p_qry_spbm_portf_definition as *mut CThostFtdcQrySPBMPortfDefinitionField, n_request_id)
        }
    }
    
    /// 投资者SPBM套餐选择查询
    pub fn req_qry_spbm_investor_portf_def(&self, p_qry_spbm_investor_portf_def: &mut CThostFtdcQrySPBMInvestorPortfDefField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMInvestorPortfDef)(self.api_ptr, p_qry_spbm_investor_portf_def as *mut CThostFtdcQrySPBMInvestorPortfDefField, n_request_id)
        }
    }
    
    /// 投资者新型组合保证金系数查询
    pub fn req_qry_investor_portf_margin_ratio(&self, p_qry_investor_portf_margin_ratio: &mut CThostFtdcQryInvestorPortfMarginRatioField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorPortfMarginRatio)(self.api_ptr, p_qry_investor_portf_margin_ratio as *mut CThostFtdcQryInvestorPortfMarginRatioField, n_request_id)
        }
    }
    
    /// 投资者产品SPBM明细查询
    pub fn req_qry_investor_prod_spbm_detail(&self, p_qry_investor_prod_spbm_detail: &mut CThostFtdcQryInvestorProdSPBMDetailField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorProdSPBMDetail)(self.api_ptr, p_qry_investor_prod_spbm_detail as *mut CThostFtdcQryInvestorProdSPBMDetailField, n_request_id)
        }
    }
    
    /// 投资者商品组SPMM记录查询
    pub fn req_qry_investor_commodity_spmm_margin(&self, p_qry_investor_commodity_spmm_margin: &mut CThostFtdcQryInvestorCommoditySPMMMarginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorCommoditySPMMMargin)(self.api_ptr, p_qry_investor_commodity_spmm_margin as *mut CThostFtdcQryInvestorCommoditySPMMMarginField, n_request_id)
        }
    }
    
    /// 投资者商品群SPMM记录查询
    pub fn req_qry_investor_commodity_group_spmm_margin(&self, p_qry_investor_commodity_group_spmm_margin: &mut CThostFtdcQryInvestorCommodityGroupSPMMMarginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorCommodityGroupSPMMMargin)(self.api_ptr, p_qry_investor_commodity_group_spmm_margin as *mut CThostFtdcQryInvestorCommodityGroupSPMMMarginField, n_request_id)
        }
    }
    
    /// SPMM合约参数查询
    pub fn req_qry_spmm_inst_param(&self, p_qry_spmm_inst_param: &mut CThostFtdcQrySPMMInstParamField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPMMInstParam)(self.api_ptr, p_qry_spmm_inst_param as *mut CThostFtdcQrySPMMInstParamField, n_request_id)
        }
    }
    
    /// SPMM产品参数查询
    pub fn req_qry_spmm_product_param(&self, p_qry_spmm_product_param: &mut CThostFtdcQrySPMMProductParamField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPMMProductParam)(self.api_ptr, p_qry_spmm_product_param as *mut CThostFtdcQrySPMMProductParamField, n_request_id)
        }
    }
    
    /// SPBM附加跨品种抵扣参数查询
    pub fn req_qry_spbm_add_on_inter_parameter(&self, p_qry_spbm_add_on_inter_parameter: &mut CThostFtdcQrySPBMAddOnInterParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQrySPBMAddOnInterParameter)(self.api_ptr, p_qry_spbm_add_on_inter_parameter as *mut CThostFtdcQrySPBMAddOnInterParameterField, n_request_id)
        }
    }
    
    /// RCAMS产品组合信息查询
    pub fn req_qry_rcams_comb_product_info(&self, p_qry_rcams_comb_product_info: &mut CThostFtdcQryRCAMSCombProductInfoField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSCombProductInfo)(self.api_ptr, p_qry_rcams_comb_product_info as *mut CThostFtdcQryRCAMSCombProductInfoField, n_request_id)
        }
    }
    
    /// RCAMS同合约风险对冲参数查询
    pub fn req_qry_rcams_instr_parameter(&self, p_qry_rcams_instr_parameter: &mut CThostFtdcQryRCAMSInstrParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSInstrParameter)(self.api_ptr, p_qry_rcams_instr_parameter as *mut CThostFtdcQryRCAMSInstrParameterField, n_request_id)
        }
    }
    
    /// RCAMS品种内风险对冲参数查询
    pub fn req_qry_rcams_intra_parameter(&self, p_qry_rcams_intra_parameter: &mut CThostFtdcQryRCAMSIntraParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSIntraParameter)(self.api_ptr, p_qry_rcams_intra_parameter as *mut CThostFtdcQryRCAMSIntraParameterField, n_request_id)
        }
    }
    
    /// RCAMS跨品种风险折抵参数查询
    pub fn req_qry_rcams_inter_parameter(&self, p_qry_rcams_inter_parameter: &mut CThostFtdcQryRCAMSInterParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSInterParameter)(self.api_ptr, p_qry_rcams_inter_parameter as *mut CThostFtdcQryRCAMSInterParameterField, n_request_id)
        }
    }
    
    /// RCAMS空头期权风险调整参数查询
    pub fn req_qry_rcams_short_opt_adjust_param(&self, p_qry_rcams_short_opt_adjust_param: &mut CThostFtdcQryRCAMSShortOptAdjustParamField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSShortOptAdjustParam)(self.api_ptr, p_qry_rcams_short_opt_adjust_param as *mut CThostFtdcQryRCAMSShortOptAdjustParamField, n_request_id)
        }
    }
    
    /// RCAMS策略组合持仓查询
    pub fn req_qry_rcams_investor_comb_position(&self, p_qry_rcams_investor_comb_position: &mut CThostFtdcQryRCAMSInvestorCombPositionField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRCAMSInvestorCombPosition)(self.api_ptr, p_qry_rcams_investor_comb_position as *mut CThostFtdcQryRCAMSInvestorCombPositionField, n_request_id)
        }
    }
    
    /// 投资者品种RCAMS保证金查询
    pub fn req_qry_investor_prod_rcams_margin(&self, p_qry_investor_prod_rcams_margin: &mut CThostFtdcQryInvestorProdRCAMSMarginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorProdRCAMSMargin)(self.api_ptr, p_qry_investor_prod_rcams_margin as *mut CThostFtdcQryInvestorProdRCAMSMarginField, n_request_id)
        }
    }
    
    /// RULE合约保证金参数查询
    pub fn req_qry_rule_instr_parameter(&self, p_qry_rule_instr_parameter: &mut CThostFtdcQryRULEInstrParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRULEInstrParameter)(self.api_ptr, p_qry_rule_instr_parameter as *mut CThostFtdcQryRULEInstrParameterField, n_request_id)
        }
    }
    
    /// RULE品种内对锁仓折扣参数查询
    pub fn req_qry_rule_intra_parameter(&self, p_qry_rule_intra_parameter: &mut CThostFtdcQryRULEIntraParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRULEIntraParameter)(self.api_ptr, p_qry_rule_intra_parameter as *mut CThostFtdcQryRULEIntraParameterField, n_request_id)
        }
    }
    
    /// RULE跨品种抵扣参数查询
    pub fn req_qry_rule_inter_parameter(&self, p_qry_rule_inter_parameter: &mut CThostFtdcQryRULEInterParameterField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryRULEInterParameter)(self.api_ptr, p_qry_rule_inter_parameter as *mut CThostFtdcQryRULEInterParameterField, n_request_id)
        }
    }
    
    /// 投资者产品RULE保证金查询
    pub fn req_qry_investor_prod_rule_margin(&self, p_qry_investor_prod_rule_margin: &mut CThostFtdcQryInvestorProdRULEMarginField, n_request_id: i32) -> i32 {
        unsafe {
            ((*(*self.api_ptr).vtable_).CThostFtdcTraderApi_ReqQryInvestorProdRULEMargin)(self.api_ptr, p_qry_investor_prod_rule_margin as *mut CThostFtdcQryInvestorProdRULEMarginField, n_request_id)
        }
    }
    
}
    