Files
ferro-ta/src/price_transform/typprice.rs
T

25 lines
733 B
Rust
Raw Normal View History

2026-03-23 23:34:28 +05:30
use crate::validation;
use numpy::{IntoPyArray, PyArray1, PyReadonlyArray1};
use pyo3::prelude::*;
/// Typical Price: (high + low + close) / 3.
#[pyfunction]
pub fn typprice<'py>(
py: Python<'py>,
high: PyReadonlyArray1<'py, f64>,
low: PyReadonlyArray1<'py, f64>,
close: PyReadonlyArray1<'py, f64>,
) -> PyResult<Bound<'py, PyArray1<f64>>> {
let highs = high.as_slice()?;
let lows = low.as_slice()?;
let closes = close.as_slice()?;
let n = highs.len();
validation::validate_equal_length(&[
(n, "high"),
(lows.len(), "low"),
(closes.len(), "close"),
])?;
2026-03-30 12:45:52 +05:30
let result = ferro_ta_core::price_transform::typprice(highs, lows, closes);
2026-03-23 23:34:28 +05:30
Ok(result.into_pyarray(py))
}