forked from Rockyzsu/stock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
big_deal.py
60 lines (53 loc) · 1.54 KB
/
big_deal.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
#-*-coding=utf-8-*-
__author__ = 'Rocky'
'''
http://30daydo.com
Contact: [email protected]
'''
import tushare as ts
#搜索大单进入的个股
import pandas as pd
from toolkit import Toolkit
import os
import numpy as np
pd.set_option('display.max_rows',None)
class Monitor_Stock():
def __init__(self):
self.mystock=Toolkit.read_stock('mystock.csv')
self.base=pd.read_csv('bases.csv',dtype={'code': np.str})
#print(self.base)
#大于某手的大单
def getBigDeal(self, code,vol):
df = ts.get_today_ticks(code)
t= df[df['volume']>vol]
s=df[df['amount']>100000000]
print('\n')
if t.size!=0:
print("Big volume")
print(self.base[self.base['code']==str(code)]['name'].values[0])
print(t)
if s.size!=0:
print("Big amount: ")
print(self.base[self.base['code']==str(code)]['name'].values[0])
print(s)
r=df[df['volume']>vol*10]
if r.size!=0:
print("Super amount:")
print(self.base[self.base['code']==str(code)]['name'].values[0])
print(r)
def loops(self):
for i in self.mystock:
self.getBigDeal(i,1000)
def main():
if ts.__version__ != '0.7.5':
print("Make sure using tushare 0.7.5")
exit()
current = os.getcwd()
folder = os.path.join(current, 'data')
if os.path.exists(folder) == False:
os.mkdir(folder)
os.chdir(folder)
obj=Monitor_Stock()
#obj.getBigDeal('002451',2000)
obj.loops()
main()