3commas-compounding icon indicating copy to clipboard operation
3commas-compounding copied to clipboard

Base and safety order funds distribution incorrectly computed

Open matthewwerny opened this issue 3 years ago • 0 comments

When you have a safety order count greater than one, there are additional considerations that need to be made to determine the full capital requirements of the bot rather than just giving half of the new funds to the base order and the other half to the safety order.

Each safety order requires an amount of funds relative to both the safety order volume and the safety order volume scale. This is why a bot with a $10 base order, Thirty $20 safety orders and a 1.05 safety order volume scale has a footprint just slightly less than $1340 and not the $610 that would be computed by simply doing 10 + (30 * 20).

When closing a deal that resulted in a $1 profit, the current computation would split it to $0.50 for the base order and $0.50 for the safety order and would update the bot to a $10.50 base order and a $20.50 safety order. Even without the safety order volume scale, this would result in a $625.50 bot footprint in a 30 safety order scenario (a $24.50 overage beyond available funds). In the case of a safety order volume scale of 1.05 like I use, it would increase to a footprint of just under $1373, or a $31 overage beyond available funds.

This also assumes the ratio of 1:2 for base to safety order volumes.

To properly compute the distribution, the overall scale of between that of the base and safety orders would need to be determined. Then a determination of the footprint per smallest currency unit (one cent in terms of USD fiat quote currency) with respect to the overall bot would need determined. In the case of the 10/20/30/1.05 example that I provided above, the effect of one cent on the base order amounts to an overall $1.34 increase in the footprint of the bot.

It would be necessary to compute the maximum amount allocatable and apply it a soon as sufficient funds are available. For traders with low amounts of capital, a configuration might only result in $0.15 or less per closed deal, which would be nowhere sufficient to cover a single cent increase to the base order as outlined above. Holding a tally of available unallocated funds from previous deals until an increase is possible would be necessary.

As time permits, I may attempt to fork and submit a PR for your review that may be a helpful contribution.

Thanks for starting the process of creating a very helpful tool!

matthewwerny avatar Jul 03 '21 00:07 matthewwerny