3

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.

Hosea
  • 149
  • The optimal solution that you are looking for may not exist, at least without imposing some additional restrictions. If you want to maximize your income after 1 period, probably the optimal thing to do is not transfering the interest because of $\phi$. However, if you want to maximize your income after a huge period of time, the optimal strategy is transfering the money from the first time you earn interest (any initial quantity will overcome the cost after a number of periods). – Papi Nov 18 '21 at 09:19
  • 1
    @Papi Good point! I didn't think of that. I have edited the question to now include finite amount of time. – Hosea Nov 19 '21 at 01:30

2 Answers2

4

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.

import graph;
size(300,300,IgnoreAspect);

real rate=0.03, // your annual rate r Tyears=30, // your time period in years penalty=100, //transfer fee principal=10000; //the principal P

real T=Tyears*rate, phi=penalty/principal;

real f(int n,real d, bool b=false) { real s=0; real dl=d, t=0; for(int k=0;k<n;++k) { t+=dl; s+=dlexp(-t); if(b) write(t/rate, ((exp(T-t)-1)dl-phi)principal); if((k<n-1 && dl>=1)||t>T) {s=0; break;} else if(k<n-1) dl=-log(1-dl); } if(b) write("total gain="+string((exp(T)s-t-phin)principal)); return max(exp(T)s-t,0)-phin;

}

real[] F(int n) { real[] q;

real u=0,v=0.0001,w=1; real M=f(n,v); for(int k=0;k<30;++k) { real uv=(u+v)/2, vw=(v+w)/2; real M1=f(n,uv); if(M1>M) {M=M1; w=v;v=uv;} else { real M2=f(n,vw); if(M2>M) {M=M2; u=v;v=vw;} else {u=uv; w=vw;} } } q[0]=v; q[1]=f(n,v); return q; }

real M=0,d; int N;

for(int n=1;n<100;++n) { real g(real x){return f(n,x);} //draw(graph(g,0,1)); real[] q=F(n); //dot((q[0],q[1]),red); //write(n,q[0],q[1]); if(q[1]>M){N=n; M=q[1]; d=q[0];} } write("schedule "+string(N)); f(N,d,true);

pause();

fedja
  • 19,348
  • Using http://asymptote.ualberta.ca/, I had to delete the final pause(); line for it to work. – user3151675 Aug 08 '22 at 21:29
  • 1
    @TamásSengel Indeed. That's because the online compiler there doesn't accept user input but keeps the output on the screen without the pause(); command while if you install Asymptote on your PC, it will run OK without pause(); but then just close the window before you have any chance to read the output :-) – fedja Aug 09 '22 at 02:19
  • Why does the schedule printed out by the program suggest that I should reinvest every half a day in the beginning with the following input: rate=1.6, Tyears=2, penalty=0.2, principal=4800 (and I edited n's maximum value in line 51 to be 1000)? I calculated it, and reinvesting earlier gains me around 0.014 extra yield, but costs me 0.2. I don't get why the program thinks that's optimal. – user3151675 Aug 10 '22 at 16:22
  • @TamásSengel Your data gave me 865 re-investments with total gain slightly above 97250 dollars. Do you know a better schedule? – fedja Aug 11 '22 at 02:32
  • I just realized how it can happen, sorry. Compounded gains earlier -> bigger gains later – user3151675 Aug 11 '22 at 02:59
  • Any ideas how to modify this program to handle moving money between two compound interest accounts with two different rates? Details here: https://math.stackexchange.com/q/4507587/533020 – user3151675 Aug 14 '22 at 11:52
1

Let's start with the case where $ \phi=0 $. No matter the choice of $ \overline{r} $ or $ T $, you are best off withdrawing continually. You're getting $ P\overline{r}t $ from the simple interest. Continually transferring it to your continuously compounding account will effectively set that account's interest at $ P\overline{r}t $, so you'll be getting $ P\overline{r}te^{\overline{r}t} $, and nothing from the simple interest account. Let's call the strategy of continual transfer $ B $ and the strategy of no transfer $ A $. So at time $ t $, $ B = P + P\overline{r}te^{\overline{r}t} $ (the first term is your principal on the simple interest account), and $ A = P+P\overline{r}t $. Assume $ B $ outperforms $ A $. Then, $ P + P\overline{r}te^{\overline{r}t} > P+P\overline{r}t $. This reduces to $ e^{\overline{r}t} > 1 $, which is true $ \forall t>0$, regardless of choice of $ r $.

Let's move on to the case where you are allowed the option to withdraw once, at time $ 0 < t_1 < T $. The first inequality is strict because the simple interest account has generated no interest yet. The last inequality is strict because withdrawing at T cannot possibly yield more than withdrawing the moment before (you'd just be losing your premium $ \phi $). Let's call $ B $ the strategy where you withdraw. At time $ T $, $ B = P\overline{r}(T-t_1)+P\overline{r}t_1e^{\overline{r}(T-t_1)} - \phi $, and the strategy of no withdraw $ A = P\overline{r}T $. Assume $ B $ outperforms $ A $, that is $ B > A $. So $ P\overline{r}(T-t_1)+P\overline{r}t_1e^{\overline{r}(T-t_1)} - \phi > P\overline{r}T $. Distribute on the $ \textit{l.h.s.} $ to get $ P\overline{r}T-P\overline{r}t_1+P\overline{r}t_1e^{\overline{r}(T-t_1)} - \phi > P\overline{r}T $. Subtract $ P\overline{r}T $ from both sides to get $ -P\overline{r}t_1+P\overline{r}t_1e^{\overline{r}(T-t_1)} - \phi > 0 $. Add $ \phi $ to both sides and factor out a $ -P\overline{r}t_1 $ from the $ \textit{l.h.s.} $ to get $ -P\overline{r}t_1(1-e^{\overline{r}(T-t_1)}) > \phi $. This is your condition for making profit allowed one withdrawal. For a chosen $ \phi $, you should withdraw at $ t_1 $. If solving for $ t_1 $ gives a value out of bounds (i.e., greater than $ T $), do not withdraw. It is only more profitable if the statement holds true. Solve for $ t_1 $ by numerically maximizing the difference in the inequality (I've added an example in the link below).

