Exemplo n.º 1
0
def get_min(df, window=20, complete_data=True):
    min = df.rolling(window).min()

    if complete_data:
        min = complete_missing_values(min)

    return min
Exemplo n.º 2
0
def get_sma(df, window=20, complete_data=True):
    df_sma = df.rolling(window).mean()

    if complete_data:
        return complete_missing_values(df_sma)

    return df_sma
Exemplo n.º 3
0
def get_volatility(df, window=20, complete_data=True):
    vol = df.rolling(window).std()

    if complete_data:
        vol = complete_missing_values(vol)

    return vol
Exemplo n.º 4
0
def get_max(df, window=20, complete_data=True):
    max = df.rolling(window).max()

    if complete_data:
        max = complete_missing_values(max)

    return max
Exemplo n.º 5
0
def get_moving_beta(df, ticker_base, window=20, complete_data=True):
    df_data = df.copy()
    cov = df_data.rolling(window=window).cov()
    cov = cov[ticker_base].unstack(level=1)

    benchmark = cov[[ticker_base]].copy()

    cov = cov.drop(ticker_base, 1)

    if complete_data:
        cov['moving beta'] = complete_missing_values(cov / benchmark.values)
    else:
        cov['moving beta'] = cov / benchmark.values

    return cov[['moving beta']]