use chrono::NaiveDateTime;
use getset::{CopyGetters, Getters};
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize, CopyGetters, Getters)]
#[serde(rename_all = "PascalCase")]
pub struct MarketInfo {
#[get = "pub"]
market_currency: String,
#[get = "pub"]
base_currency: String,
#[get = "pub"]
market_currency_long: String,
#[get = "pub"]
base_currency_long: String,
#[get_copy = "pub"]
min_trade_size: f64,
#[get = "pub"]
market_name: String,
#[get_copy = "pub"]
is_active: bool,
#[get_copy = "pub"]
created: NaiveDateTime,
#[get = "pub"]
notice: Option<String>,
#[get_copy = "pub"]
is_sponsored: Option<bool>,
#[get = "pub"]
logo_url: Option<String>,
}
#[derive(Debug, Clone, Deserialize, Getters, CopyGetters)]
#[serde(rename_all = "PascalCase")]
pub struct CurrencyInfo {
#[get = "pub"]
currency: String,
#[get = "pub"]
currency_long: String,
#[get_copy = "pub"]
min_confirmation: u32,
#[get_copy = "pub"]
tx_fee: f32,
#[get_copy = "pub"]
is_active: bool,
#[get = "pub"]
coin_type: String,
#[get = "pub"]
base_address: Option<String>,
#[get = "pub"]
notice: Option<String>,
}
#[derive(Debug, Copy, Clone, Deserialize, CopyGetters)]
#[serde(rename_all = "PascalCase")]
pub struct TickerInfo {
#[get_copy = "pub"]
bid: f32,
#[get_copy = "pub"]
ask: f32,
#[get_copy = "pub"]
last: f32,
}
#[derive(Debug, Clone, Deserialize, CopyGetters, Getters)]
#[serde(rename_all = "PascalCase")]
pub struct MarketSummary {
#[get = "pub"]
market_name: String,
#[get_copy = "pub"]
high: Option<f32>,
#[get_copy = "pub"]
low: Option<f32>,
#[get_copy = "pub"]
last: Option<f32>,
#[get_copy = "pub"]
bid: Option<f32>,
#[get_copy = "pub"]
ask: Option<f32>,
#[get_copy = "pub"]
volume: Option<f32>,
#[get_copy = "pub"]
base_volume: Option<f32>,
#[get_copy = "pub"]
time_stamp: NaiveDateTime,
#[get_copy = "pub"]
open_buy_orders: Option<u32>,
#[get_copy = "pub"]
open_sell_orders: Option<u32>,
#[get_copy = "pub"]
prev_day: Option<f32>,
#[get_copy = "pub"]
created: NaiveDateTime,
#[get = "pub"]
display_market_name: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OrderBook {
buy: Box<[Order]>,
sell: Box<[Order]>,
}
impl OrderBook {
pub(crate) fn new<B, S>(buy: B, sell: S) -> Self
where
B: Into<Box<[Order]>>,
S: Into<Box<[Order]>>,
{
Self {
buy: buy.into(),
sell: sell.into(),
}
}
pub fn buy(&self) -> &[Order] {
&self.buy
}
pub fn sell(&self) -> &[Order] {
&self.sell
}
}
#[derive(Debug, Copy, Clone, Deserialize, CopyGetters)]
#[serde(rename_all = "PascalCase")]
pub struct Order {
#[get_copy = "pub"]
quantity: f32,
#[get_copy = "pub"]
rate: f32,
}
#[derive(Debug, Clone, Deserialize, CopyGetters, Getters)]
#[serde(rename_all = "PascalCase")]
pub struct BalanceInfo {
#[get = "pub"]
currency: String,
#[get_copy = "pub"]
balance: f32,
#[get_copy = "pub"]
available: f32,
#[get_copy = "pub"]
pending: f32,
#[get = "pub"]
crypto_address: Option<String>,
#[get_copy = "pub"]
requested: Option<bool>,
#[get = "pub"]
uuid: Option<String>,
}