polakowo / vectorbt

Find your trading edge, using the fastest engine for backtesting, algorithmic trading, and research.
https://vectorbt.dev
Other
3.96k stars 582 forks source link

Not finding definition for sharpe_ratio #509

Open Mattiatore opened 1 year ago

Mattiatore commented 1 year ago

Hello, congrats for the amazing project! I am using the following snippet of code in PyCharm: image Although PyCharm does not allow me to access the code for the sharpe_ratio (Ctrl + click), I tried to look into base.py and found the following for sharpe: image Although the function returns_acc.sharpe_ratio is not found anywhere else in the scope of the project via PyCharm. Is that because this part is coded with Numba? Is it possible to access that (with or without PyCharm)? Thanks

Mattiatore commented 1 year ago

The question sparked from the following: image Here we have a strategy with a negative total return but positive sharpe ratio, which I thought must have been a mistake although it could be due to the fact that positive sharpe implies positive total returns only if the same notional is invested for every trade.

eabase commented 1 year ago

Sharpe is defined in the following functions. https://github.com/polakowo/vectorbt/blob/6228c72fa2886f54c369395df4501a00519029e6/vectorbt/returns/nb.py#L329-L371

eromoe commented 1 year ago

have a strategy with a negative total return but positive sharpe ratio I also find this on minute granularity, sharpe_ratio is usual for day granularity I think.