// 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.