Closed rise0chen closed 5 months ago
It is fine for me to just add another kind of "Ticker".
Like this?
pub struct Ticker {
/// Timestamp.
#[serde(with = "time::serde::rfc3339")]
pub ts: OffsetDateTime,
/// Last traded price.
pub last: Decimal,
/// Last traded size.
#[serde(default)]
pub size: Decimal,
/// Last traded side.
#[serde(default)]
pub buy: Option<bool>,
/// Current best bid.
#[serde(default)]
pub bid: Option<Decimal>,
/// The size of current best bid.
#[serde(default)]
pub bid_size: Option<Decimal>,
/// Current best ask.
#[serde(default)]
pub ask: Option<Decimal>,
/// The size of current best ask.
#[serde(default)]
pub ask_size: Option<Decimal>,
}
pub struct Statistics {
/// Timestamp.
#[serde(with = "time::serde::rfc3339")]
pub ts: OffsetDateTime,
/// Last traded price.
pub close: Decimal,
/// Open price in the past 24 hours
#[serde(default)]
pub open: Decimal,
/// Highest price in the past 24 hours
#[serde(default)]
pub high: Decimal,
/// Lowest price in the past 24 hours
#[serde(default)]
pub low: Decimal,
/// 24h trading volume.
#[serde(default)]
pub vol: Decimal,
}
Yes, I think that would be better.
let mut sub_ticker = self.ticker.subscribe_tickers(&self.inst).await?;
let mut sub_statistic = self.statistic.subscribe_statistics(&self.inst).await?;
sub_ticker will close, when subscribe_statistics, on okx.
let mut sub_ticker = self.ticker.subscribe_tickers(&self.inst).await?; let mut sub_statistic = self.statistic.subscribe_statistics(&self.inst).await?;
sub_ticker will close, when subscribe_statistics, on okx.
Thank you for your work, I will check.
let mut sub_ticker = self.ticker.subscribe_tickers(&self.inst).await?; let mut sub_statistic = self.statistic.subscribe_statistics(&self.inst).await?;
sub_ticker will close, when subscribe_statistics, on okx.
I can't reproduce. It just returned the "already subscribed" error as expected.
I can't reproduce. It just returned the "already subscribed" error as expected.
I can't reproduce, too. subscribe_statistics
returned the "already subscribed" error, and sub_ticker
not close.
Closing this PR as it's stale, but feel free to reopen it at any time.
Why not just add
MiniTicker
for the 24-hour statistics and keepTicker
as it is now? Since we can calculate the 24-hour statistics just by usinglast
.