[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
CTP是上海期货交易所开发的一套程序化交易的API。这篇文章呢,是进行扫盲和引路的,让你在开发时可以少走弯路。
1、如果你要进行CTP开发,那么先是在模拟环境下调试,这就需要去上期的仿真模拟网站simnow下载相应的API包。地址如下:
上期所仿真交易网站
比如下载其中的:6.3.19看穿式API_20200106
因为我目前在开发时,用的是这个版本,而且测试下来能正常登录,接收行情数据。
2、解压下载的包,其中的文件结构如下:
CTP开发的相关文件
这里我要说明下,我喜欢在Linux下进行开发,毕竟C++嘛,做服务器端开发还是需要在Linux下进行的。再说了,这个CTP
C++开发,如果没计算机基础也很难做,而一般懂计算机的也会玩Linux,所以我就选择讲Linux。这里的几个文件我说明下:
(1)ThostFtdcMdApi.h 行情相关的API头文件
(2)ThostFtdcTraderApi.h 交易相关的API头文件
(3)ThostFtdcUserApiStruct.h、ThostFtdcUserApiDataType.h 各种数据结构、数据类型的定义。
(4)thostmduserapi_se.so、thosttraderapi_se.so Linux下的动态链接库,编译和运行时要用到。这个懂C++
Linux的自然懂。
3、别忘了,这时你还没有测试账号哦,这个测试账号去simnow申请。注册登录后,进入自己的后台,你可以得到这几个信息:
模拟账号
一般在交易时,需要用到这几个信息:
(1)gBrokerID 模拟经纪商代码
(2)InvesterID 投资者账户名
(3)InvesterPassword 投资者密码
(4)AppID 测试时填:simnow_client_test
(5)AuthCode 授权码 测试时填:0000000000000000
好了,到现在为止,基本的CTP开发概念都已经讲清楚了,下面就可以开发CTP的开发之旅了。我们先开发行情端,再开发交易端。