Skip to content

feat: ML-powered pricing agent with online learning#25

Merged
abhicris merged 1 commit into
mainfrom
feat/ml-pricing-agent
Apr 23, 2026
Merged

feat: ML-powered pricing agent with online learning#25
abhicris merged 1 commit into
mainfrom
feat/ml-pricing-agent

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

Summary

  • Adds MLPricingAgent — market-making agent with online machine learning
  • Uses recursive least squares (RLS) to predict short-term price direction
  • Features: returns, volatility, momentum, inventory ratio
  • Volatility-adaptive spread + ML-confidence-weighted directional skew
  • Inventory-aware bid/ask adjustment to manage position risk
  • 10 tests covering spread dynamics, inventory skew, rebalancing, model learning

Test plan

  • Unit tests pass
  • Backtest against historical price data vs constant-spread agent
  • Compare PnL and Sharpe ratio against AvellanedaStoikov agent

🤖 Generated with Claude Code

abhicris added a commit that referenced this pull request Apr 23, 2026
Three fixes to make the CI on PR #25 (ML pricing agent) green:

1. **contracts** — `npm ci` failed with "no package-lock.json". The `deploy/`
   wrapper also couldn't find contracts since hardhat paths defaulted to
   `deploy/contracts/` which doesn't exist. Moved `package.json` +
   `hardhat.config.js` to repo root, committed `package-lock.json`, set
   `paths.sources = "./contracts"` + `paths.tests = "./tests/contracts"`,
   bumped solc to 0.8.26 with cancun evm (OZ ^5.0.0 uses `mcopy`).
   Workflow no longer needs `working-directory: deploy`.

2. **python / pytest-asyncio** — Three async message-handling tests for
   the WebSocket feed failed with "async def functions are not natively
   supported". Added `pytest-asyncio>=0.23.0` to requirements.txt and
   shipped `pytest.ini` with `asyncio_mode = auto`.

3. **test_unknown_pair_raises** — `patch.object(oracle, "w3")` eagerly
   invoked the property getter during setup, which tried to connect to
   `http://localhost:8545` and raised `OracleConnectionError` before the
   real assertion ran. The unknown-pair branch never needs `self.w3` —
   `_get_contract` raises `OracleFeedNotFound` before any RPC call.
   Dropped the patch.

Local:
- `npm ci && npx hardhat compile` → "Compiled 24 Solidity files successfully"
- `pytest tests/` → 91 passed, 2 skipped (live-integration, correctly gated
  on WEB3_PROVIDER_URL_SEPOLIA).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds MLPricingAgent — a market-making agent that uses recursive least
squares (RLS) online regression to predict short-term price direction
and dynamically adjust spreads and skew.

- Online linear model with exponential forgetting for non-stationarity
- Feature extraction: returns, volatility, momentum, inventory ratio
- Volatility-adaptive spread width + ML-confidence-weighted skew
- Inventory-aware bid/ask adjustment
- 10 tests covering spread dynamics, inventory skew, rebalancing

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abhicris abhicris force-pushed the feat/ml-pricing-agent branch from 6c562d2 to 6299362 Compare April 23, 2026 12:59
@abhicris abhicris merged commit 7a87fa6 into main Apr 23, 2026
4 checks passed
@abhicris abhicris deleted the feat/ml-pricing-agent branch April 23, 2026 13:00
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