diff --git a/README.md b/README.md index 2740282..a2d5c36 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The official Python client for communicating with the get_user_fund_margin: %s\n" % e) diff --git a/test/sdk_tests/scp_test.py b/test/sdk_tests/scp_test.py new file mode 100644 index 0000000..a08ad0b --- /dev/null +++ b/test/sdk_tests/scp_test.py @@ -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) \ No newline at end of file diff --git a/upstox_client/api_client.py b/upstox_client/api_client.py index 554f853..4a43e98 100644 --- a/upstox_client/api_client.py +++ b/upstox_client/api_client.py @@ -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: diff --git a/upstox_client/models/holdings_data.py b/upstox_client/models/holdings_data.py index 9fb954b..2f2d5ad 100644 --- a/upstox_client/models/holdings_data.py +++ b/upstox_client/models/holdings_data.py @@ -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): diff --git a/upstox_client/models/order_book_data.py b/upstox_client/models/order_book_data.py index d5817e5..76f02c3 100644 --- a/upstox_client/models/order_book_data.py +++ b/upstox_client/models/order_book_data.py @@ -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 @@ -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 diff --git a/upstox_client/models/order_data.py b/upstox_client/models/order_data.py index 3417446..0c2043a 100644 --- a/upstox_client/models/order_data.py +++ b/upstox_client/models/order_data.py @@ -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 @@ -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 diff --git a/upstox_client/models/position_data.py b/upstox_client/models/position_data.py index 8b5896f..a0de70f 100644 --- a/upstox_client/models/position_data.py +++ b/upstox_client/models/position_data.py @@ -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 diff --git a/upstox_client/models/profile_data.py b/upstox_client/models/profile_data.py index 2e2aa7a..ac3ec1c 100644 --- a/upstox_client/models/profile_data.py +++ b/upstox_client/models/profile_data.py @@ -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 @@ -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 diff --git a/upstox_client/models/token_response.py b/upstox_client/models/token_response.py index 25c7446..15bb379 100644 --- a/upstox_client/models/token_response.py +++ b/upstox_client/models/token_response.py @@ -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 @@ -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 diff --git a/upstox_client/models/trade_data.py b/upstox_client/models/trade_data.py index 4b54c96..d95d367 100644 --- a/upstox_client/models/trade_data.py +++ b/upstox_client/models/trade_data.py @@ -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 @@ -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