Skip to content

Commit

Permalink
update example (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
wboayue authored Nov 5, 2024
1 parent 2172e5c commit 16ee567
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "ibapi"
version = "0.5.0"
version = "1.0.0"
edition = "2021"
authors = ["Wil Boayue <[email protected]>"]
description = "Unofficial Rust implementation of the Interactive Brokers TWS API, providing a reliable and ergonomic interface for TWS and IB Gateway. Designed with a focus on simplicity, ensuring smooth integration into trading systems."
description = "Unofficial 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, ensuring smooth integration into trading systems."
readme = "README.md"
homepage = "https://github.com/wboayue/rust-ibapi/"
repository = "https://github.com/wboayue/rust-ibapi/"
Expand Down
19 changes: 14 additions & 5 deletions examples/market_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ fn main() {
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed");

let contract = Contract::stock("AAPL");
let generic_ticks = &[];

// https://www.interactivebrokers.com/campus/ibkr-api-page/twsapi-doc/#available-tick-types
let generic_ticks = &["233", "293"];
let snapshot = false;
let regulatory_snapshot = false;

Expand All @@ -17,10 +19,17 @@ fn main() {
.expect("error requesting market data");

for tick in &subscription {
println!("{tick:?}");

if let TickTypes::SnapshotEnd = tick {
subscription.cancel();
match tick {
TickTypes::Price(tick_price) => println!("{:?}", tick_price),
TickTypes::Size(tick_size) => println!("size: {:?}", tick_size),
TickTypes::PriceSize(tick_price_size) => println!("{:?}", tick_price_size),
TickTypes::Generic(tick_generic) => println!("{:?}", tick_generic),
TickTypes::String(tick_string) => println!("{:?}", tick_string),
TickTypes::EFP(tick_efp) => println!("{:?}", tick_efp),
TickTypes::OptionComputation(option_computation) => println!("{:?}", option_computation),
TickTypes::RequestParameters(tick_request_parameters) => println!("{:?}", tick_request_parameters),
TickTypes::SnapshotEnd => subscription.cancel(),
TickTypes::Notice(notice) => println!("{:?}", notice),
}
}
}

0 comments on commit 16ee567

Please sign in to comment.