macd展示period;柱子的值保留两位小数
This commit is contained in:
9
chart.py
9
chart.py
@@ -91,7 +91,8 @@ def add_macd(
|
||||
)
|
||||
df["DIF"] = macd
|
||||
df["DEA"] = signal
|
||||
df["MACD"] = hist * 2
|
||||
macd_name = f"MACD_{fastperiod}_{slowperiod}_{signalperiod}"
|
||||
df[macd_name] = np.round(hist * 2, 2)
|
||||
macd_chart = chart.create_subchart(
|
||||
position=position, width=1, height=height, sync=True
|
||||
)
|
||||
@@ -100,9 +101,9 @@ def add_macd(
|
||||
)
|
||||
macd_chart.time_scale(visible=False)
|
||||
|
||||
histogram = macd_chart.create_histogram(name="MACD")
|
||||
hist_data = df[["time", "MACD"]].copy()
|
||||
hist_data["color"] = hist_data["MACD"].apply(
|
||||
histogram = macd_chart.create_histogram(name=macd_name)
|
||||
hist_data = df[["time", macd_name]].copy()
|
||||
hist_data["color"] = hist_data[macd_name].apply(
|
||||
lambda x: "#00FF00" if x < 0 else "#ff0000" # 绿色 : 红色
|
||||
)
|
||||
histogram.set(hist_data)
|
||||
|
||||
Reference in New Issue
Block a user