历史版本xtquant
PTD
阅读:17
2025-06-09 14:27:30
评论:0
XtQuant 接口文档
xtdata 模块
数据获取函数
get_full_tick(code_list)
获取盘口tick数据
- 参数:
code_list
: (list)由stock.market组成的股票代码列表
- 返回:
- dict格式数据,键为股票代码,值为对应的tick数据字典
xttrader 模块
主要类
XtQuantTrader
类
交易主类,提供各种交易相关功能
初始化
__init__(self, path, session, callback=None)
- 参数:
path
: mini版迅投极速交易客户端安装路径下,userdata文件夹具体路径session
: 当前任务执行所属的会话idcallback
: 回调方法
交易相关方法
下单
order_stock(self, account, stock_code, order_type, order_volume, price_type, price, strategy_name='', order_remark='')
同步股票下单
- 参数:
account
: 证券账号stock_code
: 证券代码, 例如”600000.SH”order_type
: 委托类型, 23:买, 24:卖order_volume
: 委托数量price_type
: 报价类型price
: 报价价格strategy_name
: 策略名称order_remark
: 委托备注
- 返回: 下单请求序号
异步下单
order_stock_async(self, account, stock_code, order_type, order_volume, price_type, price, strategy_name='', order_remark='')
参数同上
撤单
cancel_order_stock(self, account, order_id)
同步撤单
- 参数:
account
: 证券账号order_id
: 委托编号
- 返回: 撤单结果
异步撤单
cancel_order_stock_async(self, account, order_id)
参数同上
查询相关方法
查询账户信息
query_account_infos(self)
- 返回: 账号列表
查询股票资产
query_stock_asset(self, account)
- 参数:
account
: 证券账号
- 返回: 当前证券账号的资产数据
查询持仓
query_stock_positions(self, account)
- 参数:
account
: 证券账号
- 返回: 当日所有持仓的持仓对象列表
查询委托
query_stock_orders(self, account, cancelable_only=False)
- 参数:
account
: 证券账号cancelable_only
: 仅查询可撤委托
- 返回: 当日所有委托的委托对象列表
查询成交
query_stock_trades(self, account)
- 参数:
account
: 证券账号
- 返回: 当日所有成交的成交对象列表
其他方法
资金划转
fund_transfer(self, account, transfer_direction, price)
- 参数:
account
: 证券账号transfer_direction
: 划拨方向price
: 划拨金额
- 返回: 划拨操作结果
连接
connect(self)
建立连接
运行
run_forever(self)
保持运行
XtQuantTraderCallback
类
交易回调类,用于处理各种交易事件
回调方法
连接状态
on_connected(self)
连接成功时调用
on_disconnected(self)
连接断开时调用
订单相关
on_order_stock_async_response(self, response)
异步下单响应
- 参数:
response
: XtOrderResponse对象
on_cancel_order_stock_async_response(self, response)
异步撤单响应
- 参数:
response
: XtCancelOrderResponse对象
on_order_error(self, order_error)
下单错误
- 参数:
order_error
: XtOrderError对象
资产持仓
on_stock_asset(self, asset)
资产变动
- 参数:
asset
: XtAsset对象
on_stock_position(self, position)
持仓变动
- 参数:
position
: XtPosition对象
其他函数
cp(s=None)
未提供详细说明
title(s=None)
未提供详细说明
current_thread()
返回当前线程对象
注:本文档基于自动生成的帮助信息整理,部分方法可能缺少详细说明。实际使用时请参考官方完整文档或联系技术支持。
本文由 海星量化研究所 作者提供,转载请保留链接和署名!网址:https://qmt.hxquant.com/?id=40
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源; 2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任; 3.作者投稿可能会经我们编辑修改或补充。