Skip to main content

Target pairs with holdings using 'pairs.bag' in AutoConfig filters

AutoConfig can target only pairs where you already hold a "bag" (a non-trivial quote balance). There is not always a direct pairs.bag parameter, so most setups check bag status in a custom filter by comparing this.pair.quoteBalance against MIN_VOLUME_TO_SELL.

Use the AutoConfig wizard

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 Concept of "Holding a Bag"​

In this context, a "bag" means your ledger shows a quote balance large enough to sell. AutoConfig jobs such as manageOverrides or changeStrategy often need this distinction. For example:

  • You wouldn't enable DOUBLE_UP (DCA) overrides if you don't have an initial bag to average down.
  • You'd only apply STOP_LIMIT settings if you actually hold the asset to protect.
  • You might switch to a "take profit" strategy only once a bag has been acquired.

Checking for a Bag in AutoConfig Filters​

Some job types or older versions may have a direct pairs.bag: true flag, but the most reliable approach is a custom filter that checks:

  1. this.pair.quoteBalance: The amount of the quote currency Gunbot's ledger says it holds for the pair.
  2. this.pair.Ask or this.pair.Last: The current price to value the quoteBalance.
  3. MIN_VOLUME_TO_SELL (MVTS): The minimum value (in base currency) of a sell order, defined in the pair's strategy. A bag is generally only considered significant if its value exceeds MVTS.

Custom Filter Example to Check for a Bag:

{
"manageActiveBagsJob": {
"enabled": true,
"type": "manageOverrides",
"schedule": "*/5 * * * *",
"pairs": {
"exchange": "binance",
"include": "USDT-"
},
"filters": {
"pairHasSignificantBag": {
"filterType": "custom",
"script": " const pairData = this.pair; \n const pairName = this.pairName; \n const exchangeName = this.exchangeName; \n \n if (!pairData || typeof pairData.quoteBalance !== 'number' || typeof pairData.Ask !== 'number') { \n // console.log(pairName + ': Insufficient ledger data to determine bag status.'); \n return false; \n } \n \n const quoteBalance = pairData.quoteBalance; \n const currentAskPrice = pairData.Ask; \n \n // Get MIN_VOLUME_TO_SELL (MVTS) from the effective strategy for the pair \n let mvts = 0.0005; // Default low value \n const strategyName = this.config.pairs[exchangeName]?.[pairName]?.strategy; \n if (strategyName) { \n mvts = this.config.pairs[exchangeName]?.[pairName]?.override?.MIN_VOLUME_TO_SELL || \n this.config.strategies[strategyName]?.MIN_VOLUME_TO_SELL || \n mvts; \n } \n \n const bagValueInBase = quoteBalance * currentAskPrice; \n \n if (quoteBalance > 0 && bagValueInBase >= mvts) { \n console.log(pairName + ': Has significant bag (Value: ' + bagValueInBase.toFixed(4) + ' >= MVTS: ' + mvts + '). Filter passes.'); \n return true; \n } \n \n // console.log(pairName + ': No significant bag or data missing.'); \n return false; "
}
},
"overrides": { // Apply these overrides only to pairs with bags
"SELL_ENABLED": true, // Example: Ensure selling is enabled
"STOP_LIMIT": 5 // Set a stop-loss
}
}
}

In pairHasSignificantBag:

  • It reads this.pair.quoteBalance and this.pair.Ask.
  • It looks up MIN_VOLUME_TO_SELL (MVTS) in overrides or the base strategy, with a small default.
  • It computes the bag value and returns true only if it is at or above MVTS.

Note on pairs.bag as a direct parameter: Some job types (especially removePairs, which also supports pairs.noBag) may expose a direct boolean flag. When in doubt, use the custom filter above for manageOverrides or changeStrategy so you can explicitly check bag status.

Use Cases for Targeting Pairs with Bags​

  1. DCA management: Apply DOUBLE_UP overrides only if this.pair.quoteBalance > 0.
  2. Stop-loss activation: Set or adjust STOP_LIMIT_PERCENT only when a position exists.
  3. Profit-taking adjustments: If a pair has a bag and this.pair.profit is high, switch to more aggressive profit-taking overrides.
  4. Strategy transitions: Move a pair from an accumulation strategy to a sell-off strategy once a bag is acquired.
  5. Reversal logic: If this.pair.reversal === true, apply overrides customized to bag cleanup.

Key Considerations​

  • Ledger accuracy: Bag checks rely on this.pair data being current.
  • MVTS matters: Set MIN_VOLUME_TO_SELL so dust is excluded.
  • Combine conditions: Bag checks are often paired with profit, order state, or volatility checks.
  • pairs.noBag in removePairs: Use the inverse flag to protect pairs with bags from removal.