Pycharm, Mac Catalina, Python 3.8 So I retrieved this json file with historical data stocks, i tried
dictionary = get_jsonparsed_data('AAPL').values()
#Because the method returns a dictionary with a key that is the name of the stock and then the values is a list of dictionaries that are separated by dates.
dictionary = []
for key, value in get_jsonparsed_data('AAPL').items():
dictionary.append(value)
The output is something exactly like this but with dates dating back ten years if i print it.
[{'date': '2020-12-22', 'open': 131.610001, 'high': 134.404999, 'low': 129.654999, 'close': 131.880005, 'adjClose': 131.880005, 'volume': 165746075.0, 'unadjustedVolume': 165746075.0, 'change': 0.27, 'changePercent': 0.205, 'vwap': 131.98, 'label': 'December 22, 20', 'changeOverTime': 0.00205}, {'date': '2020-12-21', 'open': 125.019997, 'high': 128.309998, 'low': 123.449997, 'close': 128.229996, 'adjClose': 128.229996, 'volume': 120093700.0, 'unadjustedVolume': 120093700.0, 'change': 3.21, 'changePercent': 2.568, 'vwap': 126.66333, 'label': 'December 21, 20', 'changeOverTime': 0.02568}, {'date': '2020-12-18', 'open': 128.960007, 'high': 129.100006, 'low': 126.120003, 'close': 126.660004, 'adjClose': 126.660004, 'volume': 192541500.0, 'unadjustedVolume': 192541500.0, 'change': -2.3, 'changePercent': -1.783, 'vwap': 127.29334, 'label': 'December 18, 20', 'changeOverTime': -0.01783}]
so then i tried
dates = [date['date'] for date in dictionary[1]]
print(dates)
prices = [price['open'] for price in dictionary[1]]
print(prices)
the output
Dates
['2020-12-22', '2020-12-21', '2020-12-18', '2020-12-17', '2020-12-16', '2020-12-15', '2020-12-14', '2020-12-11', '2020-12-10', '2020-12-09', '2020-12-08', '2020-12-07', '2020-12-04', '2020-12-03', '2020-12-02', '2020-12-01', '2020-11-30', '2020-11-27', '2020-11-25', '2020-11-24', '2020-11-23', '2020-11-20', '2020-11-19', '2020-11-18', '2020-11-17', '2020-11-16', '2020-11-13', '2020-11-12', '2020-11-11', '2020-11-10', '2020-11-09', '2020-11-06', '2020-11-05', '2020-11-04', '2020-11-03', '2020-11-02', '2020-10-30', '2020-10-29']
Price
[131.610001, 125.019997, 128.960007, 128.899994, 127.410004, 124.339996, 122.599998, 122.43, 120.5, 124.529999, 124.370003, 122.309998, 122.599998, 123.519997, 122.019997, 121.010002, 116.970001, 116.57, 115.550003, 113.910004, 117.18, 118.639999, 117.589996, 118.610001, 119.550003, 118.919998, 119.440002, 119.620003, 117.190002, 115.550003, 120.5, 118.32, 117.949997, 114.139999, 109.660004, 109.110001, 111.059998, 112.370003, 115.050003, 115.489998, 114.010002, 116.389999, 117.449997, 116.669998, 116.199997, 119.959999]
These are the ouputs but they go all the way back ten years it would be to long to put it on here, but I only want 30 days worth of both values each value is a date. I want only 30 days to plot them.