All URIs are relative to https://api-v2.upstox.com
Method | HTTP request | Description |
---|---|---|
convertPositions | PUT /portfolio/convert-position | Convert Positions |
getHoldings | GET /portfolio/long-term-holdings | Get Holdings |
getPositions | GET /portfolio/short-term-positions | Get Positions |
ConvertPositionResponse convertPositions(body, apiVersion)
Convert Positions
Convert the margin product of an open position
// Import classes:
//import com.upstox.ApiClient;
//import com.upstox.ApiException;
//import com.upstox.Configuration;
//import com.upstox.auth.*;
//import io.swagger.client.api.PortfolioApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAUTH2
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("YOUR ACCESS TOKEN");
PortfolioApi apiInstance = new PortfolioApi();
ConvertPositionRequest body = new ConvertPositionRequest(); // ConvertPositionRequest |
String apiVersion = "apiVersion_example"; // String | API Version Header
try {
ConvertPositionResponse result = apiInstance.convertPositions(body, apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PortfolioApi#convertPositions");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
body | ConvertPositionRequest | ||
apiVersion | String | API Version Header |
GetHoldingsResponse getHoldings(apiVersion)
Get Holdings
Fetches the holdings which the user has bought/sold in previous trading sessions.
// Import classes:
//import com.upstox.ApiClient;
//import com.upstox.ApiException;
//import com.upstox.Configuration;
//import com.upstox.auth.*;
//import io.swagger.client.api.PortfolioApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAUTH2
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("YOUR ACCESS TOKEN");
PortfolioApi apiInstance = new PortfolioApi();
String apiVersion = "apiVersion_example"; // String | API Version Header
try {
GetHoldingsResponse result = apiInstance.getHoldings(apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PortfolioApi#getHoldings");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
apiVersion | String | API Version Header |
GetPositionResponse getPositions(apiVersion)
Get Positions
Fetches the current positions for the user for the current day.
// Import classes:
//import com.upstox.ApiClient;
//import com.upstox.ApiException;
//import com.upstox.Configuration;
//import com.upstox.auth.*;
//import io.swagger.client.api.PortfolioApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure OAuth2 access token for authorization: OAUTH2
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("YOUR ACCESS TOKEN");
PortfolioApi apiInstance = new PortfolioApi();
String apiVersion = "apiVersion_example"; // String | API Version Header
try {
GetPositionResponse result = apiInstance.getPositions(apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PortfolioApi#getPositions");
e.printStackTrace();
}
Name | Type | Description | Notes |
---|---|---|---|
apiVersion | String | API Version Header |