When automating the removal of trading pairs using Gunbot's AutoConfig removePairs
job type, a critical consideration is whether the bot currently holds an inventory of the quote currency for that pair (often referred to as a "bag"). The pairs.noBag
option provides a safeguard, ensuring that the removePairs
job only delists a pair if Gunbot does not currently have a quote currency balance tied up in it, specifically when that balance is below the strategy's MIN_VOLUME_TO_SELL
(MVTS) threshold and there are no open orders.
Nearly every option that follows can be set without editing files by hand.
Click the โฎ (three-dots) menu โ AutoConfig, step through the wizard, and press Save; it will write a correct autoconfig.json
for you.
The Problem of "Stranded Bags"โ
If an AutoConfig removePairs
job delists a pair from your config.js
while Gunbot is still holding a quantity of that pair's quote currency (e.g., you have 1 ETH in an USDT-ETH pair, and USDT-ETH is removed), Gunbot will cease to actively manage that ETH. It won't try to sell it according to the strategy that was assigned because the pair configuration is gone. This can result in "stranded assets" or "stuck bags" that you'd have to manage or sell manually.
The pairs.noBag
option is designed to prevent this scenario by adding a crucial precondition to the removal process.
How pairs.noBag: true
Worksโ
When you include pairs.noBag: true
in the pairs
object of an AutoConfig job with type: "removePairs"
(or "removePairs2"
):
- Pair Evaluation: The job iterates through the pairs defined by
pairs.include
/pairs.exclude
that are older thanpairs.notRemoveBefore
(if set). - "No Bag" Check (Precondition): For each such candidate pair, before evaluating the job's main
filters
(like low profit, low volume), AutoConfig performs the "no bag" check. This check typically involves verifying:this.pair.quoteBalance
: The amount of quote currency held for the pair.this.pair.Ask
: The current ask price, to value the quote balance.MIN_VOLUME_TO_SELL
(MVTS): The minimum value (in base currency) required for a sell order, as defined by the pair's strategy.this.pair.openOrders
: Checks if there are any open orders.this.pair.reversal
: Checks if the pair is currently in a reversal trading process (e.g. after a stop-loss). A pair is considered to have "no bag" if(quoteBalance * Ask) < MIN_VOLUME_TO_SELL
AND there are no open orders AND no active reversal. Essentially, any remaining quote currency is dust or insignificant.
- Filter Evaluation:
- If the "no bag" check passes (meaning no significant bag is held, no open orders, no reversal), then and only then will the job proceed to evaluate the pair against its main
filters
block (e.g., low profit, low volume). - If the "no bag" check fails (meaning a significant bag exists, or there are open orders/reversal), the pair is skipped for that run of the
removePairs
job, regardless of whether it would meet the other removal criteria. It's protected from removal to allow Gunbot to continue managing the existing bag.
- If the "no bag" check passes (meaning no significant bag is held, no open orders, no reversal), then and only then will the job proceed to evaluate the pair against its main
Configuration Exampleโ
Here's a removePairs
job configured to only delist pairs if they have no significant holdings:
{
"safePairRemover": {
"enabled": true,
"type": "removePairs",
"schedule": "0 3 * * *", // Runs daily at 3 AM
"pairs": {
"exchange": "binance",
"include": "-USDT",
"notRemoveBefore": 10080, // Only consider pairs older than 1 week
"noBag": true // User setting: Only proceed if no significant bag is held
},
"filters": { // These filters apply ONLY if 'noBag' condition is true
"isUnprofitable": {
"filterType": "custom",
"script": "return (this.pair && typeof this.pair.profit === 'number' && this.pair.profit < -5);" // Example: profit < -5%
},
"hasLowActivity": {
"filterType": "maxVolume24h",
"maxVol": 100000 // Volume less than 100k USDT
}
}
}
}
In the safePairRemover
job:
- It targets USDT pairs on Binance older than one week.
- Crucially, because
"noBag": true
:- For each candidate pair, it first checks if
(quoteBalance * Ask) < MVTS
and no open orders/reversal. - If
true
(no bag), it then checks if the pair is unprofitable OR has low activity. If these main filters also pass, the pair is removed. - If
false
(a bag exists), the pair is NOT removed in this job run, even if it's unprofitable and has low activity. Gunbot is given more time to try and sell the bag.
- For each candidate pair, it first checks if
Benefits of pairs.noBag: true
โ
- Asset Protection: Prevents AutoConfig from delisting pairs where you still have funds invested, avoiding stranded assets.
- Safer Automation: Makes the
removePairs
process much safer, as it respects existing positions. - Works with Sell Strategies: Allows Gunbot's active selling strategies the chance to divest the quote currency before a pair is removed from active management.
- Dust Management: By comparing against MVTS, it allows removal if the remaining balance is mere "dust" and not worth actively managing.
Important Considerationsโ
- Ledger Accuracy (
this.pair
data): ThenoBag
check relies on accurate ledger information (especiallyquoteBalance
,openOrders
,reversal
) maintained by Gunbot for the pair. MIN_VOLUME_TO_SELL
(MVTS): The effectiveness of the "dust" check part ofnoBag
depends onMIN_VOLUME_TO_SELL
being set appropriately in your strategies. If MVTS is extremely low, even small amounts of quote currency might be considered a "bag".- Patience Required: If
noBag: true
, pairs with bags will not be removed until Gunbot manages to sell those bags. If a coin is in a deep loss and your strategy isn't selling, the pair will remain active indefinitely despiteremovePairs
filters, which is often the desired behavior to avoid realizing losses by manual intervention. - Alternative:
pairs.bag: true
formanageOverrides
: If you want to take specific actions (like applying aggressive selling overrides) because a bag exists, you would use amanageOverrides
job withpairs.bag: true
in itsfilters
or as a separate filter condition.noBag
is specifically for preventing removal when a bag exists.
Using pairs.noBag: true
is a highly recommended best practice for most removePairs
AutoConfig job setups. It ensures that your automated cleanup processes don't interfere with active positions or leave you with unmanaged funds, adding a crucial layer of safety to your automated portfolio management.