pub struct MarketService { /* private fields */ }Expand description
Market data service for public endpoints.
Implementations§
Source§impl MarketService
impl MarketService
Sourcepub fn new(http: HttpClient) -> Self
pub fn new(http: HttpClient) -> Self
Create a new market service.
Sourcepub async fn get_server_time(&self) -> Result<ServerTime, BybitError>
pub async fn get_server_time(&self) -> Result<ServerTime, BybitError>
Get server time.
§Example
let client = BybitClient::public_only()?;
let time = client.market().get_server_time().await?;
println!("Server time: {} ms", time.as_millis());Sourcepub async fn get_kline(
&self,
params: &GetKlineParams,
) -> Result<KlineResult, BybitError>
pub async fn get_kline( &self, params: &GetKlineParams, ) -> Result<KlineResult, BybitError>
Get kline/candlestick data.
§Arguments
category- Product category (spot, linear, inverse)symbol- Trading symbol (e.g., “BTCUSDT”)interval- Kline intervalparams- Optional parameters (start, end, limit)
§Example
let client = BybitClient::public_only()?;
let params = GetKlineParams::new(Category::Linear, "BTCUSDT", KlineInterval::Hour1)
.limit(100);
let result = client.market().get_kline(¶ms).await?;
for kline in result.klines() {
println!("{}: O={} H={} L={} C={}",
kline.start_time, kline.open_price, kline.high_price,
kline.low_price, kline.close_price);
}Sourcepub async fn get_mark_price_kline(
&self,
params: &GetKlineParams,
) -> Result<KlineResult, BybitError>
pub async fn get_mark_price_kline( &self, params: &GetKlineParams, ) -> Result<KlineResult, BybitError>
Get mark price kline data.
Sourcepub async fn get_index_price_kline(
&self,
params: &GetKlineParams,
) -> Result<KlineResult, BybitError>
pub async fn get_index_price_kline( &self, params: &GetKlineParams, ) -> Result<KlineResult, BybitError>
Get index price kline data.
Get premium index price kline data.
Sourcepub async fn get_instruments_info(
&self,
params: &GetInstrumentsInfoParams,
) -> Result<InstrumentInfoResult, BybitError>
pub async fn get_instruments_info( &self, params: &GetInstrumentsInfoParams, ) -> Result<InstrumentInfoResult, BybitError>
Get instrument/symbol information.
§Example
let client = BybitClient::public_only()?;
let params = GetInstrumentsInfoParams::new(Category::Linear)
.symbol("BTCUSDT");
let result = client.market().get_instruments_info(¶ms).await?;
for inst in &result.list {
println!("{}: status={}", inst.symbol, inst.status);
}Sourcepub async fn get_orderbook(
&self,
params: &GetOrderbookParams,
) -> Result<Orderbook, BybitError>
pub async fn get_orderbook( &self, params: &GetOrderbookParams, ) -> Result<Orderbook, BybitError>
Get order book depth.
§Arguments
params- Order book parameters
§Example
let client = BybitClient::public_only()?;
let params = GetOrderbookParams::new(Category::Linear, "BTCUSDT")
.limit(25);
let orderbook = client.market().get_orderbook(¶ms).await?;
println!("Best bid: {} @ {}", orderbook.bids[0].size, orderbook.bids[0].price);
println!("Best ask: {} @ {}", orderbook.asks[0].size, orderbook.asks[0].price);Sourcepub async fn get_tickers(
&self,
params: &GetTickersParams,
) -> Result<TickerResult, BybitError>
pub async fn get_tickers( &self, params: &GetTickersParams, ) -> Result<TickerResult, BybitError>
Get tickers for one or all symbols.
§Example
let client = BybitClient::public_only()?;
let params = GetTickersParams::new(Category::Linear)
.symbol("BTCUSDT");
let result = client.market().get_tickers(¶ms).await?;
if let Some(ticker) = result.list.first() {
println!("{}: last={:?}", ticker.symbol, ticker.last_price);
}Sourcepub async fn get_funding_rate_history(
&self,
params: &GetFundingRateHistoryParams,
) -> Result<FundingRateHistoryResult, BybitError>
pub async fn get_funding_rate_history( &self, params: &GetFundingRateHistoryParams, ) -> Result<FundingRateHistoryResult, BybitError>
Get funding rate history.
§Example
let client = BybitClient::public_only()?;
let params = GetFundingRateHistoryParams::new(Category::Linear, "BTCUSDT")
.limit(10);
let result = client.market().get_funding_rate_history(¶ms).await?;
for rate in &result.list {
println!("{}: {}", rate.funding_rate_timestamp, rate.funding_rate);
}Sourcepub async fn get_public_trading_history(
&self,
params: &GetPublicTradingHistoryParams,
) -> Result<PublicTradeResult, BybitError>
pub async fn get_public_trading_history( &self, params: &GetPublicTradingHistoryParams, ) -> Result<PublicTradeResult, BybitError>
Get public trading history (recent trades).
§Example
let client = BybitClient::public_only()?;
let params = GetPublicTradingHistoryParams::new(Category::Linear, "BTCUSDT")
.limit(50);
let result = client.market().get_public_trading_history(¶ms).await?;
for trade in &result.list {
println!("{}: {} {} @ {}", trade.time, trade.side, trade.size, trade.price);
}Sourcepub async fn get_open_interest(
&self,
params: &GetOpenInterestParams,
) -> Result<OpenInterestResult, BybitError>
pub async fn get_open_interest( &self, params: &GetOpenInterestParams, ) -> Result<OpenInterestResult, BybitError>
Get open interest.
Sourcepub async fn get_historical_volatility(
&self,
params: &GetHistoricalVolatilityParams,
) -> Result<Vec<HistoricalVolatility>, BybitError>
pub async fn get_historical_volatility( &self, params: &GetHistoricalVolatilityParams, ) -> Result<Vec<HistoricalVolatility>, BybitError>
Get historical volatility (options only).
Sourcepub async fn get_insurance(
&self,
coin: Option<&str>,
) -> Result<InsuranceResult, BybitError>
pub async fn get_insurance( &self, coin: Option<&str>, ) -> Result<InsuranceResult, BybitError>
Get insurance fund data.
Sourcepub async fn get_risk_limit(
&self,
params: &GetRiskLimitParams,
) -> Result<RiskLimitResult, BybitError>
pub async fn get_risk_limit( &self, params: &GetRiskLimitParams, ) -> Result<RiskLimitResult, BybitError>
Get risk limit information.
Sourcepub async fn get_delivery_price(
&self,
params: &GetDeliveryPriceParams,
) -> Result<DeliveryPriceResult, BybitError>
pub async fn get_delivery_price( &self, params: &GetDeliveryPriceParams, ) -> Result<DeliveryPriceResult, BybitError>
Get delivery price (futures/options).
Sourcepub async fn get_long_short_ratio(
&self,
params: &GetLongShortRatioParams,
) -> Result<LongShortRatioResult, BybitError>
pub async fn get_long_short_ratio( &self, params: &GetLongShortRatioParams, ) -> Result<LongShortRatioResult, BybitError>
Get long/short ratio.
Trait Implementations§
Source§impl Clone for MarketService
impl Clone for MarketService
Source§fn clone(&self) -> MarketService
fn clone(&self) -> MarketService
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for MarketService
impl !RefUnwindSafe for MarketService
impl Send for MarketService
impl Sync for MarketService
impl Unpin for MarketService
impl !UnwindSafe for MarketService
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