How often should I invest considering that each additional investment has a transaction fee? Today a friend opened a stock portfolio, asked me this and I started thinking about it instead of studying:
Let’s say you earn so much that you can save up $100$ € each day. If you invest the money in stocks you get $10$% plus each year on your investment, but investing an additional amount of money costs $25$ € in transaction fees. How often should you invest? It would of course not be reasonable to invest $100$ € each day because you’d loose $25$ € every time, on the other hand, waiting $10$ years is also stupid, because you’d be missing out on the exponential growth and you would only get a linear one. So what is the optimal strategy?
I think investing continuously would generate
$$
\int_0^t 100\cdot \exp\left[\ln(1.1){\frac{t-x}{365}}\right]dx
$$
in the time $t$, but is there a function to maximise if we now take the $25$ € into account, or is this a strictly discrete problem? Also I would assume that a periodic investment would be optimal, is that true? I‘ve never done any discrete optimisation, so I‘d be interested in what you all think:)
 A: It seems clear that you should invest periodically, because whatever is the right time to wait for the first investment after you make it you are starting  in the same place except you have this account that is growing.  We want to compare waiting $k$ days with waiting $k-1$ days and find where the crossover occurs.  We will look at the balance at the end of $n=k(k-1)$ days.  Define $i=1+\frac {0.1}{365}$ to be the daily interest factor
If we invest every $k$ days at the end of $k(k-1)$ days we have
$$(100k-25)\left(i^{n-k}+i^{n-2k}+i^{n-3k}\ldots+1\right)$$
where there are $k-1$ terms in the sum, one for each investment.  The first investment is made after $k$ days, so it compounds for $n-k$ days and so on.  We can sum the geometric series to get
$$(100k-25)\frac {i^n-1}{i^k-1}$$
Similarly, if we invest every $k-1$ days there are $k$ investments and $k$ terms in the sum.  We then have
$$(100(k-1)-25)\left(i^{n-k+1}+i^{n-2k+2}+i^{n-3k+3}\ldots+1\right)=(100(k-1)-25)\frac {i^n-1}{i^{k-1}-1}$$
I made a spreadsheet to compare these and the breakeven came at $43$ days.
A: There is an analytical solution to the problem
Starting from @Ross Millikan's answer, writing
$$(100k-25)\frac {i^n-1}{i^k-1}=(100(k-1)-25)\frac {i^n-1}{i^{k-1}-1}$$ simplifying, we end with
$$\frac{(i^n-1)}{\left(i^k-1\right) \left(i^k-i\right)}\Big[(4 (i-1) k-5 i+1) i^k+4 i\Big]=0$$ and the solution is
$$k=\frac{5}{4}+\frac{1}{i-1}+\frac{1}{\log (i)}W\left(-\frac{i^{-\frac{i+3}{4 (i-1)}}}{i-1}\log (i)\right)$$ where $W(.)$ is Lambert function.
For $i=1+\frac {0.1}{365}$, this gives exactly $k=43.3094$.
We can make approximations using $i=1+r^2$
$$k=\frac{1}{r\sqrt{2} }\left(1+\frac{7 }{6 \sqrt{2}}r+\frac{37 }{72}r^2+O\left(r^3\right) \right)$$ which, for $r^2=\frac 1 {3650}$ gives
$$k=\frac{7}{12}+\frac{262837}{720 \sqrt{73}}=43.3094$$
Edit
Making the problem more general, let $s$ the amount you can save and $c$ the commission fee, we have (with $a=\frac c s$)
$$k=\frac i{i-1} +a+\frac 1{\log(i)}W\left(-\frac{i^{\frac{1}{1-i}-a}}{i-1}\log(i)\right)$$ and, with $i=1+r^2$, the approximation
$$k = \frac{\sqrt{2a} }{r}+\frac{2 a+3}{6}+\frac{8 a^2+36 a+9}{72 \sqrt{2a}} r +\frac{2 a^2 }{135}r^2+O(r^3)$$
