单均线交易系统程式码部分1【.h头文件】
test.h头文件部件:[code]#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:
int numod = 0;
HWND hwnd;
string sName;
string sPeriod;
string sInst;
string t1, t2, t3, t4, t0;
int jxzq, jyfx, num, hd, yxpc, jg, fx, ss, tm,cscc;
double jx, zg, zd, ma, rcjg, dbfx, ccjg;
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);
double avg(string period, string inst, int num);
double highest(string period, string inst, int num);
double lowerest(string period, string inst, int num);
double avg1(string period, string inst, int num, int ref);
double highest1(string period, string inst, int num, int ref);
double lowerest1(string period, string inst, int num, int ref);
void chedan();
void shuchurizhi();
void xieruzhuangtai();
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);
};
[/code] 我做了一下整理优化,更方便理解和阅读:[code]#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:
int numod = 0;
HWND hwnd;
string t1, t2, t3, t4, t0;
//在交易界面设置时传递的变量(开始)*****************************************
string sName;
string sPeriod;
string sInst;
//在交易界面设置时传递的变量(结束)*****************************************
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 xieruzhuangtai();
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 highest(string period, string inst, int num);
double lowerest(string period, string inst, int num);
double avg1(string period, string inst, int num, int ref);
double highest1(string period, string inst, int num, int ref);
double lowerest1(string period, string inst, int num, int ref);
//公式变量传递(结束)*******************************************
private:
//参数设置相关的变量传递(开始)*******************************
int jxzq, jyfx, num, hd, yxpc, jg, fx, ss, tm, dbfx, cscc;
double jx, zg, zd, ma;
//参数设置相关的变量传递(结束)*******************************
};
/*
相关说明,上面大部分变量都不建议改动,平时在交易设计中主要变动修改问题为底部的交易参数设置与新公式的设计,这个根据需要自行增减变量函数名称。
*/
[/code]
页:
[1]