Skip to content

Commit d807ff8

Browse files
authored
Gtt order updates streamer (#99)
* added gtt_order update in portfolio streamer * added gtt error message
1 parent 4837309 commit d807ff8

File tree

7 files changed

+51
-10
lines changed

7 files changed

+51
-10
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The official Python client for communicating with the <a href="https://upstox.co
99
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.
1010

1111
- API version: v2
12-
- Package version: 2.13.0
12+
- Package version: 2.14.0
1313
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen
1414

1515
This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project.
@@ -728,7 +728,7 @@ if __name__ == "__main__":
728728
```
729729
<br/>
730730

731-
Position and holding updates can be enabled by setting the corresponding flag to `True` in the constructor of the `PortfolioDataStreamer` class.
731+
Position, holding, and GTT order updates can be enabled by setting the corresponding flag to `True` in the constructor of the `PortfolioDataStreamer` class.
732732

733733
```python
734734
import upstox_client
@@ -747,7 +747,11 @@ def main():
747747
configuration = upstox_client.Configuration()
748748
configuration.access_token = <ACCESS_TOKEN>
749749

750-
streamer = upstox_client.PortfolioDataStreamer(upstox_client.ApiClient(configuration),order_update=True,position_update=True,holding_update=True)
750+
streamer = upstox_client.PortfolioDataStreamer(upstox_client.ApiClient(configuration),
751+
order_update=True,
752+
position_update=True,
753+
holding_update=True,
754+
gtt_update=True)
751755

752756
streamer.on("message", on_message)
753757
streamer.on("open", on_open)
@@ -763,6 +767,13 @@ if __name__ == "__main__":
763767

764768
### Exploring the PortfolioDataStreamer Functionality
765769

770+
#### Constructor Parameters
771+
1. **api_client**: Your API client instance
772+
2. **order_update**: Set to `True` to receive real-time order updates (default: `True`)
773+
3. **position_update**: Set to `True` to receive position updates (default: `False`)
774+
4. **holding_update**: Set to `True` to receive holding updates (default: `False`)
775+
5. **gtt_update**: Set to `True` to receive GTT order updates (default: `False`)
776+
766777
#### Functions
767778
1. **constructor PortfolioDataStreamer()**: Initializes the streamer.
768779
2. **connect()**: Establishes the WebSocket connection.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
long_description = (this_directory / "README.md").read_text()
1919

2020
NAME = "upstox-python-sdk"
21-
VERSION = "2.13.0"
21+
VERSION = "2.14.0"
2222
# To install the library, run the following
2323
#
2424
# python setup.py install

test/sdk_tests/portfolio_update_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414
configuration = upstox_client.Configuration()
1515
configuration.access_token = data_token.access_token
1616

17-
streamer = upstox_client.PortfolioDataStreamer(upstox_client.ApiClient(configuration),order_update=True,position_update=True,holding_update=True)
17+
streamer = upstox_client.PortfolioDataStreamer(upstox_client.ApiClient(configuration),order_update=True,position_update=True,holding_update=True, gtt_update=True)
1818

1919
streamer.on("message", on_message)
2020
streamer.on("open", on_open)

upstox_client/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
7474
# Set default User-Agent.
7575
self.user_agent = 'Swagger-Codegen/1.0.0/python'
7676
self.default_headers["X-Upstox-SDK-Language"] = "python"
77-
self.default_headers["X-Upstox-SDK-Version"] = "2.13.0"
77+
self.default_headers["X-Upstox-SDK-Version"] = "2.14.0"
7878

7979
def __del__(self):
8080
try:

upstox_client/feeder/portfolio_data_feeder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class PortfolioDataFeeder(Feeder):
88

99
def __init__(self, api_client=None, on_open=None, on_message=None, on_error=None, on_close=None, order_update=True,
10-
position_update=False, holding_update=False):
10+
position_update=False, holding_update=False, gtt_update=False):
1111
super().__init__(api_client=api_client)
1212
self.api_client = api_client
1313
self.on_open = on_open
@@ -19,6 +19,7 @@ def __init__(self, api_client=None, on_open=None, on_message=None, on_error=None
1919
self.order_update = order_update
2020
self.position_update = position_update
2121
self.holding_update = holding_update
22+
self.gtt_update = gtt_update
2223

2324
def connect(self):
2425
if self.ws and self.ws.sock:
@@ -51,6 +52,8 @@ def get_websocket_url(self):
5152
update_types.append("holding")
5253
if self.position_update:
5354
update_types.append("position")
55+
if self.gtt_update:
56+
update_types.append("gtt_order")
5457

5558
if update_types:
5659
ws_url += "?update_types=" + "%2C".join(update_types)

upstox_client/feeder/portfolio_data_streamer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44

55
class PortfolioDataStreamer(Streamer):
66

7-
def __init__(self, api_client=None, order_update=True, position_update=False, holding_update=False):
7+
def __init__(self, api_client=None, order_update=True, position_update=False, holding_update=False, gtt_update=False):
88
super().__init__(api_client)
99
self.api_client = api_client
1010
self.order_update = order_update
1111
self.position_update = position_update
1212
self.holding_update = holding_update
13+
self.gtt_update = gtt_update
1314
self.feeder = None
1415

1516
def connect(self):
1617
self.feeder = PortfolioDataFeeder(
1718
api_client=self.api_client, on_open=self.handle_open, on_message=self.handle_message,
1819
on_error=self.handle_error, on_close=self.handle_close, order_update=self.order_update,
19-
position_update=self.position_update, holding_update=self.holding_update)
20+
position_update=self.position_update, holding_update=self.holding_update, gtt_update=self.gtt_update)
2021
self.feeder.connect()
2122

