-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathafter_jump.py
85 lines (77 loc) · 2.49 KB
/
after_jump.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
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
#!/usr/local/bin/python`
import urllib
import re
import math
import sys
import os
import thread
import tushare as ts
reload(sys)
sys.setdefaultencoding("utf-8")
import threading
import time
import pandas as pd
from MyStock import *
f = open('pure_code', 'r')
class myThread (threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
self.name = name
def run(self):
print "Starting " + self.name
f_out=open("result/after_just_%s" % (datetime.today().date().strftime('%Y%m%d')), 'a')
while True:
code = get_code()
if not code:
return
try:
current_data = ts.get_realtime_quotes('%s' % (code))
peak_data = pd.read_csv('pd_5days/%s.csv' % (code))
if current_data.empty or peak_data.empty:
continue
ph_today = float(current_data['high'].values[0])
price = float(current_data['price'].values[0])
if price > 15:
continue
pre_close = float(current_data['pre_close'].values[0])
pl_today = float(current_data['low'].values[0])
ma5, ma10, ma20, ma30 = get_mas_live(code, price)
if (ma5 < ma10) or (ma10 < ma20):
continue
print pl_today, ma5
if pl_today > ma5:
continue
if is_later(current_data['time'].values[0], '15:00:00'):
ma5_y, ma10_y, ma20_y, ma30_y = get_mas_yesterday(code)
pl_y = float(peak_data.head(2).tail(1)['low'].values[0])
else:
ma5_y, ma10_y, ma20_y, ma30_y = get_mas(code)
pl_y = float(peak_data.head(1)['low'].values[0])
if pl_y >= ma5_y:
continue
if hist_zt(peak_data.head(6)):
print code, ma5, ma10, ma20, ma30
f_out.write('%s\n' % (code))
except Exception as e:
print 'something wrong with code: %s, %s' % (code, str(e))
f_out.close()
def get_code():
threadLock.acquire()
r = f.readline()
threadLock.release()
return r.strip()
threadLock = threading.Lock()
threads = []
# 创建新线程
i = 0
while (i<10):
threads.append(myThread(i))
i = i + 1
# 开启新线程
for thread in threads:
thread.start()
# 等待所有线程完成
for t in threads:
t.join()
f.close()