forked from pegasusTrader/PandoraTrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcwEmptyStrategy.cpp
108 lines (88 loc) · 2.33 KB
/
cwEmptyStrategy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "cwEmptyStrategy.h"
#ifndef cwDouble_EQ
#include <limits>
#define cwDouble_EQ (std::numeric_limits<double>::epsilon())
#endif // !cwDouble_EQ
#ifndef MAX_PATH
#define MAX_PATH 260
#endif // !MAX_PATH
cwEmptyStrategy::cwEmptyStrategy()
: m_bShowPosition(true)
{
}
cwEmptyStrategy::~cwEmptyStrategy()
{
}
std::string cwEmptyStrategy::GetStrategyName()
{
std::string strStrategyName("EmptyStrategy");
if (m_strStrategyName.size() > 0)
{
strStrategyName.append("_");
strStrategyName.append(m_strStrategyName);
}
return strStrategyName;
}
void cwEmptyStrategy::PriceUpdate(cwMarketDataPtr pPriceData)
{
if (pPriceData.get() == NULL)
{
return;
}
m_strCurrentUpdateTime = pPriceData->UpdateTime;
if ((!m_bStrategyReady))
{
return;
}
}
void cwEmptyStrategy::InitialStrategy(const char * pConfigFilePath)
{
if (pConfigFilePath == NULL
|| strlen(pConfigFilePath) == 0)
{
char exeFullPath[MAX_PATH];
memset(exeFullPath, 0, MAX_PATH);
#ifdef _MSC_VER
TCHAR TexeFullPath[MAX_PATH];
::GetModuleFileName(NULL, TexeFullPath, MAX_PATH);
int iLength;
//»ñÈ¡×Ö½Ú³¤¶È
iLength = WideCharToMultiByte(CP_ACP, 0, TexeFullPath, -1, NULL, 0, NULL, NULL);
//½«tcharÖµ¸³¸ø_char
WideCharToMultiByte(CP_ACP, 0, TexeFullPath, -1, exeFullPath, iLength, NULL, NULL);
m_strConfigFileFullPath = exeFullPath;
std::size_t found = m_strConfigFileFullPath.find_last_of("/\\");
m_strConfigFileFullPath = m_strConfigFileFullPath.substr(0, found);
m_strConfigFileFullPath.append("\\EmptyStrategy.xml");
#else
size_t cnt = readlink("/proc/self/exe", exeFullPath, MAX_PATH);
if (cnt < 0 || cnt >= MAX_PATH)
{
printf("***Error***\n");
exit(-1);
}
m_strConfigFileFullPath = exeFullPath;
std::size_t found = m_strConfigFileFullPath.find_last_of("/\\");
m_strConfigFileFullPath = m_strConfigFileFullPath.substr(0, found);
m_strConfigFileFullPath.append("/EmptyStrategy.xml");
#endif
}
else
{
m_strConfigFileFullPath = pConfigFilePath;
}
}
void cwEmptyStrategy::OnReady()
{
std::vector<std::string> SubscribeInstrument;
for (auto it = m_InstrumentMap.begin(); it != m_InstrumentMap.end(); it++)
{
SubscribeInstrument.push_back(it->first);
if (SubscribeInstrument.size() >= 10)
{
//SubScribePrice(SubscribeInstrument);
SubscribeInstrument.clear();
}
}
//SubScribePrice(SubscribeInstrument);
}