> This page is for Web API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ibkrcampus.com/docs/llms.txt.

# All Account Positions In An Instrument

GET https://localhost:5000/v1/api/portfolio/positions/{conid}

Get positions in accounts for a given instrument (no secDef await control)

Reference: https://ibkrcampus.com/docs/web-api/api-reference/trading/trading-portfolio/get-all-accounts-for-conid

## Authentication

- `Authorization` header (bearer token, required) — SSO bearer token.

## Servers

- `https://localhost:5000` (Client Portal Gateway, default)
- `https://api.ibkr.com` (Production)
- `https://qa.interactivebrokers.com` (Sandbox)

## Request

### Path parameters

- `conid` (long, required)

## Response

### 200

Object containing positions in the requested conid broken out by account.

- `map from string to individualPosition`

## Errors

### 400 Bad Request Error

Missing, empty, non-numeric, or out-of-range parameter. The `error` field is always prefixed with `Bad Request:`.

- `status` (long, optional)
- `error` (string, optional)
- `message` (string, optional)

### 401 Unauthorized Error

Missing, invalid, or unparseable Authorization token.

- `status` (long, optional)
- `error` (string, optional)
- `message` (string, optional)

### 500 Internal Server Error

internal server error, returned when incoming request cannot be processed. It can sometimes include subset of bad requests. For example, wrong accountId passed and it can only be detected later in handling request. Error contains reason of the problem.

- `error` (string, optional) — error reason

### 503 Service Unavailable Error

service is unavailable. For example if request takes more than 10s due to some internal service unavailability, request aborted and this status returned

- `error` (string, optional) — error reason
- `statusCode` (long, optional) — mimic response status code

## Types

### individualPosition

A specific account's position in the requested conid.

- `acctId` (string, optional) — IB accountId of an account with a position in the requested conid.
- `allExchanges` (string, optional) — Comma separated all exchanges on which the instrument trades.
- `assetClass` (string, optional) — Asset class of the requested instrument.
- `avgCost` (double, optional) — The account's average cost for its position.
- `avgPrice` (double, optional) — The account's average price for its position.
- `baseAvgCost` (double, optional) — Average cost in the account's base currency.
- `baseAvgPrice` (double, optional) — Average price in the account's base currency.
- `baseMktPrice` (double, optional) — Market price of instrument in the account's base currency.
- `baseMktValue` (double, optional) — Market value of the position in the account's base currency.
- `baseRealizedPnl` (double, optional) — Realized PnL for the instrument in the account's base currency.
- `baseUnrealizedPnl` (double, optional) — Unrealized PnL for the instrument in the account's base currency.
- `chineseName` (string, optional) — Chinese name of the instrument.
- `conExchMap` (list of any, optional)
- `conid` (long, optional) — IB contract ID for the instrument.
- `contractDesc` (string, optional) — Human-readable description of the instrument.
- `countryCode` (string, optional) — Country in which the instrument is issued.
- `currency` (string, optional) — Currency in which the instrument trades.
- `displayRule` (IndividualPositionDisplayRule, optional) — Object defining minimum increments used in displaying market data for the instrument.
- `exchs` (IndividualPositionExchs, optional, nullable)
- `exerciseStyle` (string, optional, nullable) — Style of exercise for options.
- `expiry` (string, optional, nullable) — Expiration of instrument, if applicable.
- `fullName` (string, optional) — Full display name of the instrument.
- `group` (string, optional) — Industry sub-categorization of the instrument.
- `hasOptions` (boolean, optional) — Indicates whether instrument has options contracts available for trading at IB.
- `incrementRules` (list of IndividualPositionIncrementRulesItems, optional) — Array containing increment rules used when pricing orders for the instrument.
- `isEventContract` (boolean, optional) — Indicates whether the instrument is an Event Contract.
- `isUS` (boolean, optional) — Indicates whether the instrument is issued in the US.
- `lastTradingDay` (string, optional) — Last day of trading in the instrument, if applicable. Formatted `YYYYMMDD`.
- `listingExchange` (string, optional) — The exchange on which the instrument is listed, or the primary exchange recognized by IB for the instrument.
- `mktPrice` (double, optional) — Current market price of the instrument, in the instrument's currency.
- `mktValue` (double, optional) — Current market value of the account's position in the instrument, in the instrument's currency.
- `model` (string, optional) — Name of the model portfolio in which the account is invested that contributes this position.
- `multiplier` (double, optional) — Instrument's multiplier, if applicable.
- `name` (string, optional) — Formal name of the entity or asset to which the instrument relates.
- `pageSize` (long, optional) — Maximum number of accounts that can be returned in a single request.
- `position` (double, optional) — Size of position in units of instrument.
- `putOrCall` (enum, optional) — The right of an options contract, if applicable.
  - Allowed values: `P`, `C`
