Message Boards Message Boards


Multi-Asset Value at Risk?

Posted 10 years ago
0 Replies
5 Total Likes
I've been demonstrating how Wolfram Finance Platform could be used for Value at Risk (VaR) for a while now, but have only been showing single asset calculations like the following and then show EmpiricalDistribution, CombinedDistribution, etc..
InverseSurvivalFunction[EstimatedDistribution[FinancialData["AAPL", "Return", DatePlus[-365], "Value"],NormalDistribution[a, b]],0.95]

But that's quite boring, so I've looked around for a guide to portfolio VaR measurements and found this amongst other resources and built the following function:
  multiAssetVaR[stocks_List, weights_List, buyDate_List, 
   estDist_: NormalDistribution[](*If no other distribution specified, 
   normal assumed*), conf_: 0.95(*risk level, default 0.95*)] := 
  Module[{initialPrices, currentPrices, ratesOfReturn, rateWeights, 
    portRateOfReturn, stockReturns, varPortRateOfReturn, multiAssetVaR},  
   initialPrices = 
        FinancialData[#[[1]], "Price", {#[[2]]}, "Value"] &, {stocks, 
         buyDate} // Transpose]], weights}];  
  currentPrices = 
   Transpose[{ParallelMap[FinancialData[#, "Price"] &, stocks], 
  ratesOfReturn = 
   Map[(Times @@ #[[2]] - Times @@ #[[1]])/Times @@ #[[1]] &, 
    Transpose[{initialPrices, currentPrices}]];  
  rateWeights = 
   Map[Times @@ #/Total[Times @@@ currentPrices] &, currentPrices];  
  portRateOfReturn = Total[Times @@@ {rateWeights, ratesOfReturn}];  
  stockReturns = 
    FinancialData[#[[1]], "Return", {#[[2]], Date[]}, "Value"] &, 
    Transpose[{stocks, buyDate}]];  
  varPortRateOfReturn = 
  multiAssetVaR = (InverseSurvivalFunction[estDist, conf]*(-1))*

multiAssetVaR[{"LLOY.L", "BARC.L", "RBS.L"}, {2000, 1423, 1000}, {{2012, 11, 1}, {2012, 11, 1}, {2012, 11, 1}}]

I've only limited experience with actually applying financial models, could anyone advise whether what I've done is appropiate?

Comments on the code would also be appreciated, I used ParallelMap for FinancialData calls to reduce the lag in collecting data (my birthday was chosen for the purchase dates at DayOfWeek told me it was a Thursday) but have assumed parallelisation is not beneficial for the rest of the maps. Note that if I had a Bloomberg subscription myself then I'd use BloombergLink, but at the moment I just have FinancialData.
POSTED BY: Martin Hadley
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract