From 00340a1dcf438bde110b5660f19b585b136df22c Mon Sep 17 00:00:00 2001 From: CelestialCrafter Date: Fri, 9 Feb 2024 15:57:09 -0600 Subject: [PATCH] Revert "utils logging" This reverts commit e5321647b05e6766e3a1ab03624c5fefeb13119b. --- src/utils.py | 18 ++---------------- src/views/signals.py | 6 +++--- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/utils.py b/src/utils.py index 1ecbcb3..403a13f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -8,14 +8,10 @@ load_dotenv() client = MongoClient(os.environ['DB_URI'], server_api=ServerApi('1')) -algorithms_collection = client['database']['algorithms'] +algorithms = client['database']['algorithms'] def get_algorithms() -> list[str]: - logger = setup_logger() - algorithms = [algorithm['name'] for algorithm in algorithms_collection.find({'owner': {'$not': {'$type': 'object'}}})] - logger.info(f'Fetching algorithms', extra={'number_of_algorithms': len(algorithms)}) - - return algorithms + return [algorithm['name'] for algorithm in algorithms.find({'owner': {'$not': {'$type': 'object'}}})] def authorize(encoded: str) -> str: if encoded.startswith('Bearer'): @@ -24,29 +20,19 @@ def authorize(encoded: str) -> str: return jwt.decode(encoded, os.environ['JWT_SECRET'], algorithms=['HS256']) def algorithm_output(algorithm_name: str, prices: list[float], backtest=False) -> tuple[str, tuple[str, float]]: - logger = setup_logger() module = import_module(f'algorithms.{algorithm_name}').Algorithm() signal, strength = module.signal(prices, module.algorithm(prices)) if backtest: return signal, strength - logger.info('Algorithm Output', - extra={ - 'algorithm': algorithm_name, - 'backtest': backtest, - 'signal': signal, - 'strength': strength - }) return algorithm_name, (signal, strength) def svg_plot() -> str: - logger = setup_logger() svg_buffer = io.StringIO() plt.savefig(svg_buffer, format='svg', transparent=True) plot_data = svg_buffer.getvalue() plt.close() svg_buffer.close() - logger.info('SVG plot') return plot_data diff --git a/src/views/signals.py b/src/views/signals.py index 9d6f8b7..09bc498 100644 --- a/src/views/signals.py +++ b/src/views/signals.py @@ -1,7 +1,7 @@ import os from flask import request from redis import from_url -from price import get_prices, default_interval, default_coin +from price import get_prices from ipaddress import ip_address from utils import get_algorithms, algorithm_output @@ -14,8 +14,8 @@ def signals(): return 'Forbidden', 403 # require explicit interval and coin instead of using get_using_x() - interval = int(request.args.get('interval', type=int) or default_interval) - coin = str(request.args.get('coin', type=str) or default_coin) + interval = request.args.get('interval', type=int) + coin = request.args.get('coin', type=str) try: prices, _ = get_prices(interval=interval, pair=coin)