Spaces:
Sleeping
Sleeping
| import os, sys | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| import pandas as pd | |
| from database import get_pg_engine | |
| import os | |
| os.environ["DATABASE_URL"] = "sqlite:///portfolio_db.sqlite3" | |
| import config | |
| from main import run_engine | |
| orig_read_sql = pd.read_sql | |
| def patched_read_sql(sql, con, *args, **kwargs): | |
| if hasattr(con, 'dialect') and con.dialect.name == 'sqlite': | |
| if isinstance(sql, str): | |
| sql = sql.replace('%s', '?') | |
| return orig_read_sql(sql, con, *args, **kwargs) | |
| pd.read_sql = patched_read_sql | |
| # Force logging to console to see the warning | |
| import logging | |
| from config import logger | |
| import sys | |
| handler = logging.StreamHandler(sys.stdout) | |
| handler.setLevel(logging.DEBUG) | |
| logger.setLevel(logging.DEBUG) | |
| logger.addHandler(handler) | |
| overrides = { | |
| 'tickers': ['AAPL', 'MSFT', 'GOOGL', 'AMZN', 'NVDA', 'META', 'TSLA', 'JPM', 'GS', 'XOM', 'CVX', 'TLT', 'IEF', 'SHY', 'LQD', 'HYG', 'GLD', 'SLV', 'USO', 'SPY', 'QQQ', 'DIA', 'ES=F', 'NQ=F', 'GC=F', 'CL=F'], | |
| 'capital': 10000000.0, | |
| 'risk_input': 5, | |
| 'model': 5, | |
| 'allocation_engine': 1, | |
| 'tax_lt': 0.15, | |
| 'tax_st': 0.35, | |
| 'current_weights': {}, | |
| 'live_execution_enabled': False | |
| } | |
| def test_engine_runs_without_crashing(): | |
| cfg = config.load_config() | |
| cfg['live_execution_enabled'] = False | |
| config.save_config(cfg) | |
| run_engine(overrides=overrides) | |
| if __name__ == '__main__': | |
| test_engine_runs_without_crashing() | |