WFA from trades (analyzeFromTrades)

Source path in repo: docs/examples/02-wfa-from-trades.md. [View on GitHub]

Mirrored from the engine repository. Prefer reading here for a consistent experience; use GitHub for file history and blame.

This example shows how to compute public WFA blocks using analyzeFromTrades() and the canonical WFAAnalysisOutput.

Key points:

  • wfaInputMode is required and must be tradeSlicedPseudoWfa.
  • For analyzeFromTrades(), each trade must include openTime and closeTime (unix ms).
  • parameterStability and benchmark may be unavailable, and that is represented explicitly in the output via available: false.

TypeScript (synthetic trades)

Optional permutationN on the analyze options (and on AnalyzeConfig when using the full contract) controls how many OOS shuffles are used for the WFE permutation p-value (default 1000, bounds 100..10000).

CLI (using a canonical engine input shape)

Prepare two files:

  1. trade-based-wfa.json - the canonical engine input shape (for validate)
  1. trades-array.json - raw trades array (for analyze-trades)

Validate the canonical contract:

Then run:

Note: analyze-trades --format auto accepts a JSON array of trades or a .csv file. Bot-specific JSON objects are not parsed in-tree; convert to Trade[] or CSV first.

[Back to documentation index]