Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Portfolio allocation example with order target percent

Can anyone here show me example of how to allocate portfolio when cash is getting used up in each trade.Let's say I am trading three stocks namely
APPLE , GOOGLE and YAHOO with an initial trade size of 1,00,000 USD.If want to allocate 1/3 size to each stock also keeping in mind after each position I add the cash to trade will decrease.

Can anyone show some real examples of how they are doing portfolio when trading multiple stocks specifically using order_target_percent or order_percent methods

9 responses

It may be as simple as this

This is a good question. I had the same problem.

@Vladimir: Does this do reallocation when the value of a stock increases a lot?

P.S. OK, I see that it rebalances every month. Good! Thanks.

You may set up rebalancing as you want using schedule_function .
In my code it happens every day.

schedule_function(trade,date_rules.every_day(), time_rules.market_close(minutes=30))  

Hello Vladimir
How are you checking cash left gor next trade after each trade is taken.Also what if i choose the values of proportion as 1.33 , 1.33 , 1.33.Will the portfolio allocation be correct.

1.33 , 1.33 , 1.33. proportion means that you borrowed additional $300000 and leverage your account 4:1
Run Full Backtest, cash value plotted in custom data.

Can you show an example of that of how to run such a strategy using leverage

You ca do this yourself in cloned code.
But here it is.

Here's an example that we shared; it allocates 99% of your portfolio among 9 sector ETFs and leaves 1% as a cash buffer. This setting can be adjusted on line 32: https://www.quantopian.com/posts/rebalance-algo-9-sector-etfs

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.