Hi all,
New user here from Quantipian. I was wnating to load 8 different securities as part of my portfolio.
Over at Quantopian, I am used to doing the following.
def initialize(context):
set_symbol_lookup_date('2015-01-01')
context.equities = symbols(
# Equity
'VV', # US large cap
'VO', # US mid cap
'VB', # US small cap
)
context.fixedincome = symbols(
# Fixed income
'TLT', # Long-term government bond
'IEF', # Mid-term government bond
'LQD', # Corporate bond
)
context.realasset = symbols(
# Commodity and REIT
'GLD', # Gold
'VNQ', # US REIT
)
context.securities = context.equities + context.fixedincome + context.realasset
context.period = 252 # One year to evaluate past performance
context.lever = 2.0 # Leverage
context.allocation_intervals = 10 # Allocation intervals (100% / 10 = 10% increment)
context.weights = dict.fromkeys(context.securities, 0)
context.shares = dict.fromkeys(context.securities, 0)
Is there no one function that lets me load all 8 ETFs? Additionally, I am wanting to set the leverage level for the portfolio at 2x. Is there something in QuantConnect that is similar to the "context.level = 2.0" line from Quantopian?
Thank you in advance :)
Flame
def Initialize(self): self.equity = ['VV', 'VO', 'VB'] self.fixedincome = ['TLT', 'IEF','LQD'] self.realasset = ['GLD', 'VNQ'] self.etfs = self.equity + self.fixedincome + self.realasset for etf in self.etfs: self.AddEquity(etf)
Something like this should work for adding the securities
Michael Manus
hi, the leverage discussion is quite new and 5 posts below your post :) (when you sort it by "Newest")
if you have time check the bootcamp (tab) inside the algorithm lab first
second would be check the multiple examples provided by the quantconnect team starting with this one: loading multiple assets using consolidator and indicator with rolling window
so you can learn whats a rolling window in the docu and how to use indicator and that stuff.....(read the documentation)
Ethan Scott
Jonathan's code should do the trick!
Hassan K
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!