Skip to content

Export the simulated portfolio to Excel or CSV - #19

Merged
botta0oss merged 1 commit into
mainfrom
claude/lucid-lovelace-h1c8tm
Sep 25, 2026
Merged

botta0oss merged 1 commit into
mainfrom
claude/lucid-lovelace-h1c8tm

Conversation

@botta0oss

Copy link
Copy Markdown
Owner

What it adds

An «Export Excel» and a «CSV» button on the Portfolio page, backed by GET /portfolio/export?format=xlsx|csv. Viewers can use them too, since the export changes nothing. The file holds the whole portfolio as it is at the time of the export, so the system's performance can be analysed in Excel, Google Sheets or LibreOffice.

Excel workbook (backend/betting/export.py, 5 sheets):

  • Summary:
    • export time and start of the simulation;
    • starting capital, current value, ROI, capital, cash, invested;
    • realised profits, and unrealised profits at the bid and at the market price;
    • expected profit of the closed bets;
    • counts by status and win rate;
    • CLV;
    • risk-free rate and uncertainty correction;
    • all the parameters of the current preset.
  • Bets (57 columns): every bet, excluded ones included.
    • Purchase: shares, price, stake, fees, probabilities, expected profit.
    • Close: resolution or sale, payout, pnl, return on outlay, sale price and reason, days held.
    • For open positions: current value and plan.
    • The forecast that led to the bet (Jev, calibrated, blend, evidence, weight, edge, signal, Kelly, news read) and its economic assessment (verdict, maximum price, net margin, annual return).
  • Equity: the capital curve.
  • Exclusions.
  • Columns: a description of every column.

Format choices

  • Column names are stable keys, the same as the API, so formulas and scripts keep working.
  • Descriptions and sheet names follow the dashboard language. Download links pass ?lang=; the middleware now also accepts it besides X-Lang.
  • Prices and probabilities are fractions 0–1, amounts are USD with $ formatting, times are real Excel dates in UTC.
  • Header rows are frozen and filters are on.
  • Excel rather than plain CSV as the main format, because a decimal-point CSV opens badly in Excel with Italian settings.
  • CSV: the bets only, comma separated, decimal point, ISO times, UTF-8 with BOM.

Other changes

  • Adds openpyxl (pure Python) to requirements.txt.
  • The exit plan of an open bet moved to portfolio.open_bet_plan, so the bet list and the export share it.
  • Docs updated (EN/IT: strategy, API).

Tests

  • New tests in tests/test_portfolio.py:
    • workbook with sheets, summary matching GET /portfolio, the sold and the open bet with all their fields, entry forecast, equity, exclusions and the column descriptions;
    • the CSV;
    • viewer access;
    • sheet names in Italian and in English.
  • Full suite: 199 passed.
  • Playwright: clicking both buttons downloads files that open correctly; no JS errors, no horizontal scroll.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JLWZrfy12imc6dQRsEtFjj


Generated by Claude Code

GET /portfolio/export and an «Export Excel» / «CSV» button on the Portfolio
page. The workbook holds everything at the time of the export: a summary
(capital, value, realised and unrealised profits at the bid and at the mid,
counts, hit rate, CLV, preset parameters), every bet with its purchase, sale
or resolution, result, current value and plan, entry forecast and economic
assessment, the equity curve, the exclusions and a sheet describing every
column. Stable column keys, fractions 0-1, USD, UTC times; descriptions in
the dashboard language (?lang= for download links). Adds openpyxl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JLWZrfy12imc6dQRsEtFjj
@botta0oss
botta0oss merged commit a687681 into main Sep 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants