Skip to content

Commit

Permalink
0.9.58 update
Browse files Browse the repository at this point in the history
  • Loading branch information
zengbin93 committed Aug 16, 2024
1 parent fe2e174 commit bd7ba95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion czsc/traders/weight_backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def backtest(self, n_jobs=1):
dfw = self.dfw.copy()
long_rate = dfw[dfw["weight"] > 0].shape[0] / dfw.shape[0]
short_rate = dfw[dfw["weight"] < 0].shape[0] / dfw.shape[0]
stats.update({"多头占比": long_rate, "空头占比": short_rate})
stats.update({"多头占比": round(long_rate, 4), "空头占比": round(short_rate, 4)})

res["绩效评价"] = stats
return res
Expand Down
3 changes: 2 additions & 1 deletion czsc/utils/st_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def show_weight_backtest(dfw, **kwargs):
stat = wb.results["绩效评价"]

st.divider()
c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 = st.columns([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 = st.columns([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
c1.metric("盈亏平衡点", f"{stat['盈亏平衡点']:.2%}")
c2.metric("单笔收益(BP)", f"{stat['单笔收益']}")
c3.metric("交易胜率", f"{stat['交易胜率']:.2%}")
Expand All @@ -433,6 +433,7 @@ def show_weight_backtest(dfw, **kwargs):
c8.metric("卡玛比率", f"{stat['卡玛']:.2f}")
c9.metric("年化波动率", f"{stat['年化波动率']:.2%}")
c10.metric("多头占比", f"{stat['多头占比']:.2%}")
c11.metric("空头占比", f"{stat['空头占比']:.2%}")
st.divider()

dret = wb.results["品种等权日收益"].copy()
Expand Down

0 comments on commit bd7ba95

Please sign in to comment.