Skip to content

Commit 5682a31

Browse files
authored
Gtt tsl (#109)
* added gtt tsl and gtt mtf
1 parent 5972eb4 commit 5682a31

File tree

9 files changed

+119
-12
lines changed

9 files changed

+119
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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.16.0
12+
- Package version: 2.17.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.

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.16.0"
21+
VERSION = "2.17.0"
2222
# To install the library, run the following
2323
#
2424
# python setup.py install
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import upstox_client
2+
import data_token
3+
4+
from upstox_client.rest import ApiException
5+
6+
configuration = upstox_client.Configuration()
7+
configuration.access_token = data_token.access_token
8+
api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
9+
10+
11+
12+
entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="ABOVE", trigger_price=71)
13+
target_rule = upstox_client.GttRule(strategy="TARGET", trigger_type="IMMEDIATE", trigger_price=90)
14+
stoploss_rule = upstox_client.GttRule(strategy="STOPLOSS", trigger_type="IMMEDIATE", trigger_price=60, trailing_gap=30)
15+
rules = [entry_rule, target_rule, stoploss_rule]
16+
body = upstox_client.GttModifyOrderRequest(type="MULTIPLE", gtt_order_id="GTT-C25300600178270", rules=rules, quantity=2)
17+
try:
18+
api_response = api_instance.modify_gtt_order(body=body)
19+
print(api_response)
20+
except ApiException as e:
21+
print("Exception when calling OrderApi->place_order: %s\n" % e)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import upstox_client
2+
import data_token
3+
4+
from upstox_client.rest import ApiException
5+
6+
configuration = upstox_client.Configuration()
7+
configuration.access_token = data_token.access_token
8+
api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
9+
10+
11+
12+
entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="IMMEDIATE", trigger_price=60)
13+
target_rule = upstox_client.GttRule(strategy="TARGET", trigger_type="IMMEDIATE", trigger_price=90)
14+
stoploss_rule = upstox_client.GttRule(strategy="STOPLOSS", trigger_type="IMMEDIATE", trigger_price=50, trailing_gap=3)
15+
rules = [entry_rule, target_rule, stoploss_rule]
16+
body = upstox_client.GttPlaceOrderRequest(type="MULTIPLE", instrument_token="NSE_EQ|INE584A01023", product="MTF", quantity=1, rules=rules, transaction_type="BUY")
17+
try:
18+
api_response = api_instance.place_gtt_order(body=body)
19+
print(api_response)
20+
except ApiException as e:
21+
print("Exception when calling OrderApi->place_order: %s\n" % e)

test/sdk_tests/sanity.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,17 @@ def is_within_market_hours():
377377
except ApiException as e:
378378
print("Exception when calling OrderApi->gtt_place_order: %s\n" % e)
379379

380+
entry_rule = upstox_client.GttRule(strategy="ENTRY", trigger_type="BELOW", trigger_price=60)
381+
target_rule = upstox_client.GttRule(strategy="TARGET", trigger_type="IMMEDIATE", trigger_price=90)
382+
stoploss_rule = upstox_client.GttRule(strategy="STOPLOSS", trigger_type="IMMEDIATE", trigger_price=50, trailing_gap=3)
383+
rules = [entry_rule, target_rule, stoploss_rule]
384+
body = upstox_client.GttPlaceOrderRequest(type="MULTIPLE", instrument_token="NSE_EQ|INE584A01023", product="MTF", quantity=1, rules=rules, transaction_type="BUY")
385+
try:
386+
api_response = api_instance.place_gtt_order(body=body)
387+
print(" tsl gtt_order => " , api_response)
388+
except ApiException as e:
389+
print("Exception when calling OrderApi->place_order: %s\n" % e)
390+
380391
body = upstox_client.GttModifyOrderRequest(type="MULTIPLE", gtt_order_id="GTT-C2503030018840", rules=rules, quantity=2)
381392
try:
382393
api_response = api_instance.modify_gtt_order(body=body)

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.16.0"
77+
self.default_headers["X-Upstox-SDK-Version"] = "2.17.0"
7878

7979
def __del__(self):
8080
try:

