(Sep-23-2022, 06:46 PM)LFin Wrote: I totally understand and I did it, exactly what you wrote in the first time but as I am going to use different weights (w1, w2...) for each assets and The computation of my last formula (Base * (1 + return1*w1 + return2*w2...) I think I need to separate them...
Maybe you should try it again. I can't see any advantages of having separate variables/names compared to list/tuple/dictionary approach. You can access both by name and in container they become iterable in case you need to access them dynamically:
>>> weights = (0.2, 0.3, 0.4) >>> weights[0] 0.2 >>> for weight in weights: ... print(weight) ... 0.2 0.3 0.4 >>> weights = {1: 0.2, 2: 0.3, 4: 0.4} >>> weights[2] 0.3You should also think about future self. If you return to your code in two days/weeks/months do you remember what tickers_3 / return_3 were? Was it AMZN or APPL?
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.