Skip to main content

How to use multiple filter sets (filters, filters2) in AutoConfig?

ยท 7 min read

Gunbot's AutoConfig feature allows for sophisticated conditional logic by enabling the use of multiple "filter sets" within a single job. While a basic job might use just one set of filters (defined in the filters object), you can define up to ten sets (filters, filters2, ..., filters10). This allows a pair to trigger a job's action if it passes any one of these complete filter sets.

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 Logic of Multiple Filter Setsโ€‹

When you define an AutoConfig job, each filter set acts as an independent block of conditions.

  • Within a single filter set (e.g., filters): All individual filter rules defined inside it must be true for a pair to pass that specific set. This is an AND logic.
  • Between multiple filter sets (e.g., filters OR filters2 OR filters3): If a pair satisfies all conditions in filters, OR all conditions in filters2, OR all conditions in filters3, etc., then the pair is considered to have passed the overall filter evaluation for the job. This is an OR logic applied at the set level.

This structure allows you to create complex decision trees where different combinations of market conditions can lead to the same outcome (e.g., adding a pair, applying an override).

How to Define Multiple Filter Setsโ€‹

You define multiple filter sets by adding objects named filters2, filters3, and so on, up to filters10, at the same level as the primary filters object within your job configuration. Each of these objects will contain its own set of filter rules.

{
"dynamicPairAdder": {
"enabled": true,
"type": "addPairs",
"schedule": "*/10 * * * *",
"pairs": {
"exchange": "binance",
"include": "USDT-",
"exclude": ""
},
"strategy": "stepgrid",

"filters": { // First set of conditions (e.g., for high volume breakouts)
"volumeCheck": {
"filterType": "minVolume24h",
"minVolume": 2000000
},
"volatilityCheck": {
"filterType": "minVolatilityPct24h",
"minVolatility": 5
}
},

"filters2": { // Second set of conditions (e.g., for steady low-volatility climbers)
"lowSpread": {
"filterType": "maxSpreadPct",
"maxSpread": 0.2
},
"steadySlope": {
"filterType": "minSlopePctInterval",
"minSlope": 0.5,
"lastSnapshots": 24 // Check slope over last 24 snapshots
},
"moderateVolume": {
"filterType": "minVolume24h",
"minVolume": 500000
}
},

"filters3": { // Third set of conditions (e.g., custom logic)
"myCustomRule": {
"filterType": "custom",
"script": " return this.pairName.startsWith('BTC');" // Example: only add BTC pairs
}
}
// Potentially up to filters10
}
}

In the dynamicPairAdder job above:

  • A USDT pair on Binance will be added if it meets:
    • ALL conditions in filters (volume > 2M AND volatility > 5%)
    • OR ALL conditions in filters2 (spread < 0.2% AND slope > 0.5% AND volume > 500k)
    • OR ALL conditions in filters3 (passes the custom script logic).

If a pair satisfies the criteria for filters but not filters2 or filters3, it still passes. If it satisfies filters2 but not filters or filters3, it also passes.

Use Cases and Advantagesโ€‹

  1. Diverse Entry Criteria: You can define different market scenarios that warrant adding a pair or applying an override. For example, one filter set for bullish conditions, another for ranging markets, and a third for specific news-driven patterns.
  2. Strategy Specialization: If an addPairs job can assign different strategies or overrides based on which filter set was passed (this usually requires more advanced logic, perhaps using setPairVariable in one job and then another job acting on that variable), multiple filter sets can help categorize pairs for different initial setups. Note: A single addPairs job typically assigns one strategy and one set of overrides to all pairs it adds, regardless of which filter set they passed. To assign different strategies based on conditions, you might need separate addPairs jobs or a more complex workflow involving variables.
  3. Combining Broad and Specific Rules: One filter set could have general, looser criteria, while another has very specific, stringent criteria for high-conviction opportunities.
  4. Testing Different Filter Combinations: You can use different filter sets to test variations of a filtering idea without creating entirely separate jobs.
  5. Readability and Organization: For very complex logic, breaking it down into multiple, named filter sets can make the job configuration easier to read and manage than one monolithic filters object with deeply nested custom logic.

Important Considerationsโ€‹

  • Order of Evaluation: The order in which filter sets are evaluated (filters, then filters2, etc.) does not typically matter since it's an OR condition between them. As soon as a pair passes one full set, it's considered successful for the job's purpose.
  • Performance: While powerful, having many filter sets with numerous complex filters in each can increase the processing time for each AutoConfig job run. Monitor system performance if you use many sets with demanding filter types (like those requiring many historical data lookups or complex custom scripts).
  • Clarity vs. Complexity: Multiple filter sets can clarify distinct conditions. However, too many sets might also make the overall job logic hard to follow. Strive for a balance. If conditions become extremely divergent, it might be cleaner to use separate AutoConfig jobs.
  • Output Actions: Remember that for job types like addPairs or manageOverrides, the defined output action (e.g., the strategy to assign, the overrides to apply) is the same for any pair that passes, regardless of which filter set it passed. If you need different outcomes based on different conditions, you'll typically need separate jobs or a multi-stage process using variables (e.g., one job sets a variable based on filters2, another job acts if that variable is set).

Multiple filter sets provide a significant boost in flexibility for AutoConfig, allowing you to craft nuanced and multifaceted conditions for your automated trading operations. By understanding the AND logic within sets and the OR logic between sets, you can design jobs that adapt to a wider variety of market situations.