Portfolio
AccountAuth RequiredGet the open positions of the current account. symbol is renamed to underlying_symbol, the loginid parameter and app_id field are removed, and contract_type values changed.
4 Breaking Changes
symbol is renamed to underlying_symbol, the loginid parameter and the app_id field are removed, and the contract_type filter accepts different values.Quick comparison
Breaking changes
1. symbol renamed to underlying_symbol
Each contract in portfolio.contracts returns its symbol as underlying_symbol instead of symbol.
Required change: Read underlying_symbol instead of symbol.
2. loginid parameter removed
In the Legacy API, loginid selected the account when you authorised several accounts. The New API does not accept it.
Required change: Remove loginid from your portfolio requests. Your token selects the account.
3. app_id removed from contracts
The Legacy API returned app_id, the ID of the app the contract was bought through, on each contract. The New API does not return it.
Required change: Stop reading app_id from portfolio contracts.
4. contract_type values changed
The contract_type filter no longer accepts CALLSPREAD, PUTSPREAD, LBFLOATCALL, LBFLOATPUT or LBHIGHLOW, and adds HIGHER and LOWER.
Required change: Remove the values the New API no longer accepts from contract_type.
Request structure
{
"portfolio": 1,
"contract_type": [
"CALL",
"PUT",
"CALLSPREAD"
],
"loginid": "CR123456",
"req_id": 1
}{
"portfolio": 1,
"contract_type": [
"CALL",
"PUT",
"HIGHER"
],
"req_id": 1
}Response structure
{
"echo_req": {
"portfolio": 1,
"contract_type": [
"CALL",
"PUT",
"CALLSPREAD"
],
"loginid": "CR123456",
"req_id": 1
},
"msg_type": "portfolio",
"portfolio": {
"contracts": [
{
"buy_price": 10,
"contract_id": 11542203588,
"contract_type": "CALL",
"currency": "USD",
"date_start": 1760000000,
"expiry_time": 1760000300,
"longcode": "Win payout if Volatility 100 Index is strictly higher than entry spot at 5 minutes after contract start time.",
"payout": 19.55,
"purchase_time": 1760000000,
"shortcode": "CALL_R_100_19.55_1760000000_1760000300_S0P_0",
"transaction_id": 11542203587,
"app_id": 1089,
"symbol": "R_100"
}
]
},
"req_id": 1
}{
"echo_req": {
"portfolio": 1,
"contract_type": [
"CALL",
"PUT",
"HIGHER"
],
"req_id": 1
},
"msg_type": "portfolio",
"portfolio": {
"contracts": [
{
"buy_price": 10,
"contract_id": 11542203588,
"contract_type": "CALL",
"currency": "USD",
"date_start": 1760000000,
"expiry_time": 1760000300,
"longcode": "Win payout if Volatility 100 Index is strictly higher than entry spot at 5 minutes after contract start time.",
"payout": 19.55,
"purchase_time": 1760000000,
"shortcode": "CALL_R_100_19.55_1760000000_1760000300_S0P_0",
"transaction_id": 11542203587,
"underlying_symbol": "R_100"
}
]
},
"req_id": 1
}Code examples
function getPortfolio(loginId) {
ws.send(JSON.stringify({ portfolio: 1, contract_type: ["CALL", "PUT", "CALLSPREAD"], loginid: loginId }));
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
if (response.msg_type !== "portfolio" || !response.portfolio) return;
response.portfolio.contracts.forEach((contract) => {
console.log(contract.contract_id, contract.symbol, contract.app_id);
});
};
}Any other questions? Get in touch