Skip to content

Commit 1898c31

Browse files
committed
updated order base url
1 parent 47ceffc commit 1898c31

File tree

5 files changed

+54
-2
lines changed

5 files changed

+54
-2
lines changed

test/Order Test/cancel_order.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import upstox_client
2+
from upstox_client.rest import ApiException
3+
4+
configuration = upstox_client.Configuration()
5+
configuration.access_token = "your_access_token"
6+
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
7+
order_id = '231221011081579'
8+
api_version = '2.0'
9+
10+
try:
11+
# Cancel order
12+
api_response = api_instance.cancel_order(order_id, api_version)
13+
print(api_response)
14+
except ApiException as e:
15+
print("Exception when calling OrderApi->cancel_order: %s\n" % e)

test/Order Test/modify_order.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import upstox_client
2+
from upstox_client.rest import ApiException
3+
4+
configuration = upstox_client.Configuration()
5+
configuration.access_token = "your_access_token"
6+
7+
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
8+
body = upstox_client.ModifyOrderRequest(2, "DAY", 0, "231222010275930", "MARKET", 0, 0)
9+
api_version = '2.0' # str | API Version Header
10+
11+
try:
12+
# Modify order
13+
api_response = api_instance.modify_order(body, api_version)
14+
print(api_response)
15+
except ApiException as e:
16+
print("Exception when calling OrderApi->modify_order: %s\n" % e)

test/Order Test/place_order.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import upstox_client
2+
from upstox_client.rest import ApiException
3+
configuration = upstox_client.Configuration()
4+
configuration.access_token = "your_access_token"
5+
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
6+
body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, True)
7+
api_version = '2.0'
8+
try:
9+
api_response = api_instance.place_order(body, api_version)
10+
print(api_response)
11+
except ApiException as e:
12+
print("Exception when calling OrderApi->place_order: %s\n" % e)

upstox_client/api_client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,10 @@ def __call_api(
145145
body = self.sanitize_for_serialization(body)
146146

147147
# request url
148-
url = self.configuration.host + resource_path
149-
148+
if self.__is_order_path(resource_path):
149+
url = self.configuration.order_host + resource_path
150+
else:
151+
url = self.configuration.host + resource_path
150152
# perform request and return response
151153
response_data = self.request(
152154
method, url, query_params=query_params, headers=header_params,
@@ -633,3 +635,6 @@ def __deserialize_model(self, data, klass):
633635
if klass_name:
634636
instance = self.__deserialize(data, klass_name)
635637
return instance
638+
639+
def __is_order_path(self, path):
640+
return path.__contains__("/order/place") or path.__contains__("/order/modify") or path.__contains__("/order/cancel")

upstox_client/configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def __init__(self):
4747
"""Constructor"""
4848
# Default Base url
4949
self.host = "https://api.upstox.com/v2"
50+
51+
# Low latency order host
52+
self.order_host = "https://api-hft.upstox.com/v2"
53+
5054
# Temp file folder for downloading files
5155
self.temp_folder_path = None
5256

0 commit comments

Comments
 (0)