INNER CODE UNIT · Python

prices_to_returns

dmarienko/QuantTradingResearch · models/helpers.py:27

def prices_to_returns(prices):
    return prices.pct_change()[1:] # drop first inf


def returns_to_prices(rets):
    return (rets + 1).cumprod() - 1


def norm(x):
    return x / x.iloc[0]


class Model:
    """
    Abstract class for any tracking models
    """
    def __init__(self, description=None):
        self.description = description

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…