-
Notifications
You must be signed in to change notification settings - Fork 7
/
boll.py
72 lines (62 loc) · 1.94 KB
/
boll.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
65
66
67
68
69
70
71
72
def dapan_zeshi():
return
def filter_stock():
ma30_1k<0
ma30_k1>0
return
def across(last_close,this_close,across_baseline,type='across_up'):
is_across = False
if type=='across_up':
is_across = this_close>=across_baseline and across_baseline>=last_close
elif type=='across_down':
is_across = this_close<=across_baseline and across_baseline<=last_close
else:
pass
return is_across
def get_days_of_strong_zone():
#表征运行的区间,强势区间为正
days_of_strong_zone = 0
days_of_last_up_across_middle = 0
days_of_last_down_across_middle = 0
if days_of_last_up_across_middle<days_of_last_down_across_middle:
days_of_strong_zone = days_of_last_up_across_middle
else:
days_of_strong_zone = -1 * days_of_last_down_across_middle
return days_of_strong_zone
def boll_trade():
days_of_strong_zone = 3 #表征运行的区间,强势区间为正
days_up_across_upper = 0 #表征运行的区间,强势区间为正
up_across_middle = True
down_across_middle = True
up_across_upper = True
down_cross_upper = True
#if close>las_close:
if days_of_strong_zone<-3:
if up_across_middle:
buy = 1
else:
just_monitor = 1
elif days_of_strong_zone>3:
if down_across_middle:
sell_now = 0.5
else:
pass
if days_up_across_upper==1:
hold = 1
elif days_up_across_upper>1:
if is_last_chang_shangyin:
sell_last_high = 1
elif down_cross_upper:
sell_now =1
else:
pass
else:
if up_across_middle:
buy = 0.5
else:
pass
if down_across_middle:
sell_now = 1
else:
pass
return