from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse

# API key for the stocks

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api key in quotes
from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse
import time

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api_key is used

aggs = client.get_aggs("AAPL", 1, "month", "2021-01-01", "2021-12-01")

data = []

for i in range (12):
    data.append({"2021-" +str(i + 1) + "-1:": aggs[i].open})
    data.append({"2021-" + str(i + 1) + "-1:": aggs[i].close})
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].open))
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].close))
    time.sleep(12)
print(data)
2021-1-1:133.52
2021-1-1:131.96
2021-2-1:133.75
2021-2-1:121.26
2021-3-1:123.75
2021-3-1:122.15
2021-4-1:123.66
2021-4-1:131.46
2021-5-1:132.04
2021-5-1:124.61
2021-6-1:125.08
2021-6-1:136.96
2021-7-1:136.6
2021-7-1:145.86
2021-8-1:146.36
2021-8-1:151.83
2021-9-1:152.83
2021-9-1:141.5
2021-10-1:141.9
2021-10-1:149.8
2021-11-1:148.985
2021-11-1:165.3
2021-12-1:167.48
2021-12-1:177.57
[{'2021-1-1:': 133.52}, {'2021-1-1:': 131.96}, {'2021-2-1:': 133.75}, {'2021-2-1:': 121.26}, {'2021-3-1:': 123.75}, {'2021-3-1:': 122.15}, {'2021-4-1:': 123.66}, {'2021-4-1:': 131.46}, {'2021-5-1:': 132.04}, {'2021-5-1:': 124.61}, {'2021-6-1:': 125.08}, {'2021-6-1:': 136.96}, {'2021-7-1:': 136.6}, {'2021-7-1:': 145.86}, {'2021-8-1:': 146.36}, {'2021-8-1:': 151.83}, {'2021-9-1:': 152.83}, {'2021-9-1:': 141.5}, {'2021-10-1:': 141.9}, {'2021-10-1:': 149.8}, {'2021-11-1:': 148.985}, {'2021-11-1:': 165.3}, {'2021-12-1:': 167.48}, {'2021-12-1:': 177.57}]
from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse
import time

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api_key is used

aggs = client.get_aggs("TSLA", 1, "month", "2021-01-01", "2021-12-01")

data = []

for i in range (12):
    data.append({"2021-" +str(i + 1) + "-1:": aggs[i].open})
    data.append({"2021-" + str(i + 1) + "-1:": aggs[i].close})
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].open))
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].close))
    time.sleep(12)
print(data)
2021-1-1:239.82
2021-1-1:264.51
2021-2-1:271.43
2021-2-1:225.1667
2021-3-1:230.0367
2021-3-1:222.6433
2021-4-1:229.4567
2021-4-1:236.48
2021-5-1:234.6
2021-5-1:208.4067
2021-6-1:209.2667
2021-6-1:226.5667
2021-7-1:227.9733
2021-7-1:229.0667
2021-8-1:233.3333
2021-8-1:245.24
2021-9-1:244.6933
2021-9-1:258.4933
2021-10-1:259.4667
2021-10-1:371.3333
2021-11-1:381.6667
2021-11-1:381.5867
2021-12-1:386.8983
2021-12-1:352.26
[{'2021-1-1:': 239.82}, {'2021-1-1:': 264.51}, {'2021-2-1:': 271.43}, {'2021-2-1:': 225.1667}, {'2021-3-1:': 230.0367}, {'2021-3-1:': 222.6433}, {'2021-4-1:': 229.4567}, {'2021-4-1:': 236.48}, {'2021-5-1:': 234.6}, {'2021-5-1:': 208.4067}, {'2021-6-1:': 209.2667}, {'2021-6-1:': 226.5667}, {'2021-7-1:': 227.9733}, {'2021-7-1:': 229.0667}, {'2021-8-1:': 233.3333}, {'2021-8-1:': 245.24}, {'2021-9-1:': 244.6933}, {'2021-9-1:': 258.4933}, {'2021-10-1:': 259.4667}, {'2021-10-1:': 371.3333}, {'2021-11-1:': 381.6667}, {'2021-11-1:': 381.5867}, {'2021-12-1:': 386.8983}, {'2021-12-1:': 352.26}]
from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse
import time

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api_key is used

aggs = client.get_aggs("GME", 1, "month", "2021-01-01", "2021-12-01")

data = []

for i in range (12):
    data.append({"2021-" +str(i + 1) + "-1:": aggs[i].open})
    data.append({"2021-" + str(i + 1) + "-1:": aggs[i].close})
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].open))
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].close))
    time.sleep(12)
