Skip to content

Commit

Permalink
update doc for market_depth (#222)
Browse files Browse the repository at this point in the history
Co-authored-by: Wil Boayue <[email protected]>
  • Loading branch information
wboayue and Wil Boayue authored Feb 13, 2025
1 parent 6db91e8 commit c8e0eb5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ibapi"
version = "1.0.15"
version = "1.0.16"
edition = "2021"
authors = ["Wil Boayue <[email protected]>"]
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."
Expand Down
14 changes: 11 additions & 3 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,13 +1188,21 @@ impl Client {
///
/// ```no_run
/// use ibapi::Client;
/// use ibapi::contracts::Contract;
/// use ibapi::market_data::{MarketDataType};
///
/// let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed");
///
/// let market_data_type = MarketDataType::Live;
/// client.switch_market_data_type(market_data_type).expect("request failed");
/// println!("market data switched: {:?}", market_data_type);
/// let contract = Contract::stock("AAPL");
///
/// let subscription = client.market_depth(&contract, 5, true).expect("error requesting market depth");
/// for row in &subscription {
/// println!("row: {row:?}");
/// }
///
/// if let Some(error) = subscription.error() {
/// println!("error: {:?}", error);
/// }
/// ```
pub fn market_depth<'a>(
&'a self,
Expand Down
6 changes: 4 additions & 2 deletions src/client/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use crate::{stubs::MessageBusStub, transport::ConnectionMetadata};

use super::Client;


#[test]
fn test_client_id() {
let client_id = 500;
let connection_metadata = ConnectionMetadata{client_id, ..ConnectionMetadata::default()};
let connection_metadata = ConnectionMetadata {
client_id,
..ConnectionMetadata::default()
};
let message_bus = Arc::new(MessageBusStub::default());

let client = Client::new(connection_metadata, message_bus).unwrap();
Expand Down

0 comments on commit c8e0eb5

Please sign in to comment.