diff --git a/README.md b/README.md index da42c42..88409dd 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ Here is a simple program that fetches the next ES mini futures trade: use std::error::Error; use databento::{ - dbn::{Dataset, SType, Schema, TradeMsg}, - live::{Subscription, SymbolMap}, + dbn::{Dataset, PitSymbolMap, SType, Schema, TradeMsg}, + live::Subscription, LiveClient, }; @@ -51,13 +51,13 @@ async fn main() -> Result<(), Box> { .unwrap(); client.start().await?; - let mut symbol_map = SymbolMap::new(); + let mut symbol_map = PitSymbolMap::new(); // Get the next trade loop { let rec = client.next_record().await?.unwrap(); if let Some(trade) = rec.get::() { - let symbol = &symbol_map[trade.hd.instrument_id]; - println!("Received trade for {symbol}: {trade:?}",); + let symbol = &symbol_map[trade]; + println!("Received trade for {symbol}: {trade:?}"); break; } symbol_map.on_record(rec)?; @@ -78,7 +78,7 @@ use databento::{ historical::timeseries::GetRangeParams, HistoricalClient, Symbols, }; -use time::macros::datetime; +use time::macros::{date, datetime}; #[tokio::main] async fn main() -> Result<(), Box> { @@ -97,8 +97,12 @@ async fn main() -> Result<(), Box> { .build(), ) .await?; + let symbol_map = decoder + .metadata() + .symbol_map_for_date(date!(2022 - 06 - 10))?; while let Some(trade) = decoder.decode_record::().await? { - println!("{trade:?}"); + let symbol = &symbol_map[trade]; + println!("Received trade for {symbol}: {trade:?}"); } Ok(()) } diff --git a/tests/historical-example.rs b/tests/historical-example.rs index d3b6c85..1af9f56 100644 --- a/tests/historical-example.rs +++ b/tests/historical-example.rs @@ -6,7 +6,7 @@ use databento::{ historical::timeseries::GetRangeParams, HistoricalClient, Symbols, }; -use time::macros::datetime; +use time::macros::{date, datetime}; #[tokio::main] async fn main() -> Result<(), Box> { @@ -25,8 +25,12 @@ async fn main() -> Result<(), Box> { .build(), ) .await?; + let symbol_map = decoder + .metadata() + .symbol_map_for_date(date!(2022 - 06 - 10))?; while let Some(trade) = decoder.decode_record::().await? { - println!("{trade:?}"); + let symbol = &symbol_map[trade]; + println!("Received trade for {symbol}: {trade:?}"); } Ok(()) } diff --git a/tests/live-example.rs b/tests/live-example.rs index ec59c85..1b222ba 100644 --- a/tests/live-example.rs +++ b/tests/live-example.rs @@ -2,8 +2,8 @@ use std::error::Error; use databento::{ - dbn::{Dataset, SType, Schema, TradeMsg}, - live::{Subscription, SymbolMap}, + dbn::{Dataset, PitSymbolMap, SType, Schema, TradeMsg}, + live::Subscription, LiveClient, }; @@ -26,13 +26,13 @@ async fn main() -> Result<(), Box> { .unwrap(); client.start().await?; - let mut symbol_map = SymbolMap::new(); + let mut symbol_map = PitSymbolMap::new(); // Get the next trade loop { let rec = client.next_record().await?.unwrap(); if let Some(trade) = rec.get::() { - let symbol = &symbol_map[trade.hd.instrument_id]; - println!("Received trade for {symbol}: {trade:?}",); + let symbol = &symbol_map[trade]; + println!("Received trade for {symbol}: {trade:?}"); break; } symbol_map.on_record(rec)?;