# Load the necessary packages and modules
import pandas as pd

# Simple Moving Average 
def TY_SMA(data, ndays):
    SMA = pd.Series(data['close'].rolling(window =ndays).mean(), name = 'SMA' + str(ndays))
    data = data.join(SMA)
    return SMA

# Exponentially-weighted Moving Average 
def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False,span = ndays,min_periods = ndays-1,adjust=True).mean(),
    name = 'EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA

# Compute the Bollinger Bands 
def TY_BBANDS(data, ndays):

    MA = pd.Series(data['close'].rolling(window=ndays,center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays,center=False).std())

    b1 = MA + (2 * SD)
    B1 = pd.Series(b1, name = 'Upper BollingerBand')
    data = data.join(B1)

    b2 = MA - (2 * SD)
    B2 = pd.Series(b2, name = 'Lower BollingerBand')
    data = data.join(B2)

    return B1,B2

# Commodity Channel Index 
def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays,center=False).mean()) / (0.015 * TP.rolling(window= ndays,center=False).std()),
    name = 'CCI')
    data = data.join(CCI)
    return CCI

# Ease of Movement 
def TY_EVM(data, ndays):
    dm = ((data['high'] + data['low'])/2) - ((data['high'].shift(1) + data['low'].shift(1))/2)
    br = (data['volume'] / 100000000) / ((data['high'] - data['low']))
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window = ndays, center = False).mean(), name = 'EVM')
    data = data.join(EVM_MA)
    return EVM_MA

# Force Index 
def TY_ForceIndex(data, ndays):
    FI = pd.Series(data['close'].diff(ndays) * data['volume'], name = 'ForceIndex')
    data = data.join(FI)
    return FI

# Rate of Change (ROC)
def TY_ROC(data,ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N/D,name='Rate of Change')
    data = data.join(ROC)
    return ROC


fab2c9c9cc8d109af5a5074c2441cc25df1d09fd
<mask token>


def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False, span=ndays,
        min_periods=ndays - 1, adjust=True).mean(), name='EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA


def TY_BBANDS(data, ndays):
    MA = pd.Series(data['close'].rolling(window=ndays, center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays, center=False).std())
    b1 = MA + 2 * SD
    B1 = pd.Series(b1, name='Upper BollingerBand')
    data = data.join(B1)
    b2 = MA - 2 * SD
    B2 = pd.Series(b2, name='Lower BollingerBand')
    data = data.join(B2)
    return B1, B2


def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays, center=False).mean()) /
        (0.015 * TP.rolling(window=ndays, center=False).std()), name='CCI')
    data = data.join(CCI)
    return CCI


def TY_EVM(data, ndays):
    dm = (data['high'] + data['low']) / 2 - (data['high'].shift(1) + data[
        'low'].shift(1)) / 2
    br = data['volume'] / 100000000 / (data['high'] - data['low'])
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window=ndays, center=False).mean(), name
        ='EVM')
    data = data.join(EVM_MA)
    return EVM_MA


<mask token>


def TY_ROC(data, ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N / D, name='Rate of Change')
    data = data.join(ROC)
    return ROC

<mask token>


def TY_SMA(data, ndays):
    SMA = pd.Series(data['close'].rolling(window=ndays).mean(), name='SMA' +
        str(ndays))
    data = data.join(SMA)
    return SMA


def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False, span=ndays,
        min_periods=ndays - 1, adjust=True).mean(), name='EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA


def TY_BBANDS(data, ndays):
    MA = pd.Series(data['close'].rolling(window=ndays, center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays, center=False).std())
    b1 = MA + 2 * SD
    B1 = pd.Series(b1, name='Upper BollingerBand')
    data = data.join(B1)
    b2 = MA - 2 * SD
    B2 = pd.Series(b2, name='Lower BollingerBand')
    data = data.join(B2)
    return B1, B2


def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays, center=False).mean()) /
        (0.015 * TP.rolling(window=ndays, center=False).std()), name='CCI')
    data = data.join(CCI)
    return CCI


def TY_EVM(data, ndays):
    dm = (data['high'] + data['low']) / 2 - (data['high'].shift(1) + data[
        'low'].shift(1)) / 2
    br = data['volume'] / 100000000 / (data['high'] - data['low'])
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window=ndays, center=False).mean(), name
        ='EVM')
    data = data.join(EVM_MA)
    return EVM_MA


<mask token>


def TY_ROC(data, ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N / D, name='Rate of Change')
    data = data.join(ROC)
    return ROC

<mask token>


def TY_SMA(data, ndays):
    SMA = pd.Series(data['close'].rolling(window=ndays).mean(), name='SMA' +
        str(ndays))
    data = data.join(SMA)
    return SMA


def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False, span=ndays,
        min_periods=ndays - 1, adjust=True).mean(), name='EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA


def TY_BBANDS(data, ndays):
    MA = pd.Series(data['close'].rolling(window=ndays, center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays, center=False).std())
    b1 = MA + 2 * SD
    B1 = pd.Series(b1, name='Upper BollingerBand')
    data = data.join(B1)
    b2 = MA - 2 * SD
    B2 = pd.Series(b2, name='Lower BollingerBand')
    data = data.join(B2)
    return B1, B2


