# Candle data and mark price not matching with he candles seen on trading terminal

**URL:** <https://community.delta.exchange/t/candle-data-and-mark-price-not-matching-with-he-candles-seen-on-trading-terminal/764>\
**Category:** APIs & Algo Trading\
**Created:** [January 29, 2025, 5:20pm UTC](https://community.delta.exchange/t/candle-data-and-mark-price-not-matching-with-he-candles-seen-on-trading-terminal/764 "2025-01-29T17:20:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MangeshGaikwad](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@MangeshGaikwad](https://community.delta.exchange/u/MangeshGaikwad)\
**Post date:** [January 29, 2025, 5:20pm UTC](https://community.delta.exchange/t/candle-data-and-mark-price-not-matching-with-he-candles-seen-on-trading-terminal/764/1 "2025-01-29T17:20:09Z")

</div>

// subscription  
DELTA\_WS\_URL = “wss://socket.delta.exchange”  
SUBSCRIBE\_MESSAGE = {  
“type”: “subscribe”,  
“payload”: {  
“channels”: [  
{“name”: “candlestick\_1m”, “symbols”: [“BTCUSD”]},  
{“name”: “candlestick\_15m”, “symbols”: [“BTCUSD”]},  
{“name”: “candlestick\_30m”, “symbols”: [“BTCUSD”]},  
{“name”: “candlestick\_1h”, “symbols”: [“BTCUSD”]},  
{“name”: “candlestick\_4h”, “symbols”: [“BTCUSD”]},  
{“name”: “v2/ticker”, “symbols”: [“BTCUSD”]}  
]  
}  
}  
// Driver code part  
log(f"Received data: {data}", level=‘debug’)  
closePrice = None  
# Handle candlestick feeds  
if msg\_type.startswith(“candlestick\_”):  
if data.get(“symbol”) == “BTCUSD”:  
o = float(data[“open”])  
h = float(data[“high”])  
l = float(data[“low”])  
c = float(data[“close”])  
vol = float(data[“volume”])  
cst\_str = data[“candle\_start\_time”] # nanoseconds

```
            # Route to the correct aggregator based on resolution
            if msg_type == "candlestick_1m":
                candles_1m.add_candle(o, h, l, c, vol, cst_str)
                log(f"1M: {data}", level='info')
            elif msg_type == "candlestick_15m":
                candles_15m.add_candle(o, h, l, c, vol, cst_str)
            elif msg_type == "candlestick_30m":
                candles_30m.add_candle(o, h, l, c, vol, cst_str)
            elif msg_type == "candlestick_1h":
                candles_1h.add_candle(o, h, l, c, vol, cst_str)
            elif msg_type == "candlestick_4h":
                candles_4h.add_candle(o, h, l, c, vol, cst_str)
            else:
                log(f"Unhandled candlestick type: {msg_type}", level='warning')

    elif msg_type == "v2/ticker":
        if "mark_price" in data:
            runningPrice = float(data['mark_price'])

```

The data I am receiving is not matching with the values of candles or current price.

---

<div class="post-metadata">

**Author:** ![ayush.aggrwl](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@ayush.aggrwl](https://community.delta.exchange/u/ayush.aggrwl)\
**Post date:** [January 29, 2025, 8:03pm UTC](https://community.delta.exchange/t/candle-data-and-mark-price-not-matching-with-he-candles-seen-on-trading-terminal/764/2 "2025-01-29T20:03:17Z")

</div>

There can be a few different reasons why the values you see in the WebSocket feed might not line up with the prices or candle data you expect.

find some common causes, along with suggestions to troubleshoot:

If you want the actual traded price, look for `last_price` or subscribe to the “trades” feed instead of using /in addition to `mark_price`

Wait for a candle to close, then compare the final data to the official chart on Delta or to the REST/historical API data. In-progress candles will always be a moving target.

Make sure candle\_start\_time is defined in UTC vs. local, partial intervals

---

<div class="post-metadata">

**Author:** ![MangeshGaikwad](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@MangeshGaikwad](https://community.delta.exchange/u/MangeshGaikwad)\
**Post date:** [January 30, 2025, 3:22am UTC](https://community.delta.exchange/t/candle-data-and-mark-price-not-matching-with-he-candles-seen-on-trading-terminal/764/3 "2025-01-30T03:22:23Z")

</div>

Thanks a lot for the help.
