This commit is contained in:
Nicolás Sánchez 2024-12-10 09:24:03 -03:00
parent d0771ad490
commit d65751df48
1 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,13 @@ import statistics
from credentials import get_credentials from credentials import get_credentials
from threading import Thread from threading import Thread
def write_to_log(message):
'''
Writes a message to the log file
'''
with open("log.txt", "a") as f:
f.write(message)
def yang_zhang(candles): def yang_zhang(candles):
''' '''
@ -128,13 +135,13 @@ def fetch_data(broker: str, pair_list: list, timeframe: str, samples: int):
try: try:
data = exchange.fetch_ohlcv(pair,timeframe=timeframe,limit=samples) data = exchange.fetch_ohlcv(pair,timeframe=timeframe,limit=samples)
except Exception as e: except Exception as e:
print(e) write_to_log(str(e))
continue continue
try: try:
parkinson_volatility = parkinson(data) parkinson_volatility = parkinson(data)
yangzhang_volatility = yang_zhang(data) yangzhang_volatility = yang_zhang(data)
except Exception as e: except Exception as e:
print(e) write_to_log(str(e))
continue continue
for item in data: for item in data:
trading_volume += item[4]*item[5] trading_volume += item[4]*item[5]