From 1ae5eb25dbc233f8195536b5a42084bfb9246ca3 Mon Sep 17 00:00:00 2001 From: Griffiths Lott Date: Wed, 30 Nov 2022 18:42:22 -0500 Subject: [PATCH] Basic order struct laid out | No interfaces/methods --- .gitignore | 4 +++- src/data.rs | 8 +++++++- src/lib.rs | 1 + src/order.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 src/order.rs diff --git a/.gitignore b/.gitignore index 17614f4..5b341bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target /Cargo.lock -to-do.txt \ No newline at end of file +to-do.txt +*.png +*.pdf \ No newline at end of file diff --git a/src/data.rs b/src/data.rs index 26712dc..3ed7675 100644 --- a/src/data.rs +++ b/src/data.rs @@ -2,4 +2,10 @@ mod equity; mod crypto; mod options; mod price_history; -mod data_service; \ No newline at end of file +mod data_service; + +pub enum AssetDataObject { + Equity(equity::Equity), + Crypro(crypto::Crypto), + OptionContract(options::OptionContract), +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 8bcc6f0..eee7e66 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ mod data; +mod order; pub type DynResult = Result>; diff --git a/src/order.rs b/src/order.rs new file mode 100644 index 0000000..ce75df1 --- /dev/null +++ b/src/order.rs @@ -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, + pub approved: bool + +} \ No newline at end of file