Skip to content

feat: Add per-coin order size overrides#123

Merged
keitaj merged 1 commit into
mainfrom
feat/per-coin-order-size
Apr 25, 2026
Merged

feat: Add per-coin order size overrides#123
keitaj merged 1 commit into
mainfrom
feat/per-coin-order-size

Conversation

@keitaj

@keitaj keitaj commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add --coin-size-overrides CLI flag to configure ORDER_SIZE_USD per coin (e.g., "TSLA:150,NVDA:150")
  • Coins without overrides fall back to the global --order-size-usd value
  • Setting a coin's size to 0 skips order placement for that coin
  • Follows the same lookup pattern as existing --coin-offset-overrides and --coin-spread-overrides (full name -> bare name -> global default)

Changes

  • strategies/market_making_strategy.py: Add _coin_size_overrides dict, _get_coin_size() helper, and update calculate_position_size() to use per-coin lookup
  • bot.py: Add --coin-size-overrides argparse flag and wire it into _STRATEGY_PARAMS
  • README.md: Document the new parameter in strategy description and YAML reference
  • tests/test_per_coin_order_size.py: 13 test cases covering override lookup, bare/prefixed name matching, zero-value skip, global fallback, and risk_level multiplier interaction
  • 8 existing test files: Add _coin_size_overrides = {} to test helpers that bypass __init__

Test plan

  • All 766 tests pass (pytest tests/ -q)
  • Lint passes (flake8 --max-line-length=120)
  • Verify --coin-size-overrides "TSLA:150" reduces TSLA order size while other coins use global default
  • Verify --coin-size-overrides "TSLA:0" skips TSLA orders entirely
  • Verify backward compatibility: omitting the flag keeps existing behavior

🤖 Generated with Claude Code

Allow configuring ORDER_SIZE_USD per coin to reduce notional exposure
on high-volatility assets while keeping the global default for others.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@keitaj keitaj left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Per-coin order size overrides

Clean implementation following the established _get_coin_*() pattern. 13 tests with real assertions.


1. Existing test helpers need _coin_size_overrides (informational)

8 existing test files updated to add _coin_size_overrides = {} — this is correct and necessary because those tests bypass __init__ and manually set attributes. ✓

2. _get_coin_size follows exact same pattern (informational)

Identical to _get_coin_offset() and _get_coin_spread(): full name → bare name → global default. Consistent. ✓

3. inventory_skew still uses global order_size_usd (informational)

_calculate_inventory_skew() normalizes position value by self.order_size_usd, not the per-coin size. This is correct — skew normalization is about the account-level position scale, not the per-coin order size. ✓


Verdict: LGTM

  • No blockers or should-fix items
  • 13 new tests covering all lookup scenarios, fallback, zero value, risk multiplier
  • Fully backward compatible (empty string default)
  • Clean reuse of existing _parse_coin_overrides() parser
  • README updated for both human and AI reference

Merging after CI check.

@keitaj
keitaj merged commit 33252e7 into main Apr 25, 2026
6 checks passed
@keitaj
keitaj deleted the feat/per-coin-order-size branch April 25, 2026 09:11
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