I need a way to add stocks and options in my universe by pulling most active stocks or other criteria into my algo
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.
Coming Soon: The Quant League team is onboarding universities, and we will officially launch soon.
I need a way to add stocks and options in my universe by pulling most active stocks or other criteri.. [discussion]
Continue ReadingCreate an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
||||||||
|
|
||||||||
|
How can I pull most active stocks from my alpaca paper trading account
Manoj Kandlikar | September 2024
I need a way to add stocks and options in my universe by pulling most active stocks or other criteria into my algo
QuantConnect™ 2025. All Rights Reserved
Mia Alissi
To add stocks and options to your universe based on criteria such as the most active stocks, you can use the
add_universe
andadd_universe_options
methods in QuantConnect. Here's a step-by-step guide to help you implement this in your algorithm:Step 1: Initialize Your Algorithm
Set up your algorithm with the necessary start and end dates, initial cash, and universe settings.
Step 2: Define Stock Selection Criteria
Create a selection function that filters stocks based on your criteria, such as daily dollar volume or P/E ratio.
Step 3: Add Options to Your Universe
Use the
add_universe_options
method to include options for the selected stocks.Step 4: Implement Data Handling
Use the
on_data
method to handle incoming data and manage your portfolio.Step 5: Respond to Universe Changes
Implement the
on_securities_changed
method to adjust your holdings based on changes in the universe.This setup will allow you to dynamically select stocks and options based on your specified criteria and manage your portfolio accordingly. Adjust the selection criteria and option filters as needed to align with your trading strategy.
Sources: Dropbox Base Data Universe Selection Algorithm, User Defined Universe Algorithm, Add Universe Selection Model Algorithm, Basic Template Options Filter Universe Algorithm, Fundamental Universe Selection Algorithm
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.
Alexandre Catarino
Hi Manoj Kandlikar ,
If Alpaca has a REST API that provides the list of stocks, you can use:
Parse current, which is a string, to the tickers, and call add_equity. You will have to remove the securities at some point too. Say that content is “SPY\nAAPL\nMSFT”, then
Best regards,
Alex
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!