curl --request GET \
--url https://drb.coinbase.com/api/v2/private/simulate_portfolio \
--header 'Content-Type: application/json' \
--data '
{
"id": 22222,
"jsonrpc": "2.0",
"method": "private/simulate_portfolio",
"params": {
"add_positions": true,
"currency": "BTC",
"simulated_positions": {
"BTC-PERPETUAL": 1
}
}
}
'import requests
url = "https://drb.coinbase.com/api/v2/private/simulate_portfolio"
payload = {
"id": 22222,
"jsonrpc": "2.0",
"method": "private/simulate_portfolio",
"params": {
"add_positions": True,
"currency": "BTC",
"simulated_positions": { "BTC-PERPETUAL": 1 }
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 22222,
jsonrpc: '2.0',
method: 'private/simulate_portfolio',
params: {
add_positions: true,
currency: 'BTC',
simulated_positions: {'BTC-PERPETUAL': 1}
}
})
};
fetch('https://drb.coinbase.com/api/v2/private/simulate_portfolio', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://drb.coinbase.com/api/v2/private/simulate_portfolio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'id' => 22222,
'jsonrpc' => '2.0',
'method' => 'private/simulate_portfolio',
'params' => [
'add_positions' => true,
'currency' => 'BTC',
'simulated_positions' => [
'BTC-PERPETUAL' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://drb.coinbase.com/api/v2/private/simulate_portfolio"
payload := strings.NewReader("{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://drb.coinbase.com/api/v2/private/simulate_portfolio")
.header("Content-Type", "application/json")
.body("{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://drb.coinbase.com/api/v2/private/simulate_portfolio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 2,
"jsonrpc": "2.0",
"result": {
"additional_reserve": 0,
"available_funds": 115871741.76065847,
"available_subaccount_transfer_funds": 0,
"available_withdrawal_funds": 115871741.76065847,
"balance": 150076473.4995114,
"cross_collateral_enabled": true,
"currency": "BTC",
"delta_total": 69080.932029,
"delta_total_map": {
"btc_usd": 68024.519462366
},
"equity": 150075253.91354558,
"fee_balance": 0,
"futures_pl": 39497.54616685,
"futures_session_rpl": 1.309136,
"futures_session_upl": -164.48253509,
"initial_margin": 37662472.03416069,
"locked_balance": 0,
"maintenance_margin": 30129215.84817124,
"margin_balance": 153534213.79481918,
"margin_model": "cross_pm",
"options_delta": 2883.38481,
"options_gamma": -0.03907,
"options_gamma_map": {
"btc_usd": -0.03907
},
"options_pl": 921.55562578,
"options_session_rpl": 0,
"options_session_upl": -174.67960675,
"options_theta": 142583.29246,
"options_theta_map": {
"btc_usd": 142583.29246
},
"options_value": -1056.41256672,
"options_vega": -39322.23046,
"options_vega_map": {
"btc_usd": -39322.23046
},
"portfolio_margining_enabled": true,
"projected_delta_total": 69080.932029,
"projected_initial_margin": 37662472.03416069,
"projected_maintenance_margin": 30129215.84817124,
"session_rpl": 1.309136,
"session_upl": -339.16214185,
"spot_reserve": 0,
"total_delta_total_usd": 6157454218.3753195,
"total_equity_usd": 13075634611389.318,
"total_initial_margin_usd": 3139528603778.822,
"total_maintenance_margin_usd": 2511559381417.215,
"total_margin_balance_usd": 12798550648250.61,
"total_pl": 40419.10179263
},
"testnet": true,
"usDiff": 13650,
"usIn": 1742210019774525,
"usOut": 1742210019788175
}private/simulate_portfolio
Calculates portfolio margin requirements and risk metrics for simulated positions or the current portfolio. This method helps you understand margin requirements before opening new positions or assess the impact of potential trades.
You can simulate adding new positions to the current portfolio or calculate margin for a completely simulated portfolio. The response includes initial margin, maintenance margin, available funds, and other risk metrics.
Note: This method has a restricted rate limit of not more than once per second due to the computational complexity of portfolio margin calculations.
📖 Related Article: Portfolio Margin
Scope: rat#view or wallet:accounts:read
curl --request GET \
--url https://drb.coinbase.com/api/v2/private/simulate_portfolio \
--header 'Content-Type: application/json' \
--data '
{
"id": 22222,
"jsonrpc": "2.0",
"method": "private/simulate_portfolio",
"params": {
"add_positions": true,
"currency": "BTC",
"simulated_positions": {
"BTC-PERPETUAL": 1
}
}
}
'import requests
url = "https://drb.coinbase.com/api/v2/private/simulate_portfolio"
payload = {
"id": 22222,
"jsonrpc": "2.0",
"method": "private/simulate_portfolio",
"params": {
"add_positions": True,
"currency": "BTC",
"simulated_positions": { "BTC-PERPETUAL": 1 }
}
}
headers = {"Content-Type": "application/json"}
response = requests.get(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: 22222,
jsonrpc: '2.0',
method: 'private/simulate_portfolio',
params: {
add_positions: true,
currency: 'BTC',
simulated_positions: {'BTC-PERPETUAL': 1}
}
})
};
fetch('https://drb.coinbase.com/api/v2/private/simulate_portfolio', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://drb.coinbase.com/api/v2/private/simulate_portfolio",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode([
'id' => 22222,
'jsonrpc' => '2.0',
'method' => 'private/simulate_portfolio',
'params' => [
'add_positions' => true,
'currency' => 'BTC',
'simulated_positions' => [
'BTC-PERPETUAL' => 1
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://drb.coinbase.com/api/v2/private/simulate_portfolio"
payload := strings.NewReader("{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://drb.coinbase.com/api/v2/private/simulate_portfolio")
.header("Content-Type", "application/json")
.body("{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://drb.coinbase.com/api/v2/private/simulate_portfolio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"id\": 22222,\n \"jsonrpc\": \"2.0\",\n \"method\": \"private/simulate_portfolio\",\n \"params\": {\n \"add_positions\": true,\n \"currency\": \"BTC\",\n \"simulated_positions\": {\n \"BTC-PERPETUAL\": 1\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"id": 2,
"jsonrpc": "2.0",
"result": {
"additional_reserve": 0,
"available_funds": 115871741.76065847,
"available_subaccount_transfer_funds": 0,
"available_withdrawal_funds": 115871741.76065847,
"balance": 150076473.4995114,
"cross_collateral_enabled": true,
"currency": "BTC",
"delta_total": 69080.932029,
"delta_total_map": {
"btc_usd": 68024.519462366
},
"equity": 150075253.91354558,
"fee_balance": 0,
"futures_pl": 39497.54616685,
"futures_session_rpl": 1.309136,
"futures_session_upl": -164.48253509,
"initial_margin": 37662472.03416069,
"locked_balance": 0,
"maintenance_margin": 30129215.84817124,
"margin_balance": 153534213.79481918,
"margin_model": "cross_pm",
"options_delta": 2883.38481,
"options_gamma": -0.03907,
"options_gamma_map": {
"btc_usd": -0.03907
},
"options_pl": 921.55562578,
"options_session_rpl": 0,
"options_session_upl": -174.67960675,
"options_theta": 142583.29246,
"options_theta_map": {
"btc_usd": 142583.29246
},
"options_value": -1056.41256672,
"options_vega": -39322.23046,
"options_vega_map": {
"btc_usd": -39322.23046
},
"portfolio_margining_enabled": true,
"projected_delta_total": 69080.932029,
"projected_initial_margin": 37662472.03416069,
"projected_maintenance_margin": 30129215.84817124,
"session_rpl": 1.309136,
"session_upl": -339.16214185,
"spot_reserve": 0,
"total_delta_total_usd": 6157454218.3753195,
"total_equity_usd": 13075634611389.318,
"total_initial_margin_usd": 3139528603778.822,
"total_maintenance_margin_usd": 2511559381417.215,
"total_margin_balance_usd": 12798550648250.61,
"total_pl": 40419.10179263
},
"testnet": true,
"usDiff": 13650,
"usIn": 1742210019774525,
"usOut": 1742210019788175
}Query Parameters
The currency symbol
Currency, i.e "BTC", "ETH", "USDC"
BTC, ETH, USDC, USDT, EURR "BTC"
If true, adds simulated positions to current positions, otherwise uses only simulated positions. By default true
Object with positions in following form: {InstrumentName1: Position1, InstrumentName2: Position2...}, for example {"BTC-PERPETUAL": -1000.0} (or corresponding URI-encoding for GET). For futures in USD, for options in base currency.
JSON string containing: object data
Was this page helpful?