def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays, center=False).mean()) /
        (0.015 * TP.rolling(window=ndays, center=False).std()), name='CCI')
    data = data.join(CCI)
    return CCI


def TY_EVM(data, ndays):
    dm = (data['high'] + data['low']) / 2 - (data['high'].shift(1) + data[
        'low'].shift(1)) / 2
    br = data['volume'] / 100000000 / (data['high'] - data['low'])
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window=ndays, center=False).mean(), name
        ='EVM')
    data = data.join(EVM_MA)
    return EVM_MA


def TY_ForceIndex(data, ndays):
    FI = pd.Series(data['close'].diff(ndays) * data['volume'], name=
        'ForceIndex')
    data = data.join(FI)
    return FI


def TY_ROC(data, ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N / D, name='Rate of Change')
    data = data.join(ROC)
    return ROC

import pandas as pd


def TY_SMA(data, ndays):
    SMA = pd.Series(data['close'].rolling(window=ndays).mean(), name='SMA' +
        str(ndays))
    data = data.join(SMA)
    return SMA


def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False, span=ndays,
        min_periods=ndays - 1, adjust=True).mean(), name='EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA


def TY_BBANDS(data, ndays):
    MA = pd.Series(data['close'].rolling(window=ndays, center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays, center=False).std())
    b1 = MA + 2 * SD
    B1 = pd.Series(b1, name='Upper BollingerBand')
    data = data.join(B1)
    b2 = MA - 2 * SD
    B2 = pd.Series(b2, name='Lower BollingerBand')
    data = data.join(B2)
    return B1, B2


def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays, center=False).mean()) /
        (0.015 * TP.rolling(window=ndays, center=False).std()), name='CCI')
    data = data.join(CCI)
    return CCI


def TY_EVM(data, ndays):
    dm = (data['high'] + data['low']) / 2 - (data['high'].shift(1) + data[
        'low'].shift(1)) / 2
    br = data['volume'] / 100000000 / (data['high'] - data['low'])
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window=ndays, center=False).mean(), name
        ='EVM')
    data = data.join(EVM_MA)
    return EVM_MA


def TY_ForceIndex(data, ndays):
    FI = pd.Series(data['close'].diff(ndays) * data['volume'], name=
        'ForceIndex')
    data = data.join(FI)
    return FI


def TY_ROC(data, ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N / D, name='Rate of Change')
    data = data.join(ROC)
    return ROC

# Load the necessary packages and modules
import pandas as pd

# Simple Moving Average 
def TY_SMA(data, ndays):
    SMA = pd.Series(data['close'].rolling(window =ndays).mean(), name = 'SMA' + str(ndays))
    data = data.join(SMA)
    return SMA

# Exponentially-weighted Moving Average 
def TY_EWMA(data, ndays):
    EMA = pd.Series(data['close'].ewm(ignore_na=False,span = ndays,min_periods = ndays-1,adjust=True).mean(),
    name = 'EWMA_' + str(ndays))
    data = data.join(EMA)
    return EMA

# Compute the Bollinger Bands 
def TY_BBANDS(data, ndays):

    MA = pd.Series(data['close'].rolling(window=ndays,center=False).mean())
    SD = pd.Series(data['close'].rolling(window=ndays,center=False).std())

    b1 = MA + (2 * SD)
    B1 = pd.Series(b1, name = 'Upper BollingerBand')
    data = data.join(B1)

    b2 = MA - (2 * SD)
    B2 = pd.Series(b2, name = 'Lower BollingerBand')
    data = data.join(B2)

    return B1,B2

# Commodity Channel Index 
def TY_CCI(data, ndays):
    TP = (data['high'] + data['low'] + data['close']) / 3
    CCI = pd.Series((TP - TP.rolling(window=ndays,center=False).mean()) / (0.015 * TP.rolling(window= ndays,center=False).std()),
    name = 'CCI')
    data = data.join(CCI)
    return CCI

# Ease of Movement 
def TY_EVM(data, ndays):
    dm = ((data['high'] + data['low'])/2) - ((data['high'].shift(1) + data['low'].shift(1))/2)
    br = (data['volume'] / 100000000) / ((data['high'] - data['low']))
    EVM = dm / br
    EVM_MA = pd.Series(EVM.rolling(window = ndays, center = False).mean(), name = 'EVM')
    data = data.join(EVM_MA)
    return EVM_MA

# Force Index 
def TY_ForceIndex(data, ndays):
    FI = pd.Series(data['close'].diff(ndays) * data['volume'], name = 'ForceIndex')
    data = data.join(FI)
    return FI

# Rate of Change (ROC)
def TY_ROC(data,ndays):
    N = data['close'].diff(ndays)
    D = data['close'].shift(ndays)
    ROC = pd.Series(N/D,name='Rate of Change')
    data = data.join(ROC)
    return ROC

