Mirrored from the engine repository. Prefer reading here for a consistent experience; use GitHub for file history and blame.
Warning: normalization is not analysis
[mapPayloadToUnified] only normalizes known subtrees of a raw integration object (for example backtestResult, walkForwardAnalysis periods). It applies decimal conversion and key alignment where implemented.
It does not:
- run
analyze(),analyzeFromTrades(), oranalyzeFromWindows(), - compute rankings, p-values, or summaries,
- invent missing trades or curves.
If you need numbers, call an analysis entrypoint after you have valid inputs. See [ENTRYPOINTS.md].
When to use mapPayloadToUnified
- Raw JSON from an integration uses legacy or mixed keys (
optimization_returnvsoptimizationReturn,walkForwardAnalysisvswfaData, etc.). - You want a single normalization pass before your own code calls window-based analysis or other builders.
Authoritative types: [UnifiedIntegrationPayload].
When not to use it
- You already have a
Trade[]or a small JSON list of trades - useanalyze()oranalyzeFromTrades()directly. - You only have CSV - use adapters (below) first, then analysis entrypoints.
CSV to trades (only external format in this guide)
From @kiploks/engine-adapters:
csvToTrades(csvString, mapping)- whole file as a string in memory.csvToTradesFromStream(stream, mapping, options)- NodeReadablestream; supports amaxTradescap for large files (see [packages/adapters/README.md] and [csvToTrades.ts]).
Performance tip: For large CSVs, prefer csvToTradesFromStream; respect the row cap behavior documented in the adapter.
Then:
analyze({ trades }, config)for basic summary, or- build [
TradeBasedWFAInput] and callanalyzeFromTrades()for public WFA.
TypeScript sketch: mapPayloadToUnified
Exact field aliases are defined in [mapPayloadToUnified.ts]. Do not rely on undocumented keys.
See also
- [
ENTRYPOINTS.md] - full entrypoint map. - [
examples/04-csv-to-trades.md] - CSV column mapping examples. - [
OPEN_CORE_INTEGRATION_PRINCIPLES.md] - why there is norunEverything().