Get MTF Positions
API to retrieve the current Margin Trade Funding (MTF) positions for the user. MTF is a facility that allows investors to buy securities by paying a fraction of the transaction value, with the remaining amount funded by the Upstox. These positions remain in the MTF portfolio until they are either sold or the loan is repaid.
Request
curl --location 'https://api.upstox.com/v3/portfolio/mtf-positions' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
For additional samples in various languages, please refer to the Sample code section on this page.
Response Body
{
"status": "success",
"data": [
{
"exchange": "NSE",
"multiplier": 1.0,
"value": 4285.0,
"pnl": 128.55,
"product": "MTF",
"instrument_token": "NSE_EQ|INE062A01020",
"average_price": 571.33,
"buy_value": 4285.0,
"overnight_quantity": 5,
"day_buy_value": 2856.65,
"day_buy_price": 571.33,
"overnight_buy_amount": 1428.35,
"overnight_buy_quantity": 2,
"day_buy_quantity": 5,
"day_sell_value": 0.0,
"day_sell_price": 0.0,
"overnight_sell_amount": 0.0,
"overnight_sell_quantity": 0,
"day_sell_quantity": 0,
"quantity": 7,
"last_price": 589.75,
"unrealised": 128.55,
"realised": 0.0,
"sell_value": 0.0,
"trading_symbol": "SBIN",
"close_price": 572.65,
"buy_price": 571.33,
"sell_price": 0.0
},
{
"exchange": "NSE",
"multiplier": 1.0,
"value": 58300.0,
"pnl": 350.0,
"product": "MTF",
"instrument_token": "NSE_EQ|INE002A01018",
"average_price": 2915.0,
"buy_value": 58300.0,
"overnight_quantity": 20,
"day_buy_value": 0.0,
"day_buy_price": 0.0,
"overnight_buy_amount": 58300.0,
"overnight_buy_quantity": 20,
"day_buy_quantity": 0,
"day_sell_value": 0.0,
"day_sell_price": 0.0,
"overnight_sell_amount": 0.0,
"overnight_sell_quantity": 0,
"day_sell_quantity": 0,
"quantity": 20,
"last_price": 2932.5,
"unrealised": 350.0,
"realised": 0.0,
"sell_value": 0.0,
"trading_symbol": "RELIANCE",
"close_price": 2920.75,
"buy_price": 2915.0,
"sell_price": 0.0
}
]
}
Name | Type | Description |
---|---|---|
status | string | A string indicating the outcome of the request. Typically success for successful operations. |
data | object[] | Response data for MTF position details |
data[].exchange | string | Exchange to which the order is associated. For MTF positions, valid exchange is NSE only. |
data[].multiplier | float | The quantity/lot size multiplier used for calculating P&Ls |
data[].value | float | Net value of the position |
data[].pnl | float | Profit and loss - net returns on the position |
data[].product | string | For MTF positions, this will always be 'MTF' |
data[].instrument_token | string | Key of the instrument. For the regex pattern applicable to this field, see the Field Pattern Appendix. |
data[].average_price | float | Average price at which the net position quantity was acquired |
data[].buy_value | float | Net value of the bought quantities |
data[].overnight_quantity | int32 | Quantity held previously and carried forward over night |
data[].day_buy_value | float | Amount at which the quantity is bought during the day |
data[].day_buy_price | float | Average price at which the day qty was bought. Default is empty string |
data[].overnight_buy_amount | float | Amount at which the quantity was bought in the previous session |
data[].overnight_buy_quantity | int32 | Quantity bought in the previous session |
data[].day_buy_quantity | int32 | Quantity bought during the day |
data[].day_sell_value | float | Amount at which the quantity is sold during the day |
data[].day_sell_price | float | Average price at which the day quantity was sold |
data[].overnight_sell_amount | float | Amount at which the quantity was sold in the previous session |
data[].overnight_sell_quantity | int32 | Quantity sold short in the previous session |
data[].day_sell_quantity | int32 | Quantity sold during the day |
data[].quantity | int32 | Quantity left after nullifying Day and CF buy quantity towards Day and CF sell quantity |
data[].last_price | float | Last traded market price of the instrument |
data[].unrealised | float | Day PnL generated against open positions |
data[].realised | float | Day PnL generated against closed positions |
data[].sell_value | float | Net value of the sold quantities |
data[].trading_symbol | string | Shows the trading symbol of the instrument |
data[].close_price | float | Closing price of the instrument from the last trading day |
data[].buy_price | float | Average price at which quantities were bought |
data[].sell_price | float | Average price at which quantities were sold |
Sample Code
Get MTF Positions
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api.upstox.com/v3/portfolio/mtf-positions'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v3/portfolio/mtf-positions';
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v3/portfolio/mtf-positions";
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v3/portfolio/mtf-positions';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);
echo $response;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
apiInstance = upstox_client.PortfolioApi(upstox_client.ApiClient(configuration))
try:
response = apiInstance.get_mtf_positions()
print("MTF positions:", response)
except ApiException as e:
print("Exception when calling PortfolioApi->get_mtf_positions: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.PortfolioApi();
apiInstance.getMtfPositions((error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data:', data);
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.*;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setAccessToken("{your_access_token}");
PortfolioApi portfolioApi = new PortfolioApi();
try {
GetPositionResponse result = portfolioApi.getMtfPositions();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling PortfolioApi->getMtfPositions: " + e.getMessage());
}
}
}
Loading...