def get_col_cal_index_df(col): col = mydb[col] rs = col.find() df = pd.DataFrame(list(rs)) if (len(df) >= 30): df['MA5'] = caltools.get_ma(df, 'MA5', 5) df['MA10'] = caltools.get_ma(df, 'MA10', 10) df['MA20'] = caltools.get_ma(df, 'MA20', 20) df['MA30'] = caltools.get_ma(df, 'MA30', 30) df['RSI6'] = caltools.get_rsi(df, 6) df['RSI12'] = caltools.get_rsi(df, 12) df['RSI24'] = caltools.get_rsi(df, 24) df['MTM'] = caltools.get_mom(df, 6) df_boll = caltools.get_boll(df) df['BOLL_UPPER'] = df_boll['upper'] df['BOLL_MIDDLE'] = df_boll['middle'] df['BOLL_LOWER'] = df_boll['lower'] return df.round(3)
def get_data_df(col): col = mydb[col] rs = col.find() # Expand the cursor and construct the DataFrame df = pd.DataFrame(list(rs)) if (len(df) >= 30): df['MA5'] = caltools.get_ma(df, 'MA5', 5) df['MA10'] = caltools.get_ma(df, 'MA10', 10) df['MA20'] = caltools.get_ma(df, 'MA20', 20) df['MA30'] = caltools.get_ma(df, 'MA30', 30) df['RSI6'] = caltools.get_rsi(df, 6) df['RSI12'] = caltools.get_rsi(df, 12) df['RSI24'] = caltools.get_rsi(df, 24) df['MTM'] = caltools.get_mom(df, 6) df_boll = caltools.get_boll(df) df['BOLL_UPPER'] = df_boll['upper'] df['BOLL_MIDDLE'] = df_boll['middle'] df['BOLL_LOWER'] = df_boll['lower'] return df