forked from aspectolog/yobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
findmin.py
57 lines (47 loc) · 1.99 KB
/
findmin.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
######################################################################
# Поиск дешёвых монет
######################################################################
import requests
import json
from decimal import Decimal
from cfg import *
limit = "0.0009"
# Получаем цены = list[str, str]
def GetInfo(pair):
otvet = requests.get('https://yobit.net/api/3/depth/' + pair)
data = json.loads(otvet.text)
return data
#Получаем i-ую от края цену
def Ask_Price(data, i):
data["asks"] = data.get("asks", ["0", "0"])
return Decimal(data["asks"][i][0]).quantize(Decimal("1.00000000"))
def Bid_Price(data, i):
data["bids"] = data.get("bids", ["0", "0"])
return Decimal(data["bids"][i][0]).quantize(Decimal("1.00000000"))
def inrurask(value, transpair):
return (value * ASK_DICT[transpair]).quantize(Decimal("1.00000000"))
def inrurbid(value, transpair):
return (value * BID_DICT[transpair]).quantize(Decimal("1.00000000"))
###############################################################################################################
res = requests.get('https://yobit.net/api/3/info') # получаем данные info
res_obj = json.loads(res.text) # переводим полученный текст в объект с данными
allpairs = []
cnt = 0
for pair in res_obj['pairs']:
if pair.endswith('_' + CURRENCY):
allpairs.append(pair)
cnt = cnt +1
print(cnt, 'пар')
cnt = 0
for pair in allpairs:
try:
cnt = cnt + 1
this_pair_info = GetInfo(pair)
thisprice = Decimal(Ask_Price(this_pair_info[pair], 0)).quantize(Decimal("1.00000000"))
print('\rProcess: {} {}'.format(str(cnt), pair), end=' ')
if thisprice < Decimal(limit) and thisprice > Decimal("0"):
print(' ')
print(pair, thisprice)
except:
continue
# if minask < maxbid and minask != 0: print('------------------------------------------------------ НАШЛАСЬ!!!')