upstox_client/models/gtt_place_order_request.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def quantity(self, quantity):
121121
def product(self):
122122
"""Gets the product of this GttPlaceOrderRequest. # noqa: E501
123123
124-
Signifies if the order was either Intraday, Delivery, CO or OCO # noqa: E501
124+
Signifies if the order was either Intraday, Delivery or MTF # noqa: E501
125125
126126
:return: The product of this GttPlaceOrderRequest. # noqa: E501
127127
:rtype: str
@@ -132,14 +132,14 @@ def product(self):
132132
def product(self, product):
133133
"""Sets the product of this GttPlaceOrderRequest.
134134
135-
Signifies if the order was either Intraday, Delivery, CO or OCO # noqa: E501
135+
Signifies if the order was either Intraday, Delivery or MTF # noqa: E501
136136
137137
:param product: The product of this GttPlaceOrderRequest. # noqa: E501
138138
:type: str
139139
"""
140140
if product is None:
141141
raise ValueError("Invalid value for `product`, must not be `None`") # noqa: E501
142-
allowed_values = ["I", "D"] # noqa: E501
142+
allowed_values = ["I", "D", "MTF"] # noqa: E501
143143
if product not in allowed_values:
144144
raise ValueError(
145145
"Invalid value for `product` ({0}), must be one of {1}" # noqa: E501

upstox_client/models/gtt_rule.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,29 @@ class GttRule(object):
3030
swagger_types = {
3131
'strategy': 'str',
3232
'trigger_type': 'str',
33-
'trigger_price': 'float'
33+
'trigger_price': 'float',
34+
'trailing_gap': 'float'
3435
}
3536

3637
attribute_map = {
3738
'strategy': 'strategy',
3839
'trigger_type': 'trigger_type',
39-
'trigger_price': 'trigger_price'
40+
'trigger_price': 'trigger_price',
41+
'trailing_gap': 'trailing_gap'
4042
}
4143

42-
def __init__(self, strategy=None, trigger_type=None, trigger_price=None): # noqa: E501
44+
def __init__(self, strategy=None, trigger_type=None, trigger_price=None, trailing_gap=None): # noqa: E501
4345
"""GttRule - a model defined in Swagger""" # noqa: E501
4446
self._strategy = None
4547
self._trigger_type = None
4648
self._trigger_price = None
49+
self._trailing_gap = None
4750
self.discriminator = None
4851
self.strategy = strategy
4952
self.trigger_type = trigger_type
5053
self.trigger_price = trigger_price
54+
if trailing_gap is not None:
55+
self.trailing_gap = trailing_gap
5156

5257
@property
5358
def strategy(self):
@@ -136,6 +141,29 @@ def trigger_price(self, trigger_price):
136141

137142
self._trigger_price = trigger_price
138143

144+
@property
145+
def trailing_gap(self):
146+
"""Gets the trailing_gap of this GttRule. # noqa: E501
147+
148+
Optional parameter defining the trailing gap for the GTT order # noqa: E501
149+
150+
:return: The trailing_gap of this GttRule. # noqa: E501
151+
:rtype: float
152+
"""
153+
return self._trailing_gap
154+
155+
@trailing_gap.setter
156+
def trailing_gap(self, trailing_gap):
157+
"""Sets the trailing_gap of this GttRule.
158+
159+
Optional parameter defining the trailing gap for the GTT order # noqa: E501
160+
161+
:param trailing_gap: The trailing_gap of this GttRule. # noqa: E501
162+
:type: float
163+
"""
164+
165+
self._trailing_gap = trailing_gap
166+
139167
def to_dict(self):
140168
"""Returns the model properties as a dict"""
141169
result = {}

upstox_client/models/rule.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class Rule(object):
3434
'trigger_type': 'str',
3535
'trigger_price': 'float',
3636
'transaction_type': 'str',
37-
'order_id': 'str'
37+
'order_id': 'str',
38+
'trailing_gap': 'float'
3839
}
3940

4041
attribute_map = {
@@ -44,10 +45,11 @@ class Rule(object):
4445
'trigger_type': 'trigger_type',
4546
'trigger_price': 'trigger_price',
4647
'transaction_type': 'transaction_type',
47-
'order_id': 'order_id'
48+
'order_id': 'order_id',
49+
'trailing_gap': 'trailing_gap'
4850
}
4951

50-
def __init__(self, strategy=None, status=None, message=None, trigger_type=None, trigger_price=None, transaction_type=None, order_id=None): # noqa: E501
52+
def __init__(self, strategy=None, status=None, message=None, trigger_type=None, trigger_price=None, transaction_type=None, order_id=None, trailing_gap=None): # noqa: E501
5153
"""Rule - a model defined in Swagger""" # noqa: E501
5254
self._strategy = None
5355
self._status = None
@@ -56,6 +58,7 @@ def __init__(self, strategy=None, status=None, message=None, trigger_type=None,
5658
self._trigger_price = None
5759
self._transaction_type = None
5860
self._order_id = None
61+
self._trailing_gap = None
5962
self.discriminator = None
6063
if strategy is not None:
6164
self.strategy = strategy
@@ -71,6 +74,8 @@ def __init__(self, strategy=None, status=None, message=None, trigger_type=None,
7174
self.transaction_type = transaction_type
7275
if order_id is not None:
7376
self.order_id = order_id
77+
if trailing_gap is not None:
78+
self.trailing_gap = trailing_gap
7479

7580
@property
7681
def strategy(self):
@@ -219,6 +224,27 @@ def order_id(self, order_id):
219224

220225
self._order_id = order_id
221226

227+
@property
228+
def trailing_gap(self):
229+
"""Gets the trailing_gap of this Rule. # noqa: E501
230+
231+
232+
:return: The trailing_gap of this Rule. # noqa: E501
233+
:rtype: float
234+
"""
235+
return self._trailing_gap
236+
237+
@trailing_gap.setter
238+
def trailing_gap(self, trailing_gap):
239+
"""Sets the trailing_gap of this Rule.
240+
241+
242+
:param trailing_gap: The trailing_gap of this Rule. # noqa: E501
243+
:type: float
244+
"""
245+
246+
self._trailing_gap = trailing_gap
247+
222248
def to_dict(self):
223249
"""Returns the model properties as a dict"""
224250
result = {}

0 commit comments

Comments
 (0)