Back

Simple Asset Allocation and Rebalance

is there a simple allocation and rebalance algo I can clone?
Update Backtest








Not that I'm aware of. I believe the concept is very similar to a rotation strategy. You develop a specific objective value function and based on the values, rebalance your holdings. I've attached the Global Rotation strategy I put together the other day. It's pretty simple, but the concept is there. I think you'll want to update how holdings are set, and instead of allocating all cash to a single stock, call SetHolding(symbol, percentage) on each stock you have with a percentage you derive from some objective value function. That's the hard part... coming up with a good function!

I hope this helps!
0

So it seems either my browser or the QuantConnect server is not enjoying me at the moment. Seems I've made duplicate comments and have been unsuccessful in attaching a project. I'll try once more, if not, you can find the Global Rotation algorithm in the Recent bar when in the Backtester.
1

Welcome @DarieUrbanky2 - here's the simplest implementation of a rebalancer adjusting every Monday. At the moment it liquidates each week so it would need some more intelligence to be more efficient - i.e. First sell off items before buying stock so only use 1.0 margin and don't run out of cash.

SetHoldings() by default uses the buying power of the algorithm (so including any margin), so in this example the first purchases total value is $50k exactly (on a $25k account).
0

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.


Thanks, this is what I was looking for

0

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.

0

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.

0

Update Backtest





0

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.


Loading...

This discussion is closed