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>
This commit is contained in:
commit
a10409c02b
61 changed files with 4890 additions and 0 deletions
32
app/services/feeds_bootstrap.py
Normal file
32
app/services/feeds_bootstrap.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"""On startup, ensure every feed in default.toml/portfolio.toml has a row in
|
||||
the `feeds` table. Existing rows are left untouched so admin overrides
|
||||
(enabled=0 to mute a noisy source) survive restarts."""
|
||||
from __future__ import annotations
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.config import load_feeds, get_settings
|
||||
from app.models import Feed
|
||||
|
||||
|
||||
async def bootstrap_feeds(session: AsyncSession) -> int:
|
||||
s = get_settings()
|
||||
declared = load_feeds(s.BASELINE_TOML, s.PORTFOLIO_TOML)
|
||||
existing = {
|
||||
(f.category, f.name): f
|
||||
for f in (await session.execute(select(Feed))).scalars().all()
|
||||
}
|
||||
inserted = 0
|
||||
for category, items in declared.items():
|
||||
for name, url in items:
|
||||
key = (category, name)
|
||||
if key in existing:
|
||||
# Refresh URL if it changed in TOML; preserve enabled/failures.
|
||||
if existing[key].url != url:
|
||||
existing[key].url = url
|
||||
continue
|
||||
session.add(Feed(category=category, name=name, url=url))
|
||||
inserted += 1
|
||||
await session.commit()
|
||||
return inserted
|
||||
Loading…
Add table
Add a link
Reference in a new issue