I have come across an artificial, simulated, stock-market type of situation, whose rules, I find, create a rather interesting problem. I want to know if there is a mathematically optimal solution for "trading" on this simplified market, and if not, what may be a good approximation of this optimal solution.
Here are the rules we are aware of for the market:
1. There are two commodities, gold coins and oil.
2. The price of a barrel of oil cannot exceed 6.4 coins.
3. The price of a barrel of oil cannot be less than 4.8 coins.
4. The price of a barrel of oil is evaluated every 5 minutes.
5. Trades placed within these 5 minutes are guaranteed at the current price.
It is observed that the price of oil changes as a large number of purchases or sells are made, and any individual "trader" cannot make a trade large enough to influence the price of oil.
A graph of a typical "day" of trading on this market is here.
Actual numbers of the given graph are available in the first comment below (until I have 10 reputation).
The first, very simple, solution that I came up with, was as follows:
1. If current oil price is greater than previous oil price, sell 10% of oil owned.
2. If current oil price is less than previous oil price, spend 10% of gold coins to buy oil.
3. If there is no change in oil price, do nothing.
However, I feel that this solution does not make good use of the conditions of the market.
Needless to say, this is a very unrealistic market. Typical investment tools, like the kelly criterion, don't apply. It is intuitive to me that with a 100% chance to recoup your investment given the appropriate time horizon, you should be leveraging your bankroll much more than 10%; you should use 50 or 100% in order to make more off of the "market".
Clearly, The range of prices oil can take on is $$6.4-4.8 = 1.6$$
The midpoint of this range is $$4.8+\frac {1.6} 2 = 5.6$$
Without consideration, it stands to reason that oil is a buy when at its minimum of 4.8 and a sell / not a buy when at its maximum of 6.4.
Assuming a random bounded walk, the price is more likely to increase in the near future when below 5.6. To be more precise, the expected value of the time oil takes to move to a higher number than the buy-in number becomes less as the value of the buy-in number gets closer to 4.8, and becomes 5 minutes at 4.8. I don't know what the step distance is because the images are no longer visible, but I'm assuming it is 0.2, with equal chances of staying, lowering, or raising within the confines of 4.8 and 6.4. The ev(x) can be derived using a markov chain, but I don't have the time to do that right now. Whatever the expected time taken is, it decreases proportionally with proximity to 4.8. ev(4.8) must be 10 minutes, because at that low bound there is equal chance of staying at 4.8 and ticking up to 5, which would each take 5 minutes. If it becomes 5, then the time was 5 minutes, which had probability 0.5. If it becomes 4.8 again, the time will now become 10 minutes, value becoming 4.8 or 5 with equal probability. There is a chance that the value remains 4.8 ad infinitum, but with diminishingly small probability. Thus the ev(4.8) is: $$\sum_{i=1}^{i=\inf} (\frac 1 2)^i (5i \min) = 10 \min$$
I don't have time now but I aim to revisit this answer mapping out the problem with markov chains. By a quick back-of-the-hand calculation, it appears that ev(5) = 15 min.