Didn't know where else to contact you or where else to put this. I'm not gonna lie, I didn't stop to truly analyze your logic for calculating order sizes, but you may be interested in this:
https://www.wolframalpha.com/input/?i2d=true&i=Sum%5Bx*Power%5B%5C%2840%29y%2Ci%5D%5C%2841%29%2C%7Bi%2C0%2Cj-1%7D%5D%3Dm%5C%2844%29+solve+for+x
That is essentially the formula that safety orders follow (max funds for safety orders "m" is a summation of all safety order sizes, where each safety order size is the base safety order size "x" by the martingale volume coefficient "y" to the power of the safety order number "i" starting from 0 up to the max safety orders number "j" minus 1. I don't account for fees but really the idea shouldn't change much). By solving for X (the safety order size) like I did on wolfram alpha, we get the following formula (I have it in JS):
const calculateSafetyOrderSize = (maxSOs, volumeStepScale, availableFundsForSOs) => { const SOSize = (availableFundsForSOs * (volumeStepScale - 1)) / (Math.pow(volumeStepScale, maxSOs) - 1); return Math.round((SOSize + Number.EPSILON) * 100) / 100; }
So you need the martingale volume coefficient for this formula (which honestly should be a given in order to account for different approaches), and the total amount of funds you'd want to reserve for safety orders.
My idea is that if you want to style your bot differently than by using a specific safety order strategy, you'll find numbers that work for you, and then you'll probably want to preserve that ratio of base order size to safety order funds size (in my case I use 500 dollars per deal, 100 dollars for base order and 400 dollars for safety orders, where I have 8 max SOs with a volume scale of 1.3, so inputting 400 dollars into the formula alongside 8 max safety orders and martingale volume coefficient of 1.3 would give me the safety order size of 16.7).
This does imply the knowledge of said base-to-safety volume ratio in order to calculate base order sizes from max funds per deal, which in my case the value 0,2 would give me what I'm looking for (500 * 0.2 = 100, base order size found and you go from there).
Also, if you request the bot data and then just pass it back as you received it (with some minor tweaks), you can skip the whole "setting all the bot settings on the script" part.
Also also, you should link this repository on your article since the formatting of the python code in the article makes it a nightmare to understand.