This got me thinking. One thing that is not discussed is that in real life trading one does not know what percentage advantage one has. Many successful traders rely on subconscious processes for part of their trading strategy that they have no way of examining, but seems to work(sometimes). If the only way to find out what your expected return is(your edge), is to bet and see what happens (maybe this is really the reason one needs "skin in the game") then ramping up your betting when you are winning is a really good idea. When you are losing money it is likely your expected return is negative and you should start scaling back your bets until you find an edge again.
It would be interesting to run this code with variable rates of return over time, including negative ones, where one scales the bet size not on your net capital but on (the percentage win on the last n bets)*(capital).
I'm sure this is all in some book written in the 18th century as people have been trading in markets for a long time.