-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathstare_change.py
174 lines (153 loc) · 5.98 KB
/
stare_change.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# -*-coding=utf-8-*-
__author__ = 'Rocky'
'''
http://30daydo.com
Contact: [email protected]
'''
#关注成交量暴涨的coin
import requests,time,datetime,threading
import pandas as pd
from jubi_wechat import Jubi_web
from alert import play
class CoinVol():
def __init__(self,wechat=False):
self.wechat=wechat
if self.wechat:
self.obj_wc=Jubi_web()
self.host='https://www.jubi.com'
self.coin_list=['IFC','DOGE','EAC','DNC','MET','ZET','SKT','YTC','PLC','LKC',
'JBC','MRYC','GOOC','QEC','PEB','XRP','NXT','WDC','MAX','ZCC',
'HLB','RSS','PGC','RIO','XAS','TFC','BLK','FZ','ANS','XPM','VTC',
'KTC','VRC','XSGS','LSK','PPC','ETC','GAME','LTC','ETH','BTC']
self.coin_name={'zet':u'泽塔币',
'doge':u'狗狗币',
'eac':u'地球币',
'dnc':u'暗网币',
'rio':u'里约币',
'blk':u'黑币',
'ifc':u'无限币',
'met':u'美通币',
'gooc':u'谷壳币',
'jbc':u'聚宝币',
'pgc':u'乐通币',
'lsk':u'LISK',
'tfc':u'传送币',
'xpm':u'质数币',
'nxt':u'未来币',
'ppc':u'点点币',
'ktc':u'肯特币',
'mtc':u'猴宝币',
'skt':u'鲨之信',
'btc':u'比特币',
'peb':u'普银币',
'ltc':u'莱特币',
'xsgs':u'雪山古树',
'eth':u'以太坊',
'vtc':u'绿币',
'bts':u'比特股',
'hlb':u'活力币',
'zcc':u'招财币',
'etc':u'以太经典',
'qec':u'企鹅币',
'fz':u'冰河币',
'plc':u'保罗币',
'max':u'最大币',
'ytc':u'一号币',
'xrp':u'瑞波币',
'lkc':u'幸运币',
'wdc':u'世界币',
'vrc':u'维理币',
'rss':u'红贝壳',
'ans':u'小蚁股',
'xas':u'阿希比',
'game':u'游戏点',
'mryc':u'美人鱼币',
}
#出现买单占比65%以上和成交量放大的,就警报
def vol_detect(self,coin,setup_timeout=60):
url=self.host+'/api/v1/orders/'
data={'coin':coin}
print "in %s" %coin
while 1:
price_max=open('args.txt','r')
price_min=open()
try:
js=requests.get(url,params=data).json()
except Exception,e:
time.sleep(10)
continue
#print js
#rint type(js)
#将字典列表转为Dataframe
df=pd.DataFrame(js)
df['date']=df['date'].map(lambda x:datetime.datetime.fromtimestamp(long(x) ))
#print df
price_min=df['price'].min()
price_max=df['price'].max()
print 'Coin : %s' %self.coin_name[coin]
print 'recent max: ',price_max
print 'recent min: ',price_min
#print df.info()
#print df.dtypes
buy_df=df[df['type']=='buy']
#print buy_df
buy_count= len(buy_df)
total= len(df)
buy_ratio=buy_count*1.00/total*100.00
if price_max>p_max:
print datetime.datetime.now().strftime('%H:%M:%S')
print 'Coin : %s' %self.coin_name[coin],
print "MAX than ",price_max
#play()
if price_min<p_min:
print datetime.datetime.now().strftime('%H:%M:%S')
print 'Coin : %s' %self.coin_name[coin],
print 'MIN than ',price_min
#play()
if buy_ratio>70.0:
print datetime.datetime.now().strftime('%H:%M:%S')
print "Coin : %s " %self.coin_name[coin],
print "buy more than 60 percent in the pass 100 order: %s\n" %buy_ratio
txt="buy more than 60 percent in the pass 100 order: %s\n" %buy_ratio
if self.wechat:
self.obj_wc.send_wechat(coin,txt)
else:
play()
if float(df['amount'].values[0]) >1000000:
print datetime.datetime.now().strftime('%H:%M:%S')
print 'Coin : %s' %self.coin_name[coin],
print " Big deal more than 10w"
if self.wechat:
self.obj_wc.send_wechat(coin," Big deal more than 10w")
else:
play()
time.sleep(setup_timeout)
def multi_thread(self,coin_list):
thread_list=[]
#print len(self.coin_name)
'''
for i in coin_list:
print i," ",
print self.coin_name[i]
#print i
t=threading.Thread(target=self.vol_detect,args=(i,0.16,0.17))
thread_list.append(t)
'''
t1=threading.Thread(target=self.vol_detect,args=(coin_list[0],0.19,0.22))
t1.start()
t1.join()
#t2=threading.Thread(target=self.vol_detect,args=(coin_list[1],0.009,0.012))
#thread_list.append(t1)
#thread_list.append(t2)
#for j in thread_list:
#j.start()
#j.join()
#for k in thread_list:
#k.join()
def testcase(self):
coin_list=['zet']
self.multi_thread(coin_list)
#self.vol_detect('zet',0.15,0.195)
if __name__=='__main__':
obj=CoinVol()
obj.testcase()