Skip to content

subscribe_candle() never returns historical backfill — server sends empty snapshot because CHANNEL_REQUEST always uses contract: "AUTO" #353

Description

@Section1256

DXLinkStreamer._channel_request hardcodes "contract": "AUTO" in the CHANNEL_REQUEST message for every event type, including Candle. For Candle subscriptions with a start_time, this means the server never sends historical backfill — it responds with a single FEED_DATA event carrying eventFlags=14 (SNAPSHOT_BEGIN | SNAPSHOT_END | REMOVE_EVENT — dxFeed's convention for an explicit empty snapshot terminator) and all-NaN/zero OHLC fields, even for a highly liquid symbol like AAPL with start_time 90 days back.

Manually driving the dxLink protocol and requesting "contract": "HISTORY" instead of "AUTO" on the same channel, with everything else identical, returns real backfill immediately — dozens of real daily OHLC bars with correct dates, prices, and volume.

Repro (using tastytrade==13.2.3):

from datetime import datetime, timedelta, timezone
from tastytrade import Session, DXLinkStreamer
from tastytrade.dxfeed import Candle

session = Session(...)
async with session:
    await session.refresh(force=True)
    start_time = datetime.now(timezone.utc) - timedelta(days=90)
    async with DXLinkStreamer(session) as streamer:
        await streamer.subscribe_candle(["AAPL"], "1d", start_time=start_time)
        candle = await streamer.get_event(Candle)
        print(candle.time, candle.open, candle.close)
        # -> time equals the requested start_time verbatim (echoed back),
        #    open/close are 0 - not a real bar.

What I found by bypassing the SDK and sending a raw CHANNEL_REQUEST with "parameters": {"contract": "HISTORY"} instead of "AUTO" (same FEED_SETUP/FEED_SUBSCRIPTION messages otherwise): real daily bars for AAPL, SPX, and a front-month futures symbol (/MESU26:XCME) all came back correctly, with realistic dates/prices/volume and proper eventFlags (4 for the live/current-day bar, 0 for closed days).

Reproduced against both the current PyPI release (13.2.3) and unreleased master_channel_request is unchanged in both.

Suggested fix: either let subscribe_candle()/_channel_request request "HISTORY" for Candle channels specifically, or expose contract as a parameter so callers can choose.

Happy to open a PR if that's useful — wanted to confirm this isn't already-known/by-design first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions