Skip to content

Nautilus with Bybit adapter silently dies if bars are requested for long period of time #3117

@h3x3d

Description

@h3x3d

Bug Report

Confirmed

  • I’ve re-read the relevant sections of the documentation.
  • I’ve searched existing issues and discussions to avoid duplicates.
  • I’ve reviewed or skimmed the source code (or examples) to confirm the behavior is not by design.
  • I’ve tested this issue using a recent development wheel (dev develop or a nightly) and can still reproduce it.

Expected Behavior

I was expecting to succesfully request bars (m1, m5) from bybit exchange for few days.

Actual Behavior

Application silently fails if i request m5 or m1 bars for a long period of time.

Steps to Reproduce the Problem

  1. Run provided strategy with provided runner
  2. Process just silently fails for some reason after receiving bar response

Code Snippets or Logs

Strategy:

class RandomConfig(StrategyConfig, frozen=True):
    instrument_id: InstrumentId


class RandomStrategy(Strategy):
    order = None
    counter = 0
    instrument: Instrument
    bar_type: BarType
    window: int = 5
    orders: dict = {}

    def __init__(self, config: RandomConfig) -> None:
        super().__init__(config)

        self.bar_type = BarType(
            instrument_id=self.config.instrument_id,
            bar_spec=BarSpecification(
                step=5,
                aggregation=BarAggregation.MINUTE,
                price_type=PriceType.LAST,
            ),
            aggregation_source=AggregationSource.EXTERNAL
        )

    def on_start(self) -> None:
        self.instrument = self.cache.instrument(self.config.instrument_id)

        self.request_bars(
            bar_type=self.bar_type,
            start=self.clock.utc_now() - pd.Timedelta(days=15)
        )

Runner:

    instrument_provider_config = InstrumentProviderConfig(load_all=True)

    data_clients = {
        BYBIT: BybitDataClientConfig(
            testnet=False,
            instrument_provider=instrument_provider_config,
            product_types=[BybitProductType.LINEAR]
        )
    }
    node_config = TradingNodeConfig(
        trader_id="STRATEGY-000001",
        exec_clients = {
            BYBIT: SandboxExecutionClientConfig(
                venue=BYBIT,
                starting_balances=["100 USDT"],
                instrument_provider=instrument_provider_config,
                account_type="MARGIN",
                oms_type="HEDGING",
            )
        },

        data_clients = data_clients,

        timeout_connection=30.0,
        timeout_reconciliation=10.0,
        timeout_portfolio=10.0,
        timeout_disconnection=10.0,
        timeout_post_stop=5.0,
    )

    node = TradingNode(config=node_config)

    node.add_data_client_factory(BYBIT, BybitLiveDataClientFactory)
    node.add_data_client_factory(BINANCE, BinanceLiveDataClientFactory)

    for exec_client in node_config.exec_clients:
        node.add_exec_client_factory(exec_client, SandboxLiveExecClientFactory)

    node.trader.add_strategy(RandomStrategy(RandomConfig(
        instrument_id=InstrumentId.from_str("XPINUSDT-LINEAR.BYBIT")
    )))

    node.build()
    node.run()

Log (tail only):

2025-10-28T07:15:22.930670603Z [INFO] STRATEGY-000001.RandomStrategy: RUNNING
2025-10-28T07:15:22.930679727Z [INFO] STRATEGY-000001.STRATEGY-000001: RUNNING
2025-10-28T07:15:22.930685314Z [INFO] STRATEGY-000001.TradingNode: RUNNING
2025-10-28T07:15:22.930802504Z [INFO] STRATEGY-000001.DataClient-BYBIT: Request XPINUSDT-LINEAR.BYBIT-5-MINUTE-LAST-EXTERNAL bars from 2025-10-13T07:15:22.930539000Z to 2025-10-28T07:15:22.930572164Z
2025-10-28T07:15:25.381041233Z [INFO] STRATEGY-000001.RandomStrategy: Received <Bar[4320]> data for XPINUSDT-LINEAR.BYBIT-5-MINUTE-LAST-EXTERNAL
(.nix-venv) 
[xxx@nuc:~/source/trading/labs]$ 

Specifications

  • OS platform: Linux
  • Python version: 3.13.7
  • nautilus_trader version: 1.221.0a20251024

PS:

Looks like this happens when pagination is involved (number of bars is more then 1000). Sorting issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions