Snapshot right after a buy + balance snapshot 2x/day #9

Merged
DasAoD merged 1 commit from feature/snapshot-after-trade into main 2026-08-31 14:57:01 +02:00
Owner

Behebt den Anzeige-Lag: nach dem ersten Live-Kauf zeigte das Dashboard „Cash 100 €", während Kraken schon 87,90 € hatte – weil der letzte Bestands-Snapshot von vor dem Kauf war (Timer 07:00 UTC, Kauf 08:00 UTC).

Änderungen

A – Snapshot direkt nach dem Kauf

  • _cmd_buy / _cmd_dip nehmen nach einem Lauf mit Fills sofort einen Preis- und Bestands-Snapshot (_snapshot_after_trade, teilt sich die schon offene Exchange-Verbindung).
  • Damit stimmt Cash / Equity im Dashboard in dem Moment, in dem der Telegram-Push kommt – nicht erst Stunden später.
  • Ein Snapshot-Fehler wird geloggt und geschluckt; der Kauf-Exitcode bleibt davon unberührt.

B – Bestands-Timer 2×/Tag

  • krypto-dca-snapshot-balance.timer: 07:00 → 07,19:00 UTC. Hält die Verlaufskurve zwischen den Käufen dichter.
  • Preis-Snapshot bleibt stündlich.

Tests

  • buy schreibt sofort einen Snapshot (balance_snapshots + price_history befüllt)
  • buy endet mit Exit 0, auch wenn der Folge-Snapshot eine Exception wirft
  • pytest → 81 passed

Deploy (vpn, nach Merge)

git pull, cp deploy/krypto-dca-snapshot-balance.timer /etc/systemd/system/, systemctl daemon-reload, systemctl restart krypto-dca-snapshot-balance.timer, Backend neu. Kein Dry-Run nötig (kein Order-Pfad berührt).

Co-authored-by: Claude claude@anthropic.com

Behebt den Anzeige-Lag: nach dem ersten Live-Kauf zeigte das Dashboard „Cash 100 €", während Kraken schon 87,90 € hatte – weil der letzte Bestands-Snapshot von *vor* dem Kauf war (Timer 07:00 UTC, Kauf 08:00 UTC). ## Änderungen **A – Snapshot direkt nach dem Kauf** - `_cmd_buy` / `_cmd_dip` nehmen nach einem Lauf mit Fills sofort einen Preis- **und** Bestands-Snapshot (`_snapshot_after_trade`, teilt sich die schon offene Exchange-Verbindung). - Damit stimmt `Cash` / `Equity` im Dashboard in dem Moment, in dem der Telegram-Push kommt – nicht erst Stunden später. - Ein Snapshot-Fehler wird geloggt und geschluckt; der Kauf-Exitcode bleibt davon unberührt. **B – Bestands-Timer 2×/Tag** - `krypto-dca-snapshot-balance.timer`: `07:00` → `07,19:00 UTC`. Hält die Verlaufskurve zwischen den Käufen dichter. - Preis-Snapshot bleibt stündlich. ## Tests - `buy` schreibt sofort einen Snapshot (`balance_snapshots` + `price_history` befüllt) - `buy` endet mit Exit 0, auch wenn der Folge-Snapshot eine Exception wirft - `pytest` → **81 passed** ## Deploy (`vpn`, nach Merge) `git pull`, `cp deploy/krypto-dca-snapshot-balance.timer /etc/systemd/system/`, `systemctl daemon-reload`, `systemctl restart krypto-dca-snapshot-balance.timer`, Backend neu. Kein Dry-Run nötig (kein Order-Pfad berührt). Co-authored-by: Claude <claude@anthropic.com>
- _cmd_buy / _cmd_dip take a price+balance snapshot immediately after a run that
  had fills (_snapshot_after_trade), so the dashboard's cash/equity is current
  the moment the Telegram push arrives - not up to a day stale. A snapshot
  failure is logged and swallowed; it never fails the buy.
- krypto-dca-snapshot-balance.timer: 07:00 -> 07:00 + 19:00 UTC, for a smoother
  history curve between trades
- tests: buy writes a snapshot straight away; buy still exits 0 when the
  follow-up snapshot raises

Co-authored-by: Claude <claude@anthropic.com>
DasAoD merged commit 7545be4f9c into main 2026-08-31 14:57:01 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DasAoD/krypto-dca-bot!9
No description provided.