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 COMMUNITY
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?
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.
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.
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
.ekz.
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/SmpNLidiDerek 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.
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?
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
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
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
MegaWattz
Hey, I dont see this feature available. Has it been disabled?
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
.ekz.
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!