I'd like to export my optimzation results so I can perform additional analysis ( eg: calculating return-to-drawdown ratio for each backtest).
How would one go about doing this?
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Export optimization results for additional analysis, such as return-to-drawdown ratio calculation. How to do it?
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
How do we / can we export optimization results?
.ekz. | ThePrinters.io | March 2021
I'd like to export my optimzation results so I can perform additional analysis ( eg: calculating return-to-drawdown ratio for each backtest).
How would one go about doing this?
QuantConnectâ„¢ 2025. All Rights Reserved
Derek Melchin
Hi .ekz.,
To open up individual backtests run by the Optimizer, scroll down to the table titled "Backtests" on the optimization results page. Each one of the backtests in the table can be opened individually to view its results, including return and drawdown.
We can also use the Lean API to fetch the backtest results in the Research environment. We just need to gather the backtest ID of the backtest we want to analyze, which can be found in the log file of the individual backtest. To gather the return and drawdown in the Research environment, we use
backtest = api.ReadBacktest(<projectID>, <backtestID>) profit = backtest.TotalPerformance.PortfolioStatistics.TotalNetProfit dd = backtest.TotalPerformance.PortfolioStatistics.Drawdown
See the attached notebook for reference.
To access the API from a local notebook, we should include
from QuantConnect.Api import Api api = Api() api.Initialize(10340, 'youshouldneverexposeyourtoken', '')
Best,
Derek Melchin
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.
.ekz. INVESTOR
Thanks for your response Derek. I realize now that I may not have clearly explained my goal.
A simpler way to state my objective, is that i need the contents of this table, inside a CSV file.. I actualy just discovered that is an export option on right-click, but the downloaded CSV file is empty.
I have 2000 backtests that have run in my optimization. I want to compare them against eachother with metrics not available in in the web optimization (even in the extra columns)
Looking at the network traffic in my chrome browser, this is the endpoint being hit for this data:
https://www.quantconnect.com/api/v2/optimizations/read
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.
.ekz. INVESTOR
I've ended up hacking together a solution. sharing here for others' benefit. The proper fix would be to make the existing export function work (the functionality is there, but an empty CSV is downloaded).
Till then, my stop-gap is to copy the request from chrome dev tools as a CURL, and use that in a python script to fetch the results JSON and convert it to CSV. Here is the script in case it helps someone else. There are instructions in the code comments.
https://pastebin.com/SmpNLidiThe 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.
Derek Melchin
Hi .ekz.,
Thanks for reporting the error with downloading the CSV from the Optimizer. We've forwarded the issue to our UX team.
Best,
Derek Melchin
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.
.ekz. INVESTOR
Follow-up nudge on this, Derek Melchin. Has the fix begun and/or is there a UI bug / ticket open somewhere that I can track?
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.
Varad Kabade
Hi .ekz.,
Unfortunately, the UX Team hasn't had the opportunity to address this issue yet. We don't have an open system to track UX issues and feature requests like this one, since, unlike Lean, the repo is private. Thank you for your patience.
Best,
Varad Kabade
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.
Jaan Sokk
Hi, quick ping… has this progressed?
Actually, I can't see a CSV downloat button at all currently. Should this be under Results? Or the separate optimization tab?
Thanks,
Jaan
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.
Varad Kabade
Hi Jaan Sokk,
Thank you for your patience. To download the optimization result in CSV format, right-click on the backtests; after the optimization is completed, you can see the export option to select CSV export. We have created a gif demonstrating the same
Best,
Varad Kabade
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.
MegaWattz
Hey, I dont see this feature available. Has it been disabled?
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.
Varad Kabade
Hi Zak Watts,
The feature is still available. Please check out the new docs for details. I created a gif showing how to export the optimization result after running the optimizer.
Best,
Varad Kabade
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!