You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all, thanks a lot for this great project.
I managed to build a 1:1 replication of my tradingview strategy and indicators and as of now two things are open that I could not get to work or better to get them in sync between the two systems.
I added Time Conditions for hours, weekdays and a backtesting period and use portfolio_from_signals in vectorbt.
The number of trades, the net profit (when fees are set to 0) and the win rate are an exact match and sync perfectly between the systems.
But I have differences for these two values:
fees
There is a small difference in the fees from tradingview and from vectorbt. But it is not only there in certain conditions, it always there. Could this be due to rounding? If yes, how can I set the number of decimal places to calculate the fees with to get an exact match with tradingview?
max_drawdown
As stated above all trades long and short match exactly and I also debugged the entry and exit prices. Considering max_drawdown the differences are more significant than for fees and differ multiple percents. To rule out open positions I added an exit condition on the last timeframe and checked that all trades are closed at the end of the respective time. I am taking max_drawdown like this: max_drawdown = portfolio.drawdowns.max_drawdown()
I did everything I could but could not figure out the differences in fees and max_drawdown.
Thanks in advance for looking into it and giving me some hints or advices how to debug this.
Kind regards
The text was updated successfully, but these errors were encountered:
VBT is solely based on floating point numbers, thus you cannot set decimal places, neither for fees nor for anything else. There are two solutions: you can calculate fees by yourself, round them, and provide them as fixed_fees (if your order size is known in advance of course), or, you can perform your backtest without fees and then "patch" the order records with the fees with new_pf = pf.replace(order_records=new_order_records).
There shouldn't be no difference between MDD, I'm not aware how it's calculated on TV but in VBT it's based on equity. You can also calculate it from returns with pf.max_drawdown(), which should yield the same number.
fees
As I am pretty new to python I exported portfolio.trades.records_readable to excel and calculated the fees. If I don't round anything it matches your calculation almost exactly. I was not able to replicate the way TV calculates. I tried rounding or cutting the numbers with different decimal places, but none matched the TV result. I will get back to their support and ask how this is calculated before I get back to you to ask how to replicate.
As I understand correctly on their website exporting portfolio.trades.records_readable is not enough to check as it calculates the drawdown on every low of every bar if I got that right.
Hey,
first of all, thanks a lot for this great project.
I managed to build a 1:1 replication of my tradingview strategy and indicators and as of now two things are open that I could not get to work or better to get them in sync between the two systems.
I added Time Conditions for hours, weekdays and a backtesting period and use
portfolio_from_signals
in vectorbt.The number of trades, the net profit (when fees are set to 0) and the win rate are an exact match and sync perfectly between the systems.
But I have differences for these two values:
fees
There is a small difference in the fees from tradingview and from vectorbt. But it is not only there in certain conditions, it always there. Could this be due to rounding? If yes, how can I set the number of decimal places to calculate the fees with to get an exact match with tradingview?
max_drawdown
As stated above all trades long and short match exactly and I also debugged the entry and exit prices. Considering max_drawdown the differences are more significant than for fees and differ multiple percents. To rule out open positions I added an exit condition on the last timeframe and checked that all trades are closed at the end of the respective time. I am taking max_drawdown like this:
max_drawdown = portfolio.drawdowns.max_drawdown()
I did everything I could but could not figure out the differences in fees and max_drawdown.
Thanks in advance for looking into it and giving me some hints or advices how to debug this.
Kind regards
The text was updated successfully, but these errors were encountered: