{
    "manageOverrides_huobi": {
        "pairs": {
            "exclude": "",
            "include": "-",
            "exchange": "huobi"
        },
        "filters": {
            "Sanity checks": {
                "type": "custom",
                "target": " (function CheckDataExists(data){if(typeof data.pair.whatstrat==='undefined'){return false;} if(typeof data.pair.ABP==='undefined'){return false;} if(typeof data.pair.candlesclose==='undefined'){return false;} if(typeof data.pair.candlesopen==='undefined'){return false;} if(typeof data.pair.atr==='undefined'){return false;} if(typeof data.pair.ema2==='undefined'){return false;} if(typeof data.pair.ema1==='undefined'){return false;} if(typeof data.pair.quoteBalance==='undefined'){return false;}else{return true;}})(this)"
            }
        },
        "setPairVariable": {
            "newOverrides": " (function handleOverrides(data){const base=data.pairName.split('-')[0];let overrides={TRADING_LIMIT:data.pair.whatstrat.TRADING_LIMIT,STOP_AFTER_SELL:data.pair.whatstrat.STOP_AFTER_SELL||false,BUY_ENABLED:data.pair.whatstrat.BUY_ENABLED,BAG_SIZE:data.pair.whatstrat.BAG_SIZE,BAG_VALUE:data.pair.whatstrat.BAG_VALUE||'none',STATUS:data.pair.whatstrat.STATUS||'new',MAX_BUY_COUNT:data.pair.whatstrat.MAX_BUY_COUNT,MIN_VOLUME_TO_SELL:base==='USDT'||base==='BUSD'||base==='USDC'||base==='USD'||base==='EUR'?10:base==='BTC'?2e-4:base==='ETH'?.005:base==='BNB'?.05:2e-4};const bid=data.pair.Bid;const quoteBalance=data.pair.quoteBalance;const baseBalance=data.pair.baseBalance;const mvts=parseFloat(overrides.MIN_VOLUME_TO_SELL);const ABP=parseFloat(data.pair.ABP);const keepQuote=parseFloat(data.pair.whatstrat.KEEP_QUOTE);const baseReservePct=parseFloat(data.pair.whatstrat.BASE_RESERVE_PCT)/100||0;const notEnoughCandles=typeof data.pair.candlesclose==='undefined'?true:data.pair.candlesclose.length<80;const maxSameBase=parseFloat(data.pair.whatstrat.MAX_PAIR_PER_BASE);const totalBaseValue=parseFloat(data.pair.whatstrat.TOTAL_BASE_VALUE)-parseFloat(data.pair.whatstrat.TOTAL_BASE_VALUE)*baseReservePct;const reserveThreshold=parseFloat(data.pair.whatstrat.TOTAL_BASE_VALUE)*baseReservePct;const tl=parseFloat(overrides.TRADING_LIMIT);const status=overrides.STATUS;const howManyTL=parseFloat(data.pair.howManyTL)||0;const TLRatio=parseFloat(data.pair.whatstrat?.TL_RATIO)||40;const lastOrderType=data.pair?.orders?.[0]?.type;const hasMissedSteps=false;function setStatus(){if(status==='new'){overrides.STATUS='active';return true}}function setBagSize(){if(overrides.BAG_SIZE!=='none'){if(lastOrderType==='sell'&&(quoteBalance-keepQuote)*bid<mvts){overrides.BAG_SIZE='none';overrides.BAG_VALUE='none'}else if((quoteBalance-keepQuote)*ABP>0){overrides.BAG_SIZE=(quoteBalance-keepQuote)*ABP;overrides.BAG_VALUE=(quoteBalance-keepQuote)*bid}}else if((quoteBalance-keepQuote)*bid<mvts){overrides.BAG_SIZE='none';overrides.BAG_VALUE='none'}else{if((quoteBalance-keepQuote)*ABP>0){overrides.BAG_SIZE=(quoteBalance-keepQuote)*ABP;overrides.BAG_VALUE=(quoteBalance-keepQuote)*bid}else{overrides.BAG_SIZE='none';overrides.BAG_VALUE='none'}}}function setTradingLimit(){const tl=totalBaseValue/maxSameBase/TLRatio;if(tl>mvts){overrides.TRADING_LIMIT=tl.toPrecision(5);overrides.BUY_ENABLED=true}else{overrides.TRADING_LIMIT=mvts*1.1;overrides.BUY_ENABLED=true}}setBagSize();if(Object.is(totalBaseValue,NaN)||totalBaseValue===0||notEnoughCandles){return overrides}if(setStatus()===true){setTradingLimit()}if(overrides.BAG_SIZE==='none'&&overrides.STATUS==='active'&&!overrides.STOP_AFTER_SELL){setTradingLimit()}if(overrides.BAG_SIZE!=='none'&&overrides.STATUS==='active'&&tl<mvts){setTradingLimit()}if(hasMissedSteps||baseBalance<reserveThreshold){overrides.MAX_BUY_COUNT=howManyTL}else if(!hasMissedSteps&&baseBalance>reserveThreshold){overrides.MAX_BUY_COUNT=999}return overrides})(this)"
        },
        "overrides": {
            "TRADING_LIMIT": " this.pairVariables.huobi[this.pairName].newOverrides.TRADING_LIMIT",
            "BUY_ENABLED": " this.pairVariables.huobi[this.pairName].newOverrides.BUY_ENABLED",
            "MIN_VOLUME_TO_SELL": " this.pairVariables.huobi[this.pairName].newOverrides.MIN_VOLUME_TO_SELL",
            "BAG_SIZE": " this.pairVariables.huobi[this.pairName].newOverrides.BAG_SIZE",
            "BAG_VALUE": " this.pairVariables.huobi[this.pairName].newOverrides.BAG_VALUE",
            "TOTAL_BASE_VALUE": " (function totalBaseBalance(data){const baseBalance=data.pair.baseBalance;const base=data.pairName.split('-')[0];let configPairCount=0;let sameBasePairs=[];Object.keys(data.config.pairs.huobi).forEach((pair=>{if(pair.split('-')[0]===base){configPairCount++;sameBasePairs.push(pair)}}));let positions=[];let combinedBaseValue=0;sameBasePairs.forEach((pair=>{if(Object.keys(data.pairVariables.huobi).indexOf(pair)>-1){if(parseFloat(data.pairVariables.huobi[pair].newOverrides.BAG_SIZE)>0){positions.push(parseFloat(data.pairVariables.huobi[pair].newOverrides.BAG_SIZE))}else if(data.pairVariables.huobi[pair].newOverrides.BAG_SIZE==='none'){positions.push(0)}}else if(data.config.pairs.huobi[pair].override.BAG_SIZE==='none'){positions.push(0);}}));if(positions.length===configPairCount){combinedBaseValue=positions.reduce((function(a,b){return a+b}),0)+baseBalance;return combinedBaseValue}else{return 0}})(this)",
            "STATUS": " this.pairVariables.huobi[this.pairName].newOverrides.STATUS",
            "MAX_BUY_COUNT": " this.pairVariables.huobi[this.pairName].newOverrides.MAX_BUY_COUNT"
        },
        "clearOverrides": false,
        "schedule": "01,11,21,31,41,51 * * * * *",
        "type": "manageOverrides",
        "debug": false,
        "enabled": true
    }
}