Skip to content

Commit c2157b6

Browse files
committed
remove profit-cost ratio
1 parent 385afe2 commit c2157b6

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

alphavec/backtest.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def backtest(
154154
costs = cmn_costs + borrow_costs + spread_costs
155155

156156
# Calc the number of valid trading periods for each asset
157-
# to calculate correct number of trades
157+
# to get correct number of trades
158158
strat_valid_periods = weights.apply(
159159
lambda col: col.loc[col.first_valid_index() :].count()
160160
)
@@ -166,7 +166,6 @@ def backtest(
166166
strat_rets = weights * (prices.pct_change() - costs).shift(-shift_periods)
167167
strat_rets = strat_rets.iloc[:-shift_periods] if shift_periods > 0 else strat_rets
168168
strat_cum = (1 + strat_rets).cumprod() - 1
169-
strat_profit_cost_ratio = strat_cum.iloc[-1] / costs.sum()
170169
strat_perf = pd.concat(
171170
[
172171
strat_rets.apply(
@@ -176,15 +175,13 @@ def backtest(
176175
strat_rets.apply(_cagr, periods=freq_year),
177176
strat_rets.apply(_max_drawdown),
178177
_trade_count(weights) / strat_total_days,
179-
strat_profit_cost_ratio,
180178
],
181179
keys=[
182180
"annual_sharpe",
183181
"annual_volatility",
184182
"cagr",
185183
"max_drawdown,",
186184
"trades_per_day",
187-
"profit_cost_ratio",
188185
],
189186
axis=1,
190187
)
@@ -193,7 +190,6 @@ def backtest(
193190
port_rets = strat_rets.sum(axis=1)
194191
port_cum = strat_cum.sum(axis=1)
195192
port_costs = costs.sum().sum()
196-
port_profit_cost_ratio = port_cum.iloc[-1] / port_costs if port_costs > 0 else None
197193
port_perf = pd.DataFrame(
198194
{
199195
"annual_sharpe": _ann_sharpe(
@@ -202,7 +198,6 @@ def backtest(
202198
"annual_volatility": _ann_vol(port_rets, periods=freq_year),
203199
"cagr": _cagr(port_rets, periods=freq_year),
204200
"max_drawdown": _max_drawdown(port_rets),
205-
"profit_cost_ratio": port_profit_cost_ratio,
206201
},
207202
index=["portfolio"],
208203
)

0 commit comments

Comments
 (0)