1
1
import importlib
2
2
import os
3
3
import pathlib
4
+ import signal
4
5
import sys
6
+ import threading
5
7
import time
6
8
from collections import OrderedDict
7
- import dill
8
- import threading
9
9
from threading import Thread , Lock
10
- import signal
11
10
12
11
import easytrader
13
12
from logbook import Logger , StreamHandler
@@ -43,8 +42,6 @@ def __init__(self, broker=None, need_data=None, quotation_engines=None,
43
42
need_data_file = pathlib .Path (need_data )
44
43
if need_data_file .exists ():
45
44
self .user .prepare (need_data )
46
- with open (ACCOUNT_OBJECT_FILE , 'wb' ) as f :
47
- dill .dump (self .user , f )
48
45
else :
49
46
log_handler .warn ("券商账号信息文件 %s 不存在, easytrader 将不可用" % need_data )
50
47
else :
@@ -91,11 +88,12 @@ def __init__(self, broker=None, need_data=None, quotation_engines=None,
91
88
self .main_shutdown = [] # 引擎自身要执行的 shutdown
92
89
self .after_shutdown = [] # 关闭引擎后的 shutdown
93
90
self .shutdown_signals = [
94
- signal .SIGQUIT , # quit 信号
95
91
signal .SIGINT , # 键盘信号
96
92
signal .SIGHUP , # nohup 命令
97
93
signal .SIGTERM , # kill 命令
98
94
]
95
+ if sys .platform != 'win32' :
96
+ self .shutdown_signals .append (signal .SIGQUIT )
99
97
100
98
for s in self .shutdown_signals :
101
99
# 捕获退出信号后的要调用的,唯一的 shutdown 接口
@@ -139,7 +137,6 @@ def load(self, names, strategy_file):
139
137
# 注销策略的监听
140
138
old_strategy = self .get_strategy (strategy_module .Strategy .name )
141
139
if old_strategy is None :
142
- print (18181818 , strategy_module_name )
143
140
for s in self .strategy_list :
144
141
print (s .name )
145
142
self .log .warn (u'卸载策略: %s' % old_strategy .name )
@@ -156,7 +153,7 @@ def load(self, names, strategy_file):
156
153
if names is None or strategy_class .name in names :
157
154
self .strategies [strategy_module_name ] = strategy_class
158
155
# 缓存加载信息
159
- new_strategy = strategy_class (log_handler = self .log , main_engine = self )
156
+ new_strategy = strategy_class (user = self . user , log_handler = self .log , main_engine = self )
160
157
self .strategy_list .append (new_strategy )
161
158
self ._cache [strategy_file ] = mtime
162
159
self .strategy_listen_event (new_strategy , "listen" )
0 commit comments