Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import pandas as pd
  2. from alpha_vantage.techindicators import TechIndicators
  3. import matplotlib.pyplot as plt
  4.  
  5. api_key = 'RNZPXZ6Q9FEFMEHM'
  6.  
  7. period = 60
  8.  
  9. ti = TechIndicators(key=api_key, output_format='pandas')
  10.  
  11. data_ti, meta_data_ti = ti.get_rsi(symbol='MSFT', interval='1min',
  12. time_period=period, series_type='close')
  13.  
  14. data_sma, meta_data_sma = ti.get_sma(symbol='MSFT', interval='1min',
  15. time_period=period, series_type='close')
  16.  
  17. df1 = data_sma.iloc[1::]
  18. df2 = data_ti
  19. df1.index = df2.index
  20.  
  21. fig, ax1 = plt.subplots()
  22. ax1.plot(df1, 'b-')
  23. ax2 = ax1.twinx()
  24. ax2.plot(df2, 'r.')
  25. plt.title("SMA & RSI graph")
  26. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement