Skip to content

Add Kraken cache-rates backfill, with VWAP support#3

Merged
Sjors merged 8 commits intomasterfrom
2026/03/archive
Mar 23, 2026
Merged

Add Kraken cache-rates backfill, with VWAP support#3
Sjors merged 8 commits intomasterfrom
2026/03/archive

Conversation

@Sjors
Copy link
Copy Markdown
Owner

@Sjors Sjors commented Mar 22, 2026

Add yearly Kraken backfill that fills recent candles from the API and older daily gaps from the OHLCVT archive, storing midpoint values when VWAP is unavailable.

Add a --vwap path that computes exact candle VWAP from Kraken trade archives (back to late 2013), supports candle overrides, reuses cached ZIP downloads, and falls back to larger trade candles when sparse intervals are missing (e.g. due to exchange outages).

Improve progress and summary logging, protect complete-archive refreshes from shrinking cached historical coverage, and add regression tests based on real Kraken CSV samples and overlap checks.

Sjors added 3 commits March 23, 2026 12:33
Move cache_key, cache_path and load_disk_cache from KrakenProvider
methods to free public functions. Add save_disk_cache as a standalone
helper. Make CACHE_DIR and CACHE_FILE constants public.

This prepares for reuse by the upcoming cache-rates command.
Factor out parse_kraken_ohlc_response from fetch_candle_for_timestamp
so the HTTP-status and JSON-decoding logic can be shared.

Add fetch_candles_since, which returns all candles from a given
timestamp instead of searching for a single one.
The export command hard-coded a 1440-minute fallback and ignored the
DEFAULT_CANDLE_MINUTES environment variable.  Change candle_minutes to
candle_override_minutes (Option) and resolve the effective interval
through resolve_candle_minutes, which checks the override, then the
env default, then falls back to 1440.

Add unit tests for argument parsing and candle-minutes resolution.
@Sjors Sjors force-pushed the 2026/03/archive branch from acdff36 to 31867a4 Compare March 23, 2026 12:35
Sjors added 5 commits March 23, 2026 13:51
Extract the OPBD (opening) balance amount, sign, and date from an
existing CAMT.053 file during the append-mode parse.  Add
opening_balance_cents and opening_date fields to Camt053ParseResult
and extend the round-trip test to cover them.

This information is needed for the upcoming prepend mode, which must
preserve the original opening balance when inserting entries before the
existing statement.
When the output file already exists and --start-date is earlier than
the file's opening balance date, switch to prepend mode: build entries
only for the gap period, then splice them before the existing entries
and recalculate statement totals.

Reject attempts to move the start date forward past the existing
opening date.  When prepending, omit the wallet balance check (the
known-good closing balance is in the existing file).

Add ExistingExportPlan, ExistingMergeMode, merge_with_existing_statement,
refresh_statement_totals and supporting helpers with unit tests.
@Sjors Sjors force-pushed the 2026/03/archive branch from 31867a4 to eb94c10 Compare March 23, 2026 12:54
@Sjors Sjors merged commit eb94c10 into master Mar 23, 2026
1 check 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.

1 participant