I tried to backtest a simple strategy on TradingView, it made 6 trades with these results: Now I want to calculate Sharpe ratio using definition provided by TradingView. So, my daily returns(profit_by_days) equals:

2020-11-07    0.45
2020-11-08    0.00
2020-11-09   -0.14
2020-11-10   -0.05
2020-11-11    0.00
2020-11-12    0.00
2020-11-13    0.24
2020-11-14   -0.08


Using this Pandas code:

sharpe = (profit_by_days.mean() - (2/365))/profit_by_days.std(ddof=0)


I get 0.257 Sharpe ratio, while TradingView shows 0.205.

Why did I get a different result?

• How does this work? In your first table, on november 9 you made 2.81%, but in the profits_by_days on november 9 you have a loss of 14%. – noob2 May 18 at 0:48
• the profit_by_day is following the cum.profit column I believe, amd it is in decimal, not percenage so it is actually 14bp of profit if i understod correctly, and not 14% – Mayeul sgc May 18 at 8:09
• @noob2 if trade profit is red, then it's loss. – konstantin_doncov May 19 at 20:49
• @Mayeulsgc I think, this column(and profit_by_days) shows (absolute_profit_of_trade * 100) / capital. What do you mean by amd and bp? – konstantin_doncov May 19 at 21:08
• @noob2 still can't figure out what is going wrong. Do you have suggestions? – konstantin_doncov May 20 at 23:14