is there a simple allocation and rebalance algo I can clone?
QUANTCONNECT COMMUNITY
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.
Michael H
Michael H
Jared Broad
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.
Brian Cahill
Thanks, this is what I was looking for
Jason Rock
I wrote rebalancer and I'm running in to an issues. Instead of liquidating and buy, the algo only buys and sells the quantity it needs. Even though I set the sell order first, the sell has not been fullfied when I execute the buy order. So, i get an error that I ran out of cash.
Any thoughts on how to solve this?
I was going to raise the on order event and buy after each sale (if there is enough cash).
Thanks you.
Jason Rock
I figure out my first issue. On market open orders were being sent. By the time I rebalancer, when I sent in buy orders, because the sell orders were not executed yet (market was not open), i received and insufficient capital error.
I used schedule.on to make the trade after market open.
My next issue is also insufficient capital error. The issue when I make a buy order is the system is checking if I have enough capital. I have enough cash to make the order but the check that is used is showing not enough capital is it ultimetly compares sum of price vs sum of average price. That difference is where the error occurs.
I'm setting leverage to 1.
Any help would be appreciated.
Kamer Ali Yüksel
Hello, how could I do hourly balance in the same way using Python?
Halldor Andersen
Hi Kamer.
You can rebalance hourly in the same way in Python:
# Define tickers self.symbols = ["IBM","AAPL","MSFT"] # Add securities for symbol in self.symbols: self.AddEquity(symbol,Resolution.Hour) def OnData(self, data): # Rebalance for symbol in self.symbols: self.SetHoldings(symbol, 1/len(self.symbols))
Alternatively, you can use the EqualWeightingPortfolioConstructionModel in the Algorithm Framework to rebalance your portfolio on an hourly basis, as I've done in the attached backtest.ÂKamer Ali Yüksel
Thanks!
DarieUrbanky2
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!