Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| # Ensure the parent directory (engine) is in the PYTHONPATH | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from main import run_engine | |
| 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': {} | |
| } | |
| if __name__ == "__main__": | |
| print("Running large 26-asset simulation...") | |
| import os | |
| os.environ["DATABASE_URL"] = "sqlite:///portfolio_db.sqlite3" | |
| # Temporarily bypass live execution for the simulation | |
| import config | |
| import pandas as pd | |
| # Monkey patch pandas read_sql to convert %s to ? for SQLite | |
| orig_read_sql = pd.read_sql | |
| def patched_read_sql(sql, con, *args, **kwargs): | |
| if "sqlite" in str(con): | |
| sql = sql.replace("%s", "?") | |
| return orig_read_sql(sql, con, *args, **kwargs) | |
| pd.read_sql = patched_read_sql | |
| cfg = config.load_config() | |
| cfg['live_execution_enabled'] = False | |
| config.save_config(cfg) | |
| import logging | |
| from config import logger | |
| import sys | |
| handler = logging.StreamHandler(sys.stdout) | |
| handler.setLevel(logging.DEBUG) | |
| logger.addHandler(handler) | |
| run_engine(overrides=overrides) | |