Skip to content

Commit

Permalink
crypto support and convenience constructor function (#112)
Browse files Browse the repository at this point in the history
Adds support for crypto
  • Loading branch information
richard-fairthorne committed May 21, 2024
1 parent dec0a18 commit 876af7e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pub enum SecurityType {
News,
/// Mutual fund
MutualFund,
/// Crypto currency
Crypto
}

impl ToField for SecurityType {
Expand Down Expand Up @@ -77,6 +79,7 @@ impl ToString for SecurityType {
SecurityType::Commodity => "CMDTY".to_string(),
SecurityType::News => "NEWS".to_string(),
SecurityType::MutualFund => "FUND".to_string(),
SecurityType::Crypto => "CRYPTO".to_string(),
}
}
}
Expand All @@ -96,7 +99,8 @@ impl SecurityType {
"CMDTY" => SecurityType::Commodity,
"NEWS" => SecurityType::News,
"FUND" => SecurityType::MutualFund,
&_ => todo!(),
"CRYPTO" => SecurityType::Crypto,
unsupported => todo!("Unimplemented security type: {unsupported}"),
}
}
}
Expand Down Expand Up @@ -169,6 +173,17 @@ impl Contract {
}
}

/// Creates Crypto contract from specified symbol
pub fn crypto(symbol: &str) -> Contract {
Contract {
symbol: symbol.to_string(),
security_type: SecurityType::Crypto,
currency: "USD".to_string(),
exchange: "PAXOS".to_string(),
..Default::default()
}
}

/// Is Bag request
pub fn is_bag(&self) -> bool {
self.security_type == SecurityType::Spread
Expand Down

0 comments on commit 876af7e

Please sign in to comment.