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

->scale() (or the scale config key) sets the decimal places of every amount: P&L, volume, value, commission, their averages, the expectancy’s and risk/reward ratio’s average win and loss, and the drawdown. bcmath truncates rather than rounds, so each figure is truncated to its scale as it is stored; ratios are divided at a higher working scale first, so an operand below the result’s precision — a loss of 0.00005 BTC, a deviation of a few basis points — still counts. Ratios and percentages are reported at a fixed scale, whatever the run’s:

FiguresDecimal places
volume, value, commission, P&L and their averages, expectancy value / averageWin / averageLoss, riskRewardRatio averageWin / averageLoss, maxDrawdown value / equity / peakthe run’s scale (default 10)
counts, wins, streaks0
frequency1
wins->winRatio, profitFactor2
cumulativeReturn (percent), duration (seconds)2
expectancy->winRate / lossRate, winRateByPeriod->rates4
riskRewardRatio->value, maxDrawdown->percentage, sharpeRatio, sortinoRatio4
riskAdjustedReturns meanReturn / standardDeviation / downsideDeviation10

Each trade’s own numbers are exact: Trade::make(), fromArray() and fromRow() keep every amount at its own decimal places (at least 10), and its P&L and value at entry (size × open price) are computed without truncation, so the run’s scale truncates them only once, into its results. Building trades shows a high-precision example.

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.