Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello community,
I have a portfolio with a lot of stocks: I'd like to use the scalar product function to calculate the return:
| Stock | Weighting | Return |
|---|---|---|
| Daimler | 30% | 17.6% |
| Siemens | 20% | 14,2% |
| Apple | 50% | 19.2% |
Expected Return = 30% * 17,6% + 20% * 14,2% + 50% * 19,2% = 17,72%
Does the scalar product function exists?
And the product function
Product(Weighting) = 30%*20%*50%=3%
=exp(Sum(Log(Weighting)))
Scalar product: =Sum(Weighting * Return)
There is no simple function for the product of an arbitrary list, I will have to think about how to implement that.
You could do it iteratively during load for a static version:
LOAD Id,
WeightFactor,
WeightFactor * Alt(Peek(ProductWeighting), 1) As ProductWeighting,
...
But this will not be suitable if the list to be used for the product is subject to users selections (dynamic version).
=exp(Sum(Log(Weighting)))
thought that would be easier to have that scalar function, but as u said i think i have to implement mysself that function
Brilliant! Why didn't I think of that!