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

Function df_to_ohlcv_columns

crates/openquant/src/data_processing.rs:305–365  ·  view source on GitHub ↗
(df: &DataFrame)

Source from the content-addressed store, hash-verified

303}
304
305fn df_to_ohlcv_columns(df: &DataFrame) -> Result<OhlcvColumns, String> {
306 let timestamps_us = df
307 .column("ts_us")
308 .map_err(|e| format!("missing ts_us: {e}"))?
309 .i64()
310 .map_err(|e| format!("ts_us type error: {e}"))?
311 .into_no_null_iter()
312 .collect::<Vec<_>>();
313 let symbols = df
314 .column("symbol")
315 .map_err(|e| format!("missing symbol: {e}"))?
316 .str()
317 .map_err(|e| format!("symbol type error: {e}"))?
318 .into_no_null_iter()
319 .map(ToString::to_string)
320 .collect::<Vec<_>>();
321 let open = df
322 .column("open")
323 .map_err(|e| format!("missing open: {e}"))?
324 .f64()
325 .map_err(|e| format!("open type error: {e}"))?
326 .into_no_null_iter()
327 .collect::<Vec<_>>();
328 let high = df
329 .column("high")
330 .map_err(|e| format!("missing high: {e}"))?
331 .f64()
332 .map_err(|e| format!("high type error: {e}"))?
333 .into_no_null_iter()
334 .collect::<Vec<_>>();
335 let low = df
336 .column("low")
337 .map_err(|e| format!("missing low: {e}"))?
338 .f64()
339 .map_err(|e| format!("low type error: {e}"))?
340 .into_no_null_iter()
341 .collect::<Vec<_>>();
342 let close = df
343 .column("close")
344 .map_err(|e| format!("missing close: {e}"))?
345 .f64()
346 .map_err(|e| format!("close type error: {e}"))?
347 .into_no_null_iter()
348 .collect::<Vec<_>>();
349 let volume = df
350 .column("volume")
351 .map_err(|e| format!("missing volume: {e}"))?
352 .f64()
353 .map_err(|e| format!("volume type error: {e}"))?
354 .into_no_null_iter()
355 .collect::<Vec<_>>();
356 let adj_close = df
357 .column("adj_close")
358 .map_err(|e| format!("missing adj_close: {e}"))?
359 .f64()
360 .map_err(|e| format!("adj_close type error: {e}"))?
361 .into_no_null_iter()
362 .collect::<Vec<_>>();

Callers 1

clean_ohlcv_columnsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected