r"""Calculate the Relative Strength Index (RSI). Parameters ---------- f : pandas.DataFrame Dataframe containing the column ``net``. c : str Name of the column in the dataframe ``f``. p : int The period over which to calculate the RSI. Returns --
(f, c, p = 14)
| 1161 | # |
| 1162 | |
| 1163 | def rsi(f, c, p = 14): |
| 1164 | r"""Calculate the Relative Strength Index (RSI). |
| 1165 | |
| 1166 | Parameters |
| 1167 | ---------- |
| 1168 | f : pandas.DataFrame |
| 1169 | Dataframe containing the column ``net``. |
| 1170 | c : str |
| 1171 | Name of the column in the dataframe ``f``. |
| 1172 | p : int |
| 1173 | The period over which to calculate the RSI. |
| 1174 | |
| 1175 | Returns |
| 1176 | ------- |
| 1177 | new_column : pandas.Series (float) |
| 1178 | The array containing the new feature. |
| 1179 | |
| 1180 | References |
| 1181 | ---------- |
| 1182 | *Developed by J. Welles Wilder, the Relative Strength Index (RSI) is a momentum |
| 1183 | oscillator that measures the speed and change of price movements* [SC_RSI]_. |
| 1184 | |
| 1185 | .. [SC_RSI] http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi |
| 1186 | |
| 1187 | """ |
| 1188 | cdiff = 'net' |
| 1189 | vexec(f, cdiff) |
| 1190 | f['pval'] = upc(f, cdiff) |
| 1191 | f['mval'] = dpc(f, cdiff) |
| 1192 | upcs = ma(f, 'pval', p) |
| 1193 | dpcs = ma(f, 'mval', p) |
| 1194 | new_column = 100 - (100 / (1 + (upcs / dpcs))) |
| 1195 | return new_column |
| 1196 | |
| 1197 | |
| 1198 | # |