Hello,
I'm trying to create custom matplotlib charts on the backtest results. Specifically I'd like to overlay icons to show when each buy and sell order was executed on a candlestick plot.
I can run my backtest in main.py, and I can create the candlestick plot in research.ipynb. However, I cannot figure out how to use the results of the backtest (the orders) in the research.ipynb to create the chart.
I also read in the docs that I should be creating my algorithm in the research.ipynb first before ever running it in main.py. However, I'm not sure how to execute the algorithm in the resarech.ipynb file? What do I use to call the class I'm creating my algorithm in?
Thank you!
Mia Alissi
Hello Brendon,
To programmatically analyze orders, you can use the
read_backtest_orders
method or the/backtests/orders/read
endpoint as mentioned in the QuantConnect documentation. This allows you to access the orders generated by your backtest.To create a candlestick plot with buy and sell markers, you can use the
plotly
library as shown in the QuantConnect documentation. Here is a code snippet from the documentation:Regarding your question about creating your algorithm in the research notebook, you can use the
QuantBook
class to access data and perform analysis. You can then use this analysis to inform the design of your algorithm. However, to actually execute the algorithm, you would need to use the main.py file.I hope this helps! Let me know if you have any other questions.
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.
Brendon Kellner
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!