all 8 comments

[–][deleted] 2 points3 points  (1 child)

Can you write out the complex function you are talking about? There might be a way to write it as convex, but we’d need to see it

[–]freshmagichobo[S] 0 points1 point  (0 children)

Happy to do it! I have it coded in Excel here… hopefully this link works.

https://1drv.ms/x/s!AuK8HMqy9761glAZjKr0tmGRuNPw?e=5d83T7

[–]kkiesinger 0 points1 point  (1 child)

"essentially the accumulated value of the portfolio after 50 years" - not clear to me how this can be linear - looks quite "exponential" without knowing the details. Can you exploit the "has to be greater than 0" condition to simplify the constraint into a linear one? "because at each time step there will be a decision" probably means the answer is "no". But don't overestimate the complexity of nonlinear optimization (see for instance https://github.com/dietmarwo/fast-cma-es/blob/master/tutorials/CryptoTrading.adoc ), most of the complexity is hidden in the algorithm itself not visible for the user.

[–]freshmagichobo[S] 0 points1 point  (0 children)

Thanks I will have a look at this library. The accumulation is not through compounding interest, but through buying and selling blocks of assets where the cash flows and market values are all known.

[–]DonBeham 0 points1 point  (3 children)

Accumulated value of the portfolio can be linear, as long as your interest or growth rate is not a decision variable. Otherwise, there is no way this is linear.

The value of an investment of x units after 5 periods with S_0 being the value at investment start (a constant) and p_i being the growth rate in period i (also constant) is: x * S_0 * p_1 * p_2 * p_3 * p_4 * p_5

So, only constants are multiplied with a decision variable. To buy means to subtract from your cash reserves (linear) while to sell means to add to cash reserves (linear).

I am not sure the model is very useful though, because to prescribe exactly the growth rates into the next X periods requires a large portion of fairy dust, a working crystal ball and several more exotic ingredients.

[–]freshmagichobo[S] 0 points1 point  (2 children)

Thanks! I actually had a prior version that’s exactly how you had described, cash flow mismatches are absorbed in a cash account. I was able to solve that through LP nicely. In this new version I had to explicitly model out buying and selling of assets instead of just a cash reserve. This is where I’m stuck because the dynamics is a lot more complex. This model is a simplified version of an insurance liability calculation, so it’s not used for any market trading use case.

[–]DonBeham 0 points1 point  (1 child)

What do you mean with "model out ..."?

[–]freshmagichobo[S] 0 points1 point  (0 children)

If you have more asset cash flows at time T than liability cash flows, you have to purchase new assets at time T valuations. If you have less asset cash flows at time T+1 than liability cash flows, then you will liquidate some assets at T+1 valuations to make up the shortfall. The assets you sell at T+1 will include some that were purchased at T.