Skip to content

DataPortal correctness bugs: wrong default value and wrong data frequency #320

@pandashark

Description

@pandashark

Description

Two correctness bugs in DataPortal (src/zipline/data/data_portal.py):

1. _first_trading_minute set to (None, None) instead of None

In DataPortal.__init__(), when _first_trading_day is None, _first_trading_minute is set to (None, None) (a tuple) instead of None. Since session_first_minute() returns a single pd.Timestamp, the else branch should return None to match the expected type.

This causes TypeError in _handle_minute_history_out_of_bounds (comparing a Timestamp with a tuple) and _get_history_minute_window (comparing Timestamp < tuple).

2. _get_daily_spot_value passes "minute" instead of "daily"

In _get_daily_spot_value(), when forward-filling the "price" field and finding a value on a previous day, the code calls get_adjusted_value(..., "minute", ...) but this is the daily code path and should pass "daily".

While this doesn't currently cause incorrect results (the spot_value parameter bypasses the frequency-dependent path), it violates the semantic contract and could cause bugs if get_adjusted_value is refactored to use data_frequency in the adjustment path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions