forked from sngyai/Sequoia-X
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork_flow.py
More file actions
68 lines (54 loc) · 2.3 KB
/
work_flow.py
File metadata and controls
68 lines (54 loc) · 2.3 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
# -*- encoding: UTF-8 -*-
import data_fetcher
import utils
import strategy.enter as enter
from strategy import turtle_trade
from strategy import backtrace_ma250
from strategy import breakthrough_platform
from strategy import parking_apron
from strategy import low_atr
import notify
import logging
import db
def process():
logging.info("************************ process start ***************************************")
utils.prepare()
data_fetcher.run()
check_exit()
stocks = utils.get_stocks()
m_filter = check_enter(end_date=None)
results = list(filter(m_filter, stocks))
logging.info('选股结果:{0}'.format(results))
notify.notify('选股结果:{0}'.format(results))
logging.info("************************ process end ***************************************")
def check_enter(end_date=None):
def end_date_filter(code_name):
data = utils.read_data(code_name)
result = backtrace_ma250.check(code_name, data, end_date=end_date)
# result = parking_apron.check(code_name, data, end_date=end_date)
# result = low_atr.check_low_increase(code_name, data, end_date=end_date)
# result = enter.check_ma(code_name, data, end_date=end_date) \
# and breakthrough_platform.check(code_name, data, end_date=end_date)
if result:
message = turtle_trade.calculate(code_name, data)
logging.info("{0} {1}".format(code_name, message))
notify.notify("{0} {1}".format(code_name, message))
return result
# low_atr.check_low_increase(code_name, name, data)
# and enter.check_breakthrough(stock, data, end_date=end_date) \
return end_date_filter
def check_exit():
t_shelve = db.ShelvePersistence()
file = t_shelve.open()
for key in file:
code_name = file[key]['code_name']
data = utils.read_data(code_name)
if turtle_trade.check_exit(code_name, data):
notify.notify("{0} 达到退出条件".format(code_name))
logging.info("{0} 达到退出条件".format(code_name))
del file[key]
elif turtle_trade.check_stop(code_name, data, file[key]):
notify.notify("{0} 达到止损条件".format(code_name))
logging.info("{0} 达到止损条件".format(code_name))
del file[key]
file.close()