pub struct Ticker {Show 20 fields
pub symbol: String,
pub timestamp: i64,
pub datetime: Option<String>,
pub high: Option<Price>,
pub low: Option<Price>,
pub bid: Option<Price>,
pub bid_volume: Option<Amount>,
pub ask: Option<Price>,
pub ask_volume: Option<Amount>,
pub vwap: Option<Price>,
pub open: Option<Price>,
pub close: Option<Price>,
pub last: Option<Price>,
pub previous_close: Option<Price>,
pub change: Option<Price>,
pub percentage: Option<Decimal>,
pub average: Option<Price>,
pub base_volume: Option<Amount>,
pub quote_volume: Option<Amount>,
pub info: HashMap<String, Value>,
}Expand description
Ticker data structure
Fields§
§symbol: StringExchange symbol
timestamp: i64Timestamp in milliseconds
datetime: Option<String>ISO8601 datetime string
high: Option<Price>Highest price in 24h
low: Option<Price>Lowest price in 24h
bid: Option<Price>Current best bid price
bid_volume: Option<Amount>Current best bid amount
ask: Option<Price>Current best ask price
ask_volume: Option<Amount>Current best ask amount
vwap: Option<Price>Volume-weighted average price
open: Option<Price>Opening price
close: Option<Price>Closing price (current price)
last: Option<Price>Last traded price
previous_close: Option<Price>Last traded price before current last
change: Option<Price>Absolute change (last - open)
percentage: Option<Decimal>Relative change ((last - open) / open)
average: Option<Price>Average price (high + low) / 2
base_volume: Option<Amount>Base volume traded in 24h
quote_volume: Option<Amount>Quote volume traded in 24h
info: HashMap<String, Value>Raw exchange info
Implementations§
Source§impl Ticker
impl Ticker
Sourcepub fn new(symbol: String, timestamp: i64) -> Ticker
pub fn new(symbol: String, timestamp: i64) -> Ticker
Creates a new ticker with required fields.
§Arguments
symbol- Trading pair symboltimestamp- Ticker timestamp in milliseconds
Sourcepub fn spread(&self) -> Option<Price>
pub fn spread(&self) -> Option<Price>
Calculates the bid-ask spread.
§Returns
Returns Some(Price) if both bid and ask are available, otherwise None.
Sourcepub fn spread_percentage(&self) -> Option<Decimal>
pub fn spread_percentage(&self) -> Option<Decimal>
Calculates the spread as a percentage of the bid price.
§Returns
Returns the spread percentage if both bid and ask are available and bid > 0.