From ce1680e0a75bfd71c308e97c3d361a80ec8f93a3 Mon Sep 17 00:00:00 2001 From: Wil Boayue Date: Fri, 15 Nov 2024 17:43:42 -0800 Subject: [PATCH] labeled release. added validation (#182) --- Cargo.toml | 2 +- README.md | 15 ++------------- src/errors.rs | 2 ++ src/market_data/historical.rs | 4 ++++ 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 77707026..750b4284 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ibapi" -version = "1.0.2" +version = "1.0.3" edition = "2021" authors = ["Wil Boayue "] description = "A Rust implementation of the Interactive Brokers TWS API, providing a reliable and user friendly interface for TWS and IB Gateway. Designed with a focus on simplicity and performance." diff --git a/README.md b/README.md index 75b480e2..b4bd23c7 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,7 @@ The [Client documentation](https://docs.rs/ibapi/latest/ibapi/struct.Client.html ## Install -Run the following Cargo command in your project directory: - -```bash -cargo add ibapi -``` - -Or add the following line to your `Cargo.toml`: - -```toml -ibapi = "1.0.0" -``` -> **Note**: Check [crates.io/crates/ibapi](https://crates.io/crates/ibapi) for the latest available version. +Check [crates.io/crates/ibapi](https://crates.io/crates/ibapi) for the latest available version and installation instructions. ## Examples @@ -245,7 +234,7 @@ fn main() { }); handles.push(handle); } - + handles.into_iter().for_each(|handle| handle.join().unwrap()); } ``` diff --git a/src/errors.rs b/src/errors.rs index 1a22729e..09be7056 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -17,6 +17,7 @@ pub enum Error { Parse(usize, String, String), ServerVersion(i32, i32, String), Simple(String), + InvalidArgument(String), ConnectionFailed, ConnectionReset, Cancelled, @@ -49,6 +50,7 @@ impl std::fmt::Display for Error { Error::UnexpectedEndOfStream => write!(f, "UnexpectedEndOfStream"), Error::Simple(ref err) => write!(f, "error occurred: {err}"), + Error::InvalidArgument(ref err) => write!(f, "InvalidArgument: {err}"), } } } diff --git a/src/market_data/historical.rs b/src/market_data/historical.rs index ba3c6cda..3fcd9751 100644 --- a/src/market_data/historical.rs +++ b/src/market_data/historical.rs @@ -341,6 +341,10 @@ pub(crate) fn historical_data( )?; } + if end_date.is_some() && what_to_show == Some(WhatToShow::AdjustedLast) { + return Err(Error::InvalidArgument("end_date must be None when requesting WhatToShow::AdjustedLast. You might have called Client::historical_data with WhatToShow::AdjustedLast".into())); + } + loop { let request_id = client.next_request_id(); let request = encoders::encode_request_historical_data(