Gunbot's AutoConfig allows for sophisticated analysis of a trading pair's live ledger data. Beyond simple value comparisons, the differenceBigger
and differenceSmaller
state filter types enable you to evaluate the percentage difference between two specified ledger keys. This is powerful for detecting relative changes, such as how far the current price has moved from an average buy price, or the percentage gap between two moving averages if they are stored in the ledger.
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.
Calculating Relative Change with Difference Filtersโ
The differenceBigger
and differenceSmaller
filters provide a way to measure how much one ledger value has changed relative to another, expressed as a percentage. The underlying calculation is typically:
Percentage Difference = ((Value of Ledger Key 2 - Value of Ledger Key 1) / abs(Value of Ledger Key 1)) * 100
(Note: The exact internal formula, especially the use of abs()
in the denominator, can sometimes vary slightly by implementation or be adapted to avoid division by zero. It's generally understood as the percentage change from Key1 to Key2.)
These filters are used in AutoConfig jobs that process existing pairs (e.g., manageOverrides
).
Filter Types and Configurationโ
filterType: "differenceBigger"
- Purpose: Passes if the calculated percentage difference (LedgerKey2 relative to LedgerKey1) is greater than a specified delta percentage.
- Logic:
((LKV2 - LKV1) / abs(LKV1)) * 100 > deltaPercent
- Example: Check if the current Bid price (
Bid
) is more than 2% above the average buy price (ABP
).This passes if"profitMarginCheck": {
"filterType": "differenceBigger",
// The first field name's value is Ledger Key 1 (base for comparison)
"averageBuy": "ABP",
// The second field name's value is Ledger Key 2 (value being compared)
"currentBidPrice": "Bid",
// The third field name's value is the delta percentage
"minProfitPct": 2
}((this.pair.Bid - this.pair.ABP) / abs(this.pair.ABP)) * 100 > 2.0
. The actual keysABP
,Bid
,minProfitPct
are descriptive names for the rule; their values ("ABP"
,"Bid"
,2
) are what AutoConfig uses.
filterType: "differenceSmaller"
- Purpose: Passes if the calculated percentage difference is less than a specified delta percentage.
- Logic:
((LKV2 - LKV1) / abs(LKV1)) * 100 < deltaPercent
- Example: Check if the current Bid price (
Bid
) has dropped by less than 1.5% from theABP
(i.e., it hasn't dropped much, or has even gone up).This filter passes if"smallDropOrProfit": {
"filterType": "differenceSmaller",
"buyReference": "ABP", // Ledger Key 1
"priceToCheck": "BID", // Ledger Key 2
"maxAcceptableDropPct": -1.5 // Delta: Note the negative for a drop
// This actually checks if Bid is NOT more than 1.5% BELOW ABP
// So, if Bid is (ABP * 0.984), diff is -1.6%, fails.
// If Bid is (ABP * 0.99), diff is -1.0%, passes.
}((this.pair.Bid - this.pair.ABP) / abs(this.pair.ABP)) * 100 < -1.5
. A more intuitive way to check if price is "not too far below" a reference might bedifferenceBigger
with a negative delta: e.g.,differenceBigger
withdeltaPercent: -1.5
would pass ifBid
is above 98.5% ofABP
.
General Configuration Structure: An AutoConfig job using these filters would look like:
{
"relativeChangeTrader": {
"enabled": true,
"type": "manageOverrides",
"schedule": "*/3 * * * *",
"pairs": { /* ... */ },
"filters": {
"significantProfitRealized": {
"filterType": "differenceBigger",
"ledgerKey1_avgCost": "ABP", // Base value for comparison
"ledgerKey2_currentPrice": "Bid", // Value to check
"delta_TargetPercent": 3.0 // Required percentage difference
}
},
"overrides": { /* Apply overrides if Bid is >3% above ABP */ }
}
}
The keys for the ledger fields and the delta (e.g., ledgerKey1_avgCost
, delta_TargetPercent
) are arbitrary for your own understanding. AutoConfig typically identifies the two ledger keys and the delta based on their order or by expecting three parameters after filterType
.
Common Ledger Keys for Difference Calculationโ
These filters work best with numerical ledger keys, like:
Bid
,Ask
,ABP
Use Casesโ
Profit/Loss Thresholds:
differenceBigger
withABP
(key1) andBid
(key2) to check if current price is X% above average cost.differenceSmaller
withABP
(key1) andBid
(key2) and a negative delta to check if price has dropped more than X% below average cost (potential stop-loss condition).
Indicator Spread/Convergence:
- If your strategy stores moving average values like
ema1
andema2
in the ledger:- Use
differenceBigger
withema2
(key1) andema1
(key2) and a small positive delta (e.g., 0.1%) to confirm a bullish MA cross where the fast MA is clearly above the slow MA. - Use
differenceSmaller
withema1
(key1) andema2
(key2) and a small positive delta (e.g., 0.05%) to find MAs that are very close (converging).
- Use
- If your strategy stores moving average values like
Distance from Price Levels:
- Check if
Bid
isdifferenceBigger
by X% fromlowBB
(if available in ledger) to see if price has bounced significantly off a lower band.
- Check if
Important Notesโ
- Numerical Values: Both ledger keys used must resolve to numerical values for the percentage difference calculation to be meaningful.
- Order of Keys Matters: The calculation
((LKV2 - LKV1) / abs(LKV1)) * 100
means the percentage difference is how much LKV2 has changed relative to LKV1. Swapping them will invert the sign of the percentage and change its meaning. - Division by Zero: If Ledger Key 1 (
LKV1
) is zero, this would lead to a division by zero error. AutoConfig's internal implementation should ideally handle this gracefully (e.g., by failing the filter), but it's good to be aware, especially ifABP
or other denominators could legitimately be zero. - Descriptive Parameter Keys: While the internal parsing might be positional, using descriptive keys in your filter definition (like
baseValueForCalc
,comparedValue
,percentageThreshold
) greatly improves the readability of your AutoConfig JSON.
The differenceBigger
and differenceSmaller
filters offer a powerful way to implement logic based on relative changes between important data points in a pair's ledger, allowing for more sophisticated and adaptive AutoConfig strategies without resorting to full custom JavaScript for these common percentage-based comparisons.