Open KikeM opened 4 years ago
Hi,
Great job you have done here.
I have realized that the methods to_price_index and to_returns have a round-trip problem.
to_price_index
to_returns
It is due to the fact that to_price_index is not including the start parameter it takes as an argument in the first value of the returned prices.
start
import ffn import numpy as np ffn.extend_pandas() ret_ss = pd.Series(np.random.randn(100)) prices_ss = ret_ss.to_price_index(start = 100) ret_ss.head() # 0 -0.934990 # 1 -0.017586 # 2 -0.116771 # 3 -0.474929 # 4 0.566763 # dtype: float64 prices_ss.head() # 0 6.500992 # 1 6.386665 # 2 5.640886 # 3 2.961868 # 4 4.640544 # dtype: float64 # The first value is using the first return, it is not start! assert prices_ss[0] == (100 * (ret_ss[0] + 1)) # No round trip prices_ss.to_returns().head() # 0 NaN # 1 -0.017586 # 2 -0.116771 # 3 -0.474929 # 4 0.566763 # dtype: float64
Hi,
Great job you have done here.
I have realized that the methods
to_price_index
andto_returns
have a round-trip problem.It is due to the fact that
to_price_index
is not including thestart
parameter it takes as an argument in the first value of the returned prices.Minimal working example