use pyo3::prelude::*;
use crate::analyze::CZSC;
use crate::analyze::utils as analyze_utils;
use crate::objects::bar::{NewBar, RawBar};
use crate::objects::bi::BI;
use crate::objects::direction::Direction;
use crate::objects::event::PyEvent;
use crate::objects::fake_bi::FakeBI;
use crate::objects::freq::Freq;
use crate::objects::fx::FX;
use crate::objects::mark::Mark;
use crate::objects::market::Market;
use crate::objects::operate::PyOperate;
use crate::objects::position::{PyLiteBar, PyPos, PyPosition};
use crate::objects::signal::{PyParsedSignalDoc, PySignal, parse_signal_doc_py};
use crate::objects::zs::ZS;
#[pyfunction]
#[pyo3(name = "check_fx")]
fn check_fx_py(k1: NewBar, k2: NewBar, k3: NewBar) -> Option<FX> {
analyze_utils::check_fx(&k1, &k2, &k3)
}
#[pyfunction]
#[pyo3(name = "check_fxs")]
fn check_fxs_py(bars: Vec<NewBar>) -> Vec<FX> {
analyze_utils::check_fxs(&bars)
}
#[pyfunction]
#[pyo3(name = "check_bi")]
fn check_bi_py(bars: Vec<NewBar>) -> Option<BI> {
let (bi, _) = analyze_utils::check_bi(&bars);
bi
}
#[pyfunction]
#[pyo3(name = "remove_include")]
fn remove_include_py(k1: NewBar, k2: NewBar, k3: RawBar) -> PyResult<(bool, NewBar)> {
analyze_utils::remove_include(&k1, &k2, k3)
.map_err(|e| pyo3::exceptions::PyValueError::new_err(e.to_string()))
}
#[pyfunction]
#[pyo3(name = "format_standard_kline")]
fn format_standard_kline_py(bars: Vec<RawBar>) -> Vec<RawBar> {
bars
}
pub fn register(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<Freq>()?;
m.add_class::<Market>()?;
m.add_class::<Mark>()?;
m.add_class::<Direction>()?;
m.add_class::<PyOperate>()?;
m.add_class::<PyPos>()?;
m.add_class::<RawBar>()?;
m.add_class::<NewBar>()?;
m.add_class::<PyLiteBar>()?;
m.add_class::<FX>()?;
m.add_class::<FakeBI>()?;
m.add_class::<BI>()?;
m.add_class::<ZS>()?;
m.add_class::<PySignal>()?;
m.add_class::<PyParsedSignalDoc>()?;
m.add_class::<PyEvent>()?;
m.add_class::<PyPosition>()?;
m.add_class::<CZSC>()?;
m.add_function(wrap_pyfunction!(parse_signal_doc_py, m)?)?;
m.add_function(wrap_pyfunction!(check_fx_py, m)?)?;
m.add_function(wrap_pyfunction!(check_fxs_py, m)?)?;
m.add_function(wrap_pyfunction!(check_bi_py, m)?)?;
m.add_function(wrap_pyfunction!(remove_include_py, m)?)?;
m.add_function(wrap_pyfunction!(format_standard_kline_py, m)?)?;
Ok(())
}