<?php

namespace App\Http\Controllers;

use App\Models\TradingSymbol;
use Illuminate\View\View;

class PipCalculatorController extends Controller
{
    public function __invoke(): View
    {
        $symbols = TradingSymbol::query()
            ->active()
            ->orderBy('category')
            ->orderBy('symbol')
            ->get()
            ->map(fn (TradingSymbol $symbol): array => [
                'symbol' => $symbol->symbol,
                'label' => $symbol->display_name,
                'quote' => $symbol->quote_currency,
                'pipSize' => (float) $symbol->pip_size,
                'contractSize' => (float) $symbol->contract_size,
                'price' => (float) $symbol->default_price,
            ])
            ->values();

        return view('trading-tools.pip-calculator', compact('symbols'));
    }
}
