Validate option series contract fields - #2
Conversation
There was a problem hiding this comment.
Pull request overview
Adds internal validation and parsing for option-series contract fields so option_series() can infer exact expiration dates (including day), normalize option rights, validate strikes, and enforce trading date constraints while maintaining backward compatibility via warnings when explicit fields disagree with the identifier.
Changes:
- Introduces internal helpers to parse option suffixes and validate/normalize
expires,callput,strike, andfirst_traded. - Updates
option_series()to construct and validate identifiers consistently, emitting targeted warnings for mismatches. - Adds focused
tinytestcoverage for exact-date parsing, normalization, warnings, and error cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| R/option_series_validation.R | Adds internal parsing/validation helpers for option-series expiration dates, rights, and strikes. |
| R/instrument.R | Switches option_series() to use the new helpers for construction/validation and to infer exact expiration dates. |
| inst/tinytest/test_option_series.R | Adds tests covering exact-date parsing, OSI-style strikes, normalization, warnings, and invalid inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
@copilot Review this PR for backward-compatibility risks, edge cases, and unintended API changes. Pay special attention to constructor behavior, parsing/normalization logic, date handling, warnings vs errors, POSIXct/POSIXlt inputs, vectorized inputs, and compatibility with existing FinancialInstrument conventions. Check whether the tests adequately cover both new functionality and legacy behavior. Do not suggest stylistic refactors unless they materially improve correctness or safety. Verify OSI-style option symbols, strike parsing, call/put normalization, explicit-vs-inferred field mismatches, and POSIXct/POSIXlt handling. |
Co-authored-by: JustinMShea <[email protected]>
I have reviewed the PR across all requested areas in commit c9f40ba:
|
…alidation origin master m A A A A B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B A B B B B B B A A A A A A A A B B B B B B B
Adds validation for option-series expiration dates, option rights, strikes, and trading dates. Exact expiration dates are inferred from option identifiers, inconsistent explicit fields produce clear conditions, and focused tinytest coverage is added without changing the exported API.