(
close_timestamps: Vec<String>,
close_prices: Vec<f64>,
t_events: Vec<String>,
target_timestamps: Vec<String>,
target_values: Vec<f64>,
pt: f64,
sl: f64,
min_ret: f64,
| 189 | out_report.set_item("symbol_count", report.symbol_count)?; |
| 190 | out_report.set_item("duplicate_key_count", report.duplicate_key_count)?; |
| 191 | out_report.set_item("gap_interval_count", report.gap_interval_count)?; |
| 192 | out_report |
| 193 | .set_item("ts_min", report.ts_min.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()))?; |
| 194 | out_report |
| 195 | .set_item("ts_max", report.ts_max.map(|v| v.format("%Y-%m-%d %H:%M:%S").to_string()))?; |
| 196 | out_report.set_item("rows_removed_by_deduplication", report.rows_removed_by_deduplication)?; |
| 197 | Ok(out_report.into_pyobject(py).unwrap().into_any().unbind()) |
| 198 | } |
| 199 | |
| 200 | pub fn build_labeling_events( |
| 201 | close_timestamps: Vec<String>, |
| 202 | close_prices: Vec<f64>, |
| 203 | t_events: Vec<String>, |
| 204 | target_timestamps: Vec<String>, |
| 205 | target_values: Vec<f64>, |
| 206 | pt: f64, |
| 207 | sl: f64, |
| 208 | min_ret: f64, |
| 209 | vertical_barrier_times: Option<Vec<(String, String)>>, |
| 210 | side_prediction: Option<Vec<(String, f64)>>, |
| 211 | ) -> PyResult<( |
| 212 | Vec<(chrono::NaiveDateTime, f64)>, |
| 213 | Vec<(chrono::NaiveDateTime, openquant::labeling::Event)>, |
| 214 | )> { |
| 215 | let close = |
| 216 | pair_timestamps_values(close_timestamps, close_prices, "close_timestamps", "close_prices")?; |
| 217 | let t_events = parse_naive_datetimes(t_events)?; |
| 218 | let target = pair_timestamps_values( |
| 219 | target_timestamps, |
| 220 | target_values, |
| 221 | "target_timestamps", |
| 222 | "target_values", |
| 223 | )?; |
| 224 | let vbars = parse_vertical_barriers(vertical_barrier_times)?; |
| 225 | |
| 226 | let side_storage: Option<Vec<(chrono::NaiveDateTime, f64)>> = |
| 227 | if let Some(side) = side_prediction { |
| 228 | let (timestamps, values): (Vec<String>, Vec<f64>) = side.into_iter().unzip(); |
| 229 | Some(pair_timestamps_values(timestamps, values, "side timestamps", "side values")?) |
| 230 | } else { |
| 231 | None |
| 232 | }; |
| 233 | |
| 234 | let events = openquant::labeling::triple_barrier_events( |
| 235 | &close, |
| 236 | &t_events, |
no test coverage detected