Add optional early stopping to prevent overfitting in PyTorch-based
FreqAI models. When `early_stopping_patience` is set in
model_training_parameters, training will stop if validation loss
does not improve for the specified number of epochs.
Changes:
- Add `early_stopping_patience` parameter (default 0 = disabled)
- `estimate_loss()` now returns average loss (float | None) instead
of None, enabling downstream use for schedulers and early stopping
- Track best validation loss and patience counter across epochs
Usage in config:
```json
{
"model_training_parameters": {
"n_epochs": 100,
"early_stopping_patience": 10
}
}
```
The change is fully backward compatible - early stopping is disabled
by default, and the return value of estimate_loss() can be safely
ignored by existing subclasses.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Kraken Futures now provides 1 year of hourly funding rate history.
The previous limit of 700 candles (29 days) was a workaround for
limited API retention. Freqtrade paginates funding rate fetches
automatically, so the CCXT default (2000) works correctly.
Kraken Futures' /orders/status returns limitPrice (not fill price) and
/fills omits fee amounts (only fillType). This adds:
- _adjust_krakenfutures_order: fetches trades for closed/filled orders
with average=None and computes VWAP average price.
- get_trades_for_order override: enriches trades with calculated fees
from the market's maker/taker fee schedule.
Tests: 7 new tests covering VWAP computation, fee enrichment with
maker/taker rates, and preservation of existing values.
CCXT's krakenfutures parse_order misses triggerPrice when the
/orders/status endpoint nests it inside priceTriggerOptions.
Override _order_contracts_to_amount to populate triggerPrice and
stopPrice from info.order.priceTriggerOptions.triggerPrice.
Kraken Futures retains only ~29 days of hourly funding rate history.
Set funding_fee_candle_limit to 700 so ohlcv_candle_limit returns the
correct cap for CandleType.FUNDING_RATE instead of the general OHLCV
limit.
- Add stoploss_query_requires_stop_flag to _ft_has so the base class
handles fetch_stoploss_order and cancel_stoploss_order (adds stop=True
which CCXT maps to trigger history endpoints).
- Remove _fix_trigger_order_id — ccxt 4.5.38 now parses order IDs
correctly in all response formats.
- Remove cancel_stoploss_order override — base class handles it.
- Remove fetch_stoploss_order override — base class handles it.
- Simplify _fetch_order_fallback — stop=True flows from base class,
no need to auto-retry with trigger=True.
Addresses review comments from freqtrade/freqtrade#12706.