<?php

namespace App\Models;

use Database\Factories\BacktestFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

#[Fillable([
    'model_version',
    'features_json',
    'coefficients_json',
    'train_start',
    'train_end',
    'eval_start',
    'eval_end',
    'directional_accuracy',
    'mae_pence',
    'calibration_table',
    'leak_suspected',
    'ran_at',
])]
class Backtest extends Model
{
    /** @use HasFactory<BacktestFactory> */
    use HasFactory;

    protected function casts(): array
    {
        return [
            'features_json' => 'array',
            'coefficients_json' => 'array',
            'calibration_table' => 'array',
            'train_start' => 'date',
            'train_end' => 'date',
            'eval_start' => 'date',
            'eval_end' => 'date',
            'directional_accuracy' => 'decimal:2',
            'mae_pence' => 'decimal:2',
            'leak_suspected' => 'boolean',
            'ran_at' => 'datetime',
        ];
    }
}
