Reject or warn on a start date older than the reachable rate history #5

Open
opened 2026-08-31 21:22:12 +00:00 by padreug · 0 comments
Owner

Problem

A contract with backfill on, payday pricing, and a start date beyond what the rate providers can answer is a guaranteed failure, and nothing catches it until ~25 minutes later.

Measured reach (rates.py, verified against both live APIs):

payday age major pair (EUR, GBP, USD…) currency Kraken doesn't quote
under 1 year Kraken CoinGecko
1–2 years Kraken unavailable
over 2 years unavailable unavailable

CoinGecko's free tier returns 401 Unauthorized past 365 days; Kraken's OHLC series is ~721 daily candles.

So a contract starting three years ago fails period 0 on every tick, writes five failed ledger rows, and auto-pauses. That is correct behaviour — it refuses rather than guessing — but the operator only finds out after five ticks, and the fix (switch to manual or current) was knowable at creation time.

Proposal

Validate in _validate_terms, where the currency is already checked:

  • if pricing_mode == payday, backfill is on, and start_date is outside the reachable window for that currency → reject with a message naming the window, or warn in the dialog and let the operator proceed
  • ideally surface the window in the contract dialog itself, next to the date picker

rates.py already knows the answer — _kraken_series returns the parsed series, whose min()/max() bound it exactly, and it is cached, so the check is nearly free.

Note

The window is a property of the providers, not of payroll, so it moves. Better to probe than to hard-code "2 years".

🤖 Generated with Claude Code

https://claude.ai/code/session_018jy52j9GRZ6XKa1Zt21LLj

## Problem A contract with `backfill` on, `payday` pricing, and a start date beyond what the rate providers can answer is a **guaranteed failure**, and nothing catches it until ~25 minutes later. Measured reach (`rates.py`, verified against both live APIs): | payday age | major pair (EUR, GBP, USD…) | currency Kraken doesn't quote | |---|---|---| | under 1 year | Kraken | CoinGecko | | 1–2 years | Kraken | **unavailable** | | over 2 years | **unavailable** | **unavailable** | CoinGecko's free tier returns `401 Unauthorized` past 365 days; Kraken's OHLC series is ~721 daily candles. So a contract starting three years ago fails period 0 on every tick, writes five failed ledger rows, and auto-pauses. That is correct behaviour — it refuses rather than guessing — but the operator only finds out after five ticks, and the fix (switch to `manual` or `current`) was knowable at creation time. ## Proposal Validate in `_validate_terms`, where the currency is already checked: - if `pricing_mode == payday`, `backfill` is on, and `start_date` is outside the reachable window for that currency → **reject** with a message naming the window, or **warn** in the dialog and let the operator proceed - ideally surface the window in the contract dialog itself, next to the date picker `rates.py` already knows the answer — `_kraken_series` returns the parsed series, whose `min()`/`max()` bound it exactly, and it is cached, so the check is nearly free. ## Note The window is a property of the *providers*, not of payroll, so it moves. Better to probe than to hard-code "2 years". 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018jy52j9GRZ6XKa1Zt21LLj
Sign in to join this conversation.
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
aiolabs/payroll#5
No description provided.