-
Notifications
You must be signed in to change notification settings - Fork 16
/
FTX_Scan_Close_Open_Evol.py
160 lines (113 loc) · 4.39 KB
/
FTX_Scan_Close_Open_Evol.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
import glob, os
from datetime import datetime
from datetime import timedelta
import ftx
import pandas as pd
import requests
import threading
import time
import ta
import math
def log_to_results(str_to_log):
fr = open("results.txt", "a")
fr.write(str_to_log + "\n")
fr.close()
def log_to_errors(str_to_log):
fr = open("errors.txt", "a")
fr.write(str_to_log + "\n")
fr.close()
def log_to_trades(str_to_log):
fr = open("trades.txt", "a")
fr.write(str_to_log + "\n")
fr.close()
def log_to_evol(str_to_log):
fr = open("evol.txt", "a")
fr.write(str_to_log + "\n")
fr.close()
# import numpy as npfrom binance.client import Client
ftx_client = ftx.FtxClient(
api_key='',
api_secret='',
subaccount_name=''
)
# result = client.get_balances()
# print(result)
if os.path.exists("results.txt"):
os.remove("results.txt")
if os.path.exists("errors.txt"):
os.remove("errors.txt")
if os.path.exists("trades.txt"):
os.remove("trades.txt")
if os.path.exists("evol.txt"):
os.remove("evol.txt")
for fg in glob.glob("CS_*.txt"):
os.remove(fg)
list_results = []
results_count = 0
stop_thread = False
def my_thread(name):
global ftx_client, list_results, results_count
log_to_evol(str(datetime.now()))
while not stop_thread:
sindex = 0
highest_close_evol = 0
highest_close_evol_symbol = ""
dict_evol = {}
new_results_found = False
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']
symbol_type = row['type']
# print("scanning", symbol, symbol_type)
delta_time = 60 * 60 * 2
try:
data = ftx_client.get_historical_data(
market_name=symbol,
resolution=60 * 60,
limit=10000,
start_time=float(round(time.time())) - delta_time,
end_time=float(round(time.time())))
except requests.exceptions.ConnectionError:
continue
pd.set_option('display.max_columns', 10)
pd.set_option('display.expand_frame_repr', False)
dframe = pd.DataFrame(data)
# dframe.reindex(index=dframe.index[::-1])
dframe = dframe.iloc[::-1]
# print(dframe)
# for indexdf, rowdf in dframe.iterrows():
# print(rowdf)
# print(symbol, dframe['startTime'].iloc[0], dframe['open'].iloc[0], dframe['high'].iloc[0], dframe['low'].iloc[0], dframe['close'].iloc[0], dframe['volume'].iloc[0])
# print(symbol, dframe['startTime'].iloc[-1], dframe['open'].iloc[-1], dframe['high'].iloc[-1], dframe['low'].iloc[-1], dframe['close'].iloc[-1], dframe['volume'].iloc[-1])
# try:
# if dframe['volume'].iloc[0] < 1000000:
# continue
# except:
# continue
try:
close0 = dframe['close'].iloc[0]
open0 = dframe['open'].iloc[0]
close_evol = close0/open0
except:
continue
sindex = sindex + 1
print("(" + str(sindex) + ") " + symbol + " CLOSE/OPEN EVOL = " + str(close_evol) + " " + str(close0) + " " + str(open0))
# log_to_results(symbol + " CLOSE EVOL = " + str(close_evol) + " " + str(close0) + " " + str(close1))
if close_evol > highest_close_evol:
highest_close_evol = close_evol
highest_close_evol_symbol = symbol
print(str(datetime.now()) + " **** highest /open evol symbol = " + highest_close_evol_symbol + " highest close/open evol = " + str(highest_close_evol))
log_to_results(str(datetime.now()) + " **** highest close/open evol symbol = " + highest_close_evol_symbol + " highest close/open evol = " + str(highest_close_evol))
# if len(data) > 1:
# print(data[1])
# for info in data:
# startTime = info['startTime']
# vol = info['volume']
# print(startTime, vol)
# else:
# print("no data for", symbol)
log_to_results(120 * "*")
x = threading.Thread(target=my_thread, args=(1,))
x.start()