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

Function align_calendar_columns

crates/openquant/src/data_processing.rs:389–473  ·  view source on GitHub ↗
(
    columns: &OhlcvColumns,
    interval_seconds: i64,
)

Source from the content-addressed store, hash-verified

387}
388
389pub fn align_calendar_columns(
390 columns: &OhlcvColumns,
391 interval_seconds: i64,
392) -> Result<AlignedOhlcvColumns, String> {
393 let df = to_polars_df(columns)?;
394 let out = align_calendar_df(&df, interval_seconds)?;
395
396 let timestamps_us = out
397 .column("ts_us")
398 .map_err(|e| format!("missing ts_us: {e}"))?
399 .i64()
400 .map_err(|e| format!("ts_us type error: {e}"))?
401 .into_no_null_iter()
402 .collect::<Vec<_>>();
403 let symbols = out
404 .column("symbol")
405 .map_err(|e| format!("missing symbol: {e}"))?
406 .str()
407 .map_err(|e| format!("symbol type error: {e}"))?
408 .into_no_null_iter()
409 .map(ToString::to_string)
410 .collect::<Vec<_>>();
411
412 let open = out
413 .column("open")
414 .map_err(|e| format!("missing open: {e}"))?
415 .f64()
416 .map_err(|e| format!("open type error: {e}"))?
417 .into_iter()
418 .collect::<Vec<_>>();
419 let high = out
420 .column("high")
421 .map_err(|e| format!("missing high: {e}"))?
422 .f64()
423 .map_err(|e| format!("high type error: {e}"))?
424 .into_iter()
425 .collect::<Vec<_>>();
426 let low = out
427 .column("low")
428 .map_err(|e| format!("missing low: {e}"))?
429 .f64()
430 .map_err(|e| format!("low type error: {e}"))?
431 .into_iter()
432 .collect::<Vec<_>>();
433 let close = out
434 .column("close")
435 .map_err(|e| format!("missing close: {e}"))?
436 .f64()
437 .map_err(|e| format!("close type error: {e}"))?
438 .into_iter()
439 .collect::<Vec<_>>();
440 let volume = out
441 .column("volume")
442 .map_err(|e| format!("missing volume: {e}"))?
443 .f64()
444 .map_err(|e| format!("volume type error: {e}"))?
445 .into_iter()
446 .collect::<Vec<_>>();

Callers 2

align_calendar_rowsFunction · 0.85
data_align_calendarFunction · 0.85

Calls 2

to_polars_dfFunction · 0.85
align_calendar_dfFunction · 0.85

Tested by

no test coverage detected