Skip to content

updated order base url #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/order/cancel_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = "your_access_token"
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
order_id = '231221011081579'
api_version = '2.0'

try:
# Cancel order
api_response = api_instance.cancel_order(order_id, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->cancel_order: %s\n" % e)
16 changes: 16 additions & 0 deletions test/order/modify_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import upstox_client
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = "your_access_token"

api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
body = upstox_client.ModifyOrderRequest(2, "DAY", 0, "231222010275930", "MARKET", 0, 0)
api_version = '2.0' # str | API Version Header

try:
# Modify order
api_response = api_instance.modify_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->modify_order: %s\n" % e)
12 changes: 12 additions & 0 deletions test/order/place_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = "your_access_token"
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
body = upstox_client.PlaceOrderRequest(1, "D", "DAY", 0.0, "string", "NSE_EQ|INE528G01035", "MARKET", "BUY", 0, 0.0, True)
api_version = '2.0'
try:
api_response = api_instance.place_order(body, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->place_order: %s\n" % e)
9 changes: 7 additions & 2 deletions upstox_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def __call_api(
body = self.sanitize_for_serialization(body)

# request url
url = self.configuration.host + resource_path

if self.__is_order_path(resource_path):
url = self.configuration.order_host + resource_path
else:
url = self.configuration.host + resource_path
# perform request and return response
response_data = self.request(
method, url, query_params=query_params, headers=header_params,
Expand Down Expand Up @@ -633,3 +635,6 @@ def __deserialize_model(self, data, klass):
if klass_name:
instance = self.__deserialize(data, klass_name)
return instance

def __is_order_path(self, path):
return path.__contains__("/order/place") or path.__contains__("/order/modify") or path.__contains__("/order/cancel")
4 changes: 4 additions & 0 deletions upstox_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def __init__(self):
"""Constructor"""
# Default Base url
self.host = "https://api.upstox.com/v2"

# Low latency order host
self.order_host = "https://api-hft.upstox.com/v2"

# Temp file folder for downloading files
self.temp_folder_path = None

Expand Down
Loading