Let's assume that I have a portfolio with two components:$$\omega_i = 0.3$$ $$\omega_j = 0.7$$
I also have two P&L vectors, $v_i$ and $v_j$ each containing 1000 P&Ls. I would like to play around with the weights and test out the VaR 95% at portfolio/total level. What would be the easiest and most intuitive approach (either in R or Python) if I wanted to extend this exercise to $n$ components instead of having only two?
Note that to find the portfolio P&L I am simply multiplying each P&L by each component's weight and then summing them together: $$PnL_t = \omega_i \times v_{i,t} + \omega_j \times v_{j,t}$$