2223
def handle_open(self, ws):

upstox_client/models/rule.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Rule(object):
3030
swagger_types = {
3131
'strategy': 'str',
3232
'status': 'str',
33+
'message': 'str',
3334
'trigger_type': 'str',
3435
'trigger_price': 'float',
3536
'transaction_type': 'str',
@@ -39,16 +40,18 @@ class Rule(object):
3940
attribute_map = {
4041
'strategy': 'strategy',
4142
'status': 'status',
43+
'message': 'message',
4244
'trigger_type': 'trigger_type',
4345
'trigger_price': 'trigger_price',
4446
'transaction_type': 'transaction_type',
4547
'order_id': 'order_id'
4648
}
4749

48-
def __init__(self, strategy=None, status=None, trigger_type=None, trigger_price=None, transaction_type=None, order_id=None): # noqa: E501
50+
def __init__(self, strategy=None, status=None, message=None, trigger_type=None, trigger_price=None, transaction_type=None, order_id=None): # noqa: E501
4951
"""Rule - a model defined in Swagger""" # noqa: E501
5052
self._strategy = None
5153
self._status = None
54+
self._message = None
5255
self._trigger_type = None
5356
self._trigger_price = None
5457
self._transaction_type = None
@@ -58,6 +61,8 @@ def __init__(self, strategy=None, status=None, trigger_type=None, trigger_price=
5861
self.strategy = strategy
5962
if status is not None:
6063
self.status = status
64+
if message is not None:
65+
self.message = message
6166
if trigger_type is not None:
6267
self.trigger_type = trigger_type
6368
if trigger_price is not None:
@@ -109,6 +114,27 @@ def status(self, status):
109114

110115
self._status = status
111116

117+
@property
118+
def message(self):
119+
"""Gets the message of this Rule. # noqa: E501
120+
121+
122+
:return: The message of this Rule. # noqa: E501
123+
:rtype: str
124+
"""
125+
return self._message
126+
127+
@message.setter
128+
def message(self, message):
129+
"""Sets the message of this Rule.
130+
131+
132+
:param message: The message of this Rule. # noqa: E501
133+
:type: str
134+
"""
135+
136+
self._message = message
137+
112138
@property
113139
def trigger_type(self):
114140
"""Gets the trigger_type of this Rule. # noqa: E501

0 commit comments

Comments
 (0)