use time::OffsetDateTime;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TradeableInstrument {
#[serde(with = "time::serde::rfc3339")]
pub added_on: time::OffsetDateTime,
pub currency_code: String,
pub isin: String,
pub max_open_quantity: f64,
pub min_trade_quantity: f64,
pub name: String,
pub short_name: String,
pub ticker: String,
#[serde(rename = "type")]
pub r#type: Type,
pub working_schedule_id: i64,
}
impl TradeableInstrument {
#[must_use]
pub const fn new() -> Self {
Self {
added_on: OffsetDateTime::UNIX_EPOCH,
currency_code: String::new(),
isin: String::new(),
max_open_quantity: 0.0,
min_trade_quantity: 0.0,
name: String::new(),
short_name: String::new(),
ticker: String::new(),
r#type: Type::Unknown,
working_schedule_id: 0,
}
}
}
impl Default for TradeableInstrument {
fn default() -> Self {
Self::new()
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "CRYPTOCURRENCY")]
Cryptocurrency,
#[serde(rename = "ETF")]
Etf,
#[serde(rename = "FOREX")]
Forex,
#[serde(rename = "FUTURES")]
Futures,
#[serde(rename = "INDEX")]
Index,
#[serde(rename = "STOCK")]
Stock,
#[serde(rename = "WARRANT")]
Warrant,
#[serde(rename = "CRYPTO")]
Crypto,
#[serde(rename = "CVR")]
Cvr,
#[serde(rename = "CORPACT")]
Corpact,
#[serde(other)]
Unknown,
}
impl Default for Type {
fn default() -> Self {
Self::Cryptocurrency
}
}