Skip to content

Commit d2de685

Browse files
authored
Update readme launchpad (#366)
* options param added to get_summaries * deleted unused imports * README update * re-ordering readme sections
1 parent 3c1570c commit d2de685

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

README.md

+27-26
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ for quote in quotes:
5555
Note: For parameter argument examples check out our docs. All required arguments are annotated with red asterisks " * " and argument examples are set.
5656
Check out an example for Aggregates(client.get_aggs) [here](https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to)
5757

58+
## WebSocket Client
59+
60+
Import classes
61+
```python
62+
from polygon import WebSocketClient
63+
from polygon.websocket.models import WebSocketMessage
64+
from typing import List
65+
```
66+
### Using the client
67+
Create a new client with your [API key](https://polygon.io/dashboard/api-keys) and subscription options.
68+
```python
69+
# Note: Multiple subscriptions can be added to the array
70+
# For example, if you want to subscribe to AAPL and META,
71+
# you can do so by adding "T.META" to the subscriptions array. ["T.AAPL", "T.META"]
72+
# If you want to subscribe to all tickers, place an asterisk in place of the symbol. ["T.*"]
73+
ws = WebSocketClient(api_key=<API_KEY>, subscriptions=["T.AAPL"])
74+
```
75+
Create a handler function and run the WebSocket.
76+
```python
77+
def handle_msg(msg: List[WebSocketMessage]):
78+
for m in msg:
79+
print(m)
80+
81+
ws.run(handle_msg=handle_msg)
82+
```
83+
Check out more detailed examples [here](https://github.com/polygon-io/client-python/tree/master/examples/websocket).
84+
5885
## Launchpad
5986
Users of the Launchpad product will need to pass in certain headers in order to make API requests using the RequestOptionBuilder.
6087
Example can be found [here](./examples/launchpad).
@@ -85,32 +112,6 @@ res = c.get_aggs("AAPL", 1, "day", "2022-04-04", "2022-04-04", options=options)
85112
```
86113
Checkout Launchpad readme for more details on RequestOptionBuilder [here](./examples/launchpad)
87114

88-
## WebSocket Client
89-
90-
Import classes
91-
```python
92-
from polygon import WebSocketClient
93-
from polygon.websocket.models import WebSocketMessage
94-
from typing import List
95-
```
96-
### Using the client
97-
Create a new client with your [API key](https://polygon.io/dashboard/api-keys) and subscription options.
98-
```python
99-
# Note: Multiple subscriptions can be added to the array
100-
# For example, if you want to subscribe to AAPL and META,
101-
# you can do so by adding "T.META" to the subscriptions array. ["T.AAPL", "T.META"]
102-
# If you want to subscribe to all tickers, place an asterisk in place of the symbol. ["T.*"]
103-
ws = WebSocketClient(api_key=<API_KEY>, subscriptions=["T.AAPL"])
104-
```
105-
Create a handler function and run the WebSocket.
106-
```python
107-
def handle_msg(msg: List[WebSocketMessage]):
108-
for m in msg:
109-
print(m)
110-
111-
ws.run(handle_msg=handle_msg)
112-
```
113-
Check out more detailed examples [here](https://github.com/polygon-io/client-python/tree/master/examples/websocket).
114115

115116
## Contributing
116117

0 commit comments

Comments
 (0)