Basic order struct laid out | No interfaces/methods

master
Griffiths Lott 3 years ago
parent a7079454a2
commit 1ae5eb25db
  1. 4
      .gitignore
  2. 8
      src/data.rs
  3. 1
      src/lib.rs
  4. 47
      src/order.rs

4
.gitignore vendored

@ -1,3 +1,5 @@
/target
/Cargo.lock
to-do.txt
to-do.txt
*.png
*.pdf

@ -2,4 +2,10 @@ mod equity;
mod crypto;
mod options;
mod price_history;
mod data_service;
mod data_service;
pub enum AssetDataObject {
Equity(equity::Equity),
Crypro(crypto::Crypto),
OptionContract(options::OptionContract),
}

@ -1,4 +1,5 @@
mod data;
mod order;
pub type DynResult<T> = Result<T, Box< dyn std::error::Error>>;

@ -0,0 +1,47 @@
use crate::data::AssetDataObject;
pub enum Direction {
Buy,
Sell
}
impl ToString for Direction {
fn to_string(&self) -> String {
match &self {
Self::Buy => "Buy".to_string(),
Self::Sell => "Sell".to_string()
}
}
}
pub enum OrderType {
Market,
Limit,
Stop,
TrailingStop
}
impl ToString for OrderType {
fn to_string(&self) -> String {
match &self {
Self::Market => "Market".to_string(),
Self::Limit => "Limit".to_string(),
Self::Stop => "Stop".to_string(),
Self::TrailingStop => "TrailingStop".to_string()
}
}
}
pub struct SimpleOrder {
pub asset: AssetDataObject,
pub price_to_pay: f64,
pub direction: Direction,
pub order_type: OrderType,
pub good_until: i64,
pub approved: bool
}
pub struct CompoundOrder {
pub orders: Vec<SimpleOrder>,
pub approved: bool
}
Loading…
Cancel
Save