Deriv API
Migration guide/Contract update history

Contract update history

Trading
Auth Required

Retrieves the historical and most recent update status of a contract, including all changes made to contract parameters such as stop loss and take profit values.

Quick comparison

AspectLegacyNewAction required
Endpoint
✅ Same
contract_update_historycontract_update_historyNone
Auth Required
✅ Same
YesYesNone
loginid Parameter
❌ Removed
OptionalRemovedRemove from requests
Response contract_update_history
⚠️ Changed
OptionalRequiredUpdate response handling
Array item fields
⚠️ Changed
All optional4 required, 1 optionalReview field handling
limit constraints
⚠️ Changed
default: 500, min: 1, max: 999Not specified in schemaVerify behavior

Breaking changes

1. LoginID parameter removed

What Changed: The loginid parameter used for multi-token authorization scenarios has been removed. Account context must now be managed through the authorization flow rather than per-request parameters.

2. Response field contract_update_history now required

What Changed: The contract_update_history array in the response is now a required field. In the legacy API, this field was optional.

Migration Action: Update response handling code. You can now rely on this field being present without null checks for the array itself.

3. Response array items have required fields

What Changed: Each item in the contract_update_history array now requires four fields: display_name, order_amount, order_date, and order_type. Only the value field remains optional.

Migration Action: You can simplify your code by removing defensive null checks for these now-required fields.

Request structure

Legacy Request Example

1{
2  "contract_update_history": 1,
3  "contract_id": 123,
4  "limit": 500,  // Optional: defaults to 500, min 1, max 999
5  "loginid": "CR123456"  // ❌ Removed in New
6}

New Request Example

1{
2  "contract_update_history": 1,
3  "contract_id": 123,
4  "limit": 500  // Optional: constraints not specified in schema
5}

Note: The Legacy API enforced limit constraints (default: 500, min: 1, max: 999). The New API schema doesn't explicitly specify these constraints - verify current behavior if your implementation relies on these defaults.

Response structure

Legacy Response Example

1// contract_update_history: OPTIONAL
2// All array item fields: OPTIONAL
3{
4  "contract_update_history": [
5    {
6      "display_name": "Stop Loss",
7      "order_amount": "10.50",
8      "order_date": 1699564800,
9      "order_type": "stop_loss",
10      "value": "1234.56"
11    },
12    {
13      "display_name": "Take Profit",
14      "order_amount": "15.75",
15      "order_date": 1699565400,
16      "order_type": "take_profit",
17      "value": "1250.00"
18    }
19  ],
20  "echo_req": {
21    "contract_update_history": 1,
22    "contract_id": 123
23  },
24  "msg_type": "contract_update_history"
25}

New Response Example

1// contract_update_history: ✅ REQUIRED
2// Required fields: display_name, order_amount, order_date, order_type
3// Optional field: value
4{
5  "contract_update_history": [
6    {
7      "display_name": "Stop Loss",
8      "order_amount": "10.50",
9      "order_date": 1699564800,
10      "order_type": "stop_loss",
11      "value": "1234.56"
12    },
13    {
14      "display_name": "Take Profit",
15      "order_amount": "15.75",
16      "order_date": 1699565400,
17      "order_type": "take_profit",
18      "value": "1250.00"
19    }
20  ],
21  "echo_req": {
22    "contract_update_history": 1,
23    "contract_id": 123
24  },
25  "msg_type": "contract_update_history"
26}

Code examples

Legacy Implementation

1async function getContractUpdateHistory(contractId) {
2  const request = {
3    contract_update_history: 1,
4    contract_id: contractId,
5    limit: 500,
6    loginid: "CR123456"  // For multi-token scenarios
7  };
8  
9  ws.send(JSON.stringify(request));
10  
11  // Handle response
12  ws.onmessage = (event) => {
13    const response = JSON.parse(event.data);
14    
15    if (response.msg_type === "contract_update_history") {
16      const updates = response.contract_update_history;
17      updates.forEach(update => {
18        console.log(`${update.display_name}: ${update.order_amount} at ${new Date(update.order_date * 1000)}`);
19        console.log(`Type: ${update.order_type}, Value: ${update.value}`);
20      });
21    }
22  };
23}

New Implementation

1async function getContractUpdateHistory(contractId) {
2  const request = {
3    contract_update_history: 1,
4    contract_id: contractId,
5    limit: 500
6    // loginid parameter removed in New
7  };
8  
9  ws.send(JSON.stringify(request));
10  
11  // Handle response
12  ws.onmessage = (event) => {
13    const response = JSON.parse(event.data);
14    
15    if (response.msg_type === "contract_update_history") {
16      const updates = response.contract_update_history;
17      updates.forEach(update => {
18        console.log(`${update.display_name}: ${update.order_amount} at ${new Date(update.order_date * 1000)}`);
19        console.log(`Type: ${update.order_type}, Value: ${update.value}`);
20      });
21    }
22  };
23}