def correlation(price_x, price_y, periods=252): rx = roc(price_x, 1) / 100 ry = roc(price_y, 1) / 100 # print(rx) # print(ry) return covariance(rx, ry, periods) / (std(ry, periods) * std(rx, periods))
def trix(series: NdType, periods: tp.Any = 18) -> NdType: ma = tema(series, periods) return roc(ma, 1)
def beta(price_x, price_y, periods=252): rx = roc(price_x, 1) / 100 ry = roc(price_y, 1) / 100 return covariance(rx, ry, periods) / variance(ry, periods)