Skip to content

Add period / fd / td date-range overrides to download()#111

Merged
csingley merged 1 commit into
csingley:masterfrom
bobwilkinson20:feature/flex-period-override
Jun 11, 2026
Merged

Add period / fd / td date-range overrides to download()#111
csingley merged 1 commit into
csingley:masterfrom
bobwilkinson20:feature/flex-period-override

Conversation

@bobwilkinson20

Copy link
Copy Markdown
Contributor

Addresses #109.

IBKR's v3 Flex Web Service may resolve a query's saved "Last N Calendar Days" period to a single day when SendRequest carries only v/t/q, silently returning a statement with no CashTransactions or Trades (positions still come back, so it fails quietly). The documented p (period) and fd/td (from/to date) SendRequest overrides fix this, but ibflex had no way to pass them.

Changes

  • download() / request_statement() / submit_request() gain optional period (p, lookback in days, max 365) and fd/td (yyyymmdd) kwargs, applied only to the SendRequest step — not the GetStatement polls.
  • period and fd/td are mutually exclusive, and fd/td must be supplied together; invalid combinations raise ValueError. (Empirically, IBKR silently ignores p when fd/td are also present, so the guard prevents a confusing no-op.)
  • flexget gains --period/-p, --fromdate/--fd, --todate/--td; invalid combinations surface as a clean argparse error (exit 2) rather than a traceback.
  • Default behavior is unchanged.

Tests

New tests cover p on SendRequest only, fd/td, the mutual-exclusion and pairing guards, and the no-override case. ruff / mypy / pytest all pass.

Verified live against a v3 account: a query that returned a 1-day window via download() returns the full window via download(..., period=90).

IBKR's v3 Flex Web Service can resolve a query's saved "Last N Calendar
Days" period to a single day when SendRequest carries only v/t/q,
silently returning a statement with no cash transactions or trades. The
documented `p` (period) and `fd`/`td` (from/to date) SendRequest
overrides address this, but the client had no way to pass them.

Add optional `period` (`p`, lookback in days, max 365) and `fd`/`td`
(`yyyymmdd`) kwargs to download() / request_statement / submit_request,
applied only to the SendRequest step (not the GetStatement polls).
`period` and `fd`/`td` are mutually exclusive, and `fd`/`td` must be given
together; invalid combinations raise ValueError, surfaced as a clean
argparse error in the flexget CLI. Matching --period/--fromdate/--todate
flags added to flexget. Default behavior is unchanged.

Addresses csingley#109.
@csingley csingley merged commit f1b96e2 into csingley:master Jun 11, 2026
4 checks passed
@csingley

Copy link
Copy Markdown
Owner

LGTM

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants