From 961af607454ac9197a348abb3fb64e3a012ed307 Mon Sep 17 00:00:00 2001 From: zengbin93 Date: Tue, 29 Oct 2024 11:13:55 +0800 Subject: [PATCH] =?UTF-8?q?0.9.60=20=E6=96=B0=E5=A2=9E=20CHOP=20=E6=B3=A2?= =?UTF-8?q?=E5=8A=A8=E6=8C=87=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- czsc/utils/ta.py | 5 ++--- ...14\207\346\240\207\350\256\241\347\256\227.py" | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 "examples/develop/\346\265\213\350\257\225TA\346\212\200\346\234\257\346\214\207\346\240\207\350\256\241\347\256\227.py" diff --git a/czsc/utils/ta.py b/czsc/utils/ta.py index 6ef0defc6..013d427eb 100644 --- a/czsc/utils/ta.py +++ b/czsc/utils/ta.py @@ -448,12 +448,11 @@ def CHOP(high, low, close, **kwargs): Calculation: Default Inputs: length=14, scalar=100, drift=1 + HH = high.rolling(length).max() LL = low.rolling(length).min() - ATR_SUM = SUM(ATR(drift), length) - CHOP = scalar * (LOG10(ATR_SUM) - LOG10(HH - LL)) - CHOP /= LOG10(length) + CHOP = scalar * (LOG10(ATR_SUM) - LOG10(HH - LL)) / LOG10(length) :param high: pd.Series, Series of 'high's :param low: pd.Series, Series of 'low's diff --git "a/examples/develop/\346\265\213\350\257\225TA\346\212\200\346\234\257\346\214\207\346\240\207\350\256\241\347\256\227.py" "b/examples/develop/\346\265\213\350\257\225TA\346\212\200\346\234\257\346\214\207\346\240\207\350\256\241\347\256\227.py" new file mode 100644 index 000000000..2eed5665c --- /dev/null +++ "b/examples/develop/\346\265\213\350\257\225TA\346\212\200\346\234\257\346\214\207\346\240\207\350\256\241\347\256\227.py" @@ -0,0 +1,15 @@ +import sys +import time + +sys.path.insert(0, r"A:\ZB\git_repo\waditu\czsc") +import talib +from czsc.utils import ta +from czsc.connectors import cooperation as coo + + +df = coo.get_raw_bars(symbol="SFIC9001", freq="日线", fq="后复权", sdt="20100101", edt="20210301", raw_bars=False) + + +def test_CHOP(): + df1 = df.copy() + df1["CHOP"] = ta.CHOP(df1["high"], df1["low"], df1["close"])