pub struct Market { /* private fields */ }Expand description
Market data API client.
Provides access to public market data endpoints.
Implementations§
Source§impl Market
impl Market
Sourcepub async fn server_time(&self) -> Result<ServerTime>
pub async fn server_time(&self) -> Result<ServerTime>
Sourcepub async fn exchange_info(&self) -> Result<ExchangeInfo>
pub async fn exchange_info(&self) -> Result<ExchangeInfo>
Sourcepub async fn exchange_info_for_symbols(
&self,
symbols: &[&str],
) -> Result<ExchangeInfo>
pub async fn exchange_info_for_symbols( &self, symbols: &[&str], ) -> Result<ExchangeInfo>
Sourcepub async fn depth(&self, symbol: &str, limit: Option<u16>) -> Result<OrderBook>
pub async fn depth(&self, symbol: &str, limit: Option<u16>) -> Result<OrderBook>
Get order book depth.
§Arguments
symbol- Trading pair symbol (e.g., “BTCUSDT”)limit- Number of entries to return. Valid limits: 5, 10, 20, 50, 100, 500, 1000, 5000. Default is 100; max is 5000.
§Example
let client = Binance::new_unauthenticated()?;
let depth = client.market().depth("BTCUSDT", Some(10)).await?;
for bid in depth.bids {
println!("Bid: {} @ {}", bid.quantity, bid.price);
}Sourcepub async fn historical_trades(
&self,
symbol: &str,
from_id: Option<u64>,
limit: Option<u16>,
) -> Result<Vec<Trade>>
pub async fn historical_trades( &self, symbol: &str, from_id: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Trade>>
Get older/historical trades.
This endpoint requires an API key but not a signature.
§Arguments
symbol- Trading pair symbolfrom_id- Trade ID to fetch fromlimit- Number of trades to return. Default 500; max 1000.
§Example
let client = Binance::new("api_key", "secret_key")?;
let trades = client.market().historical_trades("BTCUSDT", Some(12345), Some(100)).await?;Sourcepub async fn agg_trades(
&self,
symbol: &str,
from_id: Option<u64>,
start_time: Option<u64>,
end_time: Option<u64>,
limit: Option<u16>,
) -> Result<Vec<AggTrade>>
pub async fn agg_trades( &self, symbol: &str, from_id: Option<u64>, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<AggTrade>>
Get compressed/aggregate trades.
Trades that fill at the same time, from the same order, with the same price will have the aggregate quantity added.
§Arguments
symbol- Trading pair symbolfrom_id- Aggregate trade ID to get fromstart_time- Start time in millisecondsend_time- End time in millisecondslimit- Default 500; max 1000
§Example
let client = Binance::new_unauthenticated()?;
let trades = client.market().agg_trades("BTCUSDT", None, None, None, Some(10)).await?;Sourcepub async fn klines(
&self,
symbol: &str,
interval: KlineInterval,
start_time: Option<u64>,
end_time: Option<u64>,
limit: Option<u16>,
) -> Result<Vec<Kline>>
pub async fn klines( &self, symbol: &str, interval: KlineInterval, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Kline>>
Get kline/candlestick data.
§Arguments
symbol- Trading pair symbolinterval- Kline intervalstart_time- Start time in millisecondsend_time- End time in millisecondslimit- Default 500; max 1000
§Example
use binance_api_client::KlineInterval;
let client = Binance::new_unauthenticated()?;
let klines = client.market().klines("BTCUSDT", KlineInterval::Hours1, None, None, Some(10)).await?;
for kline in klines {
println!("Open: {}, Close: {}", kline.open, kline.close);
}Sourcepub async fn ui_klines(
&self,
symbol: &str,
interval: KlineInterval,
start_time: Option<u64>,
end_time: Option<u64>,
limit: Option<u16>,
) -> Result<Vec<Kline>>
pub async fn ui_klines( &self, symbol: &str, interval: KlineInterval, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Kline>>
Get UI optimized kline/candlestick data.
This endpoint mirrors the /api/v3/klines response format.
§Arguments
symbol- Trading pair symbolinterval- Kline intervalstart_time- Start time in millisecondsend_time- End time in millisecondslimit- Default 500; max 1000
§Example
use binance_api_client::KlineInterval;
let client = Binance::new_unauthenticated()?;
let klines = client
.market()
.ui_klines("BTCUSDT", KlineInterval::Hours1, None, None, Some(10))
.await?;Sourcepub async fn avg_price(&self, symbol: &str) -> Result<AveragePrice>
pub async fn avg_price(&self, symbol: &str) -> Result<AveragePrice>
Sourcepub async fn ticker_24h(&self, symbol: &str) -> Result<Ticker24h>
pub async fn ticker_24h(&self, symbol: &str) -> Result<Ticker24h>
Sourcepub async fn ticker_24h_all(&self) -> Result<Vec<Ticker24h>>
pub async fn ticker_24h_all(&self) -> Result<Vec<Ticker24h>>
Sourcepub async fn trading_day_ticker(
&self,
symbol: &str,
time_zone: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<TradingDayTicker>
pub async fn trading_day_ticker( &self, symbol: &str, time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<TradingDayTicker>
Get trading day ticker statistics (FULL).
§Arguments
symbol- Trading pair symboltime_zone- Optional timezone (e.g., “0” or “-1:00”)symbol_status- Optional symbol trading status filter
Sourcepub async fn trading_day_ticker_mini(
&self,
symbol: &str,
time_zone: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<TradingDayTickerMini>
pub async fn trading_day_ticker_mini( &self, symbol: &str, time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<TradingDayTickerMini>
Get trading day ticker statistics (MINI).
Sourcepub async fn trading_day_tickers(
&self,
symbols: &[&str],
time_zone: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<Vec<TradingDayTicker>>
pub async fn trading_day_tickers( &self, symbols: &[&str], time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<TradingDayTicker>>
Get trading day ticker statistics (FULL) for multiple symbols.
Sourcepub async fn trading_day_tickers_mini(
&self,
symbols: &[&str],
time_zone: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<Vec<TradingDayTickerMini>>
pub async fn trading_day_tickers_mini( &self, symbols: &[&str], time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<TradingDayTickerMini>>
Get trading day ticker statistics (MINI) for multiple symbols.
Sourcepub async fn rolling_window_ticker(
&self,
symbol: &str,
window_size: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<RollingWindowTicker>
pub async fn rolling_window_ticker( &self, symbol: &str, window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<RollingWindowTicker>
Get rolling window ticker statistics (FULL).
§Arguments
symbol- Trading pair symbolwindow_size- Optional window size (e.g., “1d”, “15m”)symbol_status- Optional symbol trading status filter
Sourcepub async fn rolling_window_ticker_mini(
&self,
symbol: &str,
window_size: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<RollingWindowTickerMini>
pub async fn rolling_window_ticker_mini( &self, symbol: &str, window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<RollingWindowTickerMini>
Get rolling window ticker statistics (MINI).
Sourcepub async fn rolling_window_tickers(
&self,
symbols: &[&str],
window_size: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<Vec<RollingWindowTicker>>
pub async fn rolling_window_tickers( &self, symbols: &[&str], window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<RollingWindowTicker>>
Get rolling window ticker statistics (FULL) for multiple symbols.
Sourcepub async fn rolling_window_tickers_mini(
&self,
symbols: &[&str],
window_size: Option<&str>,
symbol_status: Option<SymbolStatus>,
) -> Result<Vec<RollingWindowTickerMini>>
pub async fn rolling_window_tickers_mini( &self, symbols: &[&str], window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<RollingWindowTickerMini>>
Get rolling window ticker statistics (MINI) for multiple symbols.
Sourcepub async fn price(&self, symbol: &str) -> Result<TickerPrice>
pub async fn price(&self, symbol: &str) -> Result<TickerPrice>
Sourcepub async fn prices(&self) -> Result<Vec<TickerPrice>>
pub async fn prices(&self) -> Result<Vec<TickerPrice>>
Sourcepub async fn prices_for(&self, symbols: &[&str]) -> Result<Vec<TickerPrice>>
pub async fn prices_for(&self, symbols: &[&str]) -> Result<Vec<TickerPrice>>
Sourcepub async fn book_ticker(&self, symbol: &str) -> Result<BookTicker>
pub async fn book_ticker(&self, symbol: &str) -> Result<BookTicker>
Get best price/qty on the order book for a symbol.
§Arguments
symbol- Trading pair symbol
§Example
let client = Binance::new_unauthenticated()?;
let ticker = client.market().book_ticker("BTCUSDT").await?;
println!("Best bid: {} @ {}", ticker.bid_qty, ticker.bid_price);
println!("Best ask: {} @ {}", ticker.ask_qty, ticker.ask_price);