panifie / PingPong.jl

Cryptocurrency trading bot, and backtesting framework in julia
https://panifie.github.io/PingPong.jl/
GNU General Public License v3.0
36 stars 9 forks source link

Several errors in Performance Metrics #41

Closed janckerchen closed 2 weeks ago

janckerchen commented 3 weeks ago

follow https://panifie.github.io/PingPong.jl/stats/#Performance-Metrics

Stats.sharpe(strategy_instance, tf"1d", rfr=0.01)
Stats.sortino(strategy_instance, tf"1d", rfr=0.01)
Stats.calmar(strategy_instance, tf"1d")
Stats.expectancy(strategy_instance, tf"1d")

output

julia> balloons(s) # works great
julia> Stats.sharpe(s, tf"1d", rfr=0.01) #<----error
ERROR: MethodError: no method matching sharpe(::Strategies.SimStrategy{:SimpleStrategy, ExchangeID{:binance}, NoMargin, :USDT}, ::TimeFrames.Day; rfr::Float64)

Closest candidates are:
  sharpe(::Strategies.Strategy, ::Any, ::Any) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:77
  sharpe(::Strategies.Strategy, ::Any) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:77
  sharpe(::Strategies.Strategy) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:77

julia> Stats.sortino(s, tf"1d", rfr=0.01)  #<----error
ERROR: MethodError: no method matching sortino(::Strategies.SimStrategy{:SimpleStrategy, ExchangeID{:binance}, NoMargin, :USDT}, ::TimeFrames.Day; rfr::Float64)

Closest candidates are:
  sortino(::Strategies.Strategy, ::Any, ::Any) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:107
  sortino(::Strategies.Strategy, ::Any) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:107
  sortino(::Strategies.Strategy) got unsupported keyword argument "rfr"
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:107

julia> Stats.calmar(s, tf"1d") # works great
-0.3158866997026408

julia> Stats.expectancy(s, tf"1d")  #<----error
ERROR: UndefVarError: `returns` not defined
Stacktrace:
 [1] expectancy(s::Strategies.SimStrategy{:SimpleStrategy, ExchangeID{:binance}, NoMargin, :USDT}, tf::TimeFrames.Day)
   @ Stats /opt/opensource/jl/PingPong.jl/Stats/src/metrics.jl:206
 [2] top-level scope
   @ /opt/opensource/jl/PingPong.jl/TimeTicks/src/module.jl:61
janckerchen commented 2 weeks ago

The invocation demonstrated in the documentation, Stats.sharpe(s, tf"1d", rfr=0.01) , does not match the function signature.

function sharpe(s::Strategy, tf=tf"1d", rfr=0.0)
...
end

Changing it to the function signature will work.

julia> Stats.sharpe(s, tf"1d", 0.01)
-11.17254906151372

julia> Stats.sortino(s, tf"1d", 0.01)
-12.01871551753598

fix doc or signature