> 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/market-data/ticker.md).

# Ticker

Real-time streaming day OHLCV data and last trade

Receive aggregated 24-hour OHLCV data from all supported exchanges and the last price before each update every 3 seconds. Subscriptions to the ticker feed will receive real-time trades that occur on any of the exchanges that are active on the sFOX platform.

### **Subscribing**

<table data-header-hidden><thead><tr><th width="100">Feed</th><th>Example</th></tr></thead><tbody><tr><td>Feed</td><td><strong><code>ticker.sfox.&#x3C;basequote></code></strong></td></tr><tr><td>Example</td><td><strong><code>ticker.sfox.btcusd</code></strong></td></tr></tbody></table>

```json
// Request -> ticker feed
{
    "type": "subscribe", 
    "feeds": ["ticker.sfox.btcusd"]
}
```

### **Ticker Message**

#### Ticker Object

<table><thead><tr><th width="178">Key</th><th>Description</th></tr></thead><tbody><tr><td><strong><code>amount</code></strong></td><td>Quantity of the most recent trade on this pair</td></tr><tr><td><strong><code>exchange</code></strong></td><td>Location of the most recent trade on this pair</td></tr><tr><td><strong><code>last</code></strong></td><td>Price of the most recent trade on this pair</td></tr><tr><td><strong><code>high</code></strong></td><td>High price since 00:00:00 GMT</td></tr><tr><td><strong><code>low</code></strong></td><td>Low price since 00:00:00 GMT</td></tr><tr><td><strong><code>open</code></strong></td><td>Open price at 00:00:00 GMT</td></tr><tr><td><strong><code>pair</code></strong></td><td>Currency pair</td></tr><tr><td><strong><code>source</code></strong></td><td>Data source</td></tr><tr><td><strong><code>timestamp</code></strong></td><td>Time of the trade</td></tr><tr><td><strong><code>volume</code></strong></td><td>Volume traded since 00:00:00 GMT (base currency)</td></tr><tr><td><strong><code>vwap</code></strong></td><td>Volume-weighted average price since 00:00:00 GMT</td></tr></tbody></table>

#### Ticker Message

```json
// Ticker feed message
{
  "sequence": 4,
  "recipient": "ticker.sfox.btcusd",
  "timestamp": 1649901842979345289,
  "payload": {
    "amount": 0.00005737,
    "exchange": "coinbase",
    "high": 41512.43,
    "last": 41420.58,
    "low": 41058.82,
    "open": 41141.31,
    "pair": "btcusd",
    "route": "Smart",
    "source": "ticker-info",
    "timestamp": "2022-04-14T02:04:02.481Z",
    "volume": 1387.77211046,
    "vwap": 41283.96339697249
  }
}
```

### Example Code & Ticker Message

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

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

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

ws.on('message', function(data) {
    console.log(data);
});

ws.on('open', function() {
  const subscribeMsg = {
    type: 'subscribe',
    feeds: ['ticker.sfox.btcusd']
  }
  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": "subscribe",
            "feeds": [
                "ticker.sfox.btcusd",
            ],
        }))
        async for msg in ws:
            print(msg)


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

{% 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/market-data/ticker.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.
