Skip to content

feat: Add market making strategy with configurable spread and order cycling#5

Merged
keitaj merged 1 commit into
mainfrom
feature/volume-farming-strategy
Mar 20, 2026
Merged

feat: Add market making strategy with configurable spread and order cycling#5
keitaj merged 1 commit into
mainfrom
feature/volume-farming-strategy

Conversation

@keitaj

@keitaj keitaj commented Mar 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • New market_making strategy that places symmetric buy/sell limit orders around the mid price
  • Orders are periodically refreshed and filled positions can be auto-closed
  • Works in any market condition (no ranging/trending filter)
  • All parameters configurable via CLI args and environment variables

New Strategy: market_making

Parameter CLI Flag Default Description
Spread --spread-bps 5 (0.05%) One-sided spread from mid price in basis points
Order size --order-size-usd 50 Size per order in USD
Max orders --max-open-orders 4 Max concurrent open orders
Refresh interval --refresh-interval 30s Cancel and replace stale orders after this duration
Auto-close --no-close-immediately enabled Disable to hold filled positions

Example Usage

# Basic market making on HIP-3 DEXes
python3 bot.py --strategy market_making --dex hyna --no-hl

# Custom spread and size
python3 bot.py --strategy market_making --dex xyz --no-hl \
  --spread-bps 10 --order-size-usd 100 --refresh-interval 60

# Hold positions instead of auto-closing
python3 bot.py --strategy market_making --no-close-immediately

How It Works

  1. For each coin, place a buy limit at mid - spread and sell limit at mid + spread (post-only)
  2. When an order fills, close the position on the next cycle (if close_immediately is enabled)
  3. Cancel and replace orders older than refresh_interval_seconds
  4. Respects RISK_LEVEL env var for dynamic position sizing (green=100%, yellow=50%, red/black=pause)

Changes

  • strategies/market_making_strategy.py: New 235-line strategy with order tracking, stale order management, and spread calculation
  • strategies/__init__.py: Export MarketMakingStrategy
  • bot.py: Add to strategy_map, default_configs, argparse choices, and CLI arg parsing

Test plan

  • Verify strategy places buy+sell limit orders around mid price
  • Verify stale orders are cancelled after refresh interval
  • Verify filled positions are closed immediately when enabled
  • Verify --no-close-immediately holds positions
  • Verify RISK_LEVEL=yellow reduces order size to 50%
  • Verify RISK_LEVEL=red stops placing new orders
  • Verify strategy works with HIP-3 coins (e.g. hyna:BTC, xyz:GOLD)

🤖 Generated with Claude Code

…ycling

New strategy that places symmetric buy/sell limit orders around the
mid price, manages order lifecycle with configurable refresh intervals,
and optionally closes filled positions immediately.

Parameters (all configurable via CLI/env):
- spread_bps: one-sided spread in basis points (default: 5)
- order_size_usd: size per order in USD (default: 50)
- max_open_orders: concurrent order limit (default: 4)
- refresh_interval_seconds: stale order timeout (default: 30)
- close_immediately: auto-close filled positions (default: true)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@keitaj
keitaj merged commit e027e9d into main Mar 20, 2026
1 check passed
@keitaj
keitaj deleted the feature/volume-farming-strategy branch March 20, 2026 09:16
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