Let $y$ be a measured time series,
and $\hat{y}(t) = A\cos(\omega t +\phi)$. How to find $A$, $\omega$, $\phi$ that minimizes
$$\sum_{k = 0}^{N - 1}|\hat{y}(k) - y_k|^2$$
The amplitude spectrum looks like
. Thus, it is not viable to try to find a particular peak in the spectrum. I tried to find $\omega$ by computing the center of mass of the spectrum, $$
\frac{\sum_{k=0}^{N/2}k|Y_k|}{\sum_{k=0}^{N/2}|Y_k|}
$$, where $Y_k$ is the elements in the DFT,
i get around 46 periods within the time series, which is way too high. By ocular inspection, it there should be around 5.75 periods, with $\phi\approx\pi$.
Hint.
This can be done by simply calculating
$$ \min_{A,\omega,\phi,y_0}\sum_k\left(f(t_k,A,\omega,\phi,y_0)-f_k\right)^2,\ \ \text{s.t.}\ \ \omega_{min}<\omega<\omega_{max} $$
My calculations gave
where
$$ f(t,A,\omega,\phi,y_0) = y_0 + A\cos(\omega t+\phi) $$
NOTE
Due to the constraints, the best way to solve this minimization problem, is by using a proper solver. Follows a MATHEMATICA script with this purpose
Here
datacontains $\{t_k, f_k\}_{k=1,\cdots,n}$tmax$\approx 1030$. The limits in $\omega$ can be established observing that for a single sinusoidal we have $5\times 2 \pi \approx \omega\times 1030$