Global allocation - disappearing assets/robustness

Answered
141
9
created on 2021-01-22 17:42:30

Comments (9)

Yongcheng · 1 month ago

Hello,


Thanks for your question. For this current challenge, the answer is no, you do not have to rebalance between the dates. You can set a weight once (as long as its tradable when you decide to hold) and hold it for as long as you want.


Hope this answers your question

Indira · 1 month ago

Thank you!

Petitfort · 1 month ago
I have a similar problem, the stress test expect an allocation on the date "2004-01-10", so i insert one weight manually?
Error in portfolio.stressTestCheckReturnsStartDate(strat = stratNew, expectedStartDate = "2004-01-10"): Please ensure the returns are generated from: 2004-01-10 . You might be assigning weights to assets that are non tradable (0 or NA returns). Please have a look at the portfolioObject@returnsMatrix slot to check the assets with 0 returns and compare them with your portfolio@weightsMatrix slot.
Traceback:

1. testGlobalAllocationSubmission(portAllocation)
2. portfolio.stressTestCheckReturnsStartDate(strat = stratNew, expectedStartDate = "2004-01-10")
3. stop(paste("Please ensure the returns are generated from:", expectedStartDate, 
 .     ". You might be assigning weights to assets that are non tradable (0 or NA returns). Please have a look at the portfolioObject@returnsMatrix slot to check the assets with 0 returns and compare them with your portfolio@weightsMatrix slot."))


Yongcheng · 1 month ago

Hello,


The test is expecting returns on that date. You might have assigned weights before this date but there might not be returns because the assets that you assigned weights to is not tradable. You can try to following to replicate this


# simulate missing data
port = portfolio.createMissingData(port)
# rerun payout on missing data
port = eval(port)
# check weights
head(port@weightsMatrix)
# check asset returns (no weights should be assigned to assets with NA returns)
head(port@returnsMatrix)


Hope this clarifies it!

Petitfort · 1 month ago

Hello Yongcheng,


The above method add some strange weights for me: (even négative ones and NA)


                     DM SP NQ         VG            Z          SMix
2003-01-01           NA NA NA         NA            NA           NA
2003-01-02  0.031208701 NA NA  0.0542797  0.0203246990  0.000000000
2003-01-03  0.001513199 NA NA -0.0051485 -0.0022550992  0.057971000
2003-01-06  0.015457901 NA NA  0.0222930 -0.0007534004 -0.001431199
2003-01-07  0.001487899 NA NA -0.0144081 -0.0108067004 -0.007780501
2003-01-08 -0.019085700 NA NA -0.0276571 -0.0091462999  0.002269900
                      NX HI          KM XP            TU FV TY         US RX G 
2003-01-01            NA NA          NA NA            NA NA NA         NA NA NA
2003-01-02  0.0269794695 NA  0.01194969 NA -0.0035579001 NA NA -0.0224626 NA NA
2003-01-03  0.0005711003 NA  0.03791175 NA  0.0001456998 NA NA  0.0011348 NA NA
2003-01-06  0.0074200895 NA  0.01317365 NA -0.0005100001 NA NA -0.0022669 NA NA
2003-01-07 -0.0249291798 NA -0.02600473 NA  0.0010934999 NA NA  0.0028401 NA NA
2003-01-08 -0.0156885509 NA  0.00242718 NA  0.0012379007 NA NA  0.0062305 NA NA
                      JB XM           GC
2003-01-01            NA NA           NA
2003-01-02  0.000000e+00 NA -0.004871062
2003-01-03  0.000000e+00 NA  0.014684713
2003-01-06 -4.223603e-04 NA  0.001418839
2003-01-07 -7.042012e-05 NA -0.012468122
2003-01-08  5.634203e-04 NA  0.018938312


Maybe i just give the daily weights matrix even they are the same? This will not add my trading cost?

Yongcheng · 1 month ago

Hello,


I think you are looking at returns for the above. Weights should be in the portfolio@weightsMatrix slot. Giving the daily weights matrix will mean that you're rebalancing daily so it will add to your rebalancing cost.

Petitfort · 1 month ago
Thank you Yongcheng, my problem is the same as indira. I assigned a weight before 2014-1-10 and the asset become not tradable on 2004-01-10 and probably tradable again after. However the code is blocked for the stress test which expect returns for all the assets for the date 2004-01-10. If i change the weight to another asset then it changed the strategy it self.


Indira · 1 month ago

Hi, Petitfort. I do not have a problem, I only clarified the rules.

Petitfort · 1 month ago

Hi Indira, yes thank you for your clarification, it helps me to identify my problem in fact.