diff --git a/utils/fetch_pair_volatility.py b/utils/fetch_pair_volatility.py index 8fb368b..3d9f763 100644 --- a/utils/fetch_pair_volatility.py +++ b/utils/fetch_pair_volatility.py @@ -11,6 +11,13 @@ import statistics from credentials import get_credentials 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): ''' @@ -128,13 +135,13 @@ def fetch_data(broker: str, pair_list: list, timeframe: str, samples: int): try: data = exchange.fetch_ohlcv(pair,timeframe=timeframe,limit=samples) except Exception as e: - print(e) + write_to_log(str(e)) continue try: parkinson_volatility = parkinson(data) yangzhang_volatility = yang_zhang(data) except Exception as e: - print(e) + write_to_log(str(e)) continue for item in data: trading_volume += item[4]*item[5]