print(data)
2021-1-1:4.75
2021-1-1:81.25
2021-2-1:79.14
2021-2-1:25.435
2021-3-1:26.135
2021-3-1:47.455
2021-4-1:48.34
2021-4-1:43.3975
2021-5-1:44.3725
2021-5-1:55.5
2021-6-1:58.37
2021-6-1:53.535
2021-7-1:53.35
2021-7-1:40.28
2021-8-1:40.5
2021-8-1:54.56
2021-9-1:56
2021-9-1:43.8675
2021-10-1:44.85
2021-10-1:45.8775
2021-11-1:45.6325
2021-11-1:49.0525
2021-12-1:49.85
2021-12-1:37.0975
[{'2021-1-1:': 4.75}, {'2021-1-1:': 81.25}, {'2021-2-1:': 79.14}, {'2021-2-1:': 25.435}, {'2021-3-1:': 26.135}, {'2021-3-1:': 47.455}, {'2021-4-1:': 48.34}, {'2021-4-1:': 43.3975}, {'2021-5-1:': 44.3725}, {'2021-5-1:': 55.5}, {'2021-6-1:': 58.37}, {'2021-6-1:': 53.535}, {'2021-7-1:': 53.35}, {'2021-7-1:': 40.28}, {'2021-8-1:': 40.5}, {'2021-8-1:': 54.56}, {'2021-9-1:': 56}, {'2021-9-1:': 43.8675}, {'2021-10-1:': 44.85}, {'2021-10-1:': 45.8775}, {'2021-11-1:': 45.6325}, {'2021-11-1:': 49.0525}, {'2021-12-1:': 49.85}, {'2021-12-1:': 37.0975}]
from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse
import time

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api_key is used

aggs = client.get_aggs("GOOGL", 1, "month", "2021-01-01", "2021-12-01")

data = []

for i in range (12):
    data.append({"2021-" +str(i + 1) + "-1:": aggs[i].open})
    data.append({"2021-" + str(i + 1) + "-1:": aggs[i].close})
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].open))
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].close))
    time.sleep(12)
print(data)
2021-1-1:88
2021-1-1:91.368
2021-2-1:92.2293
2021-2-1:101.0955
2021-3-1:102.4
2021-3-1:103.126
2021-4-1:104.6125
2021-4-1:117.675
2021-5-1:118.2455
2021-5-1:117.8425
2021-6-1:118.722
2021-6-1:122.0895
2021-7-1:121.725
2021-7-1:134.7265
2021-8-1:135.117
2021-8-1:144.6975
2021-9-1:145
2021-9-1:133.676
2021-10-1:134.4475
2021-10-1:148.046
2021-11-1:148.046
2021-11-1:141.8975
2021-12-1:144
2021-12-1:144.852
[{'2021-1-1:': 88}, {'2021-1-1:': 91.368}, {'2021-2-1:': 92.2293}, {'2021-2-1:': 101.0955}, {'2021-3-1:': 102.4}, {'2021-3-1:': 103.126}, {'2021-4-1:': 104.6125}, {'2021-4-1:': 117.675}, {'2021-5-1:': 118.2455}, {'2021-5-1:': 117.8425}, {'2021-6-1:': 118.722}, {'2021-6-1:': 122.0895}, {'2021-7-1:': 121.725}, {'2021-7-1:': 134.7265}, {'2021-8-1:': 135.117}, {'2021-8-1:': 144.6975}, {'2021-9-1:': 145}, {'2021-9-1:': 133.676}, {'2021-10-1:': 134.4475}, {'2021-10-1:': 148.046}, {'2021-11-1:': 148.046}, {'2021-11-1:': 141.8975}, {'2021-12-1:': 144}, {'2021-12-1:': 144.852}]
from polygon import RESTClient
from typing import cast
from urllib3 import HTTPResponse
import time

client = RESTClient("w4oXBFSyC3bTkpJeVwSnKt8iuwBgMeMy") # api_key is used

aggs = client.get_aggs("AMZN", 1, "month", "2021-01-01", "2021-12-01")

data = []

for i in range (12):
    data.append({"2021-" +str(i + 1) + "-1:": aggs[i].open})
    data.append({"2021-" + str(i + 1) + "-1:": aggs[i].close})
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].open))
    print("2021-" + str(i + 1) + "-1:" + str(aggs[i].close))
    time.sleep(12)
print(data)
2021-1-1:163.5
2021-1-1:160.31
2021-2-1:162.118
2021-2-1:154.6465
2021-3-1:156.3945
2021-3-1:154.704
2021-4-1:155.897
2021-4-1:173.371
2021-5-1:174.2365
2021-5-1:161.1535
2021-6-1:162.1748
2021-6-1:172.008
2021-7-1:171.7305
2021-7-1:166.3795
2021-8-1:167.655
2021-8-1:173.5395
2021-9-1:174.8198
2021-9-1:164.252
2021-10-1:164.4505
2021-10-1:168.6215
2021-11-1:168.09
2021-11-1:175.3535
2021-12-1:177.25
2021-12-1:166.717
[{'2021-1-1:': 163.5}, {'2021-1-1:': 160.31}, {'2021-2-1:': 162.118}, {'2021-2-1:': 154.6465}, {'2021-3-1:': 156.3945}, {'2021-3-1:': 154.704}, {'2021-4-1:': 155.897}, {'2021-4-1:': 173.371}, {'2021-5-1:': 174.2365}, {'2021-5-1:': 161.1535}, {'2021-6-1:': 162.1748}, {'2021-6-1:': 172.008}, {'2021-7-1:': 171.7305}, {'2021-7-1:': 166.3795}, {'2021-8-1:': 167.655}, {'2021-8-1:': 173.5395}, {'2021-9-1:': 174.8198}, {'2021-9-1:': 164.252}, {'2021-10-1:': 164.4505}, {'2021-10-1:': 168.6215}, {'2021-11-1:': 168.09}, {'2021-11-1:': 175.3535}, {'2021-12-1:': 177.25}, {'2021-12-1:': 166.717}]