MCPcopy Create free account
hub / github.com/Open-Quant/openquant / load_dollar_bars

Function load_dollar_bars

crates/openquant/tests/microstructural_features.rs:11–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9use std::path::Path;
10
11fn load_dollar_bars() -> (Vec<f64>, Vec<f64>, Vec<f64>, Vec<f64>, Vec<f64>) {
12 let path = Path::new(env!("CARGO_MANIFEST_DIR"))
13 .join("../../tests/fixtures/microstructural_features/dollar_bar_sample.csv");
14 let mut rdr = ReaderBuilder::new().has_headers(true).from_path(path).unwrap();
15 let mut close = Vec::new();
16 let mut high = Vec::new();
17 let mut low = Vec::new();
18 let mut cum_dollar = Vec::new();
19 let mut cum_vol = Vec::new();
20 for rec in rdr.records() {
21 let rec = rec.unwrap();
22 close.push(rec[4].parse::<f64>().unwrap());
23 high.push(rec[2].parse::<f64>().unwrap());
24 low.push(rec[3].parse::<f64>().unwrap());
25 cum_dollar.push(rec[6].parse::<f64>().unwrap());
26 cum_vol.push(rec[5].parse::<f64>().unwrap());
27 }
28 (close, high, low, cum_dollar, cum_vol)
29}
30
31#[test]
32fn test_second_generation_intra_bar() {

Calls

no outgoing calls

Tested by

no test coverage detected