1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use derive_more::Display;
use futures::stream::BoxStream;
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use crate::{ExchangeError, Request};
pub type TradeStream = BoxStream<'static, Result<Trade, ExchangeError>>;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, Display)]
#[display(fmt = "ts={ts} ({price}, {size}, {buy})")]
pub struct Trade {
#[serde(with = "time::serde::rfc3339")]
pub ts: OffsetDateTime,
pub price: Decimal,
pub size: Decimal,
pub buy: bool,
}
#[derive(Debug, Clone)]
pub struct SubscribeTrades {
pub instrument: String,
}
impl Request for SubscribeTrades {
type Response = TradeStream;
}