How to simulate TradingView StrategyTester in Backtrader
-
I got data of 'TSLA' with yfinance library for same period of TradingView platform StrategyTester assumes.
For example I have used RSI_SMA Strategy with 14 period parameters in both.
interval is 1 minute.
start period is 2023-06-12
end period is nowI have calculate ROI in stop method of backtrader strategy class.
After executing cerebro.run() and its plot, The ROI is different than Net profit of TradingView.
In manner of Number of trades, TradingView shows so little than backtrader.
The initial cash is same.
The parameters the same.What is the reason of this mismach?
-
There could be multiple things that are causing this issue, but, there is 1 thing that definitely has an effect on the result: yfinance and TradingView have different data. All brokers/data suppliers have different data. When you choose a data supplier ensure that their data is acceptably accurate in terms of what you want. I will tell you that yfinance has absolutely terrible accuracy. You can see what I mean if you look at the yfinance data that you're loading, and then look at the actual Yahoo Finance website. The data is completely different.
-
@EMR Number of orders is vastly different so Net profit or ROI is not same.
-
@Z Thank you for mentioning it. If yfinance has terrible accuracy so how to get more accurate stock data? Is there any better solution for free?
-
@Mohsen-Ebrahimi I am not entirely sure where I am going to get data from yet. As of this moment I am trying to set up other things within Backtrader, so the accuracy of my data doesn't matter right this second. I am simply using it as a placeholder. Here is a post where I asked that exact question. I only got one answer, but, hopefully it helps. I will try to remember to come back to this post when I end up choosing a data broker.