Missing values problem while submitting

Hello ,

I have an issue in the final step with the function : testGlobalAllocationSubmission(portAllocation)


Error in value[3L]: Payout cannot be evaluated when certain data points are missing. Please ensure your payout function is able to handle NaN values (e.g. using fillna or dropna). If necessary, run portfolio.createMissingData(portfolioObject) to simulate missing data points inside returnsMatrix and features@pxs attributes.


Can’t submitt my strategy because of some missing values.

How can i solve this problem ?


Thank you !!

Hello,


Can you have a look at this forum post and see if it resolves your issue? It should be related to the user Petitfort’s comment.


Alphien Dashboard

Thank you !


Hello,

I tried all instructions and it works well with the EW payout. But for the GMV Payout i got another error while executing my code (The same payout GMV proposed by M. Clauss in the last publication). Here is it :



myPayout_GMV = function(features)

{

 df = getTickersGlobalAllocationChallenge()

 bbLive = subset(features, tickers=df[df$field==“bb live”, “ticker”], fields=“bb_live”)

 bbLive = bbLive@pxs

   

 # Covariance matrix

 n <- ncol(bbLive)

 T <- nrow(bbLive)

 e <- rep(1, n)

 returns <- matrix(0, T, n)

 for (j in 1:n) returns[, j] <- Delt(bbLive[, j], type = ‘arithmetic’)

 Sigma <- cov(returns[2:T,]) * (T - 1) / (T - n - 2)


 # Empirical constrained GMV with no short selling and a maximum weight of 0.2 by asset

 # min(-d^T b + 1/2 b^T D b) with the constraints A^T b >= b_0


 dvec <- numeric(n)


 # Constraints of sum of the weights equal to 1 and weights between 0 and 0.2

 Amat <- cbind(e, diag(1, n, n), -diag(1, n, n))

 bvec <- cbind(1, t(numeric(n)), t(rep(-0.2, n)))

 omega <- solve.QP(Sigma, dvec, Amat, bvec, meq = 1)$solution

 signal = xts(x = matrix(0, nrow(bbLive), ncol(bbLive)), order.by = index(bbLive))


 for(i in 1:T) signal[i, ] = omega

 colnames(signal) = df[df$field==“bb live”, “ticker”]

 return(signal)

}



# recreate object using this

portAllocation = portfolio(as.list(allocation[allocation$field==“bb live”, “ticker”]))

# payout only added after above line is ran

portAllocation = payout(portAllocation, myPayout_GMV)

portAllocation = eval(portAllocation, zoom=“2004::2015”)

backtest(portAllocation, tc=0.01, rebalancePenalty=0.02, rebalancePenaltyPerAsset=FALSE)


portTest = portfolio.createMissingData(portAllocation)

head(portTest@features@pxs)

portTest = eval(portTest)

head(portTest@weightsMatrix)

head(portTest@returnsMatrix)







Error in solve.QP(Sigma, dvec, Amat, bvec, meq = 1): NA/NaN/Inf in foreign function call (arg 1)

This looks like the payout is failing when there is missing data. You will have to debug the payout function itself as the below doesnt work.


myPayout_GMV(portTest@features)


Please note that your payout function is returning an allocation for each of the underlying asset, on of the requirement of a payout is that it shouldn’t have any “NA”, if you have as an output a “NA”, then while the strategy is being tested we do not know the allocation to put of NA. Please refer to the documentation :


Alphien Dashboard


for more explanation on a payout. A payout output should be valid allocation for every single day (in whatever manner you are getting to the allocation).


I hope that helps and clarifies. Thanks.