Hmm. not true, IMO. Proof: This gives a wrong result ec when sc is negative: sc=-200; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec -300.00000032494801157600 But when used with a positive sc it suddenly gives a correct result: sc=100; pp=10.668192; n=4; ec = sc * pow(1 + pp / 100, n) ; ec 150.00000016247400578800 sc is startcap, ec is endcap. The pp (ie. periodpercent) is from your previous example; it gives 50% after 4 periods (ie. n=4 above) [ie. after subtracting the initial 100%]. As you can see: using a negative value does not work (gives wrong result), and sometimes even impossible to calculate b/c logarithm of a negative value is mathematically undefined (that variant of the above formula is used when solving it for n). Btw, the above code is from the "bc" calculator under Linux.
First of all, use the same (in absolute value) starting point sc, otherwise, you won't be able to compare and understand what is going on. When debugging, the first rule is to make one change at a time. (I would advise you to use more meaningful names for your variables and round the printout to 2 decimal digits ) Second, why do you think the first result is wrong? (hint: have you noticed the negative interest in my previous table to "reduce debt" ?)
A dumb advise to a professional These are default settings of the calculator. It's just an external tool. B/c when PnL is positive (-200 to -100 means +100 profit), then consequently the PnL% has to be positive as well. Q.E.D. Such folks like you are just some hot-air talkers, nothing more.
Dear earth_imperator, I cannot see any wrong results in the output. All I can see, instead, is that the line of code: ec = sc * pow(1 + pp / 100, n) ; makes no sense whatsoever in your context. What do you think to achieve plugging a relative change into the formula for periodic interest? Which, further, in this case, is still wrong, as requires a negative interest with negative values? This is similar to computing the fall of bodies using the formula for uniform motion and also getting the wrong sign for the velocity vector. > A dumb advise to a professional > Such folks like you are just some hot-air talkers, nothing more. btw, before I respond to your ungrammatical insults towards a person helping you, are you an adult or a kid?
my suggestion was actually more akin to a thought experiment In case of doubts, one could simply take the function as a black box process (hence the need to have it from a reputable source), plug in a few positive and negative numbers, and confirm the correct application of the formula by looking at the output. I'm no quant, but I suppose that there are libraries available for any major language with all the basic financial functions. Heck, we are talking about the formula for calculating percent returns, not about an obscure stochastic volatility model..
I have negative interest ... in this topic. I'll be gone now, but not before asking where can I get one of those negative start capital trading accounts? I've got -$10,000 burning a hole in my pocket.
It's the value of an account deep in the reds, sometimes later, not in the beginning. It happens with short positions. As everybody should now: when shorting then even more than 100% loss is possible (ie. mathematically even < than -100%). Still, the account has to be calculated about its daily changes (absolute as well relative daily change). It's primarily about this task. But one can use it also for some more advanced calculations (portfolio calcs and margin calcs)
Do this simple "experiment". Use the formula improperly used by the OP: ec = sc * pow(1 + pp / 100, n) ; and run with the following settings: sc = 200 or sc=-200 and pp = -15.91 do it for n= 0,1,2,3,4.