-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_eth.py
More file actions
144 lines (133 loc) · 5.02 KB
/
run_eth.py
File metadata and controls
144 lines (133 loc) · 5.02 KB
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
import requests
from bs4 import BeautifulSoup
import os
count = 0
birds = ''
asks = ''
arr_bird = []
arr_asks = []
arr_price_green = []
arr_price_green_2 = []
arr_price_red = []
arr_price_red_2 = []
sum_bird = 0
sum_asks = 0
val = "ETH"
url = "https://www.binance.com/api/v1/depth?symbol=" + val + "USDT"
response = requests.get(url)
soup = str(BeautifulSoup(response.text, "html.parser"))
soup += "&"
# print(soup)
# print("________________")
while soup[count] != '&':
if soup[count] == ',' and soup[count + 1] == '"' and soup[count + 2] == 'a':
break
else:
count += 1
# print(count)
# print(len('{"lastUpdateId":119575240,'))
birds = str(soup[10 + 26:3142])
# print(birds)
asks = str(soup[3144 + 7:-3])
# print(asks)
count = 0
for i in range(12):
while birds[count] != '[':
count += 1
m_str = birds[count + 2: count + 12]
arr_price_green.append("{:.5f}".format(float(m_str)))
count += 1
# print(arr_price_green)
count = 0
for i in range(len(birds)):
if birds[count] == '"' and birds[count + 1] == ',' and birds[count + 2] == '"':
m_str = birds[count + 3:count + 12]
arr_price_green_2.append(m_str)
count += 1
else:
count += 1
if len(arr_price_green_2) == 12:
break
# print(arr_price_green_2)
#
for i in range(len(arr_price_green)):
a = float(arr_price_green[i])
b = float(arr_price_green_2[i])
arr_bird.append(a * b)
sum_bird = sum(arr_bird)
#
# # -----------------------------
#
count = 0
for i in range(12):
while asks[count] != '[':
count += 1
m_str = asks[count + 2: count + 12]
try:
arr_price_red.append("{:.3f}".format(float(m_str)))
count += 1
except ValueError:
print('Извините, у нас возникли неполадки, перезайдите позже. Вы пока можете продолжить работу с другой монетой')
print('Для продолжения работы нажмите 1, для выхода нажмите 0:')
error = int(input())
if error == 1:
os.system('start_programm.py')
elif error == 0:
exit()
# print(arr_price_red)
count = 0
for i in range(len(asks)):
if asks[count] == '"' and asks[count + 1] == ',' and asks[count + 2] == '"':
m_str = asks[count + 3:count + 12]
arr_price_red_2.append(m_str)
count += 1
else:
count += 1
if len(arr_price_red_2) == 12:
break
# print(arr_price_red_2)
for i in range(len(arr_price_green)):
a = float(arr_price_red[i])
b = float(arr_price_red_2[i])
arr_asks.append(a * b)
sum_asks = sum(arr_asks)
# # -----------------------------------
# print('Таков стакан по валюте -', val)
# print('sum_bird',sum_bird)
# print('sum_asks',sum_asks)
print("------------------------------")
url = "https://www.binance.com/api/v3/ticker/price?symbol=ETHUSDT"
price_old = 0
inc = 1
response = requests.get(url)
soup = str(BeautifulSoup(requests.get(url).text, "html.parser"))
print('Текущий курс по монете -', soup[29:36])
price = float(soup[29:38])
print("-------------------------------")
answer = int(input('Вы собираетесь покупать монеты или же хотите продать?\n1 - покупка, 2 - продажа,3 - получить совет, 4 - выход\n'))
os.system('cls')
print("Данная программа не покупает и не продает никакие валюты, а лишь просчитывает возможный курс после возможной транзакции.\nНаша организация ответственности за ущер и крах не несет. Спасибо, что выбираете 'SiBears New'!")
c = price
if answer == 1:
k = sum_bird
n = int(input("Введите ваш возможный баланс, на который вы хотите закупить монету Money\n"))
for i in range(10):
c = c * (1 - k / (k + c * n / 10)) + c
# print(i, c)
print("Курс изменится на такой", "{:.10f}".format(float(c)), 'после вашего возможного трейда')
elif answer == 2:
k = sum_asks
n = int(input("Введите вашу возможную сумму на которую вы хотите продать монеты(монету) Money\n"))
for i in range(10):
c = (k / (k + c * n / 10)) * c
c1 = "{:.8f}".format(float(c))
print(i, c1)
print("Курс изменится на такой", c1, 'после вашего возможного трейда')
elif answer == 3:
os.system('info.py')
elif answer == 4:
exit()
print('Хотите начать все сначала? Тогда нажмите 1, иначе любую другую клавишу')
answer = int(input())
if answer == 1:
os.system('start_programm.py')