|
| 1 | +import pandas as pd |
| 2 | +import mplfinance as mpf |
| 3 | + |
| 4 | +infile = 'data/yahoofinance-SPY-20200901-20210113.csv' |
| 5 | + |
| 6 | +df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:60] |
| 7 | + |
| 8 | +import rsi |
| 9 | +df['rsi'] = rsi.relative_strength(df['Close'],n=7) |
| 10 | + |
| 11 | +print(df.head()) |
| 12 | +print(df.tail()) |
| 13 | + |
| 14 | +apd = mpf.make_addplot(df['rsi'],panel=2,color='lime',ylim=(10,90),secondary_y=True) |
| 15 | + |
| 16 | +mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6)) |
| 17 | +mpf.plot(df,type='candle',style='charles',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6)) |
| 18 | +mpf.plot(df,type='candle',style='mike',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6)) |
| 19 | +mpf.plot(df,type='candle',style='checkers',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6)) |
| 20 | +mpf.plot(df,type='candle',style='yahoo',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6)) |
0 commit comments