upstox-java

PortfolioApi

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

convertPositions

ConvertPositionResponse convertPositions(body, apiVersion)

Convert Positions

Convert the margin product of an open position

Example

// 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();
}

Parameters

Name Type Description Notes
body ConvertPositionRequest    
apiVersion String API Version Header  

Return type

ConvertPositionResponse

Authorization

OAUTH2

HTTP request headers

getHoldings

GetHoldingsResponse getHoldings(apiVersion)

Get Holdings

Fetches the holdings which the user has bought/sold in previous trading sessions.

Example

// 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();
}

Parameters

Name Type Description Notes
apiVersion String API Version Header  

Return type

GetHoldingsResponse

Authorization

OAUTH2

HTTP request headers

getPositions

GetPositionResponse getPositions(apiVersion)

Get Positions

Fetches the current positions for the user for the current day.

Example

// 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();
}

Parameters

Name Type Description Notes
apiVersion String API Version Header  

Return type

GetPositionResponse

Authorization

OAUTH2

HTTP request headers