- UID
- 2
- 积分
- 2892307
- 威望
- 1396185 布
- 龙e币
- 1496122 刀
- 在线时间
- 13313 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2024-12-25
|
鼎元C++程序化交易系统教程【test.h文件解读】
C++头文件说明:
第一部分:- #pragma once
- #include <iostream>
- #include "Interface.h"
- #include <map>
- #include <iostream>
- #include <string>
- #include <list>
- #include <sstream>
- #include <vector>
- #include "cStruct.h"
- using namespace std;
- #pragma warining(disable:4996)
复制代码 第二部分:- class test :public Interface
- {
- public:
- test(HWND hw, string sName, string sPeriod, string sInst);
- virtual ~test();
- public:
- virtual void InitParm();
- virtual void UpdateParm(string s);
- virtual void UpdateSub(string sub, double ratio);
- virtual void OnRun();
- virtual void OnStop();
- virtual void OnTimer(string s);
- virtual void OnMarketData(CThostFtdcDepthMarketDataField* t);
- virtual void OnRsqBar(string sPeriod, string sInst, map<string, TKVALUE> mapK);
- virtual void OnBarOpen(TKVALUE t);
- virtual void OnRtnOrder(CThostFtdcOrderField t);
- virtual void OnRtnTrade(CThostFtdcTradeField t);
- virtual void OnInstrumentStatus(CThostFtdcInstrumentStatusField* t);
- virtual void OnInstrumentAll(map<string,CThostFtdcInstrumentField>*m);
- virtual void OnInstrument(CThostFtdcInstrumentField t);
- virtual void OnRspQryOrder(map <string, CThostFtdcOrderField>* m);
- virtual void OnRspQryTrade(map <string, CThostFtdcTradeField>* m);
- virtual void OnPosition(map<string, map <string, TPOSITION>>* m);
- virtual void OnPositionDetail(map<string, TDETAIL>* m);
- virtual void OnCommissionRate(map<string, map<string, TCOMMISSION>>* m);
- virtual void OnAccount(map<string, CThostFtdcTradingAccountField>* m);
- private:
- map<string, CThostFtdcDepthMarketDataField>mapMd;
- map<string, CThostFtdcInstrumentField>mapInstrument;
- map<string, CThostFtdcOrderField>mapOrder;
- map<string, CThostFtdcTradeField>mapTrade;
- map<string, map<string, TPOSITION>>mapPos;
- map<string, CThostFtdcTradingAccountField>mapAcc;
- map<string, map<string, TKVALUE>>mapReal;
- map<string, double>mapSub;
- map <string, map<string, map<string, TKVALUE>>>mapK;
- map<string, TDETAIL> mapPosDeta;
- map<string, map<string, TCOMMISSION>>mapCom;
- map<int, string>maps; // 日志信息
- private:
- int n = 0;
- map<string, TDLLPARM>parm;
- list<string>lst;
- list<string>lstActionOrdrSysID;
- list<string>lstbeigenOrdrSysID;
- bool IsActionOrdrSysID(string orderid);
- bool IsbeigenOrdrSysID(string orderid);
- string state = "stop";
- string path = "D:\\data\\log";
- void OnState(string s);
- void end();
- void tend(TDLLPARM t);
- void SubscribeMarketData(string s);
- void OrderInsert(string acc, string inst, char bs, char oc, int volume, double price, string forfok, string ref2);
- void OrderAction(CThostFtdcOrderField t);
- void RsqBar(string period, string inst);
- void InsertLog(string msg);
- void RsqInstrument(string inst);
- void RsqRspQryOrder();
- void RsqRspQryTrade();
- void RsqPosition();
- void RsqPositionDetail(string acc);
- void RsqCommissionRate();
- void RsqAccount();
- void sound(string s);
- //跟交易相关的变量,一般不建议修改
- void chedan();
- void shuchurizhi();
- void chongfa(CThostFtdcOrderField t);
- void closesell1(string sInvestorID, string sName, int sl, double jg);
- void closebuy1(string sInvestorID, string sName, int sl, double jg);
- void closesell2(string sInvestorID, string sName, int sl, double jg);
- void closebuy2(string sInvestorID, string sName, int sl, double jg);
- private: //指标变量库,不一定本策略能用到
- double avg(string period, string inst, int num); //均线函数名
- double avg1(string period, string inst, int num, int ref);//均线回溯,类似MC中MA[ref]
- double highest(string period, string inst, int num); //最高价函数名
- double highest1(string period, string inst, int num, int ref);//最高价回说,类似mc中的high[ref]
- double lowerest(string period, string inst, int num);//最低价函数名
- double lowerest1(string period, string inst, int num, int ref);//最低价回溯,类似mc中的lowerest[ref]
- private:
- int numod = 0;
- //面板交易配置函数
- HWND hwnd;
- string sName;//策略名
- string sPeriod; //交易周期
- string sInst; //交易合约品种
-
- string t1, t2, t3, t4, t0, sfcf, sss;
- //策略参数函数
- string dyt; //第一腿
- string det; //第二腿
- string bsfx;//第一腿买卖方向
- string ocfx;//第一腿开平方向
- double tjjc; //条件价差
- string tjjcfx, sfcd;//tjjcfx:条件价差方向,sfcd:是否重发
- int sl, cs, sjjg, num, tm;//sl:数量,
- int gdl;//挂弹量
- double jc, hd;//jc:价差,hd:交易滑点值
- bool yfd, dytcj, detcj, tz;
- };
复制代码 |
论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
|