Skip to content

options.expirations returns an empty DataFrame when columns=["expirations"] is passed #23

@MarketDataDev03

Description

@MarketDataDev03

Problem

Calling options.expirations with columns=["expirations"] returns a DataFrame that looks empty, even
though the data is present — it's silently moved to the index.

Reproduction

from marketdata import MarketDataClient

df = MarketDataClient(token="...").options.expirations(
    symbol="AAPL", columns=["expirations"]
)
print(df)
# Empty DataFrame
# Columns: []
# Index: [2025-12-05, 2025-12-12, ...]

Root cause

src/marketdata/resources/options/expirations.py:70 forces index_columns=["expirations"]. When the user
filters to only that column, the handler promotes the single column to the index, leaving zero data columns.

Suggested fix

Skip the set_index step when it would leave the DataFrame with zero columns (generic fix in the output
handler), or don't pass index_columns when the user explicitly filtered via columns.

Related (latent)

In INTERNAL output format, OptionsExpirations requires updated, so any partial response raises
__init__() missing 1 required positional argument: 'updated'. Worth making the field optional while in the
area.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions