Skip to content

Validate futures series contract dates - #1

Merged
JustinMShea merged 5 commits into
masterfrom
fix/future-series-validation
Sep 5, 2026
Merged

JustinMShea merged 5 commits into
masterfrom
fix/future-series-validation

Conversation

@JustinMShea

Copy link
Copy Markdown
Owner

Adds validation for futures contract suffixes and dates. Invalid dates now produce clear errors, inconsistent contract months produce warnings, and the existing continuous-contract and spread formats remain supported. Adds focused tinytest coverage without changing the public API.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds internal validation for futures series identifiers and contract dates, surfacing invalid inputs as clear errors and warning when an outright suffix month/year conflicts with the supplied expiration, while keeping existing storage formats (including YYYY-MM) and series/spread/continuous formats supported.

Changes:

  • Introduces internal parsing/validation helpers for suffixes and date inputs, including mismatch warnings and invalid-date errors.
  • Wires the new validation into future_series() construction flow.
  • Adds focused tinytest coverage for successful creation, warnings, and error cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
R/instrument.R Calls the new internal validator during future_series() construction.
R/future_series_validation.R Adds internal helpers to parse/validate suffixes and (month/day) date inputs, emitting warnings/errors.
inst/tinytest/test_future_series.R Adds regression tests covering valid series creation, mismatch warnings, and invalid inputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/future_series_validation.R Outdated
Comment thread inst/tinytest/test_future_series.R
JustinMShea and others added 2 commits July 13, 2026 18:30
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Vector formats and dates are mishandled, and invalid expiration errors can be masked by suffix validation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

R/future_series_validation.R:120

  • parse_suffix() can return multiple format values for a recognized butterfly whose legs use different suffix formats (it calls unique() across the legs). Passing that vector directly to || warns on older R versions and errors on current R versions, so an existing spread format such as U1.Z11.H2012 is rejected. Collapse the missingness check to one logical value.
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread R/future_series_validation.R Outdated
Comment on lines +173 to +174
if (!is.null(first_info) && !is.null(expiry_info) &&
nrow(first_info) == 1L && nrow(expiry_info) == 1L) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1f8c2d1: vector date inputs now have explicit R-style recycling semantics in the validation path, with regression coverage for scalar-to-vector recycling; paired vectors continue to reject any invalid chronological pair.

Comment thread R/future_series_validation.R Outdated
@JustinMShea
JustinMShea merged commit 0583138 into master Sep 5, 2026
6 checks passed
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.

3 participants