File size: 1,536 Bytes
208fbf8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)