3 ms·
I don't really know anything about this, and I'm finding the code written hard to understand (what language is this?). If I would have to guess, you need to ad
by gcp 15y ago
I don't really know anything about this, and I'm finding the code written hard to understand (what language is this?).
If I would have to guess, you need to add var amazon = (foo, bar), adjust myreturns and myrisks to calculate over 3 arguments (or generalize them). Then modify the maps to map over 2 variables instead of one (like nested loops). The allocation is the x,y in sharpes() that gave sharpes.max, though I have no idea how to get that out of this language.
Edit: Ok, so you need to define another rho, and the problem is that a) not all mappings over x,y (0->1) are valid allocations a) the stocks are discrete. So that's where the combinatorics come in, as you need to consider all possible combinations of allocating 100 dollars over 3 stocks, and then map over that instead. I'd have absolutely no idea how to express that in this language.
Also, what are the stock prices? Google, Amazon and Apple all trade at >100USD/share. You can't buy fractional shares, can you?
PS. One thing I like in this approach is that you're requested to understand code that's already written. This is what happens in real life, too.