public function allocate(array $ratios): array
    {
        $total = array_sum($ratios);
        $remainder = $this->amount;
        $shares = [];

        foreach ($ratios as $ratio) {
            $amount = $this->castToInteger($this->amount * $ratio / $total);
            $shares[] = $this->withAmount($amount);
            $remainder -= $amount;
        }

        for ($i = 0; $i < $remainder; $i++) {
            $shares[$i] = $this->withAmount($shares[$i]->amount + 1);
        }

        return $shares;
    }