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

Function build_trades

crates/pyopenquant/src/helpers.rs:95–117  ·  view source on GitHub ↗
(
    timestamps: Vec<String>,
    prices: Vec<f64>,
    volumes: Vec<f64>,
)

Source from the content-addressed store, hash-verified

93}
94
95pub fn build_trades(
96 timestamps: Vec<String>,
97 prices: Vec<f64>,
98 volumes: Vec<f64>,
99) -> PyResult<Vec<openquant::data_structures::Trade>> {
100 if timestamps.len() != prices.len() || prices.len() != volumes.len() {
101 return Err(PyValueError::new_err(format!(
102 "timestamps/prices/volumes length mismatch: {} / {} / {}",
103 timestamps.len(),
104 prices.len(),
105 volumes.len()
106 )));
107 }
108 let mut trades = Vec::with_capacity(prices.len());
109 for i in 0..prices.len() {
110 trades.push(openquant::data_structures::Trade {
111 timestamp: parse_one_naive_datetime(&timestamps[i])?,
112 price: prices[i],
113 volume: volumes[i],
114 });
115 }
116 Ok(trades)
117}
118
119pub fn bars_to_rows(
120 bars: Vec<openquant::data_structures::StandardBar>,

Callers 6

bars_build_time_barsFunction · 0.85
bars_build_tick_barsFunction · 0.85
bars_build_volume_barsFunction · 0.85
bars_build_dollar_barsFunction · 0.85
bars_build_run_barsFunction · 0.85

Calls 2

parse_one_naive_datetimeFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected