-
Notifications
You must be signed in to change notification settings - Fork 18
/
Binance_Ichimoku_Scanner_With_Chikou_DOWN.py
554 lines (463 loc) · 26.9 KB
/
Binance_Ichimoku_Scanner_With_Chikou_DOWN.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# Not maintained anymore ; Instead, use https://github.com/reuniware/Binance-and-FTX-API-Work/blob/main/Binance_Ichimoku_Scanner_With_Chikou.py
import glob, os
from datetime import datetime
from datetime import timedelta
from binance.client import Client
from binance.enums import HistoricalKlinesType
import binance
import pandas as pd
import requests
import threading
import time
import ta
import math
from enum import Enum
class ScanType(Enum):
UP = 0
DOWN = 1
# Set this variable to ScanType.UP for scanning uptrend assets or to ScanType.DOWN for scanning downtrend assets
scan_type = ScanType.DOWN
# Set this variable to False to scan in spot mode
scan_futures = True
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()
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)
# print("Scanning type = ", scan_type.name)
# log_to_results("Scanning type = " + scan_type.name)
HISTORY_RESOLUTION_1MINUTE = 60
HISTORY_RESOLUTION_3MINUTE = 60 * 3
HISTORY_RESOLUTION_5MINUTE = 60 * 5
HISTORY_RESOLUTION_15MINUTE = 60 * 15
HISTORY_RESOLUTION_30MINUTE = 60 * 30
HISTORY_RESOLUTION_HOUR = 60 * 60
HISTORY_RESOLUTION_4HOUR = 60 * 60 * 4
HISTORY_RESOLUTION_DAY = 60 * 60 * 24
results_count = 0
stop_thread = False
list_results = []
array_futures = []
def my_thread(name):
global client, list_results, results_count, stop_thread
log_to_evol(str(datetime.now()))
while not stop_thread:
dict_evol = {}
new_results_found = False
info_binance = Client().get_all_tickers()
#print(info_binance)
#exit()
df = pd.DataFrame(info_binance)
df.set_index('symbol')
for index, row in df.iterrows():
symbol = row['symbol']
symbol_type = "n/a" #row['type']
#print(symbol)
# filtering symbols to scan here
if not symbol.endswith('USDT') or symbol.endswith("DOWNUSDT") or symbol.endswith("UPUSDT"):
continue
#if symbol != 'BANDUSDT':
#continue
if scan_futures:
print(symbol, "trying to scan in futures")
else:
print(symbol, "trying to scan")
# if symbol.endswith("BEAR/USD") or symbol.endswith("BULL/USD") or symbol.endswith("HEDGE/USD") or symbol.endswith():
# continue
# Define the resolution for data downloading and scanning on the line below
history_resolution = HISTORY_RESOLUTION_30MINUTE # define the resolution used for the scan here
if history_resolution == HISTORY_RESOLUTION_1MINUTE:
interval_for_klinesT = Client.KLINE_INTERVAL_1MINUTE
elif history_resolution == HISTORY_RESOLUTION_3MINUTE:
interval_for_klinesT = Client.KLINE_INTERVAL_3MINUTE
elif history_resolution == HISTORY_RESOLUTION_5MINUTE:
interval_for_klinesT = Client.KLINE_INTERVAL_5MINUTE
elif history_resolution == HISTORY_RESOLUTION_15MINUTE:
interval_for_klinesT = Client.KLINE_INTERVAL_15MINUTE
elif history_resolution == HISTORY_RESOLUTION_30MINUTE:
interval_for_klinesT = Client.KLINE_INTERVAL_30MINUTE
elif history_resolution == HISTORY_RESOLUTION_HOUR:
interval_for_klinesT = Client.KLINE_INTERVAL_1HOUR
elif history_resolution == HISTORY_RESOLUTION_4HOUR:
interval_for_klinesT = Client.KLINE_INTERVAL_4HOUR
elif history_resolution == HISTORY_RESOLUTION_DAY:
interval_for_klinesT = Client.KLINE_INTERVAL_1DAY
else:
print("What should I set for Client KLINE_INTERVAL ?")
exit()
days_ago_for_klinest = "80 day ago UTC" # for daily download by default
if interval_for_klinesT == Client.KLINE_INTERVAL_1MINUTE:
days_ago_for_klinest = "120 minute ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_3MINUTE:
days_ago_for_klinest = "360 minute ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_5MINUTE:
days_ago_for_klinest = "800 minute ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_15MINUTE:
days_ago_for_klinest = "1200 minute ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_30MINUTE:
days_ago_for_klinest = "2400 minute ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_1HOUR:
days_ago_for_klinest = "80 hour ago UTC"
elif interval_for_klinesT == Client.KLINE_INTERVAL_4HOUR:
days_ago_for_klinest = "320 hour ago UTC"
try:
#klinesT = Client().get_historical_klines(symbol, interval_for_klinesT, "09 May 2022")
if scan_futures:
klinesT = Client().get_historical_klines(
symbol, interval_for_klinesT, days_ago_for_klinest, klines_type=HistoricalKlinesType.FUTURES)
else:
klinesT = Client().get_historical_klines(
symbol, interval_for_klinesT, days_ago_for_klinest)
dframe = pd.DataFrame(klinesT,
columns=[
'timestamp', 'open', 'high', 'low',
'close', 'volume', 'close_time',
'quote_av', 'trades', 'tb_base_av',
'tb_quote_av', 'ignore'
])
del dframe['ignore']
del dframe['close_time']
del dframe['quote_av']
del dframe['trades']
del dframe['tb_base_av']
del dframe['tb_quote_av']
dframe['close'] = pd.to_numeric(dframe['close'])
dframe['high'] = pd.to_numeric(dframe['high'])
dframe['low'] = pd.to_numeric(dframe['low'])
dframe['open'] = pd.to_numeric(dframe['open'])
dframe = dframe.set_index(dframe['timestamp'])
dframe.index = pd.to_datetime(dframe.index, unit='ms')
except requests.exceptions.HTTPError:
print(
"Erreur (HTTPError) tentative obtention données historiques pour "
+ symbol)
log_to_errors(
"Erreur (HTTPError) tentative obtention données historiques pour "
+ symbol)
continue
except requests.exceptions.ConnectionError:
print(
"Erreur (ConnectionError) tentative obtention données historiques pour "
+ symbol)
log_to_errors(
"Erreur (ConnectionError) tentative obtention données historiques pour "
+ symbol)
continue
except binance.exceptions.BinanceAPIException:
# in case the symbol does not exist in futures then this exception is thrown
continue
# a = time.time()
# my_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(a))
# my_time_2 = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(a - delta_time))
#dframe = pd.DataFrame(data)
# dframe['time'] = pd.to_datetime(dframe['time'], unit='ms')
# print(dframe)
try:
dframe['ICH_SSA'] = ta.trend.ichimoku_a(dframe['high'],
dframe['low'],
window1=9,
window2=26).shift(26)
dframe['ICH_SSB'] = ta.trend.ichimoku_b(dframe['high'],
dframe['low'],
window2=26,
window3=52).shift(26)
dframe['ICH_KS'] = ta.trend.ichimoku_base_line(
dframe['high'], dframe['low'])
dframe['ICH_TS'] = ta.trend.ichimoku_conversion_line(
dframe['high'], dframe['low'])
dframe['ICH_CS'] = dframe['close'].shift(-26)
except KeyError as err:
print(err)
continue
for indexdf, rowdf in dframe.iterrows():
openp = rowdf['open']
high = rowdf['high']
low = rowdf['low']
close = rowdf['close']
ssa = rowdf['ICH_SSA']
ssb = rowdf['ICH_SSB']
ks = rowdf['ICH_KS']
ts = rowdf['ICH_TS']
# cs = rowdf['ICH_CS']
try:
cs = dframe['ICH_CS'].iloc[
-26 - 1] # chikou span concernant bougie n en cours
cs2 = dframe['ICH_CS'].iloc[
-26 - 2] # chikou span concernant bougie n-1
#ssbchikou = dframe['ICH_SSB'].iloc[-26 - 1 + 2]
#ssbchikou2 = dframe['ICH_SSB'].iloc[-26 - 2 + 2]
#ssbchikou3 = dframe['ICH_SSB'].iloc[-26 - 3 + 2]
ssbchikou = dframe['ICH_SSB'].iloc[-52]
ssbchikou2 = dframe['ICH_SSB'].iloc[-52 - 1]
ssbchikou3 = dframe['ICH_SSB'].iloc[-52 - 2]
ssachikou = dframe['ICH_SSA'].iloc[-26 + 1]
ssachikou2 = dframe['ICH_SSA'].iloc[-26 - 1]
ssachikou3 = dframe['ICH_SSA'].iloc[-26 - 2]
closechikou = dframe['close'].iloc[-26]
closechikou2 = dframe['close'].iloc[-26 - 1]
openchikou = dframe['open'].iloc[-26]
openchikou2 = dframe['open'].iloc[-26 - 1]
lowchikou = dframe['low'].iloc[-26]
lowchikou2 = dframe['low'].iloc[-26 - 1]
highchikou = dframe['high'].iloc[-26]
highchikou2 = dframe['high'].iloc[-26 - 1]
kijunchikou = dframe['ICH_KS'].iloc[-26 - 1 + 1]
kijunchikou2 = dframe['ICH_KS'].iloc[-26 - 2 + 1]
kijunchikou3 = dframe['ICH_KS'].iloc[-26 - 3 + 1]
tenkanchikou = dframe['ICH_TS'].iloc[-26 - 1 + 1]
tenkanchikou2 = dframe['ICH_TS'].iloc[-26 - 2 + 1]
tenkanchikou3 = dframe['ICH_TS'].iloc[-26 - 3 + 1]
except IndexError as error:
print(symbol + " EXCEPTION " + str(error))
log_to_errors(symbol + " EXCEPTION " + str(error) + '\n')
# quit(0)
continue
#timestamp = pd.to_datetime(rowdf['time'], unit='ms')
timestamp = pd.to_datetime(rowdf['timestamp'], unit='ms')
error_nan_values = False
# To check the values of Ichimoku data (use TradingView with Ichimoku Cloud to compare them)
#print(str(timestamp) + " " + symbol + " closecs=" + str(closechikou) + " closecs2=" + str(closechikou2) + " CS=" + str(cs) + " CS2=" + str(cs2) + " SSBCS=" + str(ssbchikou) + " SSBCS2=" + str(ssbchikou2) + " SSBCS3=" + str(ssbchikou3) + " KSCS=" + str(kijunchikou)+ " KSCS2=" + str(kijunchikou2)+ " KSCS3=" + str(kijunchikou3) + " TSCS=" + str(tenkanchikou)+ " TSCS2=" + str(tenkanchikou2)+ " TSCS3=" + str(tenkanchikou3) + " SSACS=" + str(ssachikou) + " SSACS2=" + str(ssachikou2) + " SSACS3=" + str(ssachikou3))
#exit()
if math.isnan(closechikou) or math.isnan(
closechikou2
) or math.isnan(cs) or math.isnan(cs2) or math.isnan(
ssbchikou) or math.isnan(ssbchikou2) or math.isnan(
ssbchikou3
) or math.isnan(kijunchikou) or math.isnan(
kijunchikou2
) or math.isnan(kijunchikou3) or math.isnan(
tenkanchikou
) or math.isnan(tenkanchikou2) or math.isnan(
tenkanchikou3) or math.isnan(
ssachikou) or math.isnan(
ssbchikou2) or math.isnan(ssachikou3):
print(symbol + " THERE ARE NAN VALUES IN ICHIMOKU DATA")
log_to_errors(symbol +
" THERE ARE NAN VALUES IN ICHIMOKU DATA" +
'\n')
error_nan_values = True
# quit(0)
if error_nan_values:
continue
filename = "CS_" + symbol.replace('/', '_') + ".txt"
if os.path.exists(filename):
os.remove(filename)
# now_cs = datetime.datetime_result_min() - timedelta(hours=4 * 26)
# # print("now_cs=" + str(now_cs))
# # quit(0)
# if timestamp.year == now_cs.year and timestamp.month == now_cs.year and timestamp.day == now_cs.day and timestamp.hour == now_cs.hour:
# print(str(cs))
data_minute = timestamp.minute
data_hour = timestamp.hour
data_day = timestamp.day
data_month = timestamp.month
data_year = timestamp.year
if history_resolution == HISTORY_RESOLUTION_1MINUTE:
datetime_result_min = datetime.now() - timedelta(minutes=1)
elif history_resolution == HISTORY_RESOLUTION_3MINUTE:
#datetime_result_min = datetime.now() - timedelta(minutes=15)
datetime_result_min = datetime.now() - timedelta(minutes=3)
elif history_resolution == HISTORY_RESOLUTION_5MINUTE:
#datetime_result_min = datetime.now() - timedelta(minutes=15)
datetime_result_min = datetime.now() - timedelta(minutes=5)
elif history_resolution == HISTORY_RESOLUTION_15MINUTE:
#datetime_result_min = datetime.now() - timedelta(hours=1)
datetime_result_min = datetime.now() - timedelta(
minutes=15)
elif history_resolution == HISTORY_RESOLUTION_30MINUTE:
#datetime_result_min = datetime.now() - timedelta(hours=1)
datetime_result_min = datetime.now() - timedelta(
minutes=30)
elif history_resolution == HISTORY_RESOLUTION_HOUR:
datetime_result_min = datetime.now() - timedelta(hours=1)
elif history_resolution == HISTORY_RESOLUTION_4HOUR:
datetime_result_min = datetime.now() - timedelta(hours=4)
elif history_resolution == HISTORY_RESOLUTION_DAY:
datetime_result_min = datetime.now() - timedelta(hours=24)
else:
datetime_result_min = datetime.now() - timedelta(
hours=1) # We should never get here
datetime_result_min_minute = datetime_result_min.minute
datetime_result_min_hour = datetime_result_min.hour
datetime_result_min_day = datetime_result_min.day
datetime_result_min_month = datetime_result_min.month
datetime_result_min_year = datetime_result_min.year
# if math.isnan(ssa):
# print(symbol, "ssa is null")
#
# if math.isnan(ssb):
# print(symbol, "ssb is null")
evol_co = round(((close - openp) / openp) * 100, 4)
scan = True
if history_resolution == HISTORY_RESOLUTION_1MINUTE:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour == datetime_result_min_hour and data_minute >= datetime_result_min_minute
elif history_resolution == HISTORY_RESOLUTION_3MINUTE:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour == datetime_result_min_hour and data_minute >= datetime_result_min_minute
elif history_resolution == HISTORY_RESOLUTION_5MINUTE:
# print("comparing : " + str(data_hour) + " " + str(data_minute) + " to " + str(datetime_result_min_hour) + " " + str(datetime_result_min_minute))
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour == datetime_result_min_hour and data_minute >= datetime_result_min_minute
elif history_resolution == HISTORY_RESOLUTION_15MINUTE:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour == datetime_result_min_hour and data_minute >= datetime_result_min_minute
elif history_resolution == HISTORY_RESOLUTION_30MINUTE:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour == datetime_result_min_hour and data_minute >= datetime_result_min_minute
elif history_resolution == HISTORY_RESOLUTION_HOUR:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour > datetime_result_min_hour #and data_minute >= datetime_result_min_minute
else:
result_ok = data_day == datetime_result_min_day and data_month == datetime_result_min_month and data_year == datetime_result_min_year and data_hour >= datetime_result_min_hour
#if symbol == "ETHUSDT":
# print ("ETHUSDT SSACHIKOU = " + str(ssachikou))
# print ("ETHUSDT SSBCHIKOU = " + str(ssbchikou))
if scan:
if result_ok:
# if openp < ssb < close or openp > ssb and close > ssb:
# Define your own criterias for filtering assets on the line below
if scan_type == ScanType.UP:
condition_is_satisfied = openp > ks and close > ks and close > ts and close > openp and close > ssa and close > ssb and cs > highchikou and cs > kijunchikou and cs > ssbchikou and cs > ssachikou and cs > tenkanchikou
elif scan_type == ScanType.DOWN:
condition_is_satisfied = openp < ks and close < ks and close < ts and close < openp and close < ssa and close < ssb and cs < lowchikou and cs < kijunchikou and cs < ssbchikou and cs < ssachikou and cs < tenkanchikou
if condition_is_satisfied:
cs_results = ""
if scan_type == ScanType.UP:
if cs > ssbchikou:
cs_results += "* CS > SSBCHIKOU - "
if cs > ssachikou:
cs_results += "* CS > SSACHIKOU - "
if cs > kijunchikou:
cs_results += "* CS > KSCHIKOU - "
if cs > tenkanchikou:
cs_results += "* CS > TSCHIKOU - "
if cs > closechikou:
cs_results += "* CS > CLOSECHIKOU - "
if cs > highchikou:
cs_results += "* CS > HIGHCHIKOU - "
# if cs_results != "":
# log_to_results(cs_results)
# print(timestamp, symbol, "O", openp, "H", high, "L", low, "C", close, "SSA", ssa, "SSB", ssb, "KS", ks, "TS", ts, "CS", cs, "EVOL%", evol_co)
elif scan_type == ScanType.DOWN:
if cs < ssbchikou:
cs_results += "* CS < SSBCHIKOU - "
if cs < ssachikou:
cs_results += "* CS < SSACHIKOU - "
if cs < kijunchikou:
cs_results += "* CS < KSCHIKOU - "
if cs < tenkanchikou:
cs_results += "* CS < TSCHIKOU - "
if cs < closechikou:
cs_results += "* CS < CLOSECHIKOU - "
if cs < highchikou:
cs_results += "* CS < LOWCHIKOU - "
# if cs_results != "":
# log_to_results(cs_results)
# print(timestamp, symbol, "O", openp, "H", high, "L", low, "C", close, "SSA", ssa, "SSB", ssb, "KS", ks, "TS", ts, "CS", cs, "EVOL%", evol_co)
# print("")
str_result = str(
timestamp
) + " " + symbol + " " + symbol_type + " SSA=" + str(
ssa
) + " SSB=" + str(ssb) + " KS=" + str(
ks
) + " TS=" + str(ts) + " O=" + str(
openp
) + " H=" + str(high) + " L=" + str(
low
) + " SSBCS=" + str(ssbchikou) # + " C=" + str(close) + " CS=" + str(cs) + " EVOL%=" + str(evol_co) # We don't concatenate the variable parts (for comparisons in list_results)
if not (str_result in list_results):
if not new_results_found:
new_results_found = True
results_count = results_count + 1
list_results.append(str_result)
# print(cs_results)
str_result = cs_results + "\n" + str(
results_count
) + " " + str_result + " C=" + str(
close
) + " CS=" + str(cs) + " EVOL(C/O)%=" + str(
evol_co
) # We add the data with variable parts
if scan_futures:
str_result += "\nhttps://fr.tradingview.com/chart/4hWFksx8/?symbol=BINANCE%3A" + symbol + "PERP"
else:
str_result += "\nhttps://fr.tradingview.com/chart/4hWFksx8/?symbol=BINANCE%3A" + symbol
print(str_result + "\n")
log_to_results(str_result + "\n")
dict_evol[symbol] = evol_co
else:
# if result_ok:
print(timestamp, symbol, "O", openp, "H", high, "L", low,
"C", close, "SSA", ssa, "SSB", ssb, "KS", ks, "TS",
ts, "CS", cs, "SSB CS", ssbchikou)
str_result = str(timestamp) + " " + symbol + " O=" + str(
openp) + " H=" + str(high) + " L=" + str(
low) + " C=" + str(close) + " SSA=" + str(
ssa) + " SSB=" + str(ssb) + " KS=" + str(
ks) + " TS=" + str(ts) + " CS=" + str(
cs) + " SSB CS=" + str(ssbchikou) + " EVOL%(C/O)=" + str(evol_co)
log_to_results(str_result)
if new_results_found:
log_to_results(100 * '*' + "\n")
new_dict = sorted(dict_evol.items(), key=lambda kv: (kv[1], kv[0]))
print(str(datetime.now()) + " " + str(new_dict))
log_to_evol(str(datetime.now()) + " " + str(new_dict))
# Remove the line below to scan in loop
#stop_thread = True
x = threading.Thread(target=my_thread, args=(1, ))
x.start()
# array_futures = []
# if scan_futures:
# interval_for_klinesT = Client.KLINE_INTERVAL_1MINUTE
# days_ago_for_klinest = "1 minute ago UTC"
# info_binance = Client().get_all_tickers()
# df = pd.DataFrame(info_binance)
# df.set_index('symbol')
# for index, row in df.iterrows():
# symbol = row['symbol']
# try:
# print("trying", symbol)
# klinesT = Client().get_historical_klines(
# symbol, interval_for_klinesT, days_ago_for_klinest, klines_type=HistoricalKlinesType.FUTURES)
# array_futures.append(symbol)
# except binance.exceptions.BinanceAPIException:
# # in case the symbol does not exist in futures then this exception is thrown
# continue
#history_resolution = HISTORY_RESOLUTION_1MINUTE # define the resolution used for the scan here
# delta_time = 0
# if history_resolution == HISTORY_RESOLUTION_1MINUTE: # using this resolution seems not ok, must be improved
# #delta_time = 60 * 5
# delta_time = 60
# elif history_resolution == HISTORY_RESOLUTION_3MINUTE:
# delta_time = 60 * 3
# elif history_resolution == HISTORY_RESOLUTION_5MINUTE: # using this resolution seems not ok, must be improved
# #delta_time = 60 * 5 * 25
# delta_time = 60 * 5
# elif history_resolution == HISTORY_RESOLUTION_15MINUTE:
# #delta_time = 60 * 60 * 15 * 3
# delta_time = 60 * 60 * 15
# elif history_resolution == HISTORY_RESOLUTION_HOUR:
# #delta_time = 60 * 60 * 3 * 15 * 2
# delta_time = 60 * 60
# elif history_resolution == HISTORY_RESOLUTION_4HOUR:
# #delta_time = 60 * 60 * 3 * 15 * 2 * 4
# delta_time = 60 * 60 * 4
# elif history_resolution == HISTORY_RESOLUTION_DAY:
# delta_time = 60 * 60 * 2000