Click here to Login





                                                   monthly rebalancing

  0

0
ivanf
2017-07-15 21:55:06


HI All,

I'm developing a simple strategy which ranks on sharpe and re balances monthly

here is some of the code
+++++++++++++++
rank1 = comp(sharpe(close,period), "rank"); // We optimized here the sharpe period

SetSimLongRank(-rank1);
buy = 1;
sell = month() != ref(month(),-1);

++++++++++++++

In the simulator this appears to work , however when I use the strat in a portfolio, after filling the initial 5 positions, when I run a get signals update, it immediately wants to sell these 5 and buy
the next 5 even though the month hasn't changed ( in fact the day is still the same)

If I change the -1 to just 1 , then the portfolio seems to behave itself, but the simulator shows its not buying on the first trading day of the new month , but a couple of trading days into the new month

Just wondering if I'm doing something obviously wrong to make the portfolio want to keep buying and selling the top 10 stocks ( its a 5 posn strat) everytime I hit the get signals button



thanks
Ivan



QuantShare
2017-07-16 08:02:33

  0

ref(xx, -1) should not be used in a portfolio because it references future bars.
What you need to do is just click on the get signals button at the end of each month.



ivanf
2017-07-17 21:57:53

  0

ok thanks , I will run manually on the first trading day of each month

can you suggest some code that I could put it so in the portfolio so it only generates the buy and sell orders it actually needs to perform for the rebalance ?

ie in the simulation, it sells all symbols each month and repurchases the ones that still fit the ranking plus new symbols if required, what I would actually like to see is that it only sells the ones that fall outside the ranking and purchases the new ones that fulfill the ranking.

thanks





QuantShare
2017-07-18 06:31:14

  0

You need to use the "rank1" variable in the buy/sell rules.
Example:
sell = rank1 < 10; // Sell a stock if its rank drop below 10



Amritendu Maji
2017-07-18 16:03:12

  0

sellRule1 = month() != ref(month(),-1);
sellRule2 = rank1 < 10; // Sell a stock if its rank drop below 10

sell = sellRule1 && sellRule2; // Sell when both conditions are met

I think the above may meet your requirements.

Good luck,
Maji



ivanf
2017-07-19 01:08:24

  0

thanks for the help on the code , I will implement and take a look at the results


No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
Monthly individual stocks put and call volume
Custom Trading System Rebalancing
Asset Allocation: Equal Weight Rebalanced Monthly
Equal Volatility Sizing
Leading Index for the United States

How-to Lessons
Difference between the watchlist and the screener tools
How to quickly add a ticker symbol
How to plot two different time frames in the same chart
How to download historical quotes of indices
How to plot the number of stock tweets per day

Related Forum Threads
Rebalancing quarterly
Print daily equity with monthly timeframe
Long/short portfolio rebalancing
Mixing Daily and Monthly (or weekly) data
Rebalancing weekly/monthly/quarterly

Blog Posts
QuantShare Trading Software: New Features in the 3.4.0 Version
Short Index - Part 1
QuantShare Trading Software: New Features in the 3.4.2 Version
How to Create Your First Meta-Strategy
Advanced Tactical Asset Allocation Strategies









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.