initial commit — cassandra v0.1
Containerised macro-strategy dashboard: 4-panel web UI (indicators,
portfolio, flash news, AI strategic log), MariaDB store, hourly
ingestion jobs, OpenRouter-backed AI analysis.
Ports the four prototype scripts in the parent dir (market_pulse,
flash_news, trading212, strategic_log) into async services backed by a
persistent DB and served via FastAPI + Jinja2 + HTMX. APScheduler runs
as a separate compose service for crash-safety and easier restarts.
Portfolio composition + position names come live from Trading 212;
news per-ticker headlines reuse those names. Tone (NOVICE/INTERMEDIATE/
PRO) and analysis style (DRY/SPECULATIVE) are env-configurable and
stored on each log row so historical entries show what produced them.
Default model is deepseek/deepseek-v4-flash (overridable via env).
Light/dark theme toggle, sans-serif for prose surfaces, monospace for
data. Bearer-token auth, OpenRouter monthly cost cap, RSS feeds auto-
disabled on consecutive failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:56:10 +01:00
|
|
|
"""Alembic environment — DB URL is sourced from app/config.Settings at runtime
|
|
|
|
|
so we keep secrets out of alembic.ini. Async engine is used in 'online' mode."""
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
from logging.config import fileConfig
|
|
|
|
|
|
|
|
|
|
from alembic import context
|
|
|
|
|
from sqlalchemy import pool
|
|
|
|
|
from sqlalchemy.engine import Connection
|
|
|
|
|
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
|
|
|
|
|
|
|
|
from app.config import get_settings
|
|
|
|
|
from app.db import Base
|
|
|
|
|
# Import models so that Base.metadata is populated.
|
|
|
|
|
from app import models # noqa: F401
|
|
|
|
|
|
|
|
|
|
config = context.config
|
|
|
|
|
|
|
|
|
|
# Inject the real DB URL from Settings.
|
|
|
|
|
config.set_main_option("sqlalchemy.url", get_settings().DATABASE_URL)
|
|
|
|
|
|
|
|
|
|
if config.config_file_name is not None:
|
2026-05-23 16:15:54 +02:00
|
|
|
# disable_existing_loggers=False is essential: the app applies
|
|
|
|
|
# migrations in-process at startup (see app.main lifespan), so the
|
|
|
|
|
# default True would disable uvicorn's already-configured loggers —
|
|
|
|
|
# silencing access logs and 500 tracebacks for the whole process.
|
|
|
|
|
fileConfig(config.config_file_name, disable_existing_loggers=False)
|
initial commit — cassandra v0.1
Containerised macro-strategy dashboard: 4-panel web UI (indicators,
portfolio, flash news, AI strategic log), MariaDB store, hourly
ingestion jobs, OpenRouter-backed AI analysis.
Ports the four prototype scripts in the parent dir (market_pulse,
flash_news, trading212, strategic_log) into async services backed by a
persistent DB and served via FastAPI + Jinja2 + HTMX. APScheduler runs
as a separate compose service for crash-safety and easier restarts.
Portfolio composition + position names come live from Trading 212;
news per-ticker headlines reuse those names. Tone (NOVICE/INTERMEDIATE/
PRO) and analysis style (DRY/SPECULATIVE) are env-configurable and
stored on each log row so historical entries show what produced them.
Default model is deepseek/deepseek-v4-flash (overridable via env).
Light/dark theme toggle, sans-serif for prose surfaces, monospace for
data. Bearer-token auth, OpenRouter monthly cost cap, RSS feeds auto-
disabled on consecutive failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:56:10 +01:00
|
|
|
|
|
|
|
|
target_metadata = Base.metadata
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_migrations_offline() -> None:
|
|
|
|
|
url = config.get_main_option("sqlalchemy.url")
|
|
|
|
|
context.configure(
|
|
|
|
|
url=url,
|
|
|
|
|
target_metadata=target_metadata,
|
|
|
|
|
literal_binds=True,
|
|
|
|
|
dialect_opts={"paramstyle": "named"},
|
|
|
|
|
compare_type=True,
|
|
|
|
|
)
|
|
|
|
|
with context.begin_transaction():
|
|
|
|
|
context.run_migrations()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_run_migrations(connection: Connection) -> None:
|
2026-05-28 00:16:09 +02:00
|
|
|
# render_as_batch is required for SQLite, which doesn't support
|
|
|
|
|
# most ALTER COLUMN / ADD CONSTRAINT operations natively. With
|
|
|
|
|
# batch mode enabled, Alembic emits a copy-and-rename dance under
|
|
|
|
|
# SQLite while still producing plain ALTER on MariaDB / Postgres,
|
|
|
|
|
# so prod migrations are unchanged. Detect via the dialect name.
|
|
|
|
|
render_as_batch = connection.dialect.name == "sqlite"
|
initial commit — cassandra v0.1
Containerised macro-strategy dashboard: 4-panel web UI (indicators,
portfolio, flash news, AI strategic log), MariaDB store, hourly
ingestion jobs, OpenRouter-backed AI analysis.
Ports the four prototype scripts in the parent dir (market_pulse,
flash_news, trading212, strategic_log) into async services backed by a
persistent DB and served via FastAPI + Jinja2 + HTMX. APScheduler runs
as a separate compose service for crash-safety and easier restarts.
Portfolio composition + position names come live from Trading 212;
news per-ticker headlines reuse those names. Tone (NOVICE/INTERMEDIATE/
PRO) and analysis style (DRY/SPECULATIVE) are env-configurable and
stored on each log row so historical entries show what produced them.
Default model is deepseek/deepseek-v4-flash (overridable via env).
Light/dark theme toggle, sans-serif for prose surfaces, monospace for
data. Bearer-token auth, OpenRouter monthly cost cap, RSS feeds auto-
disabled on consecutive failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:56:10 +01:00
|
|
|
context.configure(
|
|
|
|
|
connection=connection,
|
|
|
|
|
target_metadata=target_metadata,
|
|
|
|
|
compare_type=True,
|
2026-05-28 00:16:09 +02:00
|
|
|
render_as_batch=render_as_batch,
|
initial commit — cassandra v0.1
Containerised macro-strategy dashboard: 4-panel web UI (indicators,
portfolio, flash news, AI strategic log), MariaDB store, hourly
ingestion jobs, OpenRouter-backed AI analysis.
Ports the four prototype scripts in the parent dir (market_pulse,
flash_news, trading212, strategic_log) into async services backed by a
persistent DB and served via FastAPI + Jinja2 + HTMX. APScheduler runs
as a separate compose service for crash-safety and easier restarts.
Portfolio composition + position names come live from Trading 212;
news per-ticker headlines reuse those names. Tone (NOVICE/INTERMEDIATE/
PRO) and analysis style (DRY/SPECULATIVE) are env-configurable and
stored on each log row so historical entries show what produced them.
Default model is deepseek/deepseek-v4-flash (overridable via env).
Light/dark theme toggle, sans-serif for prose surfaces, monospace for
data. Bearer-token auth, OpenRouter monthly cost cap, RSS feeds auto-
disabled on consecutive failures.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-15 21:56:10 +01:00
|
|
|
)
|
|
|
|
|
with context.begin_transaction():
|
|
|
|
|
context.run_migrations()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def run_migrations_online() -> None:
|
|
|
|
|
connectable = async_engine_from_config(
|
|
|
|
|
config.get_section(config.config_ini_section, {}),
|
|
|
|
|
prefix="sqlalchemy.",
|
|
|
|
|
poolclass=pool.NullPool,
|
|
|
|
|
)
|
|
|
|
|
async with connectable.connect() as connection:
|
|
|
|
|
await connection.run_sync(do_run_migrations)
|
|
|
|
|
await connectable.dispose()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if context.is_offline_mode():
|
|
|
|
|
run_migrations_offline()
|
|
|
|
|
else:
|
|
|
|
|
asyncio.run(run_migrations_online())
|