df_hyperliquid_core/live/
market.rs1use crate::markets::Level;
7use crate::utils::Dec;
8use serde::Deserialize;
9
10#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
13#[serde(from = "RawBbo")]
14pub struct Bbo {
15 pub coin: String,
16 pub time: u64,
18 pub bid: Option<Level>,
19 pub ask: Option<Level>,
20}
21
22#[derive(Deserialize)]
23struct RawBbo {
24 coin: String,
25 time: u64,
26 bbo: (Option<Level>, Option<Level>),
27}
28
29impl From<RawBbo> for Bbo {
30 fn from(raw: RawBbo) -> Self {
31 let (bid, ask) = raw.bbo;
32 Bbo { coin: raw.coin, time: raw.time, bid, ask }
33 }
34}
35
36#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
39pub struct Mids {
40 #[serde(default)]
41 pub dex: String,
42 pub mids: crate::markets::mids::Mids,
44}
45
46impl Mids {
47 #[must_use]
49 pub fn get(&self, coin: &str) -> Option<Dec> {
50 self.mids.get(coin)
51 }
52}
53
54#[cfg(test)]
55#[path = "tests/market.rs"]
56mod tests;