Skip to content

Commit edd2b2f

Browse files
authored
V3 API + Sandbox (#88)
* Added v3 APIs and Sandbox mode
1 parent 4b40dfd commit edd2b2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3815
-24
lines changed

README.md

Lines changed: 38 additions & 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.10.0
12+
- Package version: 2.11.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.
@@ -51,6 +51,30 @@ Then import the package:
5151
import upstox_client
5252
```
5353

54+
## Sandbox Mode
55+
We recommend using the sandbox environment for testing purposes. To enable sandbox mode, set the `sandbox` flag to `True` in the configuration object.
56+
57+
```python
58+
import upstox_client
59+
from upstox_client.rest import ApiException
60+
61+
configuration = upstox_client.Configuration(sandbox=True)
62+
configuration.access_token = 'SANDBOX_ACCESS_TOKEN'
63+
64+
api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
65+
body = upstox_client.PlaceOrderV3Request(quantity=1, product="D",validity="DAY", price=9.12, tag="string", instrument_token="NSE_EQ|INE669E01016", order_type="LIMIT",
66+
transaction_type="BUY", disclosed_quantity=0, trigger_price=0.0, is_amo=True, slice=True)
67+
68+
try:
69+
api_response = api_instance.place_order(body)
70+
print(api_response)
71+
except ApiException as e:
72+
print("Exception when calling OrderApi->place_order: %s\n" % e)
73+
```
74+
To learn more about the sandbox environment and the available sandbox APIs, please visit the [Upstox API documentation - Sandbox](https://upstox.com/developer/api-documentation/sandbox).
75+
76+
77+
5478
## Examples
5579

5680
[Sample Implementations](examples/) can be found within `/examples` folder.
@@ -70,6 +94,7 @@ Class | Method | HTTP request | Description
7094
*HistoryApi* | [**get_historical_candle_data1**](docs/HistoryApi.md#get_historical_candle_data1) | **GET** /v2/historical-candle/{instrumentKey}/{interval}/{to_date}/{from_date} | Historical candle data
7195
*HistoryApi* | [**get_intra_day_candle_data**](docs/HistoryApi.md#get_intra_day_candle_data) | **GET** /v2/historical-candle/intraday/{instrumentKey}/{interval} | Intra day candle data
7296
*LoginApi* | [**authorize**](docs/LoginApi.md#authorize) | **GET** /v2/login/authorization/dialog | Authorize API
97+
*LoginApi* | [**init_token_request_for_indie_user**](docs/LoginApi.md#init_token_request_for_indie_user) | **POST** /v3/login/auth/token/request/{client_id} | Init token API
7398
*LoginApi* | [**logout**](docs/LoginApi.md#logout) | **DELETE** /v2/logout | Logout
7499
*LoginApi* | [**token**](docs/LoginApi.md#token) | **POST** /v2/login/authorization/token | Get token API
75100
*MarketHolidaysAndTimingsApi* | [**get_exchange_timings**](docs/MarketHolidaysAndTimingsApi.md#get_exchange_timings) | **GET** /v2/market/timings/{date} | Get Exchange Timings on particular date
@@ -105,6 +130,9 @@ Class | Method | HTTP request | Description
105130
*WebsocketApi* | [**get_market_data_feed_authorize**](docs/WebsocketApi.md#get_market_data_feed_authorize) | **GET** /v2/feed/market-data-feed/authorize | Market Data Feed Authorize
106131
*WebsocketApi* | [**get_portfolio_stream_feed**](docs/WebsocketApi.md#get_portfolio_stream_feed) | **GET** /v2/feed/portfolio-stream-feed | Portfolio Stream Feed
107132
*WebsocketApi* | [**get_portfolio_stream_feed_authorize**](docs/WebsocketApi.md#get_portfolio_stream_feed_authorize) | **GET** /v2/feed/portfolio-stream-feed/authorize | Portfolio Stream Feed Authorize
133+
*OrderApiV3* | [**cancel_order**](docs/OrderApiV3.md#cancel_order) | **DELETE** /v3/order/cancel |
134+
*OrderApiV3* | [**modify_order**](docs/OrderApiV3.md#modify_order) | **PUT** /v3/order/modify |
135+
*OrderApiV3* | [**place_order**](docs/OrderApiV3.md#place_order) | **POST** /v3/order/place |
108136

109137
## Documentation for Feeder Functions
110138

@@ -762,6 +790,7 @@ if __name__ == "__main__":
762790
- [CancelOrExitOrderErrorData](docs/CancelOrExitOrderErrorData.md)
763791
- [CancelOrderData](docs/CancelOrderData.md)
764792
- [CancelOrderResponse](docs/CancelOrderResponse.md)
793+
- [CancelOrderV3Response](docs/CancelOrderV3Response.md)
765794
- [ConvertPositionData](docs/ConvertPositionData.md)
766795
- [ConvertPositionRequest](docs/ConvertPositionRequest.md)
767796
- [ConvertPositionResponse](docs/ConvertPositionResponse.md)
@@ -794,6 +823,9 @@ if __name__ == "__main__":
794823
- [HistoricalCandleData](docs/HistoricalCandleData.md)
795824
- [HoldingsData](docs/HoldingsData.md)
796825
- [HolidayData](docs/HolidayData.md)
826+
- [IndieUserInitTokenData](docs/IndieUserInitTokenData.md)
827+
- [IndieUserInitTokenResponse](docs/IndieUserInitTokenResponse.md)
828+
- [IndieUserTokenRequest](docs/IndieUserTokenRequest.md)
797829
- [Instrument](docs/Instrument.md)
798830
- [InstrumentData](docs/InstrumentData.md)
799831
- [IntraDayCandleData](docs/IntraDayCandleData.md)
@@ -809,11 +841,13 @@ if __name__ == "__main__":
809841
- [ModifyOrderData](docs/ModifyOrderData.md)
810842
- [ModifyOrderRequest](docs/ModifyOrderRequest.md)
811843
- [ModifyOrderResponse](docs/ModifyOrderResponse.md)
844+
- [ModifyOrderV3Response](docs/ModifyOrderV3Response.md)
812845
- [MultiOrderData](docs/MultiOrderData.md)
813846
- [MultiOrderError](docs/MultiOrderError.md)
814847
- [MultiOrderRequest](docs/MultiOrderRequest.md)
815848
- [MultiOrderResponse](docs/MultiOrderResponse.md)
816849
- [MultiOrderSummary](docs/MultiOrderSummary.md)
850+
- [MultiOrderV3Data](docs/MultiOrderV3Data.md)
817851
- [OAuthClientException](docs/OAuthClientException.md)
818852
- [OAuthClientExceptionCause](docs/OAuthClientExceptionCause.md)
819853
- [OAuthClientExceptionCauseStackTrace](docs/OAuthClientExceptionCauseStackTrace.md)
@@ -822,10 +856,13 @@ if __name__ == "__main__":
822856
- [OptionStrikeData](docs/OptionStrikeData.md)
823857
- [OrderBookData](docs/OrderBookData.md)
824858
- [OrderData](docs/OrderData.md)
859+
- [OrderMetadata](docs/OrderMetadata.md)
825860
- [OtherTaxes](docs/OtherTaxes.md)
826861
- [PlaceOrderData](docs/PlaceOrderData.md)
827862
- [PlaceOrderRequest](docs/PlaceOrderRequest.md)
828863
- [PlaceOrderResponse](docs/PlaceOrderResponse.md)
864+
- [PlaceOrderV3Request](docs/PlaceOrderV3Request.md)
865+
- [PlaceOrderV3Response](docs/PlaceOrderV3Response.md)
829866
- [PositionData](docs/PositionData.md)
830867
- [PostMarginResponse](docs/PostMarginResponse.md)
831868
- [Problem](docs/Problem.md)

docs/CancelOrderV3Response.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CancelOrderV3Response
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**status** | **str** | | [optional]
7+
**data** | [**CancelOrderData**](CancelOrderData.md) | | [optional]
8+
**metadata** | [**OrderMetadata**](OrderMetadata.md) | | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+

docs/ChargeApi.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,55 @@ Name | Type | Description | Notes
6868

6969
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
7070

71+
# **post_margin**
72+
> PostMarginResponse post_margin(body)
73+
74+
Calculate Margin
75+
76+
Compute Margin
77+
78+
### Example
79+
```python
80+
from __future__ import print_function
81+
import time
82+
import upstox_client
83+
from upstox_client.rest import ApiException
84+
from pprint import pprint
85+
86+
# Configure OAuth2 access token for authorization: OAUTH2
87+
configuration = upstox_client.Configuration()
88+
configuration.access_token = 'YOUR_ACCESS_TOKEN'
89+
90+
# create an instance of the API class
91+
api_instance = upstox_client.ChargeApi(upstox_client.ApiClient(configuration))
92+
body = upstox_client.MarginRequest() # MarginRequest |
93+
94+
try:
95+
# Calculate Margin
96+
api_response = api_instance.post_margin(body)
97+
pprint(api_response)
98+
except ApiException as e:
99+
print("Exception when calling ChargeApi->post_margin: %s\n" % e)
100+
```
101+
102+
### Parameters
103+
104+
Name | Type | Description | Notes
105+
------------- | ------------- | ------------- | -------------
106+
**body** | [**MarginRequest**](MarginRequest.md)| |
107+
108+
### Return type
109+
110+
[**PostMarginResponse**](PostMarginResponse.md)
111+
112+
### Authorization
113+
114+
[OAUTH2](../README.md#OAUTH2)
115+
116+
### HTTP request headers
117+
118+
- **Content-Type**: application/json
119+
- **Accept**: application/json, */*
120+
121+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
122+

docs/IndieUserInitTokenData.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IndieUserInitTokenData
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**authorization_expiry** | **str** | authorize token expiry | [optional]
7+
**notifier_url** | **str** | notifier webhook url | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+

docs/IndieUserInitTokenResponse.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IndieUserInitTokenResponse
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**status** | **str** | | [optional]
7+
**data** | [**IndieUserInitTokenData**](IndieUserInitTokenData.md) | | [optional]
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+

docs/IndieUserTokenRequest.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# IndieUserTokenRequest
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**client_secret** | **str** | OAuth client secret that is a private secret known only to app and authorization server | [optional]
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

docs/LoginApi.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,56 @@ No authorization required
6363

6464
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6565

66+
# **init_token_request_for_indie_user**
67+
> IndieUserInitTokenResponse init_token_request_for_indie_user(body, client_id)
68+
69+
Init token API
70+
71+
This API provides the initialize the generate token and it's expiry for an indie user
72+
73+
### Example
74+
```python
75+
from __future__ import print_function
76+
import time
77+
import upstox_client
78+
from upstox_client.rest import ApiException
79+
from pprint import pprint
80+
81+
# create an instance of the API class
82+
api_instance = upstox_client.LoginApi()
83+
body = upstox_client.IndieUserTokenRequest() # IndieUserTokenRequest |
84+
client_id = 'client_id_example' # str |
85+
86+
try:
87+
# Init token API
88+
api_response = api_instance.init_token_request_for_indie_user(body, client_id)
89+
pprint(api_response)
90+
except ApiException as e:
91+
print("Exception when calling LoginApi->init_token_request_for_indie_user: %s\n" % e)
92+
```
93+
94+
### Parameters
95+
96+
Name | Type | Description | Notes
97+
------------- | ------------- | ------------- | -------------
98+
**body** | [**IndieUserTokenRequest**](IndieUserTokenRequest.md)| |
99+
**client_id** | **str**| |
100+
101+
### Return type
102+
103+
[**IndieUserInitTokenResponse**](IndieUserInitTokenResponse.md)
104+
105+
### Authorization
106+
107+
No authorization required
108+
109+
### HTTP request headers
110+
111+
- **Content-Type**: application/json
112+
- **Accept**: application/json, */*
113+
114+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
115+
66116
# **logout**
67117
> LogoutResponse logout(api_version)
68118

docs/ModifyOrderV3Response.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ModifyOrderV3Response
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**status** | **str** | | [optional]
7+
**data** | [**ModifyOrderData**](ModifyOrderData.md) | | [optional]
8+
**metadata** | [**OrderMetadata**](OrderMetadata.md) | | [optional]
9+
10+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
11+

docs/MultiOrderV3Data.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# MultiOrderV3Data
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**order_ids** | **list[str]** | | [optional]
7+
8+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
9+

0 commit comments

Comments
 (0)