-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventType.py
64 lines (47 loc) · 2.2 KB
/
eventType.py
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
# encoding: UTF-8
'''
本文件仅用于存放对于事件类型常量的定义。
由于python中不存在真正的常量概念,因此选择使用全大写的变量名来代替常量。
这里设计的命名规则以EVENT_前缀开头。
常量的内容通常选择一个能够代表真实意义的字符串(便于理解)。
建议将所有的常量定义放在该文件中,便于检查是否存在重复的现象。
'''
# 系统相关
EVENT_TIMER = 'eTimer' # 计时器事件,每隔1秒发送一次
EVENT_LOG = 'eLog' # 日志事件,全局通用
# Gateway相关
EVENT_TICK = 'eTick.' # TICK行情事件,可后接具体的vtSymbol
EVENT_TRADE = 'eTrade.' # 成交回报事件
EVENT_ORDER = 'eOrder.' # 报单回报事件
EVENT_POSITION = 'ePosition.' # 持仓回报事件
EVENT_ACCOUNT = 'eAccount.' # 账户回报事件
EVENT_CONTRACT = 'eContract.' # 合约基础信息回报事件
EVENT_ERROR = 'eError.' # 错误回报事件
# CTA模块相关
EVENT_CTA_LOG = 'eCtaLog' # CTA相关的日志事件
EVENT_CTA_STRATEGY = 'eCtaStrategy.' # CTA策略状态变化事件
# 行情记录模块相关
EVENT_DATARECORDER_LOG = 'eDataRecorderLog' # 行情记录日志更新事件
# Wind接口相关
EVENT_WIND_CONNECTREQ = 'eWindConnectReq' # Wind接口请求连接事件
#----------------------------------------------------------------------
def test():
"""检查是否存在内容重复的常量定义"""
check_dict = {}
global_dict = globals()
for key, value in global_dict.items():
if '__' not in key: # 不检查python内置对象
if value in check_dict:
check_dict[value].append(key)
else:
check_dict[value] = [key]
for key, value in check_dict.items():
if len(value)>1:
print u'存在重复的常量定义:' + str(key)
for name in value:
print name
print ''
print u'测试完毕'
# 直接运行脚本可以进行测试
if __name__ == '__main__':
test()