It appears that QC stores fundamentals in `data\equity\{country}\fundamental\{fine | coarse}\{symbol}\{YYYYMMDD}.zip\{symbol}.json` with a specific JSON structure (Morningstar?). I've searched around and I don't believe there's a way of downloading fundamental data through Lean's CLI, but I can download them through my own means using IBKR's API through ib_insync. However it downloads in an XML format (Wall Street Events Horizon Calendar? Reuters? I don't know for sure where IB sources fundamentals from but I've read both). Even if I can get the data, it seems it only goes back a couple of years for the stock I'm interested in. I really just need to download a few stocks' worth of fundamentals in order to do local machine learning research.
I want to use QC's existing API for managing the retrieval of fundamental data (qb.GetFundamental for example) so that I don't need to change my script when it comes time to backtest/go live. In that respect I need to be able to save the fundamental data in Lean's expected format. Does anyone have a solution to my problem?
Fred Painchaud
Hi Jake,
You need to translate (by machine) the data you download (wherever it comes from) from its data format to LEAN's data format for fundamentals.
In Python, such translations are usually easy to program (I've done it tons and tons of times). You do need to understand the source format AND the target format, however, for things to run smoothly.
Once the translator script (assuming Python) is done, it would need to run on your machine, taking your downloaded data as input and spitting the same data in LEAN. Since we are talking about a mapping between one representation and another, some data in your source data might not find a spot in the output (format incompatibilities) and/or some data usually present in LEAN fundamentals might be missing (since it might be missing in the source data).
I did my best to make this explanation simple and easy to understand. Hope I succeeded.
I'm willing to freely help to code this translator, if needed, but I would need your source data and LEAN's fundamentals' format. Ideally, you work with specifications of both formats, if available. In practice, you can reverse-engineer both formats from the data itself, especially with verbose textual representations like XML and JSON… but it is then still more effort. In practice also, there are licenses to honor, especially the one that might comes with your downloaded data… so it might be against the license to translate the data and such.
Anyway. that's the gist of it.
Fred
Jake Mitchell
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!