資源簡介
本范例是根據上期技術提供的C++的API接口編寫的可以進行實盤的代碼,需要進行商品期貨程序化交易的同學請看來
代碼片段和文件信息
//?AutoTrader.cpp?:?單合約版本輸入經紀公司代碼,實盤帳號,密碼即可下單。
//自動保存訂閱合約TICK數據到\Bin\TickData下,文件名合約名稱_日期.txt
//
//
//
//AutoTrader.cpp?:?定義控制臺應用程序的入口點。
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
#include?“.\ThostTraderApi\ThostFtdcTraderApi.h“
#include?“.\ThostTraderApi\ThostFtdcMdApi.h“
#include?“TraderSpi.h“
#include?“MdSpi.h“
#include?“Common.h“
#include?“DataSniffer.h“
#include?“MyTrader.h“
#pragma?warning(disable?:?4996)
//?UserApi對象
CThostFtdcTraderApi?*pUserApi;
//?MdApi對象
CThostFtdcMdApi?*pMdApi;
//?配置參數
char??FRONT_ADDR_1A[]?=?“tcp://front111.ctp.gtjafutures.com:41205“; //?前置地址1交易:實盤
char??FRONT_ADDR_1B[]?=?“tcp://front111.ctp.gtjafutures.com:41213“; //?前置地址2行情:實盤
char??FRONT_ADDR_2A[]?=?“tcp://csv101.ctp.gtjafutures.com:41205“; //?前置地址1交易:盤后
char??FRONT_ADDR_2B[]?=?“tcp://csv101.ctp.gtjafutures.com:41213“; //?前置地址2行情:盤后
char??FRONT_ADDR_3A[]?=?“tcp://asp-sim2-front1.financial-trading-platform.com:26205“; //?前置地址3交易:仿真?17:00開始
char??FRONT_ADDR_3B[]?=?“tcp://asp-sim2-md1.financial-trading-platform.com:26213“; //?前置地址3行情:仿真?17:00開始
TThostFtdcBrokerIDType BROKER_ID?=?“7090“; //?實盤:經紀公司代碼?國泰君安=7090
TThostFtdcInvestorIDType?INVESTOR_ID?=?“88888888“; //?實盤:投資者代碼
TThostFtdcPasswordType??PASSWORD?=?“123456“; //?實盤:用戶密碼
//TThostFtdcBrokerIDType BROKER_ID?=?“2030“; //?經紀公司代碼:仿真
//TThostFtdcInvestorIDType?INVESTOR_ID?=?“00092“; //?投資者代碼:仿真
//TThostFtdcPasswordType??PASSWORD?=?“888888“; //?用戶密碼:仿真
TThostFtdcInstrumentIDType?INSTRUMENT_ID?=?“ag1412“; //?交易合約代碼
TThostFtdcDirectionType DIRECTION; //?交易買賣方向
TThostFtdcOffsetFlagType?MARKETState; //?開平倉
TThostFtdcPriceType LIMIT_PRICE; //?交易價格
//char?*ppInstrumentID[]?=?{“IF1406“?“rb1410“?“j1409“?“ru1409““SR409“?“m1409“?“y1409“?“p1409““ag1412“?“cu1408“}; //?行情訂閱列表
char?*ppInstrumentID[]?=?{“ag1412“}; //?行情訂閱列表
int?iInstrumentID?=?1; //?行情訂閱數量
bool RunMode=0; //?實盤下單=1否則=0;??影響Common.h中的SendOrder()函數
bool ReceiveTick?=?false;
//?請求編號
int?iRequestID?=?0;
//?交易時間
bool JustRun?=?false; //正在啟動標志
TThostFtdcDateExprType TradingDay;
//?User行情數據
extern char *InstrumentID_name; //
extern string Q_BarTime_s; //時間字符串
extern int Q_BarTime_1; //時間采用秒計
extern double Q_BarTime_2; //時間格式0.145100
extern double Q_UpperLimit; //
extern double Q_LowerLimit; //
extern double NewPrice; //
extern int FirstVolume; //前一次成交量數據
extern double??Mn_open[3]; //?
extern double??Mn_high[3]; //?
extern double??Mn_low[3]; //?
extern double??Mn_close[3]; //?
extern double??BuyPrice; //開倉價
extern double??SellPrice; //開倉價
extern int BNum; //開倉次數
extern int SNum; //開倉次數
extern bool BuySignal; //
extern bool SellSignal; //
extern double BSVolume;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????9728??2017-02-22?09:49??上期技術CTP_C++_API實盤范例代碼及幫助文件\.vs\AutoTrader\v14\.suo
????..A..H.????113152??2017-09-28?11:17??上期技術CTP_C++_API實盤范例代碼及幫助文件\.vs\MyAutoTrader\v14\.suo
?????文件????????682??2014-05-28?21:44??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.cfg
?????文件???????5336??2014-05-28?21:43??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.cpp
?????文件?????????48??2014-05-06?15:47??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.dat
?????文件????4295680??2014-04-18?09:11??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.ncb
?????文件???????5679??2014-05-28?21:00??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.vcproj
?????文件???????1427??2014-06-03?16:14??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.vcproj.PC-200912071906.Administrator.user
?????文件???????6496??2017-02-22?09:48??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.vcxproj
?????文件???????2781??2017-02-22?09:48??上期技術CTP_C++_API實盤范例代碼及幫助文件\AutoTrader.vcxproj.filters
?????文件????????885??2014-04-18?08:54??上期技術CTP_C++_API實盤范例代碼及幫助文件\Backup\MyAutoTrader.sln
?????文件???????7135??2014-05-28?21:27??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrade\20140529.txt
?????文件?????????32??2014-04-21?08:35??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrader.bat
?????文件????????682??2014-05-28?21:44??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrader.cfg
?????文件?????????30??2014-05-28?21:25??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrader.dat
?????文件??????????0??2014-05-09?15:15??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrader.log
?????文件?????838656??2017-02-21?13:46??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\AutoTrader.pdb
????..A.SH.??????9216??2014-05-08?00:12??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\temp\Thumbs.db
?????文件?????685568??2013-12-04?18:48??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thostmduserapi.dll
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thostmduserapi.dllDialogRsp.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thostmduserapi.dllQueryRsp.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thostmduserapi.dllTradingDay.con
?????文件????1245696??2013-12-05?10:24??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dll
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dllDialogRsp.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dllPrivate.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dllPublic.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dllQueryRsp.con
?????文件??????????6??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\thosttraderapi.dllTradingDay.con
?????文件??????73582??2014-05-28?21:31??上期技術CTP_C++_API實盤范例代碼及幫助文件\Bin\TickData\ag1412_20140529.txt
?????文件???????6747??2014-06-03?16:10??上期技術CTP_C++_API實盤范例代碼及幫助文件\Common.h
............此處省略79個文件信息
- 上一篇:C++飛機游戲源代碼
- 下一篇:linuxc.pdf
評論
共有 條評論