- `realizedPnl` (double, optional) — Realized PnL for the instrument in the instrument's currency.
- `sector` (string, optional) — Industry sector categorization of the instrument.
- `sectorGroup` (string, optional) — Industry sub-categorization of the instrument.
- `strike` (string, optional) — Strike price, if applicable. Returned as string.
- `ticker` (string, optional) — Symbol associated with the instrument.
- `time` (long, optional) — Time taken to retrieve position data in milliseconds.
- `type` (string, optional) — Description of instrument, used to differentiate classes, if applicable.
- `undConid` (long, optional) — Contract ID of underlying instrument, if applicable.
- `unrealizedPnl` (double, optional) — Unrealized PnL for the instrument in the account.

### IndividualPositionDisplayRule

Object defining minimum increments used in displaying market data for the instrument.

- `displayRuleStep` (list of IndividualPositionDisplayRuleDisplayRuleStepItems, optional) — Array containing objects corresponding to display rule increments.
- `magnification` (long, optional) — Magnifier applied to pricing, if applicable.

### IndividualPositionExchs

### IndividualPositionIncrementRulesItems

Objects describing a single increment rule.

- `increment` (double, optional) — The pricing increment.
- `lowerEdge` (double, optional) — Lower edge from which the price increment rule is effective.

### IndividualPositionDisplayRuleDisplayRuleStepItems

A single display rule increment.

- `decimalDigits` (long, optional) — Number of decimal digits to display.
- `lowerEdge` (double, optional) — Lower edge from which the display rule is effective.
- `wholeDigits` (long, optional) — Number of integer digits to display.

## Examples

### withPartialSecDefForSomeAccount

**Response**

```json
{
  "DU123456": [
    {
      "acctId": "DU123456",
      "allExchanges": "AMEX,NYSE,CBOE,PHLX,CHX,ARCA,ISLAND,ISE,IDEAL,NASDAQQ,REALNYSE,DRCTEDGE,BEX,BATS,NITEECN,EDGEA,CSFBALGO,PSX,BYX,ITG,PDQ,IBKRATS,NYSEFLOOR,CITADEL,NYSEDARK,MIAX,IBDARK,CITADELDP,NASDDARK,IEX,WEDBUSH,SUMMER,WINSLOW,FINRA,LIQITG,UBSDARK,BTIG,VIRTU,JEFF,OPCO,COWEN,DBK,JPMC,EDGX,JANE,NEEDHAM,FRACSHARE,RBCALGO,VIRTUDP,BAYCREST,FOXRIVER,MND,NITEEXST,PEARL,GSDARK,NITERTL,NYSENAT,IEXMID,HRT,FLOWTRADE,HRTDP,JANELP,PEAK6,CTDLZERO,HRTMID,JANEZERO,HRTEXST,IMCLP,LTSE,SOCGENDP,MEMX,INTELCROS,VIRTUBYIN,JUMPTRADE,NITEZERO,TPLUS1,XTXEXST,XTXDP,XTXMID,COWENLP,BARCDP,JUMPLP,OLDMCLP,RBCCMALP,WALLBETH,IBEOS,JONES,GSLP,BLUEOCEAN,USIBSILP,OVERNIGHT,JANEMID,IBATSEOS,HRTZERO,VIRTUALGO,G1XLP,VIRTUMID,GLOBALXLP,CTDLMID,TPLUS0",
      "assetClass": "STK",
      "avgCost": 144.46141,
      "avgPrice": 144.46141,
      "chineseName": "&#x56FD;&#x9645;&#x5546;&#x4E1A;&#x673A;&#x5668;",
      "conExchMap": [],
      "conid": 8314,
      "contractDesc": "IBM",
      "countryCode": "US",
      "currency": "USD",
      "displayRule": {
        "displayRuleStep": [
          {
            "decimalDigits": 2,
            "lowerEdge": 0,
            "wholeDigits": 4
          }
        ],
        "magnification": 0
      },
      "exchs": null,
      "exerciseStyle": null,
      "expiry": null,
      "fullName": "IBM",
      "group": "Computers",
      "hasOptions": true,
      "incrementRules": [
        {
          "increment": 0.01,
          "lowerEdge": 0
        }
      ],
      "isEventContract": false,
      "isUS": true,
      "lastTradingDay": null,
      "listingExchange": "NYSE",
      "mktPrice": 166.7599945,
      "mktValue": 235465.11,
      "model": "",
      "multiplier": 0,
      "name": "INTL BUSINESS MACHINES CORP",
      "pageSize": 100,
      "position": 1412,
      "putOrCall": null,
      "realizedPnl": 0,
      "sector": "Technology",
      "sectorGroup": "Computer Services",
      "strike": "0",
      "ticker": "IBM",
      "time": 64,
      "type": "COMMON",
      "undConid": 0,
      "unrealizedPnl": 31485.6
    }
  ],
  "DU123457": [
    {
      "acctId": "DU123457",
      "assetClass": "STK",
      "avgCost": 144.46141,
      "avgPrice": 144.46141,
      "conExchMap": [],
      "conid": 8314,
      "contractDesc": "IBM",
      "currency": "USD",
      "exchs": null,
      "exerciseStyle": null,
      "expiry": null,
      "mktPrice": 166.7599945,
      "mktValue": 235465.11,
      "model": "",
      "multiplier": null,
      "position": 1412,
      "putOrCall": null,
      "realizedPnl": 0,
      "strike": 0,
      "undConid": 0,
      "unrealizedPnl": 31485.6
    }
  ]
}
```

