Skip to content

Claim generic-CSV adapter when headers fully resolve; fall back to history import - #41

Open
vinay-veerappa wants to merge 2 commits into
LuxAlgo:mainfrom
vinay-veerappa:pr/generic-csv-history-fallback
Open

vinay-veerappa wants to merge 2 commits into
LuxAlgo:mainfrom
vinay-veerappa:pr/generic-csv-history-fallback

Conversation

@vinay-veerappa

Copy link
Copy Markdown

What

Two changes to statement import fallbacks:

  1. The generic CSV adapter now CLAIMS a file when its header row fully resolves against a known trade shape, instead of declining it to whatever comes next. A statement whose headers are unambiguous is parsed locally; a file whose headers only partially resolve still declines exactly as before.

  2. The import API's no-mapping path now falls back to the history importer (\parseHistory) when \parseAuto\ declines: \parseAuto(value) ?? parseHistory(value). Statements with a full trade shape that auto-detect skipped are imported instead of rejected with 'could not detect format'.

Verification

  • \packages/importers/tests/history.test.ts\ extended: a generic CSV with a complete trade shape (open time, close time, symbol, direction, quantity, prices) is auto-claimed, and a partial/unresolvable header shape still declines to the fallback path.
  • Full suite: 566 tests green (2 test files touch these paths).

Co-Authored-By: Claude noreply@anthropic.com

vinay and others added 2 commits October 7, 2026 13:02
…rted

f375ac6 made genericCsvAdapter claim a table whose headers resolve to a
complete trade (symbol, direction, both times, both prices, quantity, P&L),
and 8 tests still asserted the old rule that the generic mapper is reachable
only by explicit choice.

The complete-shape fixtures now go through parseClaimedGeneric, which asserts
the automatic route imports exactly what the explicit adapter does. The
incomplete shapes (pipe fills, no P&L column) keep asserting parseAuto is
null. The routing test now proves both directions: GENERIC is claimed, and
fills or the same table minus its P&L column still go to the column mapper.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

1 participant