import sys, traceback
sys.path.insert(0, '/home/hmo/MoFin')

errors = []
for mod, name in [
    ('mo_data', 'read_portfolio'),
    ('mo_data', 'read_decisions'),
    ('mo_data', 'read_watchlist'),
    ('mofin_db', 'get_conn'),
    ('mofin_db', 'write_holdings_batch'),
    ('mofin_db', 'write_portfolio_summary'),
    ('mofin_db', 'write_watchlist_stock'),
    ('mofin_db', 'write_holding_strategy'),
    ('mo_models', 'is_hk_stock'),
    ('mo_models', 'get_hk_rate'),
]:
    try:
        m = __import__(mod, fromlist=[name])
        getattr(m, name)
        print(f"OK: {mod}.{name}")
    except Exception as e:
        print(f"FAIL: {mod}.{name} -> {e}")
        errors.append(str(e))

print(f"\n=== price_monitor.py import test ===")
try:
    import price_monitor
    print("price_monitor imported OK")
except Exception as e:
    print(f"FAIL: {traceback.format_exc()}")

if errors:
    print(f"\n{len(errors)} import errors!")
