bestnaf / ARS

ARS addon for Gunbot MM
https://gunbot.ru
10 stars 2 forks source link

Liquidation Spread Limit Modification #17

Closed tr0lldermort closed 3 years ago

tr0lldermort commented 3 years ago

Description

The existing liquidation spread function takes into account the fact that longs have much more tolerance than shorts when it comes to liquidating your wallet if you're trading on USDT futures. However, one very practical use-case of LS limiting is to prevent GB from executing DCA orders when a position grows to a certain amount of -uPNL (focusing on bag prevention as opposed to liquidation prevention).

This works well with short positions, but due to the safe nature of long postitions, LS limit will not be reached until the -uPNL of a position is very large. A simple way to get more value out of this function would be to:

  1. Separate LIQUIDATION_LIMIT into two values, long and short.
  2. Unbound the Liquidation Spread % calculation internally, and as seen on the TG status message.
  3. Limit long and short positions separately as specified in (1)

Other functions that rely on LS would also need updating to accept long and short LS, such as uPNLK.

Example

Configuration Parameters

Remove <pair>.settings.LIQUIDATION_LIMIT = 90 <pair>.settings.uPNLK_LS = 90

Add <pair>.settings.LIQUIDATION_LIMIT_SHORT = 90 <pair>.settings.LIQUIDATION_LIMIT_LONG = 190 <pair>.settings.uPNLK_LS_SHORT = 90 <pair>.settings.uPNLK_LS_LONG = 190

there may be more functions that need updating too

tr0lldermort commented 3 years ago

Something to think about here - instead of presenting users with two separate liquidation limits, we could think about creating a normalised LS limit that scales LIQUIDATION_LIMIT_LONG and LIQUIDATION_LIMIT_SHORT internally (assuming there is a reasonable mathematical relationship between long and short liqidation distances for equvalent positions).

For USDT-M: For a given short position, if the liquidation spread of an identical long position is always x2 (or can be transformed by some formula), then it would be possible to take a normalised LS limit and scale it appropriately to set the long and short LS limits. For example:

for
   <pair>.settings.LIQUIDATION_LIMIT_NORM = 90
then
   LIQUIDATION_LIMIT_SHORT = 90 (internally set)
   LIQUIDATION_LIMIT_LONG = 180 (internally set)

For COIN-M: ARS will swap the long and short calculations accordingly:

for
   <pair>.settings.LIQUIDATION_LIMIT_NORM = 90
then
   LIQUIDATION_LIMIT_SHORT = 180 (internally set)
   LIQUIDATION_LIMIT_LONG = 90 (internally set)
tr0lldermort commented 3 years ago

This is not possible. Closing the request and using "position size" in other functions instead.