use chrono::NaiveDateTime;
use serde::{
Deserialize,
Serialize,
};
use crate::deserialization::{
option_iso_date_time,
option_string_as_float,
string_as_float,
};
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
pub struct Product {
pub id: String,
pub base_currency: String,
pub quote_currency: String,
#[serde(with = "string_as_float")]
pub base_min_size: f64,
#[serde(with = "string_as_float")]
pub base_max_size: f64,
#[serde(with = "string_as_float")]
pub quote_increment: f64,
#[serde(with = "string_as_float")]
pub base_increment: f64,
pub display_name: String,
#[serde(with = "string_as_float")]
pub min_market_funds: f64,
#[serde(with = "string_as_float")]
pub max_market_funds: f64,
pub margin_enabled: bool,
pub post_only: bool,
pub limit_only: bool,
pub cancel_only: bool,
pub status: String,
pub status_message: String,
pub trading_disabled: Option<bool>,
pub fx_stablecoin: Option<bool>,
#[serde(with = "option_string_as_float")]
pub max_slippage_percentage: Option<f64>,
pub auction_mode: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
pub struct ProductBook {
pub bids: Vec<Orders>,
pub asks: Vec<Orders>,
pub sequence: f64,
pub auction_mode: Option<bool>,
pub auction: Option<Auction>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Currency {
pub id: String,
pub name: String,
pub min_size: String,
pub status: String,
pub message: String,
pub max_precision: String,
pub convertible_to: Vec<String>,
pub details: CurrencyDetails,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
pub struct CurrencyDetails {
#[serde(rename = "type")]
pub type_string: Option<String>,
pub symbol: Option<String>,
pub network_confirmations: Option<i32>,
pub sort_order: Option<i32>,
pub crypto_address_link: Option<String>,
pub crypto_transaction_link: Option<String>,
pub push_payment_methods: Vec<String>,
pub group_types: Vec<String>,
pub display_name: Option<String>,
pub processing_time_seconds: Option<f64>,
pub min_withdrawal_amount: Option<f64>,
pub max_withdrawal_amount: Option<f64>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Orders {
#[serde(with = "string_as_float")]
pub price: f64,
#[serde(with = "string_as_float")]
pub size: f64,
pub num_orders: i64,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(default)]
pub struct Auction {
#[serde(with = "string_as_float")]
pub open_price: f64,
#[serde(with = "string_as_float")]
pub open_size: f64,
#[serde(with = "string_as_float")]
pub best_bid_price: f64,
#[serde(with = "string_as_float")]
pub best_bid_size: f64,
#[serde(with = "string_as_float")]
pub best_ask_price: f64,
#[serde(with = "string_as_float")]
pub best_ask_size: f64,
#[serde(with = "string_as_float")]
pub auction_state: f64,
pub can_open: Option<String>,
#[serde(with = "option_iso_date_time")]
pub time: Option<NaiveDateTime>,
}