第八版

This commit is contained in:
YuWuKunCheng
2026-05-29 04:05:36 +08:00
parent ae57090d7f
commit 5c3179eec8
31 changed files with 4111 additions and 1730 deletions
+42 -28
View File
@@ -25,14 +25,15 @@
use crate::kline::chan_kline::K线;
use crate::types::;
use crate::types::;
use std::rc::Rc;
use std::sync::atomic::Ordering;
use std::sync::Arc;
/// 分型 — 由三根缠K构成(可能缺左或右)
#[derive(Debug, Clone)]
pub struct {
pub : Option<Rc<K线>>,
pub : Rc<K线>,
pub : Option<Rc<K线>>,
pub : Option<Arc<K线>>,
pub : Arc<K线>,
pub : Option<Arc<K线>>,
pub : ,
pub : i64,
pub : f64,
@@ -40,11 +41,11 @@ pub struct 分型 {
impl {
pub fn new(
: Option<Rc<K线>>, : Rc<K线>, : Option<Rc<K线>>
: Option<Arc<K线>>, : Arc<K线>, : Option<Arc<K线>>
) -> Self {
let = ..unwrap_or(::);
let = .;
let = .;
let = ..read().unwrap().unwrap_or(::);
let = ..load(Ordering::Relaxed);
let = ..get();
Self {
,
,
@@ -60,9 +61,9 @@ impl 分型 {
let = self..as_ref()?;
let = self..as_ref()?;
Some((
::(., ., self.., self..),
::(self.., self.., ., .),
::(., ., ., .),
::(..get(), ..get(), self...get(), self...get()),
::(self...get(), self...get(), ..get(), ..get()),
::(..get(), ..get(), ..get(), ..get()),
))
}
@@ -97,17 +98,19 @@ impl 分型 {
if let (Some(ref ), Some(ref )) = (&self., &self.) {
if self. == :: {
if .K线. > .K线. {
if .K线.read().unwrap(). > .K线.read().unwrap(). {
return "";
} else if .K线. > self..K线. {
} else if .K线.read().unwrap(). > self..K线.read().unwrap().
{
return "";
} else {
return "";
}
} else if self. == :: {
if .K线. < .K线. {
if .K线.read().unwrap(). < .K线.read().unwrap(). {
return "";
} else if .K线. < self..K线. {
} else if .K线.read().unwrap(). < self..K线.read().unwrap().
{
return "";
} else {
return "";
@@ -121,15 +124,21 @@ impl 分型 {
pub fn MACD柱子分型匹配(&self) -> bool {
if let (Some(ref ), Some(ref )) = (&self., &self.) {
if self. == :: {
let _k = .K线.read().unwrap();
let _k = self..K线.read().unwrap();
let _k = .K线.read().unwrap();
if let (Some(ref macd), Some(ref macd), Some(ref macd)) =
(&.K线.macd, &self..K线.macd, &.K线.macd)
(&_k.macd, &_k.macd, &_k.macd)
{
return macd.MACD柱 > macd.MACD柱 && macd.MACD柱 < macd.MACD柱;
}
}
if self. == :: {
let _k = .K线.read().unwrap();
let _k = self..K线.read().unwrap();
let _k = .K线.read().unwrap();
if let (Some(ref macd), Some(ref macd), Some(ref macd)) =
(&.K线.macd, &self..K线.macd, &.K线.macd)
(&_k.macd, &_k.macd, &_k.macd)
{
return macd.MACD柱 < macd.MACD柱 && macd.MACD柱 > macd.MACD柱;
}
@@ -139,35 +148,36 @@ impl 分型 {
}
/// 判断两个分型是否匹配
pub fn (: &Rc<>, : &Rc<>, : &str) -> bool {
pub fn (: &Arc<>, : &Arc<>, : &str) -> bool {
match {
"" => Rc::as_ptr() == Rc::as_ptr(),
"" => Arc::as_ptr() == Arc::as_ptr(),
_ => false,
}
}
/// 从缠K序列中获取以指定缠K为中元素的分型
pub fn K序列中获取分型(
K线序列: &[Rc<K线>], : &Rc<K线>
K线序列: &[Arc<K线>],
: &Arc<K线>,
) -> Option<Self> {
let idx = K线序列
.iter()
.position(|k| Rc::as_ptr(k) == Rc::as_ptr())?;
.position(|k| Arc::as_ptr(k) == Arc::as_ptr())?;
let = if idx > 0 {
Some(Rc::clone(&K线序列[idx - 1]))
Some(Arc::clone(&K线序列[idx - 1]))
} else {
None
};
let = if idx + 1 < K线序列.len() {
Some(Rc::clone(&K线序列[idx + 1]))
Some(Arc::clone(&K线序列[idx + 1]))
} else {
None
};
Some(Self::new(, Rc::clone(), ))
Some(Self::new(, Arc::clone(), ))
}
/// 向分型序列中添加新分型
pub fn (: &mut Vec<Rc<>>, : Rc<>) {
pub fn (: &mut Vec<Arc<>>, : Arc<>) {
if .is_empty() {
if . != :: && . != ::
{
@@ -188,10 +198,10 @@ impl 分型 {
impl crate::types::fractal:: for {
fn (&self) -> f64 {
self..
self...get()
}
fn (&self) -> f64 {
self..
self...get()
}
}
@@ -200,7 +210,11 @@ impl std::fmt::Display for 分型 {
write!(
f,
"{}<{}, {}, None: {}, None: {}>",
self...unwrap_or(crate::types::::),
self.
.
.read()
.unwrap()
.unwrap_or(crate::types::::),
self.,
crate::utils::format_f64_g(self.),
if self..is_none() { "True" } else { "False" },