Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The official Python client for communicating with the <a href="https://upstox.co
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.

- API version: v2
- Package version: 2.15.0
- Package version: 2.16.0
- Build package: io.swagger.codegen.v3.generators.python.PythonClientCodegen

This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
long_description = (this_directory / "README.md").read_text()

NAME = "upstox-python-sdk"
VERSION = "2.15.0"
VERSION = "2.16.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
4 changes: 2 additions & 2 deletions test/sdk_tests/sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def is_within_market_hours():
try:
# Get User Fund And Margin
api_response = api_instance.get_profile(api_version)
if api_response.data.user_id != "7PBC6D":
print("get profile returned wrong response")
if api_response.status!="success":
print("error in get profile API")

except ApiException as e:
print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
Expand Down
62 changes: 62 additions & 0 deletions test/sdk_tests/scp_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import upstox_client
import data_token
from upstox_client.rest import ApiException

configuration = upstox_client.Configuration()
configuration.access_token = data_token.access_token
api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
api_version = '2.0'
order_id = 'xxxxxxxx'
try:

# get order details
api_response = api_instance.get_order_status(order_id=order_id)
print(api_response)

except ApiException as e:
json_string = e.body.decode('utf-8')
data_dict = json.loads(json_string)
if data_dict.get('errors')[0].get('errorCode') != "UDAPI100010":
print("order details giving wrong response")

try:
# order history
api_response = api_instance.get_order_details(order_id=order_id, api_version=api_version)
print(api_response)
except ApiException as e:
json_string = e.body.decode('utf-8')
data_dict = json.loads(json_string)
if data_dict.get('errors')[0].get('errorCode') != "UDAPI100010":
print("order history giving wrong response")

try:
# Get order book
api_response = api_instance.get_order_book(api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->get_order_book: %s\n" % e)


try:
# Get trades for the day
api_response = api_instance.get_trade_history(api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->get_trade_history: %s\n" % e)



try:
# Get trades for order
api_response = api_instance.get_trades_by_order(order_id, api_version)
print(api_response)
except ApiException as e:
print("Exception when calling OrderApi->get_trades_by_order: %s\n" % e)

api_instance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))

try:
api_response = api_instance.get_positions(api_version)
print(api_response)
except ApiException as e:
print("Exception when calling position: %s\n" % e)
2 changes: 1 addition & 1 deletion upstox_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
# Set default User-Agent.
self.user_agent = 'Swagger-Codegen/1.0.0/python'
self.default_headers["X-Upstox-SDK-Language"] = "python"
self.default_headers["X-Upstox-SDK-Version"] = "2.15.0"
self.default_headers["X-Upstox-SDK-Version"] = "2.16.0"

def __del__(self):
try:
Expand Down
7 changes: 0 additions & 7 deletions upstox_client/models/holdings_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,6 @@ def exchange(self, exchange):
:param exchange: The exchange of this HoldingsData. # noqa: E501
:type: str
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if exchange not in allowed_values:
raise ValueError(
"Invalid value for `exchange` ({0}), must be one of {1}" # noqa: E501
.format(exchange, allowed_values)
)

self._exchange = exchange

def to_dict(self):
Expand Down
13 changes: 0 additions & 13 deletions upstox_client/models/order_book_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ def exchange(self, exchange):
:param exchange: The exchange of this OrderBookData. # noqa: E501
:type: str
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if exchange not in allowed_values:
raise ValueError(
"Invalid value for `exchange` ({0}), must be one of {1}" # noqa: E501
.format(exchange, allowed_values)
)

self._exchange = exchange

@property
Expand All @@ -236,12 +229,6 @@ def product(self, product):
:param product: The product of this OrderBookData. # noqa: E501
:type: str
"""
allowed_values = ["I", "D", "CO", "OCO", "MTF"] # noqa: E501
if product not in allowed_values:
raise ValueError(
"Invalid value for `product` ({0}), must be one of {1}" # noqa: E501
.format(product, allowed_values)
)

self._product = product

Expand Down
12 changes: 0 additions & 12 deletions upstox_client/models/order_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ def exchange(self, exchange):
:param exchange: The exchange of this OrderData. # noqa: E501
:type: str
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if exchange not in allowed_values:
raise ValueError(
"Invalid value for `exchange` ({0}), must be one of {1}" # noqa: E501
.format(exchange, allowed_values)
)

self._exchange = exchange

Expand Down Expand Up @@ -239,12 +233,6 @@ def product(self, product):
:param product: The product of this OrderData. # noqa: E501
:type: str
"""
allowed_values = ["I", "D", "CO", "OCO", "MTF"] # noqa: E501
if product not in allowed_values:
raise ValueError(
"Invalid value for `product` ({0}), must be one of {1}" # noqa: E501
.format(product, allowed_values)
)

self._product = product

Expand Down
7 changes: 0 additions & 7 deletions upstox_client/models/position_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,6 @@ def exchange(self, exchange):
:param exchange: The exchange of this PositionData. # noqa: E501
:type: str
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if exchange not in allowed_values:
raise ValueError(
"Invalid value for `exchange` ({0}), must be one of {1}" # noqa: E501
.format(exchange, allowed_values)
)

self._exchange = exchange

@property
Expand Down
14 changes: 0 additions & 14 deletions upstox_client/models/profile_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ def exchanges(self, exchanges):
:param exchanges: The exchanges of this ProfileData. # noqa: E501
:type: list[str]
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX", "NSCOM"] # noqa: E501
if not set(exchanges).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `exchanges` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set(exchanges) - set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values)))
)

self._exchanges = exchanges

Expand All @@ -160,13 +153,6 @@ def products(self, products):
:param products: The products of this ProfileData. # noqa: E501
:type: list[str]
"""
allowed_values = ["I", "D", "CO", "OCO", "MTF"] # noqa: E501
if not set(products).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `products` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set(products) - set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values)))
)

self._products = products

Expand Down
14 changes: 0 additions & 14 deletions upstox_client/models/token_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,6 @@ def exchanges(self, exchanges):
:param exchanges: The exchanges of this TokenResponse. # noqa: E501
:type: list[str]
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if not set(exchanges).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `exchanges` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set(exchanges) - set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values)))
)

self._exchanges = exchanges

Expand All @@ -170,13 +163,6 @@ def products(self, products):
:param products: The products of this TokenResponse. # noqa: E501
:type: list[str]
"""
allowed_values = ["I", "D", "CO", "OCO", "MTF"] # noqa: E501
if not set(products).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `products` [{0}], must be a subset of [{1}]" # noqa: E501
.format(", ".join(map(str, set(products) - set(allowed_values))), # noqa: E501
", ".join(map(str, allowed_values)))
)

self._products = products

Expand Down
12 changes: 0 additions & 12 deletions upstox_client/models/trade_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ def exchange(self, exchange):
:param exchange: The exchange of this TradeData. # noqa: E501
:type: str
"""
allowed_values = ["NSE", "NFO", "CDS", "BSE", "BFO", "BCD", "MCX"] # noqa: E501
if exchange not in allowed_values:
raise ValueError(
"Invalid value for `exchange` ({0}), must be one of {1}" # noqa: E501
.format(exchange, allowed_values)
)

self._exchange = exchange

Expand All @@ -161,12 +155,6 @@ def product(self, product):
:param product: The product of this TradeData. # noqa: E501
:type: str
"""
allowed_values = ["I", "D", "CO", "OCO", "MTF"] # noqa: E501
if product not in allowed_values:
raise ValueError(
"Invalid value for `product` ({0}), must be one of {1}" # noqa: E501
.format(product, allowed_values)
)

self._product = product

Expand Down