pub struct ExchangeClient { /* private fields */ }Expand description
A client that fetches market data from a specific exchange.
All methods return Option and never panic; network or parse errors
are silently mapped to None so callers can retry or fall back.
Implementations§
Source§impl ExchangeClient
impl ExchangeClient
Sourcepub fn fetch_candles(
&self,
symbol: &str,
interval: &str,
limit: usize,
) -> Option<Vec<Candle>>
pub fn fetch_candles( &self, symbol: &str, interval: &str, limit: usize, ) -> Option<Vec<Candle>>
Fetch OHLCV kline candles.
-
Binance –
symbolis a trading pair like"BTCUSDT",intervalis a Binance interval string ("1m","5m","1h","1d", …), andlimitis the number of candles (max 1000). -
CoinGecko –
symbolis the coin id (e.g."bitcoin"),intervalis interpreted as the number of days of history ("1","7","30","365"), andlimitis currently unused (the API decides granularity fromdays).
Sourcepub fn fetch_prices(
&self,
symbol: &str,
interval: &str,
limit: usize,
) -> Option<Vec<Point>>
pub fn fetch_prices( &self, symbol: &str, interval: &str, limit: usize, ) -> Option<Vec<Point>>
Fetch close prices as Points suitable for line charts.
Each point has x = timestamp (seconds) and y = close price.
- Binance – uses klines;
xis the candle open time. - CoinGecko – uses the
market_chartendpoint which returns price samples at varying resolution depending ondays.
Sourcepub fn fetch_spot_price(&self, symbol: &str) -> Option<f64>
pub fn fetch_spot_price(&self, symbol: &str) -> Option<f64>
Fetch the current spot (last traded) price.
- Binance – uses
/api/v3/ticker/price. - CoinGecko – uses
/api/v3/simple/price.
Auto Trait Implementations§
impl Freeze for ExchangeClient
impl RefUnwindSafe for ExchangeClient
impl Send for ExchangeClient
impl Sync for ExchangeClient
impl Unpin for ExchangeClient
impl UnsafeUnpin for ExchangeClient
impl UnwindSafe for ExchangeClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more