feat: TA-Lib candlestick patterns — Doji family (part 3 of 9) (#134)
* feat: add Doji-family candlestick patterns Five single-/two-bar Doji patterns, all `Input = Candle`, `Output = f64`: - Doji Star (CDLDOJISTAR) — a long body followed by a doji gapping away in the trend direction; bullish +1 (after a black bar), bearish -1 (after a white bar). - Dragonfly Doji (CDLDRAGONFLYDOJI) — a doji opening and closing at the high with a long lower shadow; bullish +1. - Gravestone Doji (CDLGRAVESTONEDOJI) — a doji opening and closing at the low with a long upper shadow; bearish -1. - Long-Legged Doji (CDLLONGLEGGEDDOJI) — a doji with long shadows on both sides; a non-directional indecision flag, +1 on detection. - Rickshaw Man (CDLRICKSHAWMAN) — a long-legged doji with the body centred in the range; a non-directional indecision flag, +1 on detection. Counter 254 -> 259 (mod-count == lib counted block; FAMILIES total 249 -> 254). * chore: sync indicator count to 259 --------- Co-authored-by: wickra-bot <wickra-bot@users.noreply.github.com>
This commit is contained in:
@@ -250,6 +250,11 @@ from ._wickra import (
|
||||
BeltHold,
|
||||
Breakaway,
|
||||
Counterattack,
|
||||
DojiStar,
|
||||
DragonflyDoji,
|
||||
GravestoneDoji,
|
||||
LongLeggedDoji,
|
||||
RickshawMan,
|
||||
# Microstructure: order book
|
||||
OrderBookImbalanceTop1,
|
||||
OrderBookImbalanceTopN,
|
||||
@@ -527,6 +532,11 @@ __all__ = [
|
||||
"BeltHold",
|
||||
"Breakaway",
|
||||
"Counterattack",
|
||||
"DojiStar",
|
||||
"DragonflyDoji",
|
||||
"GravestoneDoji",
|
||||
"LongLeggedDoji",
|
||||
"RickshawMan",
|
||||
# Microstructure: order book
|
||||
"OrderBookImbalanceTop1",
|
||||
"OrderBookImbalanceTopN",
|
||||
|
||||
@@ -11638,6 +11638,11 @@ candle_pattern_no_param!(PyAdvanceBlock, wc::AdvanceBlock, "AdvanceBlock");
|
||||
candle_pattern_no_param!(PyBeltHold, wc::BeltHold, "BeltHold");
|
||||
candle_pattern_no_param!(PyBreakaway, wc::Breakaway, "Breakaway");
|
||||
candle_pattern_no_param!(PyCounterattack, wc::Counterattack, "Counterattack");
|
||||
candle_pattern_no_param!(PyDojiStar, wc::DojiStar, "DojiStar");
|
||||
candle_pattern_no_param!(PyDragonflyDoji, wc::DragonflyDoji, "DragonflyDoji");
|
||||
candle_pattern_no_param!(PyGravestoneDoji, wc::GravestoneDoji, "GravestoneDoji");
|
||||
candle_pattern_no_param!(PyLongLeggedDoji, wc::LongLeggedDoji, "LongLeggedDoji");
|
||||
candle_pattern_no_param!(PyRickshawMan, wc::RickshawMan, "RickshawMan");
|
||||
// ============================== Microstructure: Order Book ==============================
|
||||
//
|
||||
// Order-book indicators consume a depth snapshot rather than OHLCV. Streaming
|
||||
@@ -14144,6 +14149,11 @@ fn _wickra(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
|
||||
m.add_class::<PyBeltHold>()?;
|
||||
m.add_class::<PyBreakaway>()?;
|
||||
m.add_class::<PyCounterattack>()?;
|
||||
m.add_class::<PyDojiStar>()?;
|
||||
m.add_class::<PyDragonflyDoji>()?;
|
||||
m.add_class::<PyGravestoneDoji>()?;
|
||||
m.add_class::<PyLongLeggedDoji>()?;
|
||||
m.add_class::<PyRickshawMan>()?;
|
||||
// Microstructure: order book.
|
||||
m.add_class::<PyOrderBookImbalanceTop1>()?;
|
||||
m.add_class::<PyOrderBookImbalanceTopN>()?;
|
||||
|
||||
@@ -563,6 +563,26 @@ CANDLE_SCALAR = {
|
||||
lambda: ta.Counterattack(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
"DojiStar": (
|
||||
lambda: ta.DojiStar(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
"DragonflyDoji": (
|
||||
lambda: ta.DragonflyDoji(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
"GravestoneDoji": (
|
||||
lambda: ta.GravestoneDoji(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
"LongLeggedDoji": (
|
||||
lambda: ta.LongLeggedDoji(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
"RickshawMan": (
|
||||
lambda: ta.RickshawMan(),
|
||||
lambda ind, h, l, c, v: ind.batch(c, h, l, c),
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
@@ -1685,6 +1705,32 @@ def test_counterattack_reference():
|
||||
assert t.update((20.0, 20.1, 14.9, 15.0, 1.0, 0)) == pytest.approx(0.0)
|
||||
assert t.update((10.0, 15.1, 9.9, 15.0, 1.0, 1)) == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_doji_star_reference():
|
||||
t = ta.DojiStar()
|
||||
assert t.update((20.0, 20.2, 14.8, 15.0, 1.0, 0)) == pytest.approx(0.0)
|
||||
assert t.update((13.0, 13.1, 12.9, 13.0, 1.0, 1)) == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_dragonfly_doji_reference():
|
||||
t = ta.DragonflyDoji()
|
||||
assert t.update((10.0, 10.05, 6.0, 10.0, 1.0, 0)) == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_gravestone_doji_reference():
|
||||
t = ta.GravestoneDoji()
|
||||
assert t.update((10.0, 14.0, 9.95, 10.0, 1.0, 0)) == pytest.approx(-1.0)
|
||||
|
||||
|
||||
def test_long_legged_doji_reference():
|
||||
t = ta.LongLeggedDoji()
|
||||
assert t.update((10.0, 12.0, 8.0, 10.05, 1.0, 0)) == pytest.approx(1.0)
|
||||
|
||||
|
||||
def test_rickshaw_man_reference():
|
||||
t = ta.RickshawMan()
|
||||
assert t.update((10.0, 12.0, 8.0, 10.0, 1.0, 0)) == pytest.approx(1.0)
|
||||
|
||||
# --- Lifecycle ------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user