You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+284-3Lines changed: 284 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ The official Python client for communicating with the <a href="https://upstox.co
9
9
Upstox API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.
The `MarketDataStreamerV3` interface is designed for effortless connection to the market WebSocket, enabling users to receive instantaneous updates on various instruments. The following example demonstrates how to quickly set up and start receiving market updates for selected instrument keys:
In this example, you first authenticate using an access token, then instantiate MarketDataStreamerV3 with specific instrument keys and a subscription mode. Upon connecting, the streamer listens for market updates, which are logged to the console as they arrive.
152
+
153
+
Feel free to adjust the access token placeholder and any other specifics to better fit your actual implementation or usage scenario.
154
+
155
+
### Exploring the MarketDataStreamerV3 Functionality
156
+
157
+
#### Modes
158
+
-**ltpc**: ltpc provides information solely about the most recent trade, encompassing details such as the last trade price, time of the last trade, quantity traded, and the closing price from the previous day.
159
+
-**full**: The full option offers comprehensive information, including the latest trade prices, D5 depth, 1-minute, 30-minute, and daily candlestick data, along with some additional details.
160
+
-**option_greeks**: Contains only option greeks.
161
+
162
+
#### Functions
163
+
1.**constructor MarketDataStreamerV3(apiClient, instrumentKeys, mode)**: Initializes the streamer with optional instrument keys and mode (`full`, `ltpc` or `option_greeks`).
164
+
2.**connect()**: Establishes the WebSocket connection.
165
+
3.**subscribe(instrumentKeys, mode)**: Subscribes to updates for given instrument keys in the specified mode. Both parameters are mandatory.
166
+
4.**unsubscribe(instrumentKeys)**: Stops updates for the specified instrument keys.
167
+
5.**changeMode(instrumentKeys, mode)**: Switches the mode for already subscribed instrument keys.
168
+
6.**disconnect()**: Ends the active WebSocket connection.
169
+
7.**auto_reconnect(enable, interval, retryCount)**: Customizes auto-reconnect functionality. Parameters include a flag to enable/disable it, the interval(in seconds) between attempts, and the maximum number of retries.
170
+
171
+
#### Events
172
+
-**open**: Emitted upon successful connection establishment.
173
+
-**close**: Indicates the WebSocket connection has been closed.
174
+
-**message**: Delivers market updates.
175
+
-**error**: Signals an error has occurred.
176
+
-**reconnecting**: Announced when a reconnect attempt is initiated.
177
+
-**autoReconnectStopped**: Informs when auto-reconnect efforts have ceased after exhausting the retry count.
178
+
179
+
The following documentation includes examples to illustrate the usage of these functions and events, providing a practical understanding of how to interact with the MarketDataStreamerV3 effectively.
180
+
181
+
<br/>
182
+
183
+
1. Subscribing to Market Data on Connection Open with MarketDataStreamerV3
The `MarketDataStreamer` interface is designed for effortless connection to the market WebSocket, enabling users to receive instantaneous updates on various instruments. The following example demonstrates how to quickly set up and start receiving market updates for selected instrument keys:
123
403
124
404
```python
@@ -388,6 +668,8 @@ if __name__ == "__main__":
388
668
```
389
669
390
670
<br/>
671
+
</p>
672
+
</details>
391
673
392
674
### PortfolioDataStreamer
393
675
@@ -451,8 +733,6 @@ if __name__ == "__main__":
451
733
452
734
<br/>
453
735
454
-
This example demonstrates initializing the PortfolioDataStreamer, connecting it to the WebSocket, and setting up an event listener to receive and print order updates. Replace <ACCESS_TOKEN> with your valid access token to authenticate the session.
455
-
456
736
### Exploring the PortfolioDataStreamer Functionality
457
737
458
738
#### Functions
@@ -569,3 +849,4 @@ This example demonstrates initializing the PortfolioDataStreamer, connecting it
0 commit comments