nickpagz / 3commas-ftx-triggers

Python script to send buy and sell triggers to 3Commas trading bots setup to trade FTX perpetual futures
36 stars 29 forks source link

Max bot usage wrong with leverage > 1 #8

Closed ghost closed 2 years ago

ghost commented 3 years ago

Hi,

When I'm using 1x leverage the calculated max bot usage is correct. When I set it to 3 it's wrong.

My settings:

UPDATE_BASE_ORDER_VOLUME = 33 #IN USD
UPDATE_TAKE_PROFIT = 1.25
UPDATE_SAFETY_ORDER_VOLUME = 60
UPDATE_MARTINGALE_VOLUME_COEFFICIENT = 1.2
UPDATE_MARTINGALE_STEP_COEFFICIENT = 1.1
UPDATE_MAX_SAFETY_ORERS = 10
UPDATE_ACTIVE_SAFETY_ORDERS_COUNT = 3
UPDATE_SAFETY_ORDER_STEP_PERCENTAGE = 2.0
UPDATE_LEVERAGE_CUSTOM_VALUE = 3
UPDATE_STOP_LOSS_TYPE = 'stop_loss'  # or stop_loss_and_disable_bot
UPDATE_STOP_LOSS_PERCENTAGE = 0
UPDATE_STOP_LOSS_TIMEOUT_ENABLED = False
UPDATE_STOP_LOSS_TIMEOUT_IN_SECONDS = 300
UPDATE_START_ORDER_TYPE = 'market'

3commas calculation: image

Your calculation: image

nickpagz commented 3 years ago

@NobbisCrypto Nice catch! I haven't used the bot with leverage before, so didn't pick up on this error. I've marked it as a bug to fix. Thanks!

ghost commented 3 years ago

I think you need to divide by the leverage factor config.LEVERAGE_CUSTOM_VALUE in the function get_max_bot_usage in Py3c_triggers.py.

Example: Your BO is 10 and SO is 20 with 1x leverage. You want to use 3x leverage, hence you set it to 3 and increase the BO to 30 and the SO to 60. That triples the amount for bot usage in your calculation - if you devide it by 3 your back to normal.

nickpagz commented 3 years ago

Yeah, exactly that.