NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages

cumulativeReturn compounds each trade’s return — its P&L divided by open price × size — in the order the trades close (see Trade order): (1 + r₁) × (1 + r₂) × … − 1, reported in percent to 2 decimals. gross uses the raw return; net subtracts the commission first. Every trade in the stream counts, open ones at their close price:

$gross = $analytics->cumulativeReturn->gross->global->total;
$net = $analytics->cumulativeReturn->net->global->total;

$gross->total;        // '2.97' — compounded return over the stream, in percent
$gross->average;      // '0.98' — geometric mean return per trade, in percent
$gross->highest;      // '5.00' — peak of the running cumulative return
$gross->highestPair;  // 'BTC/USD' — the pair whose trade set that peak
$gross->lowest;       // '-0.25' — trough of the running cumulative return (lowestPair 'ETH/USD')
$net->total;          // '2.71' — the same, with commissions subtracted

$analytics->cumulativeReturn->net->forPair('BTC/USD')->buy->total;
  • total — the compounded return at the end of the stream.
  • average — the geometric mean return per trade, computed entirely in bcmath.
  • highest / lowest — the peak and the trough the running cumulative return reached, each with the pair of the trade that set it. Zero is a value like any other, so the highest can be below 0.

Like every aggregate metric, gross and net both break down per pair, base and quote currency, and into buys and sells.

Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

More ways to support, including crypto

By donating, you agree to our donation terms.

Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.