**SDK Code**

```python withPartialSecDefForSomeAccount
import requests

url = "https://localhost:5000/v1/api/portfolio/positions/8314"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript withPartialSecDefForSomeAccount
const url = 'https://localhost:5000/v1/api/portfolio/positions/8314';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go withPartialSecDefForSomeAccount
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://localhost:5000/v1/api/portfolio/positions/8314"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby withPartialSecDefForSomeAccount
require 'uri'
require 'net/http'

url = URI("https://localhost:5000/v1/api/portfolio/positions/8314")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java withPartialSecDefForSomeAccount
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://localhost:5000/v1/api/portfolio/positions/8314")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php withPartialSecDefForSomeAccount
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://localhost:5000/v1/api/portfolio/positions/8314', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp withPartialSecDefForSomeAccount
using RestSharp;

var client = new RestClient("https://localhost:5000/v1/api/portfolio/positions/8314");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift withPartialSecDefForSomeAccount
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:5000/v1/api/portfolio/positions/8314")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### withSecDefForAllAccounts

**Response**

```json
{
  "DU123456": [
    {
      "acctId": "DU123456",
      "allExchanges": "AMEX,NYSE,CBOE,PHLX,CHX,ARCA,ISLAND,ISE,IDEAL,NASDAQQ,REALNYSE,DRCTEDGE,BEX,BATS,NITEECN,EDGEA,CSFBALGO,PSX,BYX,ITG,PDQ,IBKRATS,NYSEFLOOR,CITADEL,NYSEDARK,MIAX,IBDARK,CITADELDP,NASDDARK,IEX,WEDBUSH,SUMMER,WINSLOW,FINRA,LIQITG,UBSDARK,BTIG,VIRTU,JEFF,OPCO,COWEN,DBK,JPMC,EDGX,JANE,NEEDHAM,FRACSHARE,RBCALGO,VIRTUDP,BAYCREST,FOXRIVER,MND,NITEEXST,PEARL,GSDARK,NITERTL,NYSENAT,IEXMID,HRT,FLOWTRADE,HRTDP,JANELP,PEAK6,CTDLZERO,HRTMID,JANEZERO,HRTEXST,IMCLP,LTSE,SOCGENDP,MEMX,INTELCROS,VIRTUBYIN,JUMPTRADE,NITEZERO,TPLUS1,XTXEXST,XTXDP,XTXMID,COWENLP,BARCDP,JUMPLP,OLDMCLP,RBCCMALP,WALLBETH,IBEOS,JONES,GSLP,BLUEOCEAN,USIBSILP,OVERNIGHT,JANEMID,IBATSEOS,HRTZERO,VIRTUALGO,G1XLP,VIRTUMID,GLOBALXLP,CTDLMID,TPLUS0",
      "assetClass": "STK",
      "avgCost": 144.46141,
      "avgPrice": 144.46141,
      "chineseName": "&#x56FD;&#x9645;&#x5546;&#x4E1A;&#x673A;&#x5668;",
      "conExchMap": [],
      "conid": 8314,
      "contractDesc": "IBM",
      "countryCode": "US",
      "currency": "USD",
      "displayRule": {
        "displayRuleStep": [
          {
            "decimalDigits": 2,
            "lowerEdge": 0,
            "wholeDigits": 4
          }
        ],
        "magnification": 0
      },
      "exchs": null,
      "exerciseStyle": null,
      "expiry": null,
      "fullName": "IBM",
      "group": "Computers",
      "hasOptions": true,
      "incrementRules": [
        {
          "increment": 0.01,
          "lowerEdge": 0
        }
      ],
      "isEventContract": false,
      "isUS": true,
      "lastTradingDay": null,
      "listingExchange": "NYSE",
      "mktPrice": 166.7599945,
      "mktValue": 235465.11,
      "model": "",
      "multiplier": 0,
      "name": "INTL BUSINESS MACHINES CORP",
      "pageSize": 100,
      "position": 1412,
      "putOrCall": null,
      "realizedPnl": 0,
      "sector": "Technology",
      "sectorGroup": "Computer Services",
      "strike": "0",
      "ticker": "IBM",
      "time": 64,
      "type": "COMMON",
      "undConid": 0,
      "unrealizedPnl": 31485.6
    }
  ],
  "DU123457": [
    {
      "acctId": "DU123457",
      "allExchanges": "AMEX,NYSE,CBOE,PHLX,CHX,ARCA,ISLAND,ISE,IDEAL,NASDAQQ,REALNYSE,DRCTEDGE,BEX,BATS,NITEECN,EDGEA,CSFBALGO,PSX,BYX,ITG,PDQ,IBKRATS,NYSEFLOOR,CITADEL,NYSEDARK,MIAX,IBDARK,CITADELDP,NASDDARK,IEX,WEDBUSH,SUMMER,WINSLOW,FINRA,LIQITG,UBSDARK,BTIG,VIRTU,JEFF,OPCO,COWEN,DBK,JPMC,EDGX,JANE,NEEDHAM,FRACSHARE,RBCALGO,VIRTUDP,BAYCREST,FOXRIVER,MND,NITEEXST,PEARL,GSDARK,NITERTL,NYSENAT,IEXMID,HRT,FLOWTRADE,HRTDP,JANELP,PEAK6,CTDLZERO,HRTMID,JANEZERO,HRTEXST,IMCLP,LTSE,SOCGENDP,MEMX,INTELCROS,VIRTUBYIN,JUMPTRADE,NITEZERO,TPLUS1,XTXEXST,XTXDP,XTXMID,COWENLP,BARCDP,JUMPLP,OLDMCLP,RBCCMALP,WALLBETH,IBEOS,JONES,GSLP,BLUEOCEAN,USIBSILP,OVERNIGHT,JANEMID,IBATSEOS,HRTZERO,VIRTUALGO,G1XLP,VIRTUMID,GLOBALXLP,CTDLMID,TPLUS0",
      "assetClass": "STK",
      "avgCost": 144.46141,
      "avgPrice": 144.46141,
      "chineseName": "&#x56FD;&#x9645;&#x5546;&#x4E1A;&#x673A;&#x5668;",
      "conExchMap": [],
      "conid": 8314,
      "contractDesc": "IBM",
      "countryCode": "US",
      "currency": "USD",
      "displayRule": {
        "displayRuleStep": [
          {
            "decimalDigits": 2,
            "lowerEdge": 0,
            "wholeDigits": 4
          }
        ],
        "magnification": 0
      },
      "exchs": null,
      "exerciseStyle": null,
      "expiry": null,
      "fullName": "IBM",
      "group": "Computers",
      "hasOptions": true,
      "incrementRules": [
        {
          "increment": 0.01,
          "lowerEdge": 0
        }
      ],
      "isEventContract": false,
      "isUS": true,
      "lastTradingDay": null,
      "listingExchange": "NYSE",
      "mktPrice": 166.7599945,
      "mktValue": 235465.11,
      "model": "",
      "multiplier": 0,
      "name": "INTL BUSINESS MACHINES CORP",
      "pageSize": 100,
      "position": 1412,
      "putOrCall": null,
      "realizedPnl": 0,
      "sector": "Technology",
      "sectorGroup": "Computer Services",
      "strike": "0",
      "ticker": "IBM",
      "time": 64,
      "type": "COMMON",
      "undConid": 0,
      "unrealizedPnl": 31485.6
    }
  ]
}
```

**SDK Code**

```python withSecDefForAllAccounts
import requests

url = "https://localhost:5000/v1/api/portfolio/positions/8314"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript withSecDefForAllAccounts
const url = 'https://localhost:5000/v1/api/portfolio/positions/8314';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go withSecDefForAllAccounts
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://localhost:5000/v1/api/portfolio/positions/8314"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby withSecDefForAllAccounts
require 'uri'
require 'net/http'

url = URI("https://localhost:5000/v1/api/portfolio/positions/8314")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java withSecDefForAllAccounts
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://localhost:5000/v1/api/portfolio/positions/8314")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php withSecDefForAllAccounts
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://localhost:5000/v1/api/portfolio/positions/8314', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp withSecDefForAllAccounts
using RestSharp;

var client = new RestClient("https://localhost:5000/v1/api/portfolio/positions/8314");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift withSecDefForAllAccounts
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:5000/v1/api/portfolio/positions/8314")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```