-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathasync_ohlcv.rs
More file actions
34 lines (28 loc) · 1.14 KB
/
async_ohlcv.rs
File metadata and controls
34 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use optionstratlib::prelude::setup_logger;
use optionstratlib::utils::read_ohlcv_from_zip_async;
use std::error::Error;
use tracing::{error, info};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
setup_logger();
info!("--- Async OHLCV Reading ---");
let zip_path = "../../examples/Data/cl-1m-sample.zip"; // Path relative to the example run dir
info!("Reading OHLCV data from {} asynchronously...", zip_path);
// We'll read without date filters first
let result: Result<Vec<optionstratlib::utils::OhlcvCandle>, optionstratlib::error::OhlcvError> =
read_ohlcv_from_zip_async(zip_path.to_string(), None, None).await;
match result {
Ok(candles) => {
info!("Successfully read {} candles.", candles.len());
if let Some(first) = candles.first() {
info!("First candle: Date={}, Close={}", first.date, first.close);
}
}
Err(e) => {
error!("Error reading OHLCV: {}", e);
// Don't fail the example if file is not found, just report it
}
}
info!("--- Async OHLCV Reading Completed ---");
Ok(())
}