Real-analytic periodic $f(z)$ that has more than 50 % of the derivatives positive?

Im looking for a real-analytic function $f(z)$ such that for any $z$

$1) $$f(z+p) =f(z)$

With $p$ a nonzero real number and where $z$ is close to , or onto the real line such that $z$ is in the domain of analyticity.

$2)$ $f(z)= 0 + a_1 z + a_2 z^2 + a_3 z^3 + ...$ where more than $50$ % of the nonzero (signs of the) $a_n$ are positive.

Thus let $f_n(z)$ be the truncated Taylor expansion of $f(z)$ of degree $n$. Let $T(n)$ be the amount of nonzero (signs in the) coefficients of the polynomial $f_n(z)$.

Let $v(n)$ be the amount of strict positive ($>0$) coefficients of $f_n(z)$.

Then $\lim_{n -> +\infty} v(n)/T(n) > 1/2$.

$3)$ $f(z)$ is nonconstant.

Also I prefer $f(z)$ to be entire if possible.

Is such a function $f(z)$ possible ?

Related :

Real-analytic $f(z)=f(\sqrt z) + f(-\sqrt z)$?


Such a function is $f(z) = \cot(z-e^{2 \pi i/3}) + \cot(z-e^{-2 \pi i/3})$. If you'd like that written in terms of real functions, it is $$\frac{2 \sin(1+2z)}{\cosh(\sqrt{3}) - \cos(1+2z)}.$$

Proof: Notice that $$g(z) := f(z) - \frac{1}{z-e^{2 \pi i/3}} - \frac{1}{z - e^{- 2 \pi i/3}}$$ has no poles within the disc of radius $\sqrt{(\pi-1/2)^2 + (\sqrt{3}/2)^2} \approx 2.78$. Therefore, the Taylor coefficients of $g(z)$ decay exponentially fast. Meanwhile, $$\frac{1}{z-e^{2 \pi i/3}} + \frac{1}{z - e^{- 2 \pi i/3}} = 1+z-2z^2+z^3+z^4-2z^5+z^6+z^7-2 z^8 + \cdots.$$

So the coefficients of $f(z)$ are very close to $(1,1,-2,1,1,-2,\dots)$ and, in particular, have this sign pattern after possibly finitely many exceptions. In fact, the data suggests the convergence is quite rapid: Here are the coefficients of $z^n$ in $f(z)$ for $0 \leq n \leq 20$:

0.708823, 0.40783, -2.02933, 0.980937, 1.00110, -1.99877, 
1.000920, 1.00047, -1.99981, 1.000080, 1.00002, -1.99999, 
1., 1., -2., 1., 1., -2., 1., 1., -2.