Skip to content

Commit b2df99c

Browse files
committed
remove hit rate/profit factor
1 parent d282fa4 commit b2df99c

1 file changed

Lines changed: 6 additions & 39 deletions

File tree

src/analytics.jl

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DataFrames: DataFrame
22
import RiskPerf
33

4-
@inline function _clean_returns(returns::AbstractVector)
4+
@inline function _clean_returns(returns)
55
out = Float64[]
66
sizehint!(out, length(returns))
77
@inbounds for r in returns
@@ -13,45 +13,17 @@ import RiskPerf
1313
out
1414
end
1515

16-
@inline function _hit_rate(returns::AbstractVector{<:Real})
17-
wins = 0
18-
losses = 0
19-
@inbounds for r in returns
20-
if r > 0
21-
wins += 1
22-
elseif r < 0
23-
losses += 1
24-
end
25-
end
26-
total = wins + losses
27-
total == 0 ? NaN : wins / total
28-
end
29-
30-
@inline function _profit_factor(returns::AbstractVector{<:Real})
31-
gains = 0.0
32-
losses = 0.0
33-
@inbounds for r in returns
34-
if r > 0
35-
gains += r
36-
elseif r < 0
37-
losses += -r
38-
end
39-
end
40-
losses == 0.0 && return gains == 0.0 ? NaN : Inf
41-
gains / losses
42-
end
43-
4416
"""
45-
performance_summary_table(returns::AbstractVector; periods_per_year=252, risk_free=0.0, mar=0.0, compound=true)
17+
performance_summary_table(returns; periods_per_year=252, risk_free=0.0, mar=0.0, compound=true)
4618
4719
Return a one-row `DataFrame` with summary performance metrics:
48-
`CAGR`, `vol`, `Sharpe`, `Sortino`, `max DD`, `MAR`, `Calmar`, `hit rate`, and `profit factor`.
20+
`CAGR`, `vol`, `Sharpe`, `Sortino`, `max DD`, `MAR`, and `Calmar`.
4921
5022
`returns` must be simple periodic returns. `risk_free` and `mar` are per-period inputs.
5123
`max_dd` is reported as a positive magnitude. `mar` is the minimum acceptable return used for Sortino.
5224
"""
5325
function performance_summary_table(
54-
returns::AbstractVector;
26+
returns;
5527
periods_per_year::Real=252,
5628
risk_free=0.0,
5729
mar=0.0,
@@ -68,8 +40,6 @@ function performance_summary_table(
6840
max_dd=NaN,
6941
mar=mar,
7042
calmar=NaN,
71-
hit_rate=NaN,
72-
profit_factor=NaN,
7343
)
7444
end
7545

@@ -79,8 +49,6 @@ function performance_summary_table(
7949
sortino = RiskPerf.sortino_ratio(r; multiplier=periods_per_year, MAR=mar)
8050
max_dd = RiskPerf.max_drawdown_pct(r; compound=compound)
8151
calmar = RiskPerf.calmar_ratio(r, periods_per_year; compound=compound)
82-
hit_rate = _hit_rate(r)
83-
profit_factor = _profit_factor(r)
8452

8553
DataFrame(;
8654
cagr=cagr,
@@ -90,8 +58,6 @@ function performance_summary_table(
9058
max_dd=max_dd,
9159
mar=mar,
9260
calmar=calmar,
93-
hit_rate=hit_rate,
94-
profit_factor=profit_factor,
9561
)
9662
end
9763

@@ -115,5 +81,6 @@ function performance_summary_table(
11581
periods_per_year=periods_per_year,
11682
risk_free=risk_free,
11783
mar=mar,
118-
compound=compound)
84+
compound=compound,
85+
)
11986
end

0 commit comments

Comments
 (0)