Guest User

Untitled

a guest
Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import pandas as pd
  2.  
  3.  
  4. class StockPrices:
  5. # param prices dict of string to list. A dictionary containing the tickers of the stocks, and each tickers daily prices.
  6. # returns list of strings. A list containing the tickers of the two most correlated stocks.
  7. @staticmethod
  8. def most_corr(prices):
  9. return
  10.  
  11. #For example, with the parameters below the function should return ['FB', 'MSFT'].
  12. prices = {
  13. 'GOOG' : [
  14. 742.66, 738.40, 738.22, 741.16,
  15. 739.98, 747.28, 746.22, 741.80,
  16. 745.33, 741.29, 742.83, 750.50
  17. ],
  18. 'FB' : [
  19. 108.40, 107.92, 109.64, 112.22,
  20. 109.57, 113.82, 114.03, 112.24,
  21. 114.68, 112.92, 113.28, 115.40
  22. ],
  23. 'MSFT' : [
  24. 55.40, 54.63, 54.98, 55.88,
  25. 54.12, 59.16, 58.14, 55.97,
  26. 61.20, 57.14, 56.62, 59.25
  27. ],
  28. 'AAPL' : [
  29. 106.00, 104.66, 104.87, 105.69,
  30. 104.22, 110.16, 109.84, 108.86,
  31. 110.14, 107.66, 108.08, 109.90
  32. ]
  33. }
  34.  
  35. df = pd.DataFrame.from_dict(prices)
  36. print(df.corr())
Add Comment
Please, Sign In to add comment