---
title: "Configuration — Trading Analytics for Laravel | Roundly"
description: "The two config keys — default bcmath scale and win-rate period — their env variables, and how a single run overrides them."
url: https://roundly-consulting.com/open-source/docs/trading-analytics-for-laravel/configuration
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Trading Analytics for Laravel](https://roundly-consulting.com/open-source/docs/trading-analytics-for-laravel.md)

# Configuration

The package works with zero configuration; publishing the config file only lets you change the defaults in one place. The published config/trading-analytics.php:

```php
return [
    // Default decimal precision (bcmath scale) for every calculation.
    'scale' => env('TRADING_ANALYTICS_SCALE', 10),

    // Default win-rate bucketing period: daily, weekly, or monthly.
    'win_rate_period' => env('TRADING_ANALYTICS_WIN_RATE_PERIOD', 'daily'),
];
```

## Every key

| Key | Type | Default | Env | Purpose |
| --- | --- | --- | --- | --- |
| `scale` | int | 10 | TRADING\_ANALYTICS\_SCALE | Decimal places used when a run does not call ->scale(). A whole number of at least 0 (TRADING\_ANALYTICS\_SCALE=8 works); a blank value (TRADING\_ANALYTICS\_SCALE=) is not set, so 10 applies; ten or 10.5 throw an InvalidConfigurationException naming the key. |
| `win_rate_period` | string | daily | TRADING\_ANALYTICS\_WIN\_RATE\_PERIOD | Win-rate bucket when a run does not call ->usingWinRatePeriod(): daily, weekly or monthly. A blank value is not set, so daily applies; anything else throws an InvalidConfigurationException listing them — a typo never falls back to daily. |

## Environment

Both keys are env-driven, so you rarely need to publish the file at all:

```bash
TRADING_ANALYTICS_SCALE=4
TRADING_ANALYTICS_WIN_RATE_PERIOD=weekly
```

## Per-run overrides

A run’s explicit ->scale(...) / ->usingWinRatePeriod(...) always overrides the configured default:

```php
use RoundlyConsulting\TradingAnalytics\Enums\Period;
use RoundlyConsulting\TradingAnalytics\Facades\TradingAnalytics;

// A run's own settings always win over the configured defaults
$analytics = TradingAnalytics::for($trades)
    ->scale(2)
    ->usingWinRatePeriod(Period::WEEKLY)
    ->calculate();

$analytics->getScale(); // 2
```

The configured defaults are read when the engine is built, so a malformed scale or win\_rate\_period throws InvalidConfigurationException even for a run that then sets its own ->scale() or ->usingWinRatePeriod().

Outside a booted Laravel app (no config bound), the built-in defaults — scale 10 and daily — apply automatically, so the engine also runs in plain scripts and unit tests.

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## 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.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/trading-analytics-for-laravel.md)
