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

Function bars_build_time_bars

crates/pyopenquant/src/bars.rs:8–20  ·  view source on GitHub ↗
(
    timestamps: Vec<String>,
    prices: Vec<f64>,
    volumes: Vec<f64>,
    interval_seconds: i64,
)

Source from the content-addressed store, hash-verified

6
7use crate::helpers::{bars_to_rows, build_trades};
8
9#[pyfunction(name = "build_time_bars")]
10fn bars_build_time_bars(
11 timestamps: Vec<String>,
12 prices: Vec<f64>,
13 volumes: Vec<f64>,
14 interval_seconds: i64,
15) -> PyResult<Vec<(String, String, f64, f64, f64, f64, f64, f64, usize)>> {
16 if interval_seconds <= 0 {
17 return Err(PyValueError::new_err("interval_seconds must be > 0"));
18 }
19 let trades = build_trades(timestamps, prices, volumes)?;
20 let bars = time_bars(&trades, chrono::Duration::seconds(interval_seconds));
21 Ok(bars_to_rows(bars))
22}
23

Callers

nothing calls this directly

Calls 3

build_tradesFunction · 0.85
time_barsFunction · 0.85
bars_to_rowsFunction · 0.85

Tested by

no test coverage detected