-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmapping.cpp
More file actions
93 lines (86 loc) · 2.76 KB
/
mapping.cpp
File metadata and controls
93 lines (86 loc) · 2.76 KB
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
#include "../util/log_assert.h"
#include "mapping.h"
namespace QuantApi {
/** @brief 把交易所编码映射到系统的交易所编码 */
ExchType map2QDExchType(const char* str_exch) throw (Util::InvalidParamException) {
// 上海期货交易所
if(strcmp(str_exch, "SHFE") == 0)
return '1';
// 郑州商品交易所
if(strcmp(str_exch, "CZCE") == 0)
return '2';
// 大连商品交易所
if(strcmp(str_exch, "DCE") == 0)
return '3';
// 中国金融期货交易所
if(strcmp(str_exch, "CFFEX") == 0)
return '4';
//上海证券交易所
if(strcmp(str_exch, "SSE") == 0)
return '5';
//深圳证券交易所
if(strcmp(str_exch, "SZSE") == 0)
return '6';
//测试专用交易所
if(strcmp(str_exch, "CC") == 0)
return '7';
throw Util::InvalidParamException("无效的编码: ", str_exch);
}
std::string mapFromQDExchType(ExchType c) throw (Util::InvalidParamException) {
switch(c) {
case '1': return "SHFE";
case '2': return "CZCE";
case '3': return "DCE";
case '4': return "CFFEX";
case '5': return "SSE";
case '6': return "SZSE";
case '7': return "CC";
default: throw Util::InvalidParamException("无效的编码: ", &c);
}
return "";
}
/** @brief 把系统的交易所编码映射到交易所编码 */
const char* map2ReadableExchType(ExchType type) throw (Util::InvalidParamException) {
switch(type) {
case '1':
return "上期";
case '2':
return "郑商";
case '3':
return "大商";
case '4':
return "中金";
case '5':
return "上证";
case '6':
return "深证";
default: throw Util::InvalidParamException("无效的编码: ", &type);
}
return "";
}
const char* tradesideMapping(TradeSide side) throw (Util::InvalidParamException) {
switch(side) {
case kKai: return "开仓";
case kPing: return "平仓";
default: throw Util::InvalidParamException("无效的编码: ", "%d", side);
}
return "";
}
const char* directionMapping(Direction direc) throw (Util::InvalidParamException) {
switch(direc) {
case LONG: return "多头";
case SHORT: return "空头";
default: throw Util::InvalidParamException("无效的编码: ", "%d", direc);
}
return "";
}
const char* priceTypeMapping(PriceType deal_type) throw (Util::InvalidParamException) {
switch(deal_type) {
case kMarket: return "市价";
case kMilliseconds: "限价";
case kLimit: return "限价";
default: throw Util::InvalidParamException("无效的编码: ", "%d", deal_type);
}
return "";
}
} /* QuantApi */