![]() |
Xlight API用户手册 v1.6.0.23
Xlight极速柜台接口文档
|
接口类 更多...
#include <xlt_trade_api.h>
Public 成员函数 | |
| bool | initialize (XLTTradeConfig *trade_config, XLTTradeSpi *trade_spi) |
| 初始化交易,登录之前必须调用此函数,只能初始化一次 | |
| void | stop () |
| 停止交易API 断开所有交易session连接,清空所有session上的回调指针,停止回调。 | |
| bool | login (uint64_t request_id, uint16_t client_id, const char *account_name, const char *password, const char *pub_key, const xlt_user_terminal_info_t *info=nullptr) |
| 用户登录请求 | |
| bool | logout (uint64_t session_id) |
| 登出请求 | |
| bool | auth_trade (uint64_t session_id, uint64_t request_id, const char *account_name, const char *password, const char *pub_key, const xlt_user_terminal_info_t *info=nullptr) |
| 交易授权认证 | |
| bool | deauth_trade (uint64_t session_id, uint64_t request_id, uint64_t trade_token) |
| 解除交易授权认证 | |
| uint32_t | get_trading_day () |
| 获取当前交易日。只有登录成功后,才能得到正确的交易日。 | |
| const xlt_init_asset_info_t * | get_init_assets (uint64_t session_id, uint64_t trade_token=0) |
| 获取初始资产信息 | |
| const XLTInitPositionList * | get_init_positions (uint64_t session_id, uint64_t trade_token=0) |
| 获取初始持仓信息 | |
| uint64_t | get_account_index (uint64_t session_id, uint64_t trade_token=0) |
| 获取账户索引,只有登录成功后,才能得到正确的资金账户索引 | |
| void | get_xid_sender (uint64_t xid, uint64_t &session_id, uint64_t &trade_token) |
| 根据订单ID获取订单发送者信息,包括session_id和trade_token | |
| void | get_biz_sender (char *biz_no, uint64_t &session_id, uint64_t &trade_token) |
| 根据业务编号获取发送者信息,包括session_id和trade_token | |
| bool | subscribe_trade_message (uint64_t session_id, uint64_t request_id, trade_message_type_t trade_message_type, TradeResumeType resume_type, uint64_t start_sequence) |
| 订阅交易数据 每个session_id,仅第一次调用有效。 | |
| bool | rebuild_trade_message (uint64_t session_id, uint64_t request_id, trade_message_type_t trade_message_type, uint64_t start_sequence, uint64_t end_sequence, uint64_t account_index=0) |
| 重推消息 | |
| void | init_local_send () |
| 本地发送初始化函数,预分配本地发送资源,非必须调用。 若不调用,会在首次发送订单时自动进行初始化,故建议在用户线程调用发送接口前调用此函数以避免首次发送订单时的延迟。 | |
| uint64_t | insert_order (uint64_t session_id, xlt_order_insert_info_t *order, uint64_t trade_token=0) |
| 委托 报单录入请求,所有业务统一报单接口,根据业务类型字段区分不同业务。 Xlight接收订单后,会在报单响应函数on_order_response, on_cancel_response, on_order_error_response中返回, 之后所有的成交明细会在on_trade_report中返回,当订单到达终止状态会触发订单状态结束响应。 | |
| uint64_t | cancel_order (uint64_t session_id, xlt_cancel_order_info_t *cancel_order, uint64_t trade_token=0) |
| 撤单 撤单请求。 如果撤单成功,会在报单响应函数on_cancel_response里返回原单部撤或者全撤的消息, 如果不成功,会在on_order_error_response响应函数中返回错误原因。 | |
| bool | resend_order_request (uint64_t session_id, uint64_t xid) |
| 重发订单请求 | |
| bool | submit_counter_fund_transfer_request (uint64_t session_id, uint64_t request_id, FundTransSide side, amount_t amount, char *biz_no=nullptr, uint64_t trade_token=0) |
| 提交主柜资金划转请求 | |
| bool | submit_cluster_fund_transfer_request (uint64_t session_id, uint64_t request_id, amount_t amount, char *biz_no=nullptr, uint64_t trade_token=0) |
| 提交双中心资金划转请求,方向固定为划入 | |
| bool | query_assets (uint64_t session_id, uint64_t request_id, uint64_t account_index=0) |
| 请求查询资产 | |
| bool | query_positions (uint64_t session_id, uint64_t request_id, const char *security_code, ExchangeIndex exchange_index=ExchangeIndex::INIT, uint64_t account_index=0) |
| 请求查询投资者持仓 | |
| bool | query_orders (uint64_t session_id, uint64_t request_id, const xlt_order_query_param_t *order_query_param, uint64_t account_index=0) |
| 请求查询订单 | |
| bool | query_orders_by_page (uint64_t session_id, uint64_t request_id, uint32_t request_count, const xlt_page_query_reference_t *query_reference, uint64_t account_index=0) |
| 分页请求查询报单 | |
| bool | query_trades (uint64_t session_id, uint64_t request_id, uint64_t xid, uint64_t account_index=0) |
| 请求查询成交回报 | |
| bool | query_init_assets (uint64_t session_id, uint64_t request_id, uint64_t account_index=0) |
| 请求查询初始资产 | |
| bool | query_init_positions (uint64_t session_id, uint64_t request_id, const char *security_code, ExchangeIndex exchange_index, uint64_t account_index=0) |
| 请求查询初始持仓 | |
| bool | query_trade_account_info (uint64_t session_id, uint64_t request_id, uint64_t account_index=0) |
| 请求查询交易账户信息 | |
| bool | dump_api_performance_info () |
静态 Public 成员函数 | |
| static XLTTradeApi * | create () |
| 创建实例(只能创建一次) | |
| static const char * | get_api_version () |
| 获取API版本号 | |
| static xlt_error_info_t | get_last_error () |
| 获取错误信息 | |
| static uint64_t | get_order_sequence (uint64_t xid) |
| 根据订单ID获取订单序列号 | |
Protected 成员函数 | |
| XLTTradeApi ()=default | |
接口类
|
protecteddefault |
| bool x1::XLTTradeApi::auth_trade | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| const char * | account_name, | ||
| const char * | password, | ||
| const char * | pub_key, | ||
| const xlt_user_terminal_info_t * | info = nullptr ) |
交易授权认证
| session_id | 会话ID,登录时得到 |
| request_id | 用于用户定位请求的ID,由用户自定义 |
| account_name | 交易账号 |
| password | 登录密码 |
| pub_key | 用户公钥(长度64字节),用户开户时申请得到,暂未启用 |
| info | 终端信息,若当前API为最终端则填nullptr,否则填写终端信息 |
| uint64_t x1::XLTTradeApi::cancel_order | ( | uint64_t | session_id, |
| xlt_cancel_order_info_t * | cancel_order, | ||
| uint64_t | trade_token = 0 ) |
撤单 撤单请求。 如果撤单成功,会在报单响应函数on_cancel_response里返回原单部撤或者全撤的消息, 如果不成功,会在on_order_error_response响应函数中返回错误原因。
| session_id | 会话id,登录时得到 |
| cancel_order | 撤单信息 |
| trade_token | 如果是普通交易账号填0;如果为授权认证的账号,填写认证成功时on_auth_trade回调函数返回的trade_token。 |
|
static |
创建实例(只能创建一次)
| bool x1::XLTTradeApi::deauth_trade | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint64_t | trade_token ) |
解除交易授权认证
| session_id | 会话ID,登录时得到 |
| request_id | 用于用户定位请求的ID,由用户自定义 |
| trade_token | 交易令牌,交易授权认证时得到 |
| bool x1::XLTTradeApi::dump_api_performance_info | ( | ) |
| uint64_t x1::XLTTradeApi::get_account_index | ( | uint64_t | session_id, |
| uint64_t | trade_token = 0 ) |
获取账户索引,只有登录成功后,才能得到正确的资金账户索引
| session_id | 会话id,登录时得到 |
| trade_token | 交易令牌,交易授权认证时得到,如果登录账户即为交易账户,填0即可 |
|
static |
获取API版本号
| void x1::XLTTradeApi::get_biz_sender | ( | char * | biz_no, |
| uint64_t & | session_id, | ||
| uint64_t & | trade_token ) |
根据业务编号获取发送者信息,包括session_id和trade_token
| biz_no | 业务编号 |
| session_id | 发送者的session_id |
| trade_token | 发送者的trade_token |
| const xlt_init_asset_info_t * x1::XLTTradeApi::get_init_assets | ( | uint64_t | session_id, |
| uint64_t | trade_token = 0 ) |
获取初始资产信息
| session_id | 会话ID,登录时得到 |
| trade_token | 交易令牌,交易授权认证时得到,如果登录账户即为交易账户,填0即可 |
| const XLTInitPositionList * x1::XLTTradeApi::get_init_positions | ( | uint64_t | session_id, |
| uint64_t | trade_token = 0 ) |
获取初始持仓信息
| session_id | 会话ID,登录时得到 |
| trade_token | 交易令牌,交易授权认证时得到,如果登录账户即为交易账户,填0即可 |
|
static |
获取错误信息
|
static |
根据订单ID获取订单序列号
| xid | 订单ID |
| uint32_t x1::XLTTradeApi::get_trading_day | ( | ) |
获取当前交易日。只有登录成功后,才能得到正确的交易日。
| void x1::XLTTradeApi::get_xid_sender | ( | uint64_t | xid, |
| uint64_t & | session_id, | ||
| uint64_t & | trade_token ) |
根据订单ID获取订单发送者信息,包括session_id和trade_token
| xid | 订单ID |
| session_id | 订单发送者的session_id |
| trade_token | 订单发送者的trade_token |
| void x1::XLTTradeApi::init_local_send | ( | ) |
本地发送初始化函数,预分配本地发送资源,非必须调用。 若不调用,会在首次发送订单时自动进行初始化,故建议在用户线程调用发送接口前调用此函数以避免首次发送订单时的延迟。
| bool x1::XLTTradeApi::initialize | ( | XLTTradeConfig * | trade_config, |
| XLTTradeSpi * | trade_spi ) |
初始化交易,登录之前必须调用此函数,只能初始化一次
| trade_config | 配置参数 |
| trade_spi | 派生自交易响应类的实例,请在登录之前设定 |
| uint64_t x1::XLTTradeApi::insert_order | ( | uint64_t | session_id, |
| xlt_order_insert_info_t * | order, | ||
| uint64_t | trade_token = 0 ) |
委托 报单录入请求,所有业务统一报单接口,根据业务类型字段区分不同业务。 Xlight接收订单后,会在报单响应函数on_order_response, on_cancel_response, on_order_error_response中返回, 之后所有的成交明细会在on_trade_report中返回,当订单到达终止状态会触发订单状态结束响应。
| session_id | 资金账户对应的session_id,登录时得到 |
| order | 委托信息 |
| trade_token | 交易令牌,如果是普通交易账号填0;如果为授权认证的账号,填写认证成功时on_auth_trade回调函数返回的trade_token。 |
| bool x1::XLTTradeApi::login | ( | uint64_t | request_id, |
| uint16_t | client_id, | ||
| const char * | account_name, | ||
| const char * | password, | ||
| const char * | pub_key, | ||
| const xlt_user_terminal_info_t * | info = nullptr ) |
用户登录请求
| request_id | 用于用户定位请求响应的ID,由用户自定义 |
| client_id | 客户端标识ID |
| account_name | 交易账号 |
| password | 登录密码 |
| pub_key | 用户公钥(长度64字节),用户开户时申请得到,暂未启用 |
| info | 终端信息,若当前API为最终端则填nullptr,否则填写终端信息 |
| bool x1::XLTTradeApi::logout | ( | uint64_t | session_id | ) |
登出请求
| session_id | 会话id,登录时得到 |
| bool x1::XLTTradeApi::query_assets | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint64_t | account_index = 0 ) |
请求查询资产
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_init_assets | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint64_t | account_index = 0 ) |
请求查询初始资产
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_init_positions | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| const char * | security_code, | ||
| ExchangeIndex | exchange_index, | ||
| uint64_t | account_index = 0 ) |
请求查询初始持仓
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| security_code | 需要查询持仓的合约代码,可以为空表示查询全市场,如果不为空,请不带空格,并以'\0'结尾 |
| exchange_index | 需要查询持仓的合约所在市场,默认为INIT。 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_orders | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| const xlt_order_query_param_t * | order_query_param, | ||
| uint64_t | account_index = 0 ) |
请求查询订单
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| order_query_param | 需要查询的订单相关筛选条件,其中xid如果不为0,则只查询指定订单,否则根据后续条件进行查询: 其中证券代码可以为空,则默认所有存在的证券代码,如果不为空,请不带空格, 其中起始时间格式为YYYYMMDDHHMMSSsss,为0则默认当前交易日0点,结束时间格式为YYYYMMDDHHMMSSsss,为0则默认当前时间 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_orders_by_page | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint32_t | request_count, | ||
| const xlt_page_query_reference_t * | query_reference, | ||
| uint64_t | account_index = 0 ) |
分页请求查询报单
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| request_count | 分页请求的订单数量,建议小于1000 |
| query_reference | 需要分页查询订单的条件,如果第一次查询,那么page_query_param.reference填0 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_positions | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| const char * | security_code, | ||
| ExchangeIndex | exchange_index = ExchangeIndex::INIT, | ||
| uint64_t | account_index = 0 ) |
请求查询投资者持仓
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| security_code | 需要查询持仓的合约代码,可以为空表示查询全市场,如果不为空,请不带空格,并以'\0'结尾 |
| exchange_index | 需要查询持仓的合约所在市场,默认为INIT。如果想正确查询指定持仓,请指定exchange_index |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_trade_account_info | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint64_t | account_index = 0 ) |
请求查询交易账户信息
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::query_trades | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| uint64_t | xid, | ||
| uint64_t | account_index = 0 ) |
请求查询成交回报
| session_id | 会话id,登录时得到 |
| request_id | 用于用户定位查询响应的ID,由用户自定义 |
| xid | 需要查询的订单ID |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::rebuild_trade_message | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| trade_message_type_t | trade_message_type, | ||
| uint64_t | start_sequence, | ||
| uint64_t | end_sequence, | ||
| uint64_t | account_index = 0 ) |
重推消息
| session_id | 会话ID,登录时得到 |
| request_id | 用于用户定位请求的ID,由用户自定义 |
| trade_message_type | 交易数据类型,可以同时订阅多种类型,用按位或方式组合 |
| start_sequence | 数据推送的起始序列号,从start_sequence+1开始推 |
| end_sequence | 数据推送的结束序列号,end_sequence必须大于start_sequence |
| account_index | 交易账号索引,0表示查所有或者当前登录交易账号索引,非0表示指定交易账号索引。可通过get_account_index或者query_trade_account_info获取交易账号索引 |
| bool x1::XLTTradeApi::resend_order_request | ( | uint64_t | session_id, |
| uint64_t | xid ) |
重发订单请求
| session_id | 会话id,登录时得到 |
| xid | 需要重发的订单ID |
| void x1::XLTTradeApi::stop | ( | ) |
停止交易API 断开所有交易session连接,清空所有session上的回调指针,停止回调。
| bool x1::XLTTradeApi::submit_cluster_fund_transfer_request | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| amount_t | amount, | ||
| char * | biz_no = nullptr, | ||
| uint64_t | trade_token = 0 ) |
提交双中心资金划转请求,方向固定为划入
| session_id | 会话id,登录时得到 |
| request_id | 由用户自定义 |
| amount | 划入金额,放大10000倍 |
| biz_no | 输出参数,返回系统生成的业务流水号,缓冲区至少20字节。传nullptr则不返回。划拨结果通过on_cluster_fund_transfer_result返回。 |
| trade_token | 如果是普通交易账号填0;如果为授权认证的账号,填写认证成功时on_auth_trade回调函数返回的trade_token。 |
| bool x1::XLTTradeApi::submit_counter_fund_transfer_request | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| FundTransSide | side, | ||
| amount_t | amount, | ||
| char * | biz_no = nullptr, | ||
| uint64_t | trade_token = 0 ) |
提交主柜资金划转请求
| session_id | 会话id,登录时得到 |
| request_id | 由用户自定义 |
| side | 划转方向,IN-划入(从主柜划入到xlight),OUT-划出(从xlight划出到主柜) |
| amount | 划转金额,放大10000倍 |
| biz_no | 输出参数,返回系统生成的业务流水号,缓冲区至少20字节。传nullptr则不返回。划拨结果通过on_counter_fund_transfer_result返回。 |
| trade_token | 如果是普通交易账号填0;如果为授权认证的账号,填写认证成功时on_auth_trade回调函数返回的trade_token。 |
| bool x1::XLTTradeApi::subscribe_trade_message | ( | uint64_t | session_id, |
| uint64_t | request_id, | ||
| trade_message_type_t | trade_message_type, | ||
| TradeResumeType | resume_type, | ||
| uint64_t | start_sequence ) |
订阅交易数据 每个session_id,仅第一次调用有效。
| session_id | 会话ID,登录时得到 |
| request_id | 用于用户定位请求的ID,由用户自定义 |
| trade_message_type | 订阅的交易数据类型,可以同时订阅多种类型,用按位或方式组合 |
| resume_type | 消息推送方式 |
| start_sequence | 数据推送的起始序列号,默认值为0,当resume_type为TradeResumeType::SPECIFY时有效 |