use Illuminate\Support\Facades\DB;
use RoundlyConsulting\TradingAnalytics\Facades\TradingAnalytics;
$analytics = TradingAnalytics::for($trades)->scale(2)->calculate();
// …or stream a query ordered by close time, one page of rows at a time:
$history = TradingAnalytics::calculate(
DB::table('trades')->where('user_id', $user->id)->orderBy('close_time')->orderBy('id'),
);
$analytics->realizedProfitAndLoss->net->global->total->total->toRawString(); // "-65.00"
$analytics->wins->winRatio->global->total->toRawString(); // "0.50"
$analytics->volume->forPair('BTC/USD')->buy->total->toRawString(); // "0.10"
$analytics->maxDrawdown->percentage;
$analytics->riskAdjustedReturns->sharpeRatio;
return $analytics; // the full result matrix as JSON
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.