修复 买卖点一致性对齐至chan.py

This commit is contained in:
YuWuKunCheng
2026-05-29 20:42:34 +08:00
parent e50172e923
commit fca62f3141
5 changed files with 64 additions and 41 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "chanlun-py"
version = "26.5.91"
version = "26.5.93"
edition = "2021"
description = "缠论技术分析库 — Rust 高性能 Python 绑定"
authors = ["YuYuKunKun"]
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "maturin"
[project]
name = "chanlun"
version = "2605.91"
version = "2605.93"
description = "缠论技术分析库 — Rust 高性能实现"
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE", content-type = "text/plain" }
+5 -3
View File
@@ -750,9 +750,11 @@ impl 线段Py {
)> {
let borrowed = .borrow();
let (a, b, c, d) = if let Some(hub_bound) = {
if let Ok(mut hub_ref) = hub_bound.extract::<PyRefMut<'_, Py>>() {
let inner_mut = Arc::make_mut(&mut hub_ref.inner);
chanlun::algorithm::segment::线::(&borrowed.inner, Some(inner_mut))
if let Ok(hub_ref) = hub_bound.extract::<PyRef<'_, Py>>() {
chanlun::algorithm::segment::线::(
&borrowed.inner,
Some(&hub_ref.inner),
)
} else {
chanlun::algorithm::segment::线::(&borrowed.inner, None)
}
+53 -34
View File
@@ -48,7 +48,12 @@ use crate::types_py::买卖点类型Py;
/// 有效性: bool — 买卖点是否仍有效
/// 与MACD柱子匹配: bool|None — 是否与MACD柱状图方向匹配
/// 与MACD柱子分型匹配: bool|None — 是否与MACD柱分型匹配
#[pyclass(name = "基础买卖点", module = "chanlun._chanlun", from_py_object)]
#[pyclass(
name = "基础买卖点",
module = "chanlun._chanlun",
subclass,
from_py_object
)]
#[derive(Clone)]
pub struct Py {
pub(crate) inner: chanlun::business::bsp::,
@@ -200,19 +205,17 @@ impl 基础买卖点Py {
// ========== 买卖点 ==========
/// 买卖点 — 静态方法容器,提供各类买卖点的构造算法(不存储数据)
/// 买卖点 — 继承 基础买卖点,添加工厂类方法
///
/// 类方法(均返回对应的买卖点对象:
/// 类方法(均返回 买卖点 实例:
/// 一卖点(...) / 一买点(...) / 二卖点(...) / 二买点(...) / 三卖点(...) / 三买点(...)
/// 生成买卖点(特征, 序号, 级别, 分型, 当前缠K, 备注?) -> 买卖点
/// — 根据特征字符串自动路由到对应的一/二/三类买卖点构造函数
#[pyclass(name = "买卖点", module = "chanlun._chanlun")]
/// 生成买卖点(特征, 序号, 级别, 分型, 当前缠K) -> 买卖点
#[pyclass(name = "买卖点", module = "chanlun._chanlun", extends=基础买卖点Py)]
pub struct Py;
#[pymethods]
impl Py {
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -220,8 +223,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -230,11 +234,12 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -242,8 +247,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -252,11 +258,12 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -264,8 +271,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -274,11 +282,12 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -286,8 +295,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -296,11 +306,12 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -308,8 +319,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -318,11 +330,12 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 买卖点分型: 买卖点对应的分型
fn (
_cls: &Bound<'_, PyType>,
: &Bound<'_, Py>,
@@ -330,8 +343,9 @@ impl 买卖点Py {
: &str,
: String,
: f64,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
Arc::clone(&.borrow().inner),
K线.borrow().inner.clone(),
@@ -340,11 +354,13 @@ impl 买卖点Py {
,
K线.borrow().inner.,
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
#[classmethod]
/// :param 特征: 特征字符串
#[pyo3(signature = (特征, 序号, 级别, 买卖点分型, 当前缠K))]
fn (
_cls: &Bound<'_, PyType>,
: &str,
@@ -352,8 +368,9 @@ impl 买卖点Py {
: &str,
: &Bound<'_, Py>,
K: &Bound<'_, K线Py>,
) -> Py {
Py {
py: Python<'_>,
) -> PyResult<Py<Self>> {
let base = Py {
inner: chanlun::business::bsp::::(
,
,
@@ -361,7 +378,9 @@ impl 买卖点Py {
Arc::clone(&.borrow().inner),
Arc::clone(&K.borrow().inner),
),
}
};
let init = PyClassInitializer::from(base).add_subclass(Py);
Ok(Bound::new(py, init)?.unbind())
}
}
+4 -2
View File
@@ -415,7 +415,8 @@ impl 笔 {
let = Arc::clone(.last().unwrap());
// Python line 2330-2335: 清理无效数据
if ...load(Ordering::Relaxed) == ...load(Ordering::Relaxed)
if ...load(Ordering::Relaxed)
== ...load(Ordering::Relaxed)
|| matches!(., :: | ::)
{
Self::(, );
@@ -430,7 +431,8 @@ impl 笔 {
let = Arc::clone(.last().unwrap());
// Python line 2338: 时序检查 — skip out-of-order fractals
if ...load(Ordering::Relaxed) > ...load(Ordering::Relaxed)
if ...load(Ordering::Relaxed)
> ...load(Ordering::Relaxed)
&& ...load(Ordering::Relaxed)
- ...load(Ordering::Relaxed)
> 1