Dear Team,
Until yesterday, I was able to access Yahoo Finance via the yFinance module while running in the Lean/CLI environment. However, since the update on Friday, February 21, attempting to access yFinance now results in the following exception:
20250222 07:32:56.361 ERROR:: Engine.Run(): During the algorithm initialization, the following exception has occurred:
Python.Runtime.PythonException: Too Many Requests. Rate limited. Try after a while.
I have the follwoing questions:
- Is this a bug or a planed behavior change?
- If this is a bug, is there any workaround or estimated timeline of the issue being resolved?
- If this is a planned behavior change, If it is a planned behavior change, I would like to note that there has been no communication regarding this update (as far as I am aware). Additionally, instead of terminating the program at runtime when trying to use yFinance to pull data, it would be more effective for the engine to handle this earlier, such as at the time of import. Real-time errors are challenging to debug proactively and make the entire CLI/Lean platform unreliable for serious deployment.
Thanks
Andy
Mia Alissi
Based on the available documentation and additional insights, here are some potential causes and solutions for the rate limitation issue with the yFinance module in QuantConnect:
Planned Behavior Change or Bug?
Handling the Rate Limitation:
RateGate
functionality to control request frequency. Alternatively, use QuantConnect'sAddData
method to integrate custom data providers, potentially bypassing the yFinance module.Effective Error Communication:
For practical implementation:
RateGate
class can help manage the rate at which your algorithm accesses APIs, adhering to the limits without triggering rate limitations.AddData
method for third-party APIs allows you to incorporate external data seamlessly, providing an alternative to direct API calls that might encounter restrictions.Reach out to QuantConnect support or forums if you need more clarification or are looking for a permanent solution from the platform.
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.
Kubid
The issue seems to be that yFinance 0.2.52 (currently packaged with qc/Lean) stopped working.
Can you guys please upgrade yFinance to 0.2.54?
Kubid
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!