-
Notifications
You must be signed in to change notification settings - Fork 16
/
FTX_Scan_Growing_Symbols_2.py
68 lines (55 loc) · 2.29 KB
/
FTX_Scan_Growing_Symbols_2.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
import os
from datetime import datetime
# import ftx
import pandas as pd
import requests
import threading
# import numpy as np
# client = ftx.FtxClient(
# api_key='',
# api_secret='',
# subaccount_name=''
# )
# result = client.get_balances()
symbolInfoInit = {}
symbolInfo = {}
symbolEvol = {}
initial_time = datetime.now()
stop_thread = False
def my_thread(name):
global symbolInfo, symbolInfoInit, symbolEvol, stop_thread
symbol_growing = {}
while not stop_thread:
markets = requests.get('https://ftx.com/api/markets').json()
df = pd.DataFrame(markets['result'])
df.set_index('name')
for index, row in df.iterrows():
symbol = row['name']
price = float(row['last'])
if symbol in symbolInfo:
if price > symbolInfo[symbol]:
symbolInfo[symbol] = price
# print(datetime.now(), "growing", symbol, "evol=", price/symbolInfoInit[symbol], "init price=", symbolInfoInit[symbol], "current price=", price, "scan time=", datetime.now() - initial_time)
symbol_growing[symbol] = price/symbolInfoInit[symbol]
else:
symbol_growing[symbol] = 0
else:
symbolInfoInit[symbol] = price
symbolInfo[symbol] = price
symbol_growing[symbol] = 0
stop_thread = False
sort_orders = sorted(symbol_growing.items(), key=lambda x: x[1], reverse=True)
show = True
k = 0
for i in sort_orders:
if show:
if i[1] > 0:
symbol = i[0]
evol = round(i[1]*100-100, 2)
curr_price = symbolInfo[symbol]
print(datetime.now(), k, symbol, (24-len(symbol))*" ", str(evol) + "%", (16-len(str(evol) + "%"))*" ", "init price=", symbolInfoInit[symbol], (16-len(str(symbolInfoInit[symbol])))*" ", "current price=", curr_price, (16-len(str(curr_price)))*" ", "scan time=", datetime.now() - initial_time)
k = k + 1
if k > 2: # only show 3 best results here. Increase to view more best results (increase 2 to 9 to see 10 best results)
show = False
x = threading.Thread(target=my_thread, args=(1,))
x.start()