Advertisement
Guest User

Untitled

a guest
Aug 1st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import pandas as pd
  2. pd.core.common.is_list_like = pd.api.types.is_list_like
  3.  
  4. from pandas_datareader import data as pdr
  5. import fix_yahoo_finance
  6. import matplotlib.pyplot as plt
  7.  
  8.  
  9.  
  10. #define each and everything to perform the operation
  11. #define each and everything to perform the operation
  12. def PPSR(data):
  13. PP = pd.Series((data['High'] + data['Low'] + data['Close']) / 3)
  14. R1 = pd.Series(2 * PP - data['Low'])
  15. S1 = pd.Series(2 * PP - data['High'])
  16. R2 = pd.Series(PP + data['High'] - data['Low'])
  17. S2 = pd.Series(PP - data['High'] + data['Low'])
  18. R3 = pd.Series(data['High'] + 2 * (PP - data['Low']))
  19. S3 = pd.Series(data['Low'] - 2 * (data['High'] - PP))
  20. psr = {'PP':PP, 'R1':R1, 'S1':S1, 'R2':R2, 'S2':S2, 'R3':R3, 'S3':S3}
  21. PSR = pd.DataFrame(psr)
  22. data= data.join(PSR)
  23. return data
  24. #extract the stock data
  25. data = pdr.get_data_yahoo("^NSEI", start="2017-01-01", end="2017-07-31")
  26. #compute and print the data
  27. LL=PPSR(data)
  28. print(LL)
  29. # plot the data
  30. pd.concat([data['Close'],PD.PP,PD.R1,PD.S1,PD.R2,PD.S2,PD.R3,PD.S3],axis=1).plot(figsize=(12,9),grid=True)
  31. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement