pub struct TickerRequest<'a> {
pub category: Category,
pub symbol: Option<Cow<'a, str>>,
pub base_coin: Option<Cow<'a, str>>,
pub exp_date: Option<Cow<'a, str>>,
}Expand description
Parameters for requesting ticker information.
This struct defines the parameters for querying ticker data via the /v5/market/tickers endpoint.
Ticker data includes the latest price snapshot, best bid/ask price, and trading volume in the last 24 hours.
Fields§
§category: CategoryThe product category (e.g., Linear, Inverse, Spot, Option).
Specifies the instrument type. This parameter is required for all ticker requests.
symbol: Option<Cow<'a, str>>The trading pair symbol (e.g., “BTCUSDT”).
Optionally specifies a single trading pair. If unset, the API returns data for all instruments
in the category. For option category, either symbol or base_coin must be provided.
base_coin: Option<Cow<'a, str>>Base coin, uppercase only.
Applies to option category only. When querying options, either symbol or base_coin must be provided.
This parameter is ignored for other categories.
exp_date: Option<Cow<'a, str>>Expiry date for options contracts.
Applies to option category only. Format: e.g., “25DEC22”. Used to filter options by expiry date.
This parameter is ignored for other categories.
Implementations§
Source§impl<'a> TickerRequest<'a>
impl<'a> TickerRequest<'a>
Sourcepub fn default() -> TickerRequest<'a>
pub fn default() -> TickerRequest<'a>
Creates a default Ticker request.
Returns a request with category set to Linear and symbol set to "BTCUSDT".
Suitable for testing but should be customized for production to match specific trading needs.
Sourcepub fn new(
category: Category,
symbol: Option<&'a str>,
base_coin: Option<&'a str>,
exp_date: Option<&'a str>,
) -> TickerRequest<'a>
pub fn new( category: Category, symbol: Option<&'a str>, base_coin: Option<&'a str>, exp_date: Option<&'a str>, ) -> TickerRequest<'a>
Constructs a new Ticker request with specified parameters.
Allows full customization. Bots should use this to tailor requests to their strategy,
ensuring category and symbol align with the instruments being traded.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validates the request parameters according to API constraints.
Returns Ok(()) if the request is valid, or Err(String) with an error message.
Sourcepub fn linear(symbol: Option<&'a str>) -> TickerRequest<'a>
pub fn linear(symbol: Option<&'a str>) -> TickerRequest<'a>
Creates a request for linear perpetual futures.
Convenience method for creating requests for USDT-margined perpetual futures.
Sourcepub fn inverse(symbol: Option<&'a str>) -> TickerRequest<'a>
pub fn inverse(symbol: Option<&'a str>) -> TickerRequest<'a>
Creates a request for inverse perpetual futures.
Convenience method for creating requests for coin-margined perpetual futures.
Sourcepub fn spot(symbol: Option<&'a str>) -> TickerRequest<'a>
pub fn spot(symbol: Option<&'a str>) -> TickerRequest<'a>
Creates a request for spot trading pairs.
Convenience method for creating requests for spot markets.
Sourcepub fn option(
symbol: Option<&'a str>,
base_coin: Option<&'a str>,
exp_date: Option<&'a str>,
) -> TickerRequest<'a>
pub fn option( symbol: Option<&'a str>, base_coin: Option<&'a str>, exp_date: Option<&'a str>, ) -> TickerRequest<'a>
Creates a request for options contracts.
Convenience method for creating requests for options markets.
Sourcepub fn option_by_base_coin(
base_coin: &'a str,
exp_date: Option<&'a str>,
) -> TickerRequest<'a>
pub fn option_by_base_coin( base_coin: &'a str, exp_date: Option<&'a str>, ) -> TickerRequest<'a>
Creates a request for options by base coin.
Convenience method for creating requests for options markets filtered by base coin.
Trait Implementations§
Source§impl<'a> Clone for TickerRequest<'a>
impl<'a> Clone for TickerRequest<'a>
Source§fn clone(&self) -> TickerRequest<'a>
fn clone(&self) -> TickerRequest<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more