Let's consider the case where you are allowed to withdraw exactly twice, at times $ 0 < t_1 < t_2 < T $. If you choose this option, at time $ T $ you will have $ B = P\overline{r}(T-t_2)+P\overline{r}t_1e^{\overline{r}(t_2-t_1)} + P\overline{r}t_2e^{\overline{r}(T-t_2)} - 2\phi $, whereas if you choose to not withdraw, you will have $ A = P\overline{r}T $, the zero-withdrawal strategy. Assume $ B $ outperforms $ A $. That is, $ P\overline{r}(T-t_2)+P\overline{r}t_1e^{\overline{r}(t_2-t_1)} + P\overline{r}t_2e^{\overline{r}(T-t_2)} - 2\phi > P\overline{r}T $. Solve for $ (t_1, t_2) $ by numerically maximizing the difference in the inequality. That is, $ \underset{(t_1,t_2)}{\mathrm{argmax}} -P\overline{r}t_2+P\overline{r}t_1e^{\overline{r}(t_2-t_1)} + P\overline{r}t_2e^{\overline{r}(T-t_2)} - 2\phi $ . If it is out of bounds (i.e., $ 0 < t_1 < t_2 < T $ is not true), then you do not withdraw two times.

Continue on in this way until you reach a $ t_{n+1} $ that is out of bounds. Compare the profits under each of the cases: 0 withdrawals, 1 withdrawal, ... , n withdrawals, with the times you found. Then you withdraw at the times that give the highest profit.

Here is an example of numerically optimizing the withdrawal time in the one-withdrawal case, written in a short Python Jupyter Notebook. https://colab.research.google.com/drive/18nAQLOUhrNxNEnv-U5-NCb3XGHAZ7uTc?usp=sharing

  • That is just not true. You suggest to withdraw at the equilibrium point, i.e., where both strategies yield the same result, which is absurd (indeed, why to bother then?). You have to wait a bit after the break-even point to get profit (the interest will accumulate for a shorter time, but on a bigger amount). Am I misunderstanding anything? – fedja Nov 29 '21 at 14:54
  • You are correct, it was not clear how one should have used the equilibrium points to arrive at the solution. I have added to my post to specify how to arrive at the solution. I have also included an example of the procedure. – Tristan Romanov Nov 29 '21 at 18:23
  • 1
    There is another issue: the optimal moment of the first withdraw does depend on how many withdraws you decide to make. The greedy algorithm is suboptimal here. – fedja Nov 29 '21 at 18:38
  • Indeed, this should be considered. I have fixed my answer. – Tristan Romanov Nov 29 '21 at 20:18
  • Great. I also posted my code so that you can compare :-) – fedja Nov 29 '21 at 20:57