diff --git a/README.md b/README.md index 3cbd40f..c28e59f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ All in one trading engine ### Paper trading & live trading - [x] Single live broker: IBKR - [x] Live trading with single broker +- [ ] Async ## Demo ```shell diff --git a/src/cmds/paper.rs b/src/cmds/paper.rs index 7bf3645..f07654a 100644 --- a/src/cmds/paper.rs +++ b/src/cmds/paper.rs @@ -78,9 +78,9 @@ async fn paper_trading(){ let contract = Contract { - symbol: "JPY".to_owned(), + symbol: "USD".to_owned(), security_type: SecurityType::ForexPair, - currency: "USD".to_owned(), + currency: "JPY".to_owned(), exchange: "IDEALPRO".to_owned(), ..Default::default() }; diff --git a/src/green/green.rs b/src/green/green.rs index 0def58c..64aefc4 100644 --- a/src/green/green.rs +++ b/src/green/green.rs @@ -57,6 +57,9 @@ impl Green { } pub fn run(&mut self) { log::info!("Running {:?}...", self.strategy); + + //! .iter() : borrows the ownership + //! .into_iter(): transfers the ownership for bar in self.data.iter() { let order = self.strategy.next(bar); let cash = self.broker.cash.last().unwrap(); @@ -105,7 +108,7 @@ impl Green { type HistoricalData = (String, Vec); impl GreenBuilder{ - pub fn add_data_feed(&mut self, symbol: Box) -> &mut GreenBuilder{ + pub fn add_data_feed(&mut self, symbol: &str) -> &mut GreenBuilder{ let file = File::open(format!("data/{symbol}.csv")).unwrap(); let mut reader = csv::ReaderBuilder::new() @@ -115,6 +118,8 @@ impl GreenBuilder{ let mut finance_data = vec![]; for result in reader.deserialize() { let record: HistoricalData = result.unwrap(); + // use record.1[2] rather than record.1.get(2) + // to get higher performance let low = record.1[2]; let open = record.1[0]; let close = record.1[3];