Every bot needs data before it decides anything. In the Deriv API with Python, the ticks_history request is the heart of this: it delivers the price history of an asset — as ticks or as candles (OHLC) — and also lets you subscribe to live updates. This guide is a direct reference: the syntax, the fields that matter, and ready-to-use code to pull history and receive ticks in real time. Short-term trading is extremely high-risk — test everything in a demo account first.

Want a ready-made Deriv bot that already collects data, calculates indicators, and manages risk? See the Python solution and test it in a demo account.

See the Deriv bot in Python →

Connection

Deriv uses a WebSocket with JSON messages. To only read market data you don’t even need a token (but to trade, you do):

import json, asyncio, websockets APP_ID = “1089” # use your own app_id URL = f”wss://ws.derivws.com/websockets/v3?app_id={APP_ID}” async def send(ws, payload): await ws.send(json.dumps(payload)) return json.loads(await ws.recv())

ticks_history in tick format

To pull the last N prices (ticks) of an asset:

req = { “ticks_history”: “R_100”, “end”: “latest”, “count”: 10, “style”: “ticks” } resp = await send(ws, req) hist = resp[“history”] print(“Prices:”, hist[“prices”]) # list of prices print(“Times:”, hist[“times”]) # list of timestamps (epoch)
Key fields: count defines how many points to go back; end accepts “latest” or a timestamp; you can also use start for a range. In ticks style, the response comes in history.prices and history.times (two parallel lists).

ticks_history in candle format (OHLC)

For candles (open/high/low/close), use style: "candles" and set the granularity in seconds (60 = 1 minute, 300 = 5 min, 3600 = 1h):

req = { “ticks_history”: “R_100”, “end”: “latest”, “count”: 50, “style”: “candles”, “granularity”: 60 # 1 minute } resp = await send(ws, req) candles = resp[“candles”] ultima = candles[-1] print(“Open :”, ultima[“open”]) print(“High :”, ultima[“high”]) print(“Low :”, ultima[“low”]) print(“Close:”, ultima[“close”]) print(“Epoch:”, ultima[“epoch”])

The response comes in candles, a list of objects with open, high, low, close, and epoch — ready to feed indicators (moving averages, RSI, ATR).

Live ticks (subscribe)

To receive each new tick in real time, add subscribe: 1 and keep reading the socket:

await ws.send(json.dumps({“ticks”: “R_100”, “subscribe”: 1})) while True: msg = json.loads(await ws.recv()) tick = msg.get(“tick”) if tick: print(tick[“epoch”], “->”, tick[“quote”])
Ending the subscription: store the returned subscription.id and send {"forget": "<id>"} to stop receiving. To stop everything at once, use {"forget_all": "ticks"}.

Tip: combine history + live

The professional pattern is simple: pull a block of candles to “warm up” your indicators (warm-up), and from there update with live ticks. That way your RSI/ATR is already calculated correctly from the start instead of having to wait for dozens of bars.

FAQ

Do I need a token to read data?
For ticks_history and market ticks, usually not. A token is required to trade (proposal/buy) and for account data.

What granularities exist?
Values in seconds such as 60, 120, 300, 600, 900, 1800, 3600, 7200, 14400, 28800, and 86400 (1 day), among others.

What’s the count limit?
There’s a per-request cap (in the thousands). For long histories, paginate using start and end.

How do I get the list of assets?
Use the active_symbols request to discover the symbols available for your account/region.

Disclaimer: trading short-term contracts and options is extremely high-risk and most retail traders lose money. This content is educational and technical; it does not constitute an investment recommendation, an offer, or financial advice. Past results do not guarantee future results. Always test in a demo account before risking real capital, and never invest more than you can afford to lose.