(
timestamps: Vec<String>,
prices: Vec<f64>,
volumes: Vec<f64>,
)
| 93 | } |
| 94 | |
| 95 | pub fn build_trades( |
| 96 | timestamps: Vec<String>, |
| 97 | prices: Vec<f64>, |
| 98 | volumes: Vec<f64>, |
| 99 | ) -> PyResult<Vec<openquant::data_structures::Trade>> { |
| 100 | if timestamps.len() != prices.len() || prices.len() != volumes.len() { |
| 101 | return Err(PyValueError::new_err(format!( |
| 102 | "timestamps/prices/volumes length mismatch: {} / {} / {}", |
| 103 | timestamps.len(), |
| 104 | prices.len(), |
| 105 | volumes.len() |
| 106 | ))); |
| 107 | } |
| 108 | let mut trades = Vec::with_capacity(prices.len()); |
| 109 | for i in 0..prices.len() { |
| 110 | trades.push(openquant::data_structures::Trade { |
| 111 | timestamp: parse_one_naive_datetime(×tamps[i])?, |
| 112 | price: prices[i], |
| 113 | volume: volumes[i], |
| 114 | }); |
| 115 | } |
| 116 | Ok(trades) |
| 117 | } |
| 118 | |
| 119 | pub fn bars_to_rows( |
| 120 | bars: Vec<openquant::data_structures::StandardBar>, |
no test coverage detected