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
80
app/templates/partials/portfolio.html
Normal file
80
app/templates/partials/portfolio.html
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
{% if not portfolios %}
|
||||
<div class="empty">no portfolio snapshots yet</div>
|
||||
{% else %}
|
||||
{% for p in portfolios %}
|
||||
{# --- overall block --- #}
|
||||
<div class="pf-overall">
|
||||
<div class="pf-overall__head">
|
||||
<span class="pf-name">{{ p.name }}</span>
|
||||
<span class="pf-as-of">
|
||||
{% if p.snapshot_at %}{{ p.snapshot_at.strftime("%Y-%m-%d %H:%M UTC") }}{% else %}—{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
<div class="pf-overall__grid">
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Total</div>
|
||||
<div class="pf-stat-value">{{ p.total_value | money }} <span class="pf-ccy">{{ p.currency }}</span></div>
|
||||
</div>
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Invested</div>
|
||||
<div class="pf-stat-value">{{ p.invested | money }}</div>
|
||||
</div>
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Cash</div>
|
||||
<div class="pf-stat-value">{{ p.cash | money }}</div>
|
||||
</div>
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Unrealised P/L</div>
|
||||
<div class="pf-stat-value {% if p.unrealized_ppl is none %}neu{% elif p.unrealized_ppl >= 0 %}pos{% else %}neg{% endif %}">
|
||||
{{ p.unrealized_ppl | signed }}
|
||||
{% if p.total_cost and p.unrealized_ppl is not none %}
|
||||
<span class="pf-pct">({{ "%+.2f"|format(p.unrealized_ppl / p.total_cost * 100) }}%)</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Realised P/L</div>
|
||||
<div class="pf-stat-value {% if p.realized_ppl is none %}neu{% elif p.realized_ppl >= 0 %}pos{% else %}neg{% endif %}">
|
||||
{{ p.realized_ppl | signed }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf-stat">
|
||||
<div class="pf-stat-label">Positions</div>
|
||||
<div class="pf-stat-value">{{ p.positions | length }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# --- per-position table --- #}
|
||||
<table class="dense">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ticker</th>
|
||||
<th>Name</th>
|
||||
<th class="num">Qty</th>
|
||||
<th class="num">Avg</th>
|
||||
<th class="num">Last</th>
|
||||
<th class="num">P/L</th>
|
||||
<th class="num">%</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for pos in p.positions %}
|
||||
<tr>
|
||||
<td class="label">{{ pos.ticker }}</td>
|
||||
<td>{{ pos.name or "" }}</td>
|
||||
<td class="num">{{ pos.quantity | price }}</td>
|
||||
<td class="num neu">{{ pos.average_price | price }}</td>
|
||||
<td class="num">{{ pos.current_price | price }}</td>
|
||||
<td class="num {% if pos.ppl is none %}neu{% elif pos.ppl >= 0 %}pos{% else %}neg{% endif %}">
|
||||
{{ pos.ppl | signed }}
|
||||
</td>
|
||||
<td class="num {% if pos.ppl_pct is none %}neu{% elif pos.ppl_pct >= 0 %}pos{% else %}neg{% endif %}">
|
||||
{% if pos.ppl_pct is not none %}{{ "%+.2f"|format(pos.ppl_pct) }}%{% else %}—{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue