Version 1 of 1 · · Current version

rebalance: story

A small resource book drifted after a run in gold, through rebalance: one well over target, two under, two on target, and a 1,500 cash reserve to keep: the buys share what the sell frees up, and the last one is trimmed.

$val positions = [
  {ticker: "FRST", shares: 4000.0, price: 2.10, target: 0.20},
  {ticker: "CPHD", shares: 1500.0, price: 3.40, target: 0.20},
  {ticker: "NRTH", shares: 300.0, price: 18.50, target: 0.25},
  {ticker: "GLDX", shares: 520.0, price: 12.00, target: 0.20},
  {ticker: "URNM", shares: 600.0, price: 4.80, target: 0.15}
]
$send pf.rebalance (positions = positions, cash = 150.0, reserve = 1500.0)
$expect payload.total > 24000.0
$expect sizeOf(payload.sells) is 1
$expect "GLDX" in payload.holds
$expect (payload.buys filter (b => b.trimmed ?? false)) is not empty
$expect payload.cashLeft >= 1500.0