Spaces:
Sleeping
Sleeping
File size: 1,469 Bytes
558db1e | 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 | 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()
|