-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,158 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use ibapi::{contracts::Contract, market_data::realtime::TickTypes, Client}; | ||
|
||
// This example demonstrates how to request realtime market data for a contract. | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed"); | ||
|
||
let contract = Contract::stock("AAPL"); | ||
let generic_ticks = &[]; | ||
let snapshot = false; | ||
let regulatory_snapshot = false; | ||
|
||
let subscription = client | ||
.market_data(&contract, generic_ticks, snapshot, regulatory_snapshot) | ||
.expect("error requesting market data"); | ||
|
||
for tick in &subscription { | ||
println!("{tick:?}"); | ||
|
||
if let TickTypes::SnapshotEnd = tick { | ||
subscription.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use ibapi::contracts::Contract; | ||
use ibapi::Client; | ||
|
||
// This example demonstrates how to request market depth data. | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed"); | ||
|
||
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:?}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use ibapi::Client; | ||
|
||
// This example demonstrates how to request market depth exchanges. | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let client = Client::connect("127.0.0.1:4002", 100).expect("connection failed"); | ||
|
||
let exchanges = client.market_depth_exchanges().expect("error requesting market depth exchanges"); | ||
|
||
for exchange in &exchanges { | ||
println!("{exchange:?}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ fn main() { | |
.version("1.0") | ||
.author("Wil Boayue <[email protected]") | ||
.about("Streams tick by tick data") | ||
.arg(arg!(--connection_string <VALUE>).default_value("localhost:4002")) | ||
.arg(arg!(--connection_string <VALUE>).default_value("127.0.0.1:4002")) | ||
.arg(arg!(--last <SYMBOL>)) | ||
.arg(arg!(--all_last <SYMBOL>)) | ||
.arg(arg!(--bid_ask <SYMBOL>)) | ||
|
@@ -46,7 +46,7 @@ fn stream_last(client: &mut Client, _symbol: &str) -> anyhow::Result<()> { | |
let contract = contract_gc(); | ||
let ticks = client.tick_by_tick_last(&contract, 0, false)?; | ||
|
||
for (i, tick) in ticks.enumerate() { | ||
for (i, tick) in ticks.iter().enumerate() { | ||
println!("{}: {i:?} {tick:?}", contract.symbol); | ||
} | ||
|
||
|
@@ -80,7 +80,7 @@ fn stream_all_last(client: &Client, _symbol: &str) -> anyhow::Result<()> { | |
let contract = contract_es(); | ||
let ticks = client.tick_by_tick_all_last(&contract, 0, false)?; | ||
|
||
for (i, tick) in ticks.enumerate().take(60) { | ||
for (i, tick) in ticks.iter().enumerate().take(60) { | ||
println!("tick: {i:?} {tick:?}"); | ||
} | ||
|
||
|
@@ -91,7 +91,7 @@ fn stream_bid_ask(client: &mut Client, _symbol: &str) -> anyhow::Result<()> { | |
let contract = contract_es(); | ||
let ticks = client.tick_by_tick_bid_ask(&contract, 0, false)?; | ||
|
||
for (i, tick) in ticks.enumerate() { | ||
for (i, tick) in ticks.iter().enumerate() { | ||
println!("tick: {i:?} {tick:?}"); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.