Skip to content

Commit

Permalink
tweak demo scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielGoldfarb committed Sep 27, 2021
1 parent 76c2c66 commit 7c7ed5a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
16 changes: 11 additions & 5 deletions examples/mpf_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 5,17 @@

df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:60]

# mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5)
# mpf.plot(df,figscale=1.5,type='candle',mav=(10,20))

import rsi
df['rsi'] = rsi.relative_strength(df['Close'],n=7)

apd = mpf.make_addplot(df['rsi'],panel=1,color='lime',ylim=(10,90),secondary_y=True)

mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,addplot=apd,style='checkers')

#mpf.plot(df,type='candle',figscale=1.5)

#df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:180]
#mpf.plot(df,type='renko',figscale=1.5)
#mpf.plot(df,type='pnf',figscale=1.5)

#mpf.plot(df,type='candle',figscale=1.5,mav=10)

mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5)
20 changes: 20 additions & 0 deletions examples/mpf_rsi_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 1,20 @@
import pandas as pd
import mplfinance as mpf

infile = 'data/yahoofinance-SPY-20200901-20210113.csv'

df = pd.read_csv(infile, index_col=0, parse_dates=True).iloc[0:60]

import rsi
df['rsi'] = rsi.relative_strength(df['Close'],n=7)

print(df.head())
print(df.tail())

apd = mpf.make_addplot(df['rsi'],panel=2,color='lime',ylim=(10,90),secondary_y=True)

mpf.plot(df,type='candle',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6))
mpf.plot(df,type='candle',style='charles',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6))
mpf.plot(df,type='candle',style='mike',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6))
mpf.plot(df,type='candle',style='checkers',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6))
mpf.plot(df,type='candle',style='yahoo',volume=True,mav=(10,20),figscale=1.5,addplot=apd,panel_ratios=(1,0.6))

0 comments on commit 7c7ed5a

Please sign in to comment.