> For the complete documentation index, see [llms.txt](https://docs.sfox.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sfox.com/websocket-api/orders-and-account-data/orders.md).

# Orders

Real-time streaming updates to your open orders

Receive real-time updates regarding open orders you've placed in your account.&#x20;

Updates include any change to an open order e.g. order creation, partial fills, status changes, amendments, etc.

### **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.open-orders</code></strong> </td></tr></tbody></table>

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

{% hint style="info" %}
The initial response payload will include all open orders in your account–a list of N order objects, each containing the latest order information.
{% endhint %}

### Orders Message

{% hint style="info" %}
Refer to [Orders reference](/rest-api/orders.md) page for payload details including order status descriptions.
{% endhint %}

```json
//Orders feed message
{
  "sequence": 5,
  "recipient": "private.user.open-orders",
  "timestamp": 1649903305545835513,
  "payload": [{
    "id": 693291242,
    "client_order_id": "577ab261-9dfc-415a-ba61-a54a18c1942c",
    "date_added": "2023-11-14T22:08:53.000Z",
    "status": "Started",
    "filled": "0.00035333",
    "filled_amount": "14.61628778",
    "vwap": "41367.24246455",
    "price": "37227.82",
    "quantity": "0.05",
    "pair": "btcusd",
    "action": "Sell",
    "type": "TWAP",
    "algorithm_id": 307,
    "fees": "0.02850176"
  }]
}
```

### Example Code

{% 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 open orders feed
const subscribeMsg = {
  type: 'subscribe',
  feeds: ['private.user.open-orders']
}

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

{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```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, subscribe to the open orders feed
        await ws.send(json.dumps({
            "type": "subscribe",
            "feeds": ["private.user.open-orders"]
        }))
        async for msg in ws:
            print(msg)


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

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sfox.com/websocket-api/orders-and-account-data/orders.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
