I've came up with another optimization idea. Right now, when bot chooses optimal buy price, it simply tries to buy the maximum amount of tokens until the limit is over. If after that the trend changes and the price goes up, we're cool and just need to wait for sell order to execute.
But the downtrend may continue for some more time. In the worst case even with further consolidation on a new lower price level. And during this period we can't make any profit or reduce the possible risks in any way. Actually, with this scenario, we are almost guaranteed to get a nice bag of high-priced tokens and a bunch of sell orders for the next couple of weeks!
But what if we abandon the idea to buy all the tokens for the exact same price, and instead we will place several orders on different price levels, so that even with further price reduction we will be able to buy more and more tokens on lower levels and thus causing the reducing of 'average buy price' of the token! Moreover we can recalculate our sell orders as well, because with lower 'average buy price' we can sell tokens at lower price as well without any loss of profit!
For example, we're trading ZEC/BTC and our price target to buy is 0.04600 BTC. When approaching this price we will create not one, but ten orders, according to the following principle: every next order will differ at a certain value. We can use Martingale strategy for calculation, so that every next order will be cheaper, but for higher volume than previous one. Here is an example of how such calculation can be made:
https://docs.google.com/spreadsheets/d/1mVUD-9ITW6LVGWZ41eKbpLND0aABE6rEM5XBP-C-OlE/edit?usp=sharingWhat do ya think?