I am trying to create multiple moving averages using TA-lib to loop through different securities.
I have this dataframe:
AAPL US Equity MSFT US Equity
date
2018-05-31 186.87 98.84
2018-06-01 190.24 100.79
2018-06-04 191.83 101.67
2018-06-05 193.31 102.19
2018-06-06 193.98 102.49
Require:
date AAPL US Equity MSFT US Equity AAPL SMA50 AAPL SMA200 MSFT SMA50
2018-05-31 186.87 98.84 .. .. ..
2018-06-01 190.24 100.79 .. .. ..
2018-06-04 191.83 101.67 .. .. ..
2018-06-05 193.31 102.19 .. .. ..
2018-06-06 193.98 102.49 .. .. ..
I have tried this link here which converts the dataframe but this does not work:
df.apply(lambda c: talib.EMA(c, 2))