Skip to content

Commit 87186c0

Browse files
author
ztsec
committed
升级python版本至 2.2.39.3
1 parent e888c43 commit 87186c0

File tree

183 files changed

+3164
-435
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+3164
-435
lines changed

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22

33
本项目是中泰证券XTP极速交易PYTHON接口的开源实现,供客户在量化交易中使用PYTHON接口快速接入XTP系统。中泰证券XTP是为股票交易而生的极速交易系统,为投资者提供极速交易、极速行情、Level2行情。
44

5-
目前xtp系统最新的api版本为2.2.33.5,支持win、linux平台运行
5+
目前xtp系统最新的api版本为2.2.39.3,支持windows、linux平台运行
66

7-
请先到中泰证券xtp官方网站申请测试账号 https://xtp.zts.com.cn 及测试环境的连接ip、端口等信息
7+
请先到中泰证券xtp官方网站申请测试账号 https://xtp.zts.com.cn 及测试环境的连接ip、端口等信息
88

99
API参考官方C++版本的接口文档 https://xtp.zts.com.cn/doc/api/xtpDoc
1010

11-
由于python版本api封装使用的vs2010,如果未安装vs环境,运行时会提示ImportError:DLL load failed。需要根据python的位数选择对应的运行库,32位的选x86,64位选x64,执行程序参考文件包vs2010运行库
12-
x86系统的vs2010运行库:vcredist_x86.exe
13-
x64系统的vs2010运行库:vcredist_x64.exe
11+
由于python版本api封装使用的Visual Studio 2015,如果未安装vs环境,运行时会提示ImportError:DLL load failed。需根据python的位数选择对应Visual C++库的运行时组件,64位选vc_redist.x64.exe,执行程序参考文件包vs2015运行库。
12+
13+
官网下载地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=48145
1414

1515
##事项说明:
1616

1717
1.当前xtp的python api封装支持win7系统、win10系统和Linux系统,在bin目录下Linux文件夹中有python3封装库,Windows文件夹中有64位的python3封装库。test文件夹下包含行情和交易的测试脚本。
1818

19-
2.当前bin目录下编译时python3使用的python3.6.5版本,如果直接使用当前的封装库,请注意使用的python版本是否为3.6系列。在Windows下如果您使用的python版本和我们编译时使用的版本不一致,会导致调用python封装库失败。
19+
2.当前bin目录下编译时python3使用的python3.6.5、python3.9.13 版本,如果直接使用当前的封装库,请注意使用的python版本是否为3.6系列、3.9系列。在Windows下如果您使用的python版本和我们编译时使用的版本不一致,会导致调用python封装库失败。
2020

2121
3.如果客户需要按自己的python版本编译封装库,可以使用source目录下的代码,根据自己的python的版本,及该python版本对应的编译后的boost库,自行编译所需的python封装库。(具体过程在doc文件夹下有编译过程文档,source文件夹下有源码,包括Linux和Windows下编译的python3封装库)。
2222

23-
4.XTP_API_20220402_2.2.33.5文件夹下存放最新的xtp系统的api,当前python封装库分别包含行情和交易库,python封装后的接口与当前xtp系统api的所有接口都保持一致,只有方法名有所区别,python封装后的接口方法名首字母小写,而xtp系统api的方法名首字母大写。因此所有封装后的python接口方法使用和功能都可以参见xtp系统api的接口方法。请在xtp_quote_api.h、xtp_trader_api.h两个头文件中了解各个接口的使用及功能。
23+
4.XTP_API_20231222_2.2.39.3文件夹下存放最新的xtp系统的api,当前python封装库分别包含行情和交易库,python封装后的接口与当前xtp系统api的所有接口都保持一致,只有方法名有所区别,python封装后的接口方法名首字母小写,而xtp系统api的方法名首字母大写。
24+
25+
因此所有封装后的python接口方法使用和功能都可以参见xtp系统api的接口方法。请在xtp_quote_api.h、xtp_trader_api.h两个头文件中了解各个接口的使用及功能。
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-12.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

XTP_API_20220402_2.2.33.5/bin/include/algo_api_struct.h renamed to XTP_API_20231222_2.2.39.3/bin/include/algo_api_struct.h

