Unit tests for Omni/Fund/Invest.hs

t-701.1·WorkTask·
·
·
Parent:t-701·Created1 month ago·Updated1 week ago·pipeline runs →

Description

Edit

Write Omni/Fund/Invest/Test.hs covering pure functions in Omni/Fund/Invest.hs.

Follow the Omni/Fund/Overview/Test.hs pattern (standalone test binary with #!/usr/bin/env run.sh, exports test :: Test.Tree).

Functions to test

1. kellyOptimalN — given rf=0.10 and [(BTC, 0.15, 0.65)], expected ≈ 0.118. Also: multiple assets, zero-vol asset, all-zero returns.

2. computeDeltas — end-to-end: given a model and actuals, verify delta list has correct assets, funds, targets, actuals, and buy/sell/aligned actions.

3. mkDelta — threshold logic: within 5% or $1000 → aligned, positive → buy, negative → sell.

4. buildActuals — maps StrategySummary fields to ActualPositions correctly. Need to construct a minimal StrategySummary for testing.

5. bucketize — histogram binning. bucketize [1..10] 5 should produce 5 bins. Edge: empty list, single element, all same value.

6. boxMuller — given a fixed StdGen seed, produces deterministic output. Statistical property: mean ≈ 0, stddev ≈ 1 over many samples.

7. buildAssetList — extracts (name, startUsd, μ, σ, yield) from model+actuals.

8. JSON round-tripsdecode (encode x) == Right x for PortfolioModel, SimConfig, ActualPositions, SimResult.

9. Monte Carlo determinism — runSimulation with a known model, fixed seed, small nPaths (e.g. 10) → reproducible P50 value.

Acceptance criteria

  • bild --test Omni/Fund/Invest/Test.hs passes
  • Covers all exported pure functions

Timeline (5)

🔄[human]Open → InProgress1 month ago
🔄[human]InProgress → Review1 month ago
💬[human]1 week ago

Ava verified: commit found in live history referencing this task/feature. Moving to Verified.

🔄[human]Review → Verified1 week ago