quantopy.ReturnSeries.from_price¶
- classmethod ReturnSeries.from_price(price)[source]¶
Generate a new ReturnSeries with simple returns from given prices.
- Parameters
- pricearray-like or Iterable
Contains price stored in Series.
- Returns
- ReturnSeries
A new ReturnSeries object with simple returns for the given price series.
See also
ReturnDataFrame.from_priceAnalogous function for ReturnDataFrame.
Examples
>>> qp.ReturnSeries.from_price([10, 15, 20]) 1 0.500000 2 0.333333 dtype: float64
>>> qp.ReturnSeries.from_price(np.array([10, 15, 20])) 1 0.500000 2 0.333333 dtype: float64
>>> qp.ReturnSeries.from_price(pd.Series([10, 15, 20])) 1 0.500000 2 0.333333 dtype: float64