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

Function parse_one_naive_datetime

crates/pyopenquant/src/helpers.rs:82–93  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

80}
81
82pub fn parse_one_naive_datetime(value: &str) -> PyResult<chrono::NaiveDateTime> {
83 chrono::NaiveDateTime::parse_from_str(value, "%Y-%m-%d %H:%M:%S")
84 .or_else(|_| {
85 chrono::NaiveDate::parse_from_str(value, "%Y-%m-%d")
86 .map(|d| d.and_hms_opt(0, 0, 0).expect("valid fixed midnight"))
87 })
88 .map_err(|e| {
89 PyValueError::new_err(format!(
90 "invalid datetime '{value}' (expected '%Y-%m-%d %H:%M:%S' or '%Y-%m-%d'): {e}"
91 ))
92 })
93}
94
95pub fn build_trades(
96 timestamps: Vec<String>,

Callers 1

build_tradesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected