nautechsystems/nautilus_trader · error · ImportError

pandas is required for report generation; install it with `p

Error message

pandas is required for report generation; install it with `pip install pandas`

What it means

validate_market_start_time rejects min_market_start_time or max_market_start_time strings that parse_betfair_timestamp cannot parse. The parser accepts RFC 3339 / ISO-8601 strings with time and offset (e.g. "2021-03-19T12:07:00+10:00"), because Betfair navigation data returns that format. The error is raised during BetfairDataClientConfig::validate(), before any network activity, and embeds the underlying parse error plus the offending value.

Source

Thrown at python/nautilus_trader/analysis/reporter.py:38

"""

from __future__ import annotations

from typing import TYPE_CHECKING

from nautilus_trader.model import OrderFilled


if TYPE_CHECKING:
    import pandas as pd


def _require_pandas() -> None:
    try:
        import pandas as pd  # noqa: F401 (presence check)
    except ImportError as e:
        raise ImportError(
            "pandas is required for report generation; install it with `pip install pandas`",
        ) from e


def _ns_to_dt(ts: int) -> pd.Timestamp:
    import pandas as pd

    return pd.Timestamp(ts, tz="UTC")


class ReportProvider:
    """
    Provides various portfolio analysis reports.
    """

    @staticmethod
    def generate_orders_report(orders: list) -> pd.DataFrame:
        _require_pandas()

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Use a full RFC 3339 timestamp with time and UTC offset, e.g. "2026-08-16T00:00:00Z" or "2026-08-16T00:00:00+01:00"
  2. Expand date-only boundaries explicitly to midnight with an offset
  3. Generate the strings programmatically with chrono (Utc::now().to_rfc3339()) instead of typing them

Example fix

// before
.min_market_start_time(Some("2026-09-01".to_string()))

// after
.min_market_start_time(Some("2026-09-01T00:00:00Z".to_string()))
Defensive patterns

Strategy: validation

Validate before calling

let ts = "2026-09-01T00:00:00Z";
chrono::DateTime::parse_from_rfc3339(ts)
    .map_err(|e| anyhow::anyhow!("invalid market start time '{ts}': {e}"))?;

Type guard

fn is_valid_betfair_timestamp(s: &str) -> bool {
    chrono::DateTime::parse_from_rfc3339(s).is_ok()
}

Prevention

When it happens

Trigger: Setting min_market_start_time or max_market_start_time to a non-RFC3339 string such as "19/03/2026", "2026-08-16" (date without time and offset), or "Aug 16 2026"; then calling validate() or starting the data client.

Common situations: Copying human-readable dates from the Betfair web UI or a spreadsheet into config; YAML date-only scalars losing time and timezone; locale-formatted dates (DD/MM/YYYY) pasted from local documents.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/32200bd03eed25fd. Report an issue: GitHub.