I am trying to modify the function below so that it gives the expected output below. For the first calculation it go like 100+ 100*-87/100 = 13
with the equation NonC_Amount + Int_amount * np.cumprod(PnL / 100)
. Since -87 is the first element in the PnL, for the second calculation it will go as 13 + 100*--4/100 = 9
. the NonC_Amounts value is updated.
PnL = np.array([-87., -4., -34.1, 8.5]) Int_amount = 100 NonC_Amount = 100 PnL.prod(initial=Int_amount) NonCompounding =NonC_Amount + Int_amount * np.cumprod(PnL / 100)
Current Output:
[ 13, 103.48 , 98.81332, 99.8991322]
Expected Output:
[ 13, 9, -25.1, -16.6]
https://stackoverflow.com/questions/66094316/iteration-with-constants-and-other-variables-with-arrays-numpy-python February 08, 2021 at 07:48AM
没有评论:
发表评论