+9
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ typedef struct XTPStrategySymbolStateReportStruct
8282
XTPRI m_error_info; ///< 错误信息
8383
} XTPStrategySymbolStateReport;
8484

85+
///推荐算法结构体
86+
typedef struct XTPStrategyRecommendationInfoStruct
87+
{
88+
uint16_t m_strategy_type; ///< 策略类型
89+
XTP_MARKET_TYPE m_market; ///< 交易市场
90+
char m_ticker[XTP_TICKER_LEN]; ///< 证券代码
91+
char m_reserved[64]; ///< 保留域
92+
} XTPStrategyRecommendationInfo;
93+
8594
#pragma pack()
8695

8796
#endif //_XTP_ALGO_API_STRUCT_H_

source/Linux/xtp_api_python3_2.2.33.5/xtpapi/xoms_api_struct.h renamed to XTP_API_20231222_2.2.39.3/bin/include/xoms_api_struct.h

+43-3
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,16 @@ struct XTPQueryStkPositionRsp
437437

438438
///持仓市值(此字段目前只有期权账户有值,其他类型账户为0)
439439
double market_value;
440+
///义务仓占用保证金(此字段目前只有期权账户有值,其他类型账户为0)
441+
double margin;
442+
443+
///昨日买入成本
444+
double last_buy_cost;
445+
///昨日盈亏成本
446+
double last_profit_cost;
440447

441448
///(保留字段)
442-
uint64_t unknown[50 - 10];
449+
uint64_t unknown[50 - 13];
443450
};
444451

445452
/////////////////////////////////////////////////////////////////////////
@@ -619,6 +626,29 @@ struct XTPQueryETFComponentRsp
619626

620627
};
621628

629+
//////////////////////////////////////////////////////////////////////////
630+
///查询债转股信息
631+
//////////////////////////////////////////////////////////////////////////
632+
struct XTPQueryBondSwapStockReq
633+
{
634+
// 交易市场
635+
XTP_MARKET_TYPE market;
636+
// 证券代码
637+
char ticker[XTP_TICKER_LEN];
638+
};
639+
640+
typedef struct XTPQueryBondSwapStockRsp
641+
{
642+
XTP_MARKET_TYPE market; // 交易市场
643+
char ticker[XTP_TICKER_LEN]; // 债券证券代码
644+
char underlying_ticker[XTP_TICKER_LEN]; // 转股后的股票证券代码
645+
int32_t unit; // 转换数量单位(张)
646+
int64_t qty_min; // 最小下单量(张)
647+
int64_t qty_max; // 最大下单量(张)
648+
double swap_price; // 转股价格
649+
int32_t swap_flag; // 是否处于转股期;0: 不可转股;1:可转股;
650+
}XTPQueryBondSwapStockRsp;
651+
622652
//////////////////////////////////////////////////////////////////////////
623653
///查询当日可申购新股信息
624654
//////////////////////////////////////////////////////////////////////////
@@ -818,7 +848,9 @@ struct XTPQueryOptCombPositionRsp {
818848

819849
XTPOptCombPlugin opt_comb_info; ///< 期权组合策略信息
820850

821-
uint64_t reserved[50]; ///< 保留字段
851+
double secu_comb_margin; ///< 组合占用保证金(公司)(目前暂未启用)
852+
853+
uint64_t reserved[50 - 1]; ///< 保留字段
822854
};
823855

824856
/// 查询期权合约行权信息的响应
@@ -1048,7 +1080,15 @@ typedef struct XTPCreditDebtExtendNotice XTPCreditDebtExtendAck;
10481080
typedef struct XTPCrdFundExtraInfo
10491081
{
10501082
double mf_rs_avl_used; ///<当前资金账户购买货币基金使用的融券卖出所得资金占用
1051-
char reserve[64]; ///<预留空间
1083+
///证券市值
1084+
double security_capital;
1085+
///融资负债
1086+
double financing_debts;
1087+
///融券负债
1088+
double short_sell_debts;
1089+
///授信总额度
1090+
double contract_debts_load;
1091+
char reserve[64-32]; ///<预留空间
10521092
}XTPCrdFundExtraInfo;
10531093

