Suppose that I have $P$ amount of money in a bank that accrues fixed interest rate $\bar{r}$ continuously. This interest rate charged on this bank account is simple, instead of compound interest rate.
Now, I can transfer the interest accrued after time $t$, $\bar{r}Pt$, to another bank account that collects compound interest rate with the same interest rate $\bar{r}$. However, I can only transfer the interest earned from the first bank account, instead of transferring the whole $P$. Every time I transfer the interest from the first bank account to second bank account, I incur a fixed cost $\phi$. I can transfer the accrued interest from the first bank to the second bank at any time $t$, and for as many times as I want to.
Q: What is the optimal strategy function $f$ that takes in $(P,\bar{r}, \phi, T)$ and tells me when I should transfer the interest accrued from the first bank to the second bank to maximize my income at time $T$, starting from time $t = 0$? Is there even a closed form solution to this problem?
This is motivated by a real-world example I witnessed, and wanted to know how I can tackle this question. It seems that I need to wait for an ample amount of time for the interest collected to be high enough that I would profit from moving to the second bank despite the fixed cost $\phi$. If I wait too long, then I may miss out on the opportunity that interest collected could have earned more compound interest.
EDIT: Note that there is a finite amount of time, since a comment suggested that there is no solution given infinite amount of time.
Best Answer
Let's say that you have the principal of $P=1$ at the first bank and $r=1$ (amount and time scaling is trivial) and transfer at the time moments $t_1<\dots<t_n<T$. Then your gain compared to doing nothing is (we set $t_0=0$) $$ \sum_{j=1}^n (t_j-t_{j-1})[e^{T-t_j}-1]-\varphi n=e^T\sum_{j=1}^n(t_j-t_{j-1})e^{-t_j}-t_n-\varphi n\,. $$ For fixed $n$ and $t_n$, we can now fix $t_{j-1}, t_{j+1}$ and look at $t_j$. This leads to the maximization problem $(s-t)e^{-s}+te^{-t}\to\max$, $0\le t\le s$. Differentiation yields $-e^{-s}+e^{-t}-te^{-t}=0$, so $t=1-e^{-(s-t)}$. This gives the relation $\Delta_{j+1}=\log \frac1{1-\Delta_j}$ between $\Delta_j=t_{j}-t_{j-1}$. Thus we reduced the problem to a two-parameter one. We need to choose an integer $n$ and the initial $\Delta=\Delta_1$ and then run this recursive sequence and compute and maximize the result $F_n(\Delta)$ in $n$ and $\Delta$ in the admissible range.
Thus it is clear that the closed form expression is out of question, but the programming is relatively easy. It looks like for each $n$, $F_n$ is unimodal in $\Delta$ in its domain and the maximum of $F_n$ is a unimodal function of $n$. If so, the computation of the maximum can be done rather simply and efficiently, but I'll not attempt to prove these properties now.
Here is a code in Asymptote (the syntax is almost the same as C but somewhat more flexible and it allows you to draw pictures easily, so I use it most of the time). It outputs the optimal schedule and the gain from each transaction as well as the total gain.