# ctppython-stepdebug **Repository Path**: martinliu0507/ctppython-stepdebug ## Basic Information - **Project Name**: ctppython-stepdebug - **Description**: 基于ctp pythonapi封装版本代码的单步测试,支持多平台的运行测试,后续会逐步拓展功能与平台 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2022-09-30 - **Last Updated**: 2025-04-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: ctp ## README 本项目为将CTP期货api转换为python模块版本的开源内容,方便直接通过actionlist文件,操作各类简单的api功能 一、config文件说明 # 网络配置(交易前置、行情前置) [network] tradefront=tcp://188.177.88.133:8888 mdfront=tcp://188.177.88.133:8889 # 20250324新增tgateapi支持 tgatefront=tcp://188.177.88.133:10098 # 认证信息 [authinfo] appid=client_test_1.0 authcode=UFFFFFFFL999999X # 基础信息 [baseinfo] brokerid=8888 userid=10121314 password=test@123 # restart(0) resume(1) quick(2) none(3) 0为重收所有数据 1为根据本地con文件续传 2为收取当前登录后的内容 3为不收取(只对公有流订阅有效) pritopicmode为私有流配置 pubtopicmode为公有流配置 pritopicmode=2 pubtopicmode=2 [searchopt] # 功能调用超时时间设置(秒)——部分功能设置了超时,一般都是一个请求对应一个返回的功能,才走这个逻辑 timeoutsec=30 # 订阅行情流合约列表 [ReqDepthMD] mdlist=ag2210,ag2211 # 交易查询行情快照配置信息 [TradeReqDepthMD] exchid= instrid= #futures (1) options(2) spotoptions(6) productclass=1 # 部分查询函数配置信息 [ReqQryOption] investorid=789789 hedgeflag=1 tradingday=20230613 # 是否接受合约变动通知 [Rtnctl] instrstatus=1 # 报单相关参数设置 [orderinfo] instrid=ag2405 pricetype=2 dir=0 offset=0 hedge=1 price=1309 volume=1 autosuspend=0 # 以下两个配置为服务器条件单相关配置,默认conticond为1是非条件单,其他情况config中列出了6和8的情况,stopprice则为条件单触发价位。 # immediate(1) lastprice >= X(6) lastprice <= X (8) conticond=1 stopprice=1299 # fak fok configuration 20250401新增fak、fok配置项目 # set fak/fok timecond = 1 普通订单 timecond配置为3,fak/fok单,timecond要首先调整为1 timecond=3 # volcond setting: 1:minvol = 1;2:minvol = x;3:fok timecond设置为fak/fok模式后,volcond配置起效:1表示任意数量,可以理解为接受最小成交单位为1;2表示指定最小成交单位,在minvol配置设置;3表示全部数量,也就是fok的定义方式 volcond=1 # minvol配置配合volcond为2的时候,一起使用 minvol=1 # tgate qry configuration 20250418新增6.7.9P1版本的tgateapi的查询appid入参, 留空表示不筛选,如果填写特定appid,需要确认服务端有对应配置 [tgateqry] appid= 二、actionlist支持功能说明 交易部分: tradeins.start # 交易api网络初始化 tradeins.ReqAuth # 客户端认证 tradeins.ReqLogin # 投资者登录 tradeins.ReqQrySettInfo # 查询结算单内容 配合[ReqQryOption]使用 tradeins.ReqQryClsIns # 查询合约 新函数,合约查询异常之后建议调用版本 tradeins.ReqQryIns # 查询合约 旧函数,基本不再生产使用 tradeins.ReqQryInsMR # 查询合约保证金率 配合[ReqQryOption]使用 tradeins.ReqQryInsCR # 查询合约合约手续费率 配合[ReqQryOption]使用 tradeins.ReqSettleInfoCf # 结算单确认函数 tradeins.ReqOrIn # 立即单/条件单报单函数 配合[orderinfo]使用,条件单特别注意config中的相关配置 tradeins.ReqPaOrIn # 预埋单报单函数 配合[orderinfo]使用 tradeins.PrintFrontInfo # 用于在用户登录后打印链接的前置信息 tradeins.ReqQryDepMD # 用于从交易接口单次查询当前的行情快照(与行情接口同名调用不同) tradeins.ReqOrDel # 报单撤销函数 在程序运行生命周期内,以上一个报单为操作对象 #当前客户已报入全撤操作: tradeins.ReqQryOr #先查询所有报单 tradeins.ReqOrDelAll #对于上述查询结果,进行全体撤单操作 行情部分: mdins.start # 行情api网络初始化 mdins.ReqLogin # 投资者登录 mdins.ReqDepthMD # 订阅合约行情 配合[ReqDepthMD]使用 tgate部分: tgins.start # tgateapi网络初始化 tgins.ReqTgateInfo # 查询前置列表请求 配合[tgateqry]