10541094
//////////////////////////////////////////////////////////////////////////

source/Windows/xtp_api_python3_2.2.33.5/xtpapi/xquote_api_struct.h renamed to XTP_API_20231222_2.2.39.3/bin/include/xquote_api_struct.h

+75-16
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ struct XTPMarketDataBondExData {
9595
int64_t total_bid_qty;
9696
///委托卖出总量(SH,SZ)
9797
int64_t total_ask_qty;
98-
///加权平均委买价格(SH,SZ)
98+
///加权平均委买价格(SZ)
9999
double ma_bid_price;
100-
///加权平均委卖价格(SH,SZ)
100+
///加权平均委卖价格(SZ)
101101
double ma_ask_price;
102102
///债券加权平均委买价格(SH)
103103
double ma_bond_bid_price;
@@ -109,10 +109,10 @@ struct XTPMarketDataBondExData {
109109
double match_lastpx;
110110
///债券加权平均价格(SH)
111111
double ma_bond_price;
112-
///预留
113-
double r2;
114-
///预留
115-
double r3;
112+
///匹配成交成交量(SZ)
113+
int64_t match_qty;
114+
///匹配成交成交金额(SZ)
115+
double match_turnover;
116116
///预留
117117
double r4;
118118
///预留
@@ -248,6 +248,8 @@ typedef struct XTPMarketDataStruct
248248
int64_t trades_count;
249249
///当前交易状态说明,参阅《XTP API常见问题.doc》文档
250250
char ticker_status[8];
251+
252+
//对于新三板行情来说,以下结构和字段均无效
251253
///数据
252254
union {
253255
XTPMarketDataStockExData stk;
@@ -260,6 +262,17 @@ typedef struct XTPMarketDataStruct
260262
XTP_MARKETDATA_TYPE_V2 data_type_v2;
261263
} XTPMD;
262264

265+
///IOPV信息
266+
struct IOPV {
267+
///交易所代码
268+
XTP_EXCHANGE_TYPE exchange_id;
269+
///合约代码(不包含交易所信息),不带空格,以'\0'结尾
270+
char ticker[XTP_TICKER_LEN];
271+
/// 时间
272+
int64_t data_time;
273+
/// iopv值
274+
double iopv;
275+
};
263276

264277
///股票行情静态信息
265278
typedef struct XTPQuoteStaticInfo {
@@ -410,13 +423,13 @@ typedef struct XTPQuoteFullInfo {
410423
XTP_EXCHANGE_TYPE exchange_id; ///<交易所代码
411424
char ticker[XTP_TICKER_LEN]; ///<证券代码
412425
char ticker_name[XTP_TICKER_NAME_LEN]; ///<证券名称
413-
XTP_SECURITY_TYPE security_type; ///<合约详细类型
414-
XTP_QUALIFICATION_TYPE ticker_qualification_class; ///<合约适当性类别
415-
bool is_registration; ///<是否注册制(仅适用创业板股票,创新企业股票及存托凭证)
416-
bool is_VIE; ///<是否具有协议控制架构(仅适用创业板股票,创新企业股票及存托凭证)
417-
bool is_noprofit; ///<是否尚未盈利(仅适用创业板股票,创新企业股票及存托凭证)
418-
bool is_weighted_voting_rights; ///<是否存在投票权差异(仅适用创业板股票,创新企业股票及存托凭证)
419-
bool is_have_price_limit; ///<是否有涨跌幅限制(注:不提供具体幅度,可通过涨跌停价和昨收价来计算幅度)
426+
XTP_SECURITY_TYPE security_type; ///<合约详细类型
427+
XTP_QUALIFICATION_TYPE ticker_qualification_class; ///<合约适当性类别
428+
bool is_registration; ///<是否注册制(仅适用创业板股票,创新企业股票及存托凭证)
429+
bool is_VIE; ///<是否具有协议控制架构(仅适用创业板股票,创新企业股票及存托凭证)
430+
bool is_noprofit; ///<是否尚未盈利(仅适用创业板股票,创新企业股票及存托凭证)
431+
bool is_weighted_voting_rights; ///<是否存在投票权差异(仅适用创业板股票,创新企业股票及存托凭证)
432+
bool is_have_price_limit; ///<是否有涨跌幅限制(注:不提供具体幅度,可通过涨跌停价和昨收价来计算幅度)
420433
double upper_limit_price; ///<涨停价(仅在有涨跌幅限制时有效)
421434
double lower_limit_price; ///<跌停价(仅在有涨跌幅限制时有效)
422435
double pre_close_price; ///<昨收价
@@ -434,11 +447,57 @@ typedef struct XTPQuoteFullInfo {
434447
int32_t market_ask_qty_lower_limit; ///<市价卖委托数量上限
435448
int32_t market_ask_qty_unit; ///<市价卖数量单位
436449
XTP_SECURITY_STATUS security_status; ///<证券状态
437-
uint32_t unknown1; ///<保留字段
438-
uint64_t unknown[3]; ///<保留字段
450+
uint32_t unknown1; ///<保留字段
451+
uint64_t unknown[3]; ///<保留字段
452+
439453
}XTPQFI;
440454

455+
///新三板全量静态信息
456+
typedef struct XTPQuoteNQFullInfo {
457+
XTP_EXCHANGE_TYPE exchange_id; ///<交易所代码
458+
char ticker[XTP_TICKER_LEN]; ///<证券代码
459+
char ticker_name[XTP_TICKER_NAME_LEN]; ///<证券名称
460+
XTP_SECURITY_TYPE security_type; ///<合约详细类型,目前均为255
461+
XTP_QUALIFICATION_TYPE ticker_qualification_class; ///<合约适当性类别
462+
char ticker_abbr_en[XTP_TICKER_NAME_LEN]; ///<英文简称
463+
char base_ticker[XTP_TICKER_LEN]; ///<基础证券
464+
char industry_type[6]; ///<行业种类
465+
char currency_type[3]; ///<货币种类
466+
int32_t trade_unit; ///<交易单位
467+
int32_t hang_out_date; ///<挂牌日期
468+
int32_t value_date; ///<起息日期
469+
int32_t maturity_date; ///<到期日
470+
int32_t per_limit_vol; ///<每笔限量
471+
int32_t buy_vol_unit; ///<买数量单位
472+
int32_t sell_vol_unit; ///<卖数量单位
473+
int32_t mini_declared_vol; ///<最小申报数量
474+
int32_t limit_price_attr; ///<限价参数性质
475+
int32_t market_maker_quantity; ///<做市商数量
476+
double price_gear; ///<价格档位
477+
double first_limit_trans; ///<首笔交易限价参数
478+
double subsequent_limit_trans; ///<后续交易限价参数
479+
double limit_upper_price; ///<涨停价格
480+
double limit_lower_price; ///<跌停价格
481+
double block_trade_upper; ///<大宗交易价格上限(预留,默认0)
482+
double block_trade_lower; ///<大宗交易价格下限(预留,默认0)
483+
double convert_into_ration; ///<折合比例
484+
XTP_TRADE_STATUS trade_status : 8; ///<交易状态
485+
XTP_SECURITY_LEVEL security_level : 8; ///<证券级别
486+
XTP_TRADE_TYPE trade_type : 8; ///<交易类型
487+
XTP_SUSPEND_FLAG suspend_flag : 8; ///<停牌标志
488+
XTP_EX_DIVIDEND_FLAG ex_dividend_flag : 8; ///<除权除息标志
489+
XTP_SECURITY_LAYER_TYPE layer_type : 8; ///<分层信息
490+
int32_t reserved1 : 16; ///<保留字段
491+
char trade_places[3]; ///<交易场所 预留
492+
char is_rzbd; ///<是否融资标的 Y是 N否
493+
char is_rqbd; ///<是否融券标的 Y是 N否
494+
char is_drrz; ///<是否当日可融资 Y是 N否
495+
char is_drrq; ///<是否当日可融券 Y是 N否
496+
char reserved; ///<保留字段
497+
uint64_t unknown[3]; ///<保留字段
498+
}XTPNQFI;
499+
500+
441501
#pragma pack()
442502

443503
#endif
444-

0 commit comments

Comments
 (0)