Skip to content

Grid ladder cleanup: reject even level counts, tighten enums#1017

Merged
carkod merged 1 commit into
masterfrom
grid-ladder-cleanup
May 20, 2026
Merged

Grid ladder cleanup: reject even level counts, tighten enums#1017
carkod merged 1 commit into
masterfrom
grid-ladder-cleanup

Conversation

@carkod
Copy link
Copy Markdown
Owner

@carkod carkod commented May 20, 2026

  • Reject even level_count at the model layer: an even count produces an asymmetric grid (e.g. 2 buys / 1 sell for level_count=4), which breaks the mean-reversion assumption.
  • Tighten GridLadderTable.exchange and market_type to NOT NULL (matching the GridLadderRecord shape), with a follow-up migration that backfills any NULL rows before adding the constraint.
  • Correct CRUD type hints for create(): ExchangeId | str and MarketType | str (the route already passes enums).
  • calculate_grid_levels now returns a CalculatedGrid carrying both the levels and the grid_step, so the route no longer has to recompute grid_step separately.
  • Tests: cover even-level rejection, SPOT and non-KuCoin rejection; refit existing tests to the new CalculatedGrid return shape.

- Reject even level_count at the model layer: an even count produces an
  asymmetric grid (e.g. 2 buys / 1 sell for level_count=4), which breaks
  the mean-reversion assumption.
- Tighten GridLadderTable.exchange and market_type to NOT NULL (matching
  the GridLadderRecord shape), with a follow-up migration that backfills
  any NULL rows before adding the constraint.
- Correct CRUD type hints for create(): `ExchangeId | str` and
  `MarketType | str` (the route already passes enums).
- calculate_grid_levels now returns a CalculatedGrid carrying both the
  levels and the grid_step, so the route no longer has to recompute
  grid_step separately.
- Tests: cover even-level rejection, SPOT and non-KuCoin rejection;
  refit existing tests to the new CalculatedGrid return shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@carkod carkod force-pushed the grid-ladder-cleanup branch from 44974b7 to 4d1fe64 Compare May 20, 2026 00:20
@carkod carkod merged commit 3e50404 into master May 20, 2026
14 checks passed
@carkod carkod deleted the grid-ladder-cleanup branch May 20, 2026 01:50
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