# Post-Trade Settlement

Receive real-time updates to your account's credit and risk metrics.

{% hint style="info" %}
Refer to the [Support Center](https://support.sfox.com/product-guides/trading/post-trade-settlement/risk-management#overview) for more information regarding risk management and risk metrics for Post-Trade Settlement (note: you may be asked to sign in to your sFOX account before being redirected to the support center)
{% endhint %}

### **Subscribing**

<table data-header-hidden><thead><tr><th width="100"></th><th>Feed Name</th></tr></thead><tbody><tr><td>Feed name</td><td><strong><code>private.user.post-trade-settlement</code></strong> </td></tr></tbody></table>

```json
// Request -> post-trade settlement feed
{
    "type": "subscribe", 
    "feeds": ["private.user.post-trade-settlement"]
}
```

{% hint style="info" %}
The initial response payload will include a snapshot of your account's current credit and risk metric data.
{% endhint %}

### **Post-Trade Settlement Message**

{% hint style="warning" %}
Messages are only sent when a transaction is executed. However, please note that asset price changes may impact your risk metrics.
{% endhint %}

#### Post-Trade Settlement Object

<table><thead><tr><th width="272">Key</th><th>Type</th><th width="442">Description</th></tr></thead><tbody><tr><td><strong><code>enabled</code></strong></td><td>boolean</td><td>Boolean whether post-trade settlement is enabled for your account</td></tr><tr><td><strong><code>equity</code></strong></td><td>string</td><td>Collateralization–The "liquidation value" of your portfolio–the USD value of your assets if all of your holdings were converted to USD.</td></tr><tr><td><strong><code>equity_for_withdrawals</code></strong></td><td>string</td><td>Your "Free Equity." The portion of your Equity that could be removed from your account (e.g. for a withdrawal) without triggering liquidation. </td></tr><tr><td><strong><code>exposure</code></strong></td><td>string</td><td>Your current total net open position (NOP) across currencies/markets–the USD value of your positions pending settlement.</td></tr><tr><td><strong><code>available_exposure</code></strong></td><td>string</td><td>Credit available before hitting your Exposure Limit.</td></tr><tr><td><strong><code>exposure_limit</code></strong></td><td>string</td><td>The maximum USD value of your total net open positions (NOPs) across currencies/markets.</td></tr><tr><td><strong><code>liquidation_level</code></strong></td><td>string</td><td>If your Equity Level drops below this level, your positions will be partially settled automatically.</td></tr></tbody></table>

#### Post-Trade Settlement Message

```json
// Post-trade settlement message
{
    "sequence": 3,
    "recipient": "private.user.post-trade-settlement",
    "timestamp": 1727392002153041890,
    "payload": {
        "enabled": true,
        "equity": "81306152.88083515",
        "equity_for_withdrawals": "81286273.68856692",
        "exposure": "0",
        "available_exposure": "250000",
        "exposure_limit": "250000",
        "liquidation_level": "0.1"
    }
}
```

### Example Code & Post-Trade Settlement Message

{% tabs %}
{% tab title="NodeJS" %}

```javascript
const WebSocket = require('ws')

const ws = new WebSocket('wss://ws.sfox.com/ws')

ws.on('open', function() {
  const authMessage = {
   type: 'authenticate',
   apiKey: '<API_KEY>',
  }
  
  ws.send(JSON.stringify(authMessage))
})

// After successful authentication, subscribe to balances feed
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['private.user.post-trade-settlement']
}

ws.send(JSON.stringify(subscribeMsg))
```

{% endtab %}

{% tab title="Python" %}

```python
import asyncio
import json

import websockets


async def main(uri):
    async with websockets.connect(uri) as ws:
        await ws.send(json.dumps({
            "type": "authenticate",
            "apiKey": "<API_KEY>"
        }))

        # After successful authentication message
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": ["private.user.post-trade-settlement"]
        }))
        async for msg in ws:
            print(msg)


asyncio.run(main("wss://ws.sfox.com/ws"))
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sfox.com/websocket-api/orders-and-account-data/post-trade-settlement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
