fix: support narrowing filters in fundamentals data (#57)#58
Open
alexpipipi wants to merge 2 commits into
Open
fix: support narrowing filters in fundamentals data (#57)#58alexpipipi wants to merge 2 commits into
alexpipipi wants to merge 2 commits into
Conversation
GetFundamentalDataAsync(ticker, filter) always deserialized into the full
FundamentalData model. But when a filter narrows the response below the top
level (e.g. "Financials" or "General"), the API returns that inner
object/array/scalar instead of the {General, Financials, ...} shape — so
every property of the returned FundamentalData was null.
Added two filter-aware overloads (and the matching interface members):
- GetFundamentalDataAsync<T>(ticker, filter): deserialize into a caller type
- GetFundamentalDataRawAsync(ticker, filter): return a JToken for any shape
(object/array/scalar)
The original typed method is unchanged; its XML doc now warns that narrowing
filters won't map to FundamentalData and points to the new overloads. Added
regression tests for both. Verified against the live API: filter=Financials
returns Balance_Sheet/Income_Statement via the raw method; filter=General::Code
returns the scalar "AAPL" via the generic method.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Do you plan publish new package version with this changes? |
…lter shape (#57) Follow-up to PR #58 review (Codex GPT-5.4 + Gemini Pro both flagged the generic overload can throw on a T/shape mismatch). Adds an XML <remarks> pointing callers to GetFundamentalDataRawAsync when the response shape is unknown/varies. Comment-only; no behavior change. (dotnet not available locally — not built here.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #57 (reported by @vlad-rob).
Problem
GetFundamentalDataAsync("AAPL.US", "Financials")returns aFundamentalDatawith every property null, while the unfiltered call is fully populated.Root cause: the EODHD
/fundamentalsendpoint reshapes the response when a filter narrows below the top level:{ General, Highlights, Financials, ... }✅ maps toFundamentalDataGeneral,Highlights{ General, Highlights }✅ mapsFinancials{ Balance_Sheet, Cash_Flow, Income_Statement }❌ allFundamentalDataprops nullGeneral{ Code, Type, Name, ... }❌General::Code"AAPL"(scalar) ❌The method always deserialized into
FundamentalData, so any narrowing filter produced an empty object.Fix (backward compatible — no breaking changes)
Added two filter-aware overloads + matching interface members:
Task<T> GetFundamentalDataAsync<T>(ticker, filter)— deserialize into a caller-chosen typeTask<JToken> GetFundamentalDataRawAsync(ticker, filter)— return raw JSON for any shape (object/array/scalar)The original
GetFundamentalDataAsyncis untouched; its XML doc now warns about the filter-reshaping and points to the new overloads.Verification
Built with .NET SDK 8; live API tested through the compiled library:
GetFundamentalDataAsync("AAPL.US", "Financials")→General == null(reproduces the bug)GetFundamentalDataRawAsync("AAPL.US", "Financials")→ JToken withBalance_Sheetpopulated ✅GetFundamentalDataAsync<string>("AAPL.US", "General::Code")→"AAPL"✅GetFundamentalDataAsync("AAPL.US")(no filter) → still fully populated ✅Added regression tests
GetFundamentalDataRawAsyncTest_WithFilterandGetFundamentalDataAsyncGenericTest_ScalarFilter(both pass against the live API).Update
GetFundamentalDataAsync<T>:Tmust match the response shape for the chosen filter; useGetFundamentalDataRawAsyncwhen the shape is unknown or varies.