CCI显示period
This commit is contained in:
12
chart.py
12
chart.py
@@ -41,7 +41,7 @@ def add_ema(df, chart, period: int = 50):
|
|||||||
|
|
||||||
def add_cci(df, chart, period: int = 14, height: float = 0.1, position: str = "bottom"):
|
def add_cci(df, chart, period: int = 14, height: float = 0.1, position: str = "bottom"):
|
||||||
cci = ta.CCI(df["high"], df["low"], df["close"], timeperiod=period)
|
cci = ta.CCI(df["high"], df["low"], df["close"], timeperiod=period)
|
||||||
df["CCI"] = cci
|
df[f"CCI_{period}"] = cci
|
||||||
cci_chart = chart.create_subchart(
|
cci_chart = chart.create_subchart(
|
||||||
position=position, width=1, height=height, sync=True
|
position=position, width=1, height=height, sync=True
|
||||||
)
|
)
|
||||||
@@ -49,8 +49,8 @@ def add_cci(df, chart, period: int = 14, height: float = 0.1, position: str = "b
|
|||||||
visible=True, font_size=14, color="#FFFFFF", font_family="Times New Roman"
|
visible=True, font_size=14, color="#FFFFFF", font_family="Times New Roman"
|
||||||
)
|
)
|
||||||
cci_chart.time_scale(visible=False)
|
cci_chart.time_scale(visible=False)
|
||||||
cci_line = cci_chart.create_line(name="CCI", color="#FF0000", width=2)
|
cci_line = cci_chart.create_line(name=f"CCI_{period}", color="#FF0000", width=2)
|
||||||
cci_line.set(df[["time", "CCI"]])
|
cci_line.set(df[["time", f"CCI_{period}"]])
|
||||||
df = df[["time"]].copy()
|
df = df[["time"]].copy()
|
||||||
df["h"] = 100
|
df["h"] = 100
|
||||||
df["l"] = -100
|
df["l"] = -100
|
||||||
@@ -149,7 +149,7 @@ def add_TD(df, chart):
|
|||||||
TDs = df[["time", "TD"]].to_dict(orient="records")
|
TDs = df[["time", "TD"]].to_dict(orient="records")
|
||||||
markers = []
|
markers = []
|
||||||
for item in TDs:
|
for item in TDs:
|
||||||
if item["TD"] == 9:
|
if item["TD"] in [9, 13]:
|
||||||
markers.append(
|
markers.append(
|
||||||
{
|
{
|
||||||
"time": item["time"].strftime("%Y-%m-%d"),
|
"time": item["time"].strftime("%Y-%m-%d"),
|
||||||
@@ -159,7 +159,7 @@ def add_TD(df, chart):
|
|||||||
"text": f"{item['TD']}",
|
"text": f"{item['TD']}",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
elif item["TD"] == -9:
|
elif item["TD"] in [-9, -13]:
|
||||||
markers.append(
|
markers.append(
|
||||||
{
|
{
|
||||||
"time": item["time"].strftime("%Y-%m-%d"),
|
"time": item["time"].strftime("%Y-%m-%d"),
|
||||||
@@ -376,7 +376,7 @@ def plot_chart(df, symbol: str, name: str, timeframe: str):
|
|||||||
add_ema(df, chart, period=30)
|
add_ema(df, chart, period=30)
|
||||||
add_ema(df, chart, period=60)
|
add_ema(df, chart, period=60)
|
||||||
add_macd(df, chart)
|
add_macd(df, chart)
|
||||||
add_cci(df, chart, period=26)
|
add_cci(df, chart, period=14)
|
||||||
add_TD(df, chart)
|
add_TD(df, chart)
|
||||||
add_buy_sell_signal_markers(df, chart)
|
add_buy_sell_signal_markers(df, chart)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user