File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -50,14 +50,17 @@ from polygon import RESTClient
50
50
51
51
def main ():
52
52
key = " your api key"
53
- client = RESTClient(key)
54
53
55
- resp = client.stocks_equities_daily_open_close(" AAPL" , " 2018-3-2" )
56
- print (f " On: { resp.from_} Apple opened at { resp.open} and closed at { resp.close} " )
54
+ # RESTClient can be used as a context manager to facilitate closing the underlying http session
55
+ # https://requests.readthedocs.io/en/master/user/advanced/#session-objects
56
+ with RESTClient(key) as client:
57
+ resp = client.stocks_equities_daily_open_close(" AAPL" , " 2018-03-02" )
58
+ print (f " On: { resp.from_} Apple opened at { resp.open} and closed at { resp.close} " )
57
59
58
60
59
61
if __name__ == ' __main__' :
60
62
main()
63
+
61
64
```
62
65
63
66
You can’t perform that action at this time.
0 commit comments