How to benchmark a FX backtest against any of the available FX assets e.g. CHFUSD (or a basket of them)?
QUANTCONNECT COMMUNITY
How to benchmark a FX backtest against any of the available FX assets e.g. CHFUSD (or a basket of them)?
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Halldor Andersen
Hi Kamer.
You can use SetBenchmark() in the method Initialize() for a single FX asset:
# Use AUD/USD as benchmark self.SetBenchmark("AUDUSD")
Alternatively, you can plot a custom benchmark using a Chart:
### In Inititalize() # Create a plot pricePlot = Chart("Portfolio benchmark") pricePlot.AddSeries(Series("Value", SeriesType.Line, 0)) self.AddChart(pricePlot) ### In OnData() # Create a custom portfolio benchmark pfolioBenchmark = 0 for ticker in self.tickers: # Create portfolio benchmark using equally weighted log returns pfolioBenchmark += self.w*np.log(self.Securities[ticker].Price/self.Portfolio[ticker].AveragePrice) # Add data points to plot self.Plot("Trade Plot", "Value", pfolioBenchmark*1000)
I've attached a backtest where I demonstrate how to set a benchmark and also create a chart where I plot a custom benchmark using equally weighted log returns. Check out this documentation on Initializing Algorithms for more information on setting benchmark.
Kamer Ali Yüksel
This is a great response, thanks!
Kamer Ali Yüksel
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!