feat(V2): unified /mcp interface; retire Bybit/Alpaca to old/
Add a common cross-exchange interface (/mcp) over the integrated venues
(deribit, hyperliquid):
- get_instruments: uniform schema where each row carries its own
`exchange`, `fees` (maker/taker, live from Deribit, null where the
venue has no per-instrument schedule) and `history_start` (listing
date, live from Deribit creation_timestamp), plus type/tick_size and a
lossless `native` blob. Optional `exchange` filter; fan-out otherwise.
- get_historical: generalized to {exchange, instrument, interval,
start_date, end_date}, returning a single chosen venue's candles.
Consensus merge stays available on /mcp-cross.
New: routers/unified.py, exchanges/cross/instruments.py (normalizers),
UnifiedClient in cross/client.py, schemas in cross/tools.py. Deribit
get_instruments now also surfaces maker/taker_commission and
creation_timestamp (additive).
Retire Bybit and Alpaca from the API surface: move clients, routers,
settings classes and their tests under old/ (history preserved via
git mv); drop them from the builder, /mcp-cross dispatch and symbol_map.
Bybit remains a public funding/OI data source in sentiment (not the
trading client). IBKR is intentionally excluded from /mcp for now.
Docs: rewrite API_REFERENCE.md (remove Bybit/Alpaca, document /mcp,
clarify that data_timestamp is injected globally by middleware).
Tests: add unified-interface coverage; update cross/settings/builder/boot
tests for the reduced venue set. Fix a pre-existing flaky assertion in
the Hyperliquid signing test (r/s use eth_utils.to_hex like the official
SDK, so a leading zero byte yields <66 chars ~1/256 of the time).
323 passed, ruff clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
"""Pydantic schemas + thin tool wrappers for the /mcp-cross router."""
|
||||
"""Pydantic schemas + thin tool wrappers for the /mcp-cross and /mcp routers."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from cerbero_mcp.exchanges.cross.client import CrossClient
|
||||
from cerbero_mcp.exchanges.cross.client import CrossClient, UnifiedClient
|
||||
|
||||
AssetClass = Literal["crypto", "stocks"]
|
||||
AssetClass = Literal["crypto"]
|
||||
Exchange = Literal["deribit", "hyperliquid"]
|
||||
|
||||
|
||||
class GetHistoricalReq(BaseModel):
|
||||
@@ -26,3 +27,39 @@ async def get_historical(client: CrossClient, params: GetHistoricalReq) -> dict:
|
||||
start_date=params.start_date,
|
||||
end_date=params.end_date,
|
||||
)
|
||||
|
||||
|
||||
# ── Unified /mcp interface ────────────────────────────────────────────
|
||||
|
||||
class GetInstrumentsReq(BaseModel):
|
||||
exchange: Exchange | None = None # None → fan-out over all integrated venues
|
||||
currency: str = "BTC" # Deribit only
|
||||
kind: str | None = "future" # Deribit only: future | option | spot
|
||||
|
||||
|
||||
class UnifiedGetHistoricalReq(BaseModel):
|
||||
exchange: Exchange
|
||||
instrument: str
|
||||
interval: str = "1h"
|
||||
start_date: str
|
||||
end_date: str
|
||||
|
||||
|
||||
async def get_instruments(client: UnifiedClient, params: GetInstrumentsReq) -> dict:
|
||||
return await client.get_instruments(
|
||||
exchange=params.exchange,
|
||||
currency=params.currency,
|
||||
kind=params.kind,
|
||||
)
|
||||
|
||||
|
||||
async def unified_get_historical(
|
||||
client: UnifiedClient, params: UnifiedGetHistoricalReq
|
||||
) -> dict:
|
||||
return await client.get_historical(
|
||||
exchange=params.exchange,
|
||||
instrument=params.instrument,
|
||||
interval=params.interval,
|
||||
start_date=params.start_date,
|
||||
end_date=params.end_date,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user