maxt 0.2.1

One Rust API for Upbit, Bithumb, Binance, and Hyperliquid market data, accounts, and orders.
Documentation
# Binance

[English]binance.md | [한국어]binance.ko.md

## Venue and constructor

One `BinanceAdapter` is fixed to Spot or USD-M perpetual futures.

| Constructor | `MarketKind` | REST | Public WebSocket |
| --- | --- | --- | --- |
| `BinanceAdapter::spot()` | `Spot` | `https://api.binance.com` | `wss://stream.binance.com:9443/stream` |
| `BinanceAdapter::usd_m_futures()` | `Perpetual` | `https://fapi.binance.com` | `wss://fstream.binance.com/public/stream` and `/market/stream` |

`BinanceAdapter::default()` is Spot. A market with the wrong exchange or
`MarketKind` returns `Error::InvalidRequest` before network I/O.

## REST

| Call | Spot | USD-M |
| --- | --- | --- |
| `markets(kind)` | `/api/v3/exchangeInfo`; Spot listings | `/fapi/v1/exchangeInfo`; `contractType == PERPETUAL` |
| `trades(market, limit)` | `/api/v3/trades`; `limit: 1..=1000` | `/fapi/v1/trades`; `limit: 1..=1000` |
| `order_book(market, depth)` | `/api/v3/depth`; `depth: 1..=5000`; at most `depth` levels per side | `/fapi/v1/depth`; `depth: {5, 10, 20, 50, 100, 500, 1000}`; at most `depth` levels per side |
| `ticker(market)` | `/api/v3/ticker/24hr`; rolling 24-hour summary | `/fapi/v1/ticker/24hr`; rolling 24-hour summary |
| `funding_rates(request)` | `Error::Unsupported` | `/fapi/v1/fundingRate`; `limit: 1..=1000`; `None -> 100` |
| `mark_price(market)` | `Error::Unsupported` | `/fapi/v1/premiumIndex`; one USD-M perpetual mark-price snapshot |
| `mark_prices()` | `Error::Unsupported` | `/fapi/v1/premiumIndex`; current snapshots for supported USD-M perpetual markets |
| `open_interest(market)` | `Error::Unsupported` | `/fapi/v1/openInterest`; one USD-M perpetual open-interest snapshot |
| `aggregate_trades(request)` | `Error::Unsupported` | USD-M only, public `/fapi/v1/aggTrades`; `limit: 1..=1000` (`None -> 500`); `from_id` is inclusive and cannot be combined with time bounds; `start_time` and `end_time` are inclusive and must span less than one hour |

Trades are newest-first. Spot order books have no provider timestamp and use
local read time; USD-M order books retain the provider timestamp. Unknown
listing statuses map to `MarketStatus::Unknown`.

## Candles

| Venue | Exposed `Interval` variants |
| --- | --- |
| Spot | `Sec1`, `Min1`, `Min3`, `Min5`, `Min15`, `Min30`, `Hour1`, `Hour2`, `Hour4`, `Hour6`, `Hour8`, `Hour12`, `Day1`, `Day3`, `Week1`, `Month1` |
| USD-M | Spot list without `Sec1` |

REST and `Feed::Candles` expose the same intervals.

| Constraint | Spot | USD-M |
| --- | ---: | ---: |
| Provider page cap | 1,000 | 1,500 |
| Provider calls per request | `<= 100` | `<= 100` |
| Preflight candle estimate | `<= 100_000` | `<= 150_000` |

## Streams

| Feed | Stream | Contract |
| --- | --- | --- |
| `Feed::Trades` (Spot) | `{symbol}@trade` | One event per execution |
| `Feed::Trades` (USD-M) | Unsupported | Binance exposes only aggregated trades, not every execution required by this feed |
| `Feed::OrderBook` | `{symbol}@depth20@100ms` | Full snapshot; 20 levels per side; fixed depth |
| `Feed::Ticker` | `{symbol}@ticker` | Rolling 24-hour summary |
| `Feed::Candles(interval)` | `{symbol}@kline_<interval>` | Preserve Binance `closed` |

Event markets are resolved from the native symbols in `Subscription`; symbols
are not split using a quote-suffix list.

USD-M routes `OrderBook` through `/public/stream`, and `Ticker` and `Candles`
through `/market/stream`. When both are required, the returned
`MarketStream` merges two sockets. Reconnect notices are per socket. If either
socket terminates, the logical stream terminates and drops the other socket.

## Private and provider-specific APIs

Configure private calls with `.with_credentials(api_key, secret_key)`. The
adapter supports HMAC-SHA-256 keys; RSA and Ed25519 keys are unsupported.

| Venue | Private features |
| --- | --- |
| Spot | Balances, open orders, place/cancel order, account stream |
| USD-M | Spot features plus positions, margin summary/configuration, funding payments, and reduce-only orders |

| Order input | Spot | USD-M |
| --- | --- | --- |
| `Size::Base` | All orders | All orders |
| `Size::Quote` | Market order only; Limit -> `Error::InvalidRequest` | `Error::InvalidRequest` |
| `time_in_force` | `GTC`, `IOC`, `FOK`; `PostOnly -> LIMIT_MAKER` | `GTC`, `IOC`, `FOK`; `PostOnly -> GTX` |
| `OrderType::Best` | `Size::Base` + `IOC` or `FOK`; `LIMIT + MARKET_PEG` | `Error::Unsupported` |
| `client_id` | 1–36 characters matching `[A-Za-z0-9./:_-]` | Same |
| `reduce_only == true` | `Error::Unsupported` | Supported |

Cancel methods return `()` after validating Binance's order response. Use an
order query when the final fill state matters.

Access the following provider-specific methods through `Client::adapter()`:

| Method | Contract |
| --- | --- |
| `spot_symbol_filters(&market)` | Spot `PRICE_FILTER`, `LOT_SIZE`, and `NOTIONAL`; unsupported on USD-M. |
| `spot_order(&market, order_id)` | One Spot order by numeric ID, including completed orders. |
| `usd_m_create_listen_key()` | Create or extend the USD-M account listen key. |
| `usd_m_keepalive_listen_key()` | Extend the active USD-M listen key owned by the configured API key. |
| `usd_m_close_listen_key()` | Close the active USD-M listen key owned by the configured API key. |

The USD-M `mark_price`, `mark_prices`, and `open_interest` calls are public and
read-only. They are fixture-verified; live reads have not been verified. The
`mark_prices()` result is limited to maxt's USD-M perpetual market universe.

`aggregate_trades(request)` is also a public, read-only USD-M endpoint. Binance
only retains the latest 48 hours of futures trade history. The endpoint returns
one page, so use the last aggregate ID plus one as the next `from_id` when
walking by cursor. This method is fixture-verified; live reads have not been
verified.

`subscribe_account` manages USD-M listen keys. Spot uses the signed
`userDataStream.subscribe.signature` request and no listen key.

Orders are not rounded or validated against symbol filters. Spot margin,
COIN-M, options, portfolio margin, quarterly futures, configurable stream
depth, diff-depth reconstruction, `@aggTrade`, testnet constructors, and
RSA/Ed25519 keys are not exposed.

## Limits and official links

Binance charges IP-based `REQUEST_WEIGHT`. Read current limits from
`exchangeInfo` and monitor `X-MBX-USED-WEIGHT-1M`. `maxt` does not throttle or
consume that header. HTTP 429 and 418 satisfy
`Error::is_rate_limited() == true`.

- [Spot REST market data]https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/rest-api/market
- [Spot REST limits]https://developers.binance.com/en/docs/products/spot/rest-api
- [Spot WebSocket streams]https://developers.binance.com/en/docs/catalog/core-trading-spot-trading/api/ws-streams/~
- [USD-M REST market data]https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/rest-api/market-data
- [USD-M Mark Price]https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Mark-Price
- [USD-M Open Interest]https://developers.binance.com/docs/derivatives/usds-margined-futures/market-data/rest-api/Open-Interest
- [USD-M Compressed/Aggregate Trades]https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/rest-api/market-data#compressed-aggregate-trades-list
- [USD-M public streams]https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-streams/public
- [USD-M market streams]https://developers.binance.com/en/docs/catalog/core-trading-derivatives-trading-usd-s-m-futures/api/ws-streams/market

[Common API](../common-api.md) · [Provider support](../providers.md)