hedgequantx 2.9.128 → 2.9.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/m/hqx-2b.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x3c2c79=_0x3286;(function(_0x29ac90,_0x4d799b){const _0x37e0b4=_0x3286,_0x2b55b4=_0x29ac90();while(!![]){try{const _0xc35e54=-parseInt(_0x37e0b4(0x170))/0x1+parseInt(_0x37e0b4(0x137))/0x2*(-parseInt(_0x37e0b4(0x12a))/0x3)+parseInt(_0x37e0b4(0x1a6))/0x4+-parseInt(_0x37e0b4(0x166))/0x5*(-parseInt(_0x37e0b4(0x16b))/0x6)+-parseInt(_0x37e0b4(0x14f))/0x7*(-parseInt(_0x37e0b4(0x163))/0x8)+-parseInt(_0x37e0b4(0x1a7))/0x9+parseInt(_0x37e0b4(0x1a5))/0xa*(-parseInt(_0x37e0b4(0x174))/0xb);if(_0xc35e54===_0x4d799b)break;else _0x2b55b4['push'](_0x2b55b4['shift']());}catch(_0x5e77b5){_0x2b55b4['push'](_0x2b55b4['shift']());}}}(_0x2306,0x6eb2b));const EventEmitter=require(_0x3c2c79(0x14b)),{v4:uuidv4}=require(_0x3c2c79(0x11d)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':_0x3c2c79(0x176),'LOW_SWEEP':'low'},ZoneType={'RESISTANCE':_0x3c2c79(0x118),'SUPPORT':'support'},DEFAULT_CONFIG={'tickSize':0.25,'tickValue':0x5,'swing':{'lookbackBars':0x3,'minStrength':0x2,'confirmationBars':0x1},'zone':{'clusterToleranceTicks':0x4,'minTouches':0x2,'maxZoneAgeBars':0xc8,'maxZoneDistanceTicks':0x28,'cooldownBars':0xa},'sweep':{'minPenetrationTicks':0.5,'maxPenetrationTicks':0x8,'maxDurationBars':0x5,'minQualityScore':0.25,'minVolumeRatio':0.5,'minBodyRatio':0.1},'execution':{'stopTicks':0xa,'targetTicks':0x28,'breakevenTicks':0x4,'trailTriggerTicks':0x8,'trailDistanceTicks':0x4,'cooldownMs':0x3a98,'minHoldTimeMs':0x2710,'slippageTicks':0x1,'commissionPerSide':0x2},'session':{'enabled':![],'startHour':0x9,'startMinute':0x1e,'endHour':0x10,'endMinute':0x0,'timezone':'America/New_York'}};class SwingPoint{constructor(_0x4c7556,_0x2b0437,_0x4a33de,_0x5510cd,_0x3ea663=0x1){const _0x531e4e=_0x3c2c79;this['type']=_0x4c7556,this[_0x531e4e(0x13e)]=_0x2b0437,this['barIndex']=_0x4a33de,this['timestamp']=_0x5510cd,this['strength']=_0x3ea663;}}function _0x2306(){const _0x1d6ecf=['tickSize','getStats','stopTicks','swingPoints','getAnalysisState','session','min','s\x20<\x20','_detectSwings','timestamp','sweepType','getBarHistory','info','delete','processTick','strategy','getHealthStatus','penetrationTicks','map','execution','minVolumeRatio','sort','low','toFixed','stats','volumeRatio','barIndex','SUPPORT','length','x\x20|\x20Q:','now','cooldownBars','[HQX-2B]\x20Preload\x20complete:\x20','reset','\x20|\x20Total:\x20','clusterToleranceTicks','set','[2B]\x20SWEEP\x20','isValid','emit','breakevenTicks','priceHigh','20LUhKRy','2891544dWvjDd','516339jAtdHk','long','wins','qualityScore','size','close','log','has','split','targetTicks','maxPenetrationTicks','barHistory','resistance','WIN','_detectSweep','priceLow','filter','uuid','floor','HIGH_SWEEP','push','signal','_getVolumeRatio','open','/5\x20bars','isWithinSession','max','\x20|\x20','config','[2B]\x20Calling\x20_generateSignal\x20for\x20','2026110EvaPsr','maxZoneAgeBars','splice','maxDurationBars','RESISTANCE','startTime','\x20|\x20Pen:','exitBarIndex','preloadBars','processBar','tickCount','shift','containsPrice','2CMiweW','\x20historical\x20signals\x20detected\x20(ignored)','getLevel','trailTriggerTicks','liquidityZones','durationBars','BID','price','currentBar','extremeBarIndex','\x20historical\x20bars...','isDST','onTrade','onTick','type','WEAK','t,\x20BE=','swing','minQualityScore','generateSignal','events','_generateSignal','get','find','21RsODKP','lastSignalTime','buy','distance','barIntervalMs','STRONG','touches','HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)','_mergeConfig','activeSweeps','cooldownMs','toUpperCase','recentTrades','HQX_2B_LIQUIDITY_SWEEP','exports','createdAt','tickValue','sweptAt','trailDistanceTicks','LOSS','2374576aztBTa','_updateZones','volume','550asBGBf','abs','MODERATE','short',',\x20value=','46668ElOrNT','Collecting\x20data...\x20','minPenetrationTicks','initialize','zone','542336KtDGBb','swept','\x20@\x20','recordTradeResult','4072398pKWXOf','lastUsedBarIndex','high','debug','[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)','getFullYear','[2B]\x20NEW\x20ZONE\x20'];_0x2306=function(){return _0x1d6ecf;};return _0x2306();}class LiquidityZone{constructor(_0x47dd02,_0x91f01b,_0x2fc927,_0x60a931,_0x970786){const _0x5b63e4=_0x3c2c79;this['id']=uuidv4(),this['type']=_0x47dd02,this['priceHigh']=_0x91f01b,this['priceLow']=_0x2fc927,this[_0x5b63e4(0x15e)]=_0x60a931,this[_0x5b63e4(0x195)]=_0x970786,this['touches']=0x1,this['swept']=![],this['sweptAt']=null,this['lastUsedBarIndex']=-0x3e7,this['qualityScore']=0.5;}[_0x3c2c79(0x136)](_0x1021bb,_0x259fdd,_0x4d601d){const _0x3c5670=_0x3c2c79,_0x56b511=_0x259fdd*_0x4d601d;return _0x1021bb>=this[_0x3c5670(0x11b)]-_0x56b511&&_0x1021bb<=this[_0x3c5670(0x1a4)]+_0x56b511;}[_0x3c2c79(0x139)](){const _0x505bc5=_0x3c2c79;return(this[_0x505bc5(0x1a4)]+this[_0x505bc5(0x11b)])/0x2;}}class SweepEvent{constructor(_0x1dd70a,_0x3f2142,_0x5da72a,_0x5d7747,_0x388d23){const _0x378def=_0x3c2c79;this[_0x378def(0x185)]=_0x1dd70a,this['zone']=_0x3f2142,this['entryBarIndex']=_0x5da72a,this[_0x378def(0x140)]=_0x5d7747,this['extremePrice']=_0x388d23,this[_0x378def(0x131)]=null,this[_0x378def(0x1a1)]=![],this['qualityScore']=0x0,this[_0x378def(0x18c)]=0x0,this[_0x378def(0x13c)]=0x0,this[_0x378def(0x194)]=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x73ec9d={}){const _0x10b74a=_0x3c2c79;super(),this['config']=this[_0x10b74a(0x157)](DEFAULT_CONFIG,_0x73ec9d),this[_0x10b74a(0x17b)]=this[_0x10b74a(0x128)]['tickSize'],this['tickValue']=this['config'][_0x10b74a(0x15f)],this['barHistory']=new Map(),this['swingPoints']=new Map(),this['liquidityZones']=new Map(),this['activeSweeps']=new Map(),this[_0x10b74a(0x13f)]=new Map(),this[_0x10b74a(0x153)]=0xea60,this[_0x10b74a(0x150)]=0x0,this['startTime']=Date['now'](),this[_0x10b74a(0x193)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this[_0x10b74a(0x15b)]=[];}[_0x3c2c79(0x157)](_0x2ed7e0,_0x35aaed){const _0xffafaf={..._0x2ed7e0};for(const _0x39396d in _0x35aaed){typeof _0x35aaed[_0x39396d]==='object'&&!Array['isArray'](_0x35aaed[_0x39396d])?_0xffafaf[_0x39396d]={..._0x2ed7e0[_0x39396d],..._0x35aaed[_0x39396d]}:_0xffafaf[_0x39396d]=_0x35aaed[_0x39396d];}return _0xffafaf;}['isWithinSession'](_0x51bb43){const _0x47c243=_0x3c2c79;if(!this[_0x47c243(0x128)][_0x47c243(0x180)]['enabled'])return!![];const _0x3aaefc=new Date(_0x51bb43),_0x1bfb98=this[_0x47c243(0x142)](_0x3aaefc)?-0x4:-0x5,_0x3bc5c9=_0x3aaefc['getUTCHours'](),_0x426554=_0x3aaefc['getUTCMinutes'](),_0xd6e43d=(_0x3bc5c9+_0x1bfb98+0x18)%0x18,{startHour:_0x5ec534,startMinute:_0xcdb89c,endHour:_0x5f856b,endMinute:_0x3f11a3}=this[_0x47c243(0x128)][_0x47c243(0x180)],_0x426f54=_0xd6e43d*0x3c+_0x426554,_0x1895fd=_0x5ec534*0x3c+_0xcdb89c,_0x5d165b=_0x5f856b*0x3c+_0x3f11a3;return _0x426f54>=_0x1895fd&&_0x426f54<_0x5d165b;}['isDST'](_0x1f9d17){const _0x273de5=_0x3c2c79,_0xb94322=new Date(_0x1f9d17[_0x273de5(0x179)](),0x0,0x1),_0x227bf7=new Date(_0x1f9d17[_0x273de5(0x179)](),0x6,0x1),_0x5dc005=Math[_0x273de5(0x126)](_0xb94322['getTimezoneOffset'](),_0x227bf7['getTimezoneOffset']());return _0x1f9d17['getTimezoneOffset']()<_0x5dc005;}['initialize'](_0x188519,_0x4ddbbf=0.25,_0x5d88e0=0x5){const _0x43c69f=_0x3c2c79;this[_0x43c69f(0x17b)]=_0x4ddbbf,this['tickValue']=_0x5d88e0,this[_0x43c69f(0x128)]['tickSize']=_0x4ddbbf,this[_0x43c69f(0x128)][_0x43c69f(0x15f)]=_0x5d88e0,this[_0x43c69f(0x117)][_0x43c69f(0x19f)](_0x188519,[]),this['swingPoints']['set'](_0x188519,[]),this[_0x43c69f(0x13b)]['set'](_0x188519,[]),this['activeSweeps']['set'](_0x188519,[]),this['currentBar'][_0x43c69f(0x188)](_0x188519),this[_0x43c69f(0x1a2)]('log',{'type':_0x43c69f(0x187),'message':'[HQX-2B]\x20Initialized\x20for\x20'+_0x188519+':\x20tick='+_0x4ddbbf+_0x43c69f(0x16a)+_0x5d88e0+',\x20TF=1min'}),this['emit'](_0x43c69f(0x1ad),{'type':_0x43c69f(0x187),'message':'[HQX-2B]\x20Params:\x20Stop='+this[_0x43c69f(0x128)]['execution']['stopTicks']+'t,\x20Target='+this[_0x43c69f(0x128)]['execution'][_0x43c69f(0x115)]+_0x43c69f(0x147)+this['config']['execution']['breakevenTicks']+'t,\x20Trail='+this[_0x43c69f(0x128)][_0x43c69f(0x18e)]['trailTriggerTicks']+'/'+this['config']['execution'][_0x43c69f(0x161)]});}[_0x3c2c79(0x189)](_0x2afd93){const _0x1b6503=_0x3c2c79,{contractId:_0x3f6535,price:_0x1b0c2c,volume:_0x21311b,timestamp:_0x539db5}=_0x2afd93,_0x222ac5=_0x539db5||Date[_0x1b6503(0x199)](),_0x15d4ff=_0x21311b||0x1;if(!this[_0x1b6503(0x125)](_0x222ac5))return null;let _0x143ce8=this[_0x1b6503(0x13f)][_0x1b6503(0x14d)](_0x3f6535);const _0x57cd92=Math[_0x1b6503(0x11e)](_0x222ac5/this[_0x1b6503(0x153)])*this[_0x1b6503(0x153)];if(!_0x143ce8||_0x143ce8[_0x1b6503(0x12f)]!==_0x57cd92){if(_0x143ce8){const _0x914633={'timestamp':_0x143ce8['startTime'],'open':_0x143ce8['open'],'high':_0x143ce8['high'],'low':_0x143ce8['low'],'close':_0x143ce8[_0x1b6503(0x1ac)],'volume':_0x143ce8['volume']},_0x1a4ebb=this[_0x1b6503(0x133)](_0x3f6535,_0x914633);return this['currentBar']['set'](_0x3f6535,{'startTime':_0x57cd92,'open':_0x1b0c2c,'high':_0x1b0c2c,'low':_0x1b0c2c,'close':_0x1b0c2c,'volume':_0x15d4ff}),_0x1a4ebb;}else return this[_0x1b6503(0x13f)][_0x1b6503(0x19f)](_0x3f6535,{'startTime':_0x57cd92,'open':_0x1b0c2c,'high':_0x1b0c2c,'low':_0x1b0c2c,'close':_0x1b0c2c,'volume':_0x15d4ff}),null;}else return _0x143ce8[_0x1b6503(0x176)]=Math[_0x1b6503(0x126)](_0x143ce8[_0x1b6503(0x176)],_0x1b0c2c),_0x143ce8[_0x1b6503(0x191)]=Math[_0x1b6503(0x181)](_0x143ce8[_0x1b6503(0x191)],_0x1b0c2c),_0x143ce8[_0x1b6503(0x1ac)]=_0x1b0c2c,_0x143ce8[_0x1b6503(0x165)]+=_0x15d4ff,null;}['onTick'](_0x1c4e6b){const _0xee5035=_0x3c2c79;return this[_0xee5035(0x189)](_0x1c4e6b);}['onTrade'](_0x3cacf6){const _0x49c4c0=_0x3c2c79;return this['processTick']({'contractId':_0x3cacf6['contractId']||_0x3cacf6['symbol'],'price':_0x3cacf6[_0x49c4c0(0x13e)],'volume':_0x3cacf6[_0x49c4c0(0x1ab)]||_0x3cacf6[_0x49c4c0(0x165)]||0x1,'timestamp':_0x3cacf6[_0x49c4c0(0x184)]||Date[_0x49c4c0(0x199)]()});}[_0x3c2c79(0x133)](_0x35e484,_0x28439a){const _0x128f24=_0x3c2c79;let _0x3f7c59=this[_0x128f24(0x117)]['get'](_0x35e484);!_0x3f7c59&&(this[_0x128f24(0x16e)](_0x35e484),_0x3f7c59=this[_0x128f24(0x117)][_0x128f24(0x14d)](_0x35e484));_0x3f7c59['push'](_0x28439a);if(_0x3f7c59[_0x128f24(0x197)]>0x1f4)_0x3f7c59['shift']();const _0x328a5c=_0x3f7c59[_0x128f24(0x197)]-0x1;if(_0x3f7c59['length']<this['config'][_0x128f24(0x148)]['lookbackBars']*0x3)return null;const _0x5b9c9b=this[_0x128f24(0x17e)]['get'](_0x35e484)['length'];this['_detectSwings'](_0x35e484,_0x3f7c59,_0x328a5c);const _0x517b49=this['swingPoints'][_0x128f24(0x14d)](_0x35e484);if(_0x517b49[_0x128f24(0x197)]>_0x5b9c9b){const _0x3cbed6=_0x517b49[_0x517b49['length']-0x1];this['emit'](_0x128f24(0x1ad),{'type':_0x128f24(0x177),'message':'[2B]\x20NEW\x20SWING\x20'+_0x3cbed6['type'][_0x128f24(0x15a)]()+'\x20@\x20'+_0x3cbed6[_0x128f24(0x13e)]['toFixed'](0x2)+_0x128f24(0x19d)+_0x517b49['length']});}const _0x1f5273=this[_0x128f24(0x11a)](_0x35e484,_0x3f7c59,_0x328a5c);_0x1f5273&&this['emit'](_0x128f24(0x1ad),{'type':_0x128f24(0x177),'message':_0x128f24(0x1a0)+_0x1f5273['sweepType']+'\x20|\x20Valid:\x20'+_0x1f5273[_0x128f24(0x1a1)]+'\x20|\x20Pen:\x20'+_0x1f5273['penetrationTicks'][_0x128f24(0x192)](0x1)+'t\x20|\x20Q:\x20'+(_0x1f5273[_0x128f24(0x1aa)]*0x64)[_0x128f24(0x192)](0x0)+'%'});const _0x547e4f=this['liquidityZones']['get'](_0x35e484)[_0x128f24(0x197)];this[_0x128f24(0x164)](_0x35e484,_0x328a5c);const _0x6a3c62=this['liquidityZones'][_0x128f24(0x14d)](_0x35e484);if(_0x6a3c62[_0x128f24(0x197)]>_0x547e4f){const _0x173ed7=_0x6a3c62[_0x6a3c62[_0x128f24(0x197)]-0x1];this['emit']('log',{'type':'debug','message':_0x128f24(0x17a)+_0x173ed7['type'][_0x128f24(0x15a)]()+_0x128f24(0x172)+_0x173ed7[_0x128f24(0x139)]()['toFixed'](0x2)+'\x20|\x20Total:\x20'+_0x6a3c62['length']});}if(_0x1f5273&&_0x1f5273[_0x128f24(0x1a1)]){this[_0x128f24(0x1a2)]('log',{'type':_0x128f24(0x177),'message':_0x128f24(0x129)+_0x1f5273[_0x128f24(0x185)]+'\x20sweep...'});const _0x170907=this[_0x128f24(0x14c)](_0x35e484,_0x28439a,_0x328a5c,_0x1f5273);return!_0x170907&&this['emit'](_0x128f24(0x1ad),{'type':'debug','message':_0x128f24(0x178)}),_0x170907;}return null;}[_0x3c2c79(0x183)](_0x53b086,_0xd2b83e,_0x2e4c6e){const _0x3d9adb=_0x3c2c79,_0x1d03d9=this[_0x3d9adb(0x128)][_0x3d9adb(0x148)]['lookbackBars'],_0x5aade9=this['config'][_0x3d9adb(0x148)]['minStrength'];if(_0x2e4c6e<_0x1d03d9*0x2)return;const _0x401dcd=this['swingPoints']['get'](_0x53b086),_0x2eb524=_0x2e4c6e-_0x1d03d9,_0x3876de=_0xd2b83e[_0x2eb524];let _0x8112a=!![],_0x33497c=0x0;for(let _0x2b97ec=_0x2eb524-_0x1d03d9;_0x2b97ec<=_0x2eb524+_0x1d03d9;_0x2b97ec++){if(_0x2b97ec===_0x2eb524||_0x2b97ec<0x0||_0x2b97ec>=_0xd2b83e['length'])continue;if(_0xd2b83e[_0x2b97ec][_0x3d9adb(0x176)]>=_0x3876de[_0x3d9adb(0x176)]){_0x8112a=![];break;}_0x33497c++;}if(_0x8112a&&_0x33497c>=_0x5aade9){const _0x896569=_0x401dcd[_0x3d9adb(0x14e)](_0x246a61=>_0x246a61[_0x3d9adb(0x195)]===_0x2eb524&&_0x246a61[_0x3d9adb(0x145)]===_0x3d9adb(0x176));!_0x896569&&_0x401dcd['push'](new SwingPoint(_0x3d9adb(0x176),_0x3876de[_0x3d9adb(0x176)],_0x2eb524,_0x3876de[_0x3d9adb(0x184)],_0x33497c));}let _0x1478c8=!![],_0x24cb3d=0x0;for(let _0x1cd509=_0x2eb524-_0x1d03d9;_0x1cd509<=_0x2eb524+_0x1d03d9;_0x1cd509++){if(_0x1cd509===_0x2eb524||_0x1cd509<0x0||_0x1cd509>=_0xd2b83e[_0x3d9adb(0x197)])continue;if(_0xd2b83e[_0x1cd509]['low']<=_0x3876de['low']){_0x1478c8=![];break;}_0x24cb3d++;}if(_0x1478c8&&_0x24cb3d>=_0x5aade9){const _0x5b749b=_0x401dcd[_0x3d9adb(0x14e)](_0x5685f3=>_0x5685f3[_0x3d9adb(0x195)]===_0x2eb524&&_0x5685f3['type']==='low');!_0x5b749b&&_0x401dcd[_0x3d9adb(0x120)](new SwingPoint(_0x3d9adb(0x191),_0x3876de['low'],_0x2eb524,_0x3876de[_0x3d9adb(0x184)],_0x24cb3d));}const _0x1eb0b7=this[_0x3d9adb(0x128)]['zone'][_0x3d9adb(0x12b)];while(_0x401dcd[_0x3d9adb(0x197)]>0x0&&_0x401dcd[0x0][_0x3d9adb(0x195)]<_0x2e4c6e-_0x1eb0b7){_0x401dcd[_0x3d9adb(0x135)]();}}[_0x3c2c79(0x164)](_0x2a7d5e,_0x4d04f6){const _0x35951b=_0x3c2c79,_0x465fe9=this[_0x35951b(0x17e)]['get'](_0x2a7d5e),_0x43d9b2=this['liquidityZones'][_0x35951b(0x14d)](_0x2a7d5e),_0x16aa39=this['config']['zone'][_0x35951b(0x19e)]*this[_0x35951b(0x17b)],_0x387e8b=this[_0x35951b(0x128)][_0x35951b(0x16f)][_0x35951b(0x12b)];for(let _0x1af409=_0x43d9b2['length']-0x1;_0x1af409>=0x0;_0x1af409--){_0x4d04f6-_0x43d9b2[_0x1af409][_0x35951b(0x195)]>_0x387e8b&&_0x43d9b2[_0x35951b(0x12c)](_0x1af409,0x1);}for(const _0x2a73ac of _0x465fe9){let _0x2a8b30=null;for(const _0x5500dc of _0x43d9b2){if(_0x5500dc['containsPrice'](_0x2a73ac[_0x35951b(0x13e)],this['config'][_0x35951b(0x16f)][_0x35951b(0x19e)],this[_0x35951b(0x17b)])){_0x2a8b30=_0x5500dc;break;}}if(_0x2a8b30){_0x2a8b30['touches']++;if(_0x2a73ac[_0x35951b(0x13e)]>_0x2a8b30['priceHigh'])_0x2a8b30['priceHigh']=_0x2a73ac['price'];if(_0x2a73ac['price']<_0x2a8b30['priceLow'])_0x2a8b30[_0x35951b(0x11b)]=_0x2a73ac[_0x35951b(0x13e)];_0x2a8b30['qualityScore']=Math['min'](0x1,0.3+_0x2a8b30['touches']*0.15);}else{const _0x299f07=_0x2a73ac['type']===_0x35951b(0x176)?ZoneType['RESISTANCE']:ZoneType['SUPPORT'],_0x343645=new LiquidityZone(_0x299f07,_0x2a73ac[_0x35951b(0x13e)]+_0x16aa39/0x2,_0x2a73ac[_0x35951b(0x13e)]-_0x16aa39/0x2,_0x2a73ac['timestamp'],_0x2a73ac[_0x35951b(0x195)]);_0x343645[_0x35951b(0x1aa)]=0.3+_0x2a73ac['strength']*0.1,_0x43d9b2[_0x35951b(0x120)](_0x343645);}}}['_detectSweep'](_0x25ee86,_0x146c82,_0x5af283){const _0x10aa22=_0x3c2c79,_0x1efb0b=this[_0x10aa22(0x13b)]['get'](_0x25ee86),_0x439ded=_0x146c82[_0x5af283],_0x2753b3=_0x439ded[_0x10aa22(0x1ac)],_0x1a7494=this['config']['sweep'],_0x3b34dc=this['config'][_0x10aa22(0x16f)];for(const _0x2c9257 of _0x1efb0b){if(_0x2c9257['lastUsedBarIndex']>=0x0&&_0x5af283-_0x2c9257[_0x10aa22(0x175)]<_0x3b34dc[_0x10aa22(0x19a)])continue;const _0x448ff6=_0x2c9257[_0x10aa22(0x139)](),_0x505f83=Math['abs'](_0x2753b3-_0x448ff6)/this[_0x10aa22(0x17b)];if(_0x505f83>_0x3b34dc['maxZoneDistanceTicks'])continue;const _0x130a81=Math[_0x10aa22(0x126)](0x0,_0x5af283-_0x1a7494[_0x10aa22(0x12d)]*0x2);for(let _0x1fe75e=_0x130a81;_0x1fe75e<_0x5af283;_0x1fe75e++){const _0x21823b=_0x146c82[_0x1fe75e];if(_0x2c9257['type']===ZoneType[_0x10aa22(0x12e)]){const _0x13df06=(_0x21823b['high']-_0x2c9257['priceHigh'])/this['tickSize'];if(_0x13df06>=_0x1a7494[_0x10aa22(0x16d)]&&_0x13df06<=_0x1a7494[_0x10aa22(0x116)]){const _0x307fae=Math[_0x10aa22(0x181)](_0x2c9257['priceHigh'],_0x2c9257[_0x10aa22(0x1a4)]+_0x13df06*this['tickSize']);if(_0x2753b3<_0x307fae+this[_0x10aa22(0x17b)]*0x2){const _0x128da3=_0x21823b[_0x10aa22(0x176)]-_0x21823b['low'],_0x14d4bf=Math['abs'](_0x21823b['close']-_0x21823b['open']),_0x5eefa3=_0x128da3>0x0?_0x14d4bf/_0x128da3:0x0;if(_0x5eefa3>=_0x1a7494['minBodyRatio']){const _0x4d188b=this[_0x10aa22(0x122)](_0x146c82,_0x1fe75e,0x14);if(_0x4d188b>=_0x1a7494[_0x10aa22(0x18f)]){const _0x759152=new SweepEvent(SweepType[_0x10aa22(0x11f)],_0x2c9257,_0x1fe75e,_0x1fe75e,_0x21823b[_0x10aa22(0x176)]);_0x759152[_0x10aa22(0x131)]=_0x5af283,_0x759152['penetrationTicks']=_0x13df06,_0x759152[_0x10aa22(0x13c)]=_0x5af283-_0x1fe75e,_0x759152['volumeRatio']=_0x4d188b,_0x759152['qualityScore']=this['_scoreSweep'](_0x759152,_0x5eefa3),_0x759152['isValid']=_0x759152[_0x10aa22(0x1aa)]>=_0x1a7494[_0x10aa22(0x149)];if(_0x759152['isValid'])return _0x759152;}}}}}if(_0x2c9257['type']===ZoneType[_0x10aa22(0x196)]){const _0x45ac67=(_0x2c9257['priceLow']-_0x21823b['low'])/this[_0x10aa22(0x17b)];if(_0x45ac67>=_0x1a7494[_0x10aa22(0x16d)]&&_0x45ac67<=_0x1a7494[_0x10aa22(0x116)]){const _0x19ee56=Math['max'](_0x2c9257[_0x10aa22(0x11b)],_0x2c9257['priceLow']-_0x45ac67*this[_0x10aa22(0x17b)]);if(_0x2753b3>_0x19ee56-this[_0x10aa22(0x17b)]*0x2){const _0x281d8b=_0x21823b['high']-_0x21823b['low'],_0xc92c37=Math[_0x10aa22(0x167)](_0x21823b['close']-_0x21823b[_0x10aa22(0x123)]),_0xbc603c=_0x281d8b>0x0?_0xc92c37/_0x281d8b:0x0;if(_0xbc603c>=_0x1a7494['minBodyRatio']){const _0x367213=this['_getVolumeRatio'](_0x146c82,_0x1fe75e,0x14);if(_0x367213>=_0x1a7494['minVolumeRatio']){const _0x3a2885=new SweepEvent(SweepType['LOW_SWEEP'],_0x2c9257,_0x1fe75e,_0x1fe75e,_0x21823b[_0x10aa22(0x191)]);_0x3a2885['exitBarIndex']=_0x5af283,_0x3a2885['penetrationTicks']=_0x45ac67,_0x3a2885['durationBars']=_0x5af283-_0x1fe75e,_0x3a2885['volumeRatio']=_0x367213,_0x3a2885['qualityScore']=this['_scoreSweep'](_0x3a2885,_0xbc603c),_0x3a2885['isValid']=_0x3a2885[_0x10aa22(0x1aa)]>=_0x1a7494[_0x10aa22(0x149)];if(_0x3a2885['isValid'])return _0x3a2885;}}}}}}}return null;}[_0x3c2c79(0x122)](_0x6fb17f,_0x1ceb64,_0x4fb291){const _0x3707b1=_0x3c2c79,_0x264191=Math[_0x3707b1(0x126)](0x0,_0x1ceb64-_0x4fb291),_0x202d8f=_0x6fb17f['slice'](_0x264191,_0x1ceb64);if(_0x202d8f['length']===0x0)return 0x1;const _0x33ba18=_0x202d8f['map'](_0x35f097=>_0x35f097[_0x3707b1(0x165)])['sort']((_0x5e80e2,_0x4ba738)=>_0x5e80e2-_0x4ba738),_0x522d9a=Math[_0x3707b1(0x11e)](_0x33ba18[_0x3707b1(0x197)]/0x2),_0x214fb5=_0x33ba18[_0x522d9a]||0x1;return _0x6fb17f[_0x1ceb64]['volume']/_0x214fb5;}['_scoreSweep'](_0x4669c0,_0x439bcc){const _0x57063=_0x3c2c79;let _0x18b656=0x0;const _0x426427=0x4,_0x12f3fa=Math[_0x57063(0x167)](_0x4669c0['penetrationTicks']-_0x426427);return _0x18b656+=Math['max'](0x0,0.3-_0x12f3fa*0.03),_0x18b656+=Math[_0x57063(0x126)](0x0,0.25-_0x4669c0[_0x57063(0x13c)]*0.05),_0x18b656+=Math['min'](0.25,_0x4669c0['volumeRatio']*0.1),_0x18b656+=Math['min'](0.2,_0x439bcc*0.4),Math[_0x57063(0x181)](0x1,_0x18b656);}['_generateSignal'](_0x46a390,_0x8b7857,_0x5e7564,_0x10cf4b){const _0x12e294=_0x3c2c79,_0xb0e6cf=Date[_0x12e294(0x199)]()-this['lastSignalTime'];if(_0xb0e6cf<this[_0x12e294(0x128)]['execution'][_0x12e294(0x159)])return this['emit'](_0x12e294(0x1ad),{'type':'debug','message':'[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20('+(_0xb0e6cf/0x3e8)['toFixed'](0x1)+_0x12e294(0x182)+this['config'][_0x12e294(0x18e)][_0x12e294(0x159)]/0x3e8+'s)'}),null;const _0x3a38ce=this[_0x12e294(0x128)]['execution'],_0x1487ea=_0x8b7857['close'],_0x3d7861=_0x10cf4b['sweepType']===SweepType['HIGH_SWEEP']?_0x12e294(0x169):'long';let _0x38c2c8,_0x331476,_0x159785,_0x3ae0d9;_0x3d7861==='long'?(_0x38c2c8=_0x1487ea-_0x3a38ce['stopTicks']*this[_0x12e294(0x17b)],_0x331476=_0x1487ea+_0x3a38ce[_0x12e294(0x115)]*this[_0x12e294(0x17b)],_0x159785=_0x1487ea+_0x3a38ce['breakevenTicks']*this['tickSize'],_0x3ae0d9=_0x1487ea+_0x3a38ce['trailTriggerTicks']*this['tickSize']):(_0x38c2c8=_0x1487ea+_0x3a38ce[_0x12e294(0x17d)]*this[_0x12e294(0x17b)],_0x331476=_0x1487ea-_0x3a38ce['targetTicks']*this['tickSize'],_0x159785=_0x1487ea-_0x3a38ce['breakevenTicks']*this['tickSize'],_0x3ae0d9=_0x1487ea-_0x3a38ce['trailTriggerTicks']*this['tickSize']);const _0x5ca101=_0x3a38ce['targetTicks']/_0x3a38ce[_0x12e294(0x17d)],_0x280928=Math[_0x12e294(0x181)](0x1,_0x10cf4b[_0x12e294(0x1aa)]*0.5+_0x10cf4b[_0x12e294(0x16f)][_0x12e294(0x1aa)]*0.3+(_0x10cf4b[_0x12e294(0x194)]>1.5?0.2:_0x10cf4b['volumeRatio']*0.1));let _0x511247=SignalStrength[_0x12e294(0x168)];if(_0x280928>=0.8)_0x511247=SignalStrength['VERY_STRONG'];else{if(_0x280928>=0.65)_0x511247=SignalStrength[_0x12e294(0x154)];else{if(_0x280928<0.5)_0x511247=SignalStrength[_0x12e294(0x146)];}}const _0x444401=0.5+(_0x280928-0.5)*0.4,_0x486bba=_0x444401*Math[_0x12e294(0x167)](_0x331476-_0x1487ea)-(0x1-_0x444401)*Math[_0x12e294(0x167)](_0x1487ea-_0x38c2c8);_0x10cf4b[_0x12e294(0x16f)]['lastUsedBarIndex']=_0x5e7564,_0x10cf4b[_0x12e294(0x16f)][_0x12e294(0x171)]=!![],_0x10cf4b['zone'][_0x12e294(0x160)]=new Date(_0x8b7857[_0x12e294(0x184)]),this['lastSignalTime']=Date['now'](),this[_0x12e294(0x193)]['signals']++;const _0xff5c2b={'id':uuidv4(),'timestamp':Date[_0x12e294(0x199)](),'symbol':_0x46a390[_0x12e294(0x114)]('.')[0x0]||_0x46a390,'contractId':_0x46a390,'side':_0x3d7861==='long'?OrderSide[_0x12e294(0x13d)]:OrderSide['ASK'],'direction':_0x3d7861,'strategy':_0x12e294(0x15c),'strength':_0x511247,'edge':_0x486bba,'confidence':_0x280928,'entry':_0x1487ea,'entryPrice':_0x1487ea,'stopLoss':_0x38c2c8,'takeProfit':_0x331476,'riskReward':_0x5ca101,'stopTicks':_0x3a38ce[_0x12e294(0x17d)],'targetTicks':_0x3a38ce['targetTicks'],'breakevenTicks':_0x3a38ce[_0x12e294(0x1a3)],'trailTriggerTicks':_0x3a38ce[_0x12e294(0x13a)],'trailDistanceTicks':_0x3a38ce[_0x12e294(0x161)],'beLevel':_0x159785,'trailTrigger':_0x3ae0d9,'sweepType':_0x10cf4b[_0x12e294(0x185)],'penetrationTicks':_0x10cf4b[_0x12e294(0x18c)],'sweepDurationBars':_0x10cf4b['durationBars'],'sweepQuality':_0x10cf4b['qualityScore'],'volumeRatio':_0x10cf4b[_0x12e294(0x194)],'zoneType':_0x10cf4b['zone']['type'],'zoneLevel':_0x10cf4b['zone'][_0x12e294(0x139)](),'zoneTouches':_0x10cf4b[_0x12e294(0x16f)][_0x12e294(0x155)],'zoneQuality':_0x10cf4b['zone'][_0x12e294(0x1aa)],'expires':Date['now']()+0xea60};return this['emit'](_0x12e294(0x121),{'side':_0x3d7861===_0x12e294(0x1a8)?_0x12e294(0x151):'sell','action':_0x12e294(0x123),'reason':'2B\x20'+_0x10cf4b['sweepType']+_0x12e294(0x130)+_0x10cf4b['penetrationTicks']['toFixed'](0x1)+'t\x20|\x20Vol:'+_0x10cf4b['volumeRatio']['toFixed'](0x1)+_0x12e294(0x198)+(_0x10cf4b['qualityScore']*0x64)[_0x12e294(0x192)](0x0)+'%',..._0xff5c2b}),this['emit'](_0x12e294(0x1ad),{'type':_0x12e294(0x187),'message':'[HQX-2B]\x20SIGNAL:\x20'+_0x3d7861[_0x12e294(0x15a)]()+_0x12e294(0x172)+_0x1487ea['toFixed'](0x2)+_0x12e294(0x127)+_0x10cf4b['sweepType']+_0x12e294(0x130)+_0x10cf4b['penetrationTicks'][_0x12e294(0x192)](0x1)+'t\x20Vol:'+_0x10cf4b[_0x12e294(0x194)]['toFixed'](0x1)+'x\x20|\x20Conf:'+(_0x280928*0x64)['toFixed'](0x0)+'%'}),_0xff5c2b;}[_0x3c2c79(0x17f)](_0x148f90,_0x38363f){const _0x5cdd8f=_0x3c2c79,_0x44cbcc=this[_0x5cdd8f(0x117)][_0x5cdd8f(0x14d)](_0x148f90)||[],_0x7c10e7=this[_0x5cdd8f(0x13b)]['get'](_0x148f90)||[],_0x25dd0c=this[_0x5cdd8f(0x17e)][_0x5cdd8f(0x14d)](_0x148f90)||[];if(_0x44cbcc[_0x5cdd8f(0x197)]<0x5)return{'ready':![],'message':_0x5cdd8f(0x16c)+_0x44cbcc[_0x5cdd8f(0x197)]+_0x5cdd8f(0x124)};const _0x2ff932=_0x7c10e7[_0x5cdd8f(0x18d)](_0x4d7d2a=>({'zone':_0x4d7d2a,'distance':Math['abs'](_0x38363f-_0x4d7d2a[_0x5cdd8f(0x139)]())}))[_0x5cdd8f(0x190)]((_0x19f3d4,_0x2b6c91)=>_0x19f3d4['distance']-_0x2b6c91[_0x5cdd8f(0x152)]),_0xacfc44=_0x2ff932[_0x5cdd8f(0x14e)](_0x17a28d=>_0x17a28d[_0x5cdd8f(0x16f)][_0x5cdd8f(0x145)]===ZoneType['RESISTANCE']),_0x34cc80=_0x2ff932[_0x5cdd8f(0x14e)](_0x203c43=>_0x203c43['zone'][_0x5cdd8f(0x145)]===ZoneType['SUPPORT']);return{'ready':!![],'barsProcessed':_0x44cbcc[_0x5cdd8f(0x197)],'swingsDetected':_0x25dd0c[_0x5cdd8f(0x197)],'activeZones':_0x7c10e7['length'],'nearestResistance':_0xacfc44?_0xacfc44[_0x5cdd8f(0x16f)]['getLevel']():null,'nearestSupport':_0x34cc80?_0x34cc80['zone']['getLevel']():null,'stopTicks':this[_0x5cdd8f(0x128)][_0x5cdd8f(0x18e)][_0x5cdd8f(0x17d)],'targetTicks':this[_0x5cdd8f(0x128)]['execution'][_0x5cdd8f(0x115)],'strategy':_0x5cdd8f(0x156)};}[_0x3c2c79(0x173)](_0x41d059){const _0xc6178f=_0x3c2c79;this[_0xc6178f(0x15b)][_0xc6178f(0x120)]({'netPnl':_0x41d059,'timestamp':Date['now']()});if(this['recentTrades']['length']>0x64)this['recentTrades'][_0xc6178f(0x135)]();_0x41d059>0x0?this['stats'][_0xc6178f(0x1a9)]++:this[_0xc6178f(0x193)]['losses']++,this['stats']['trades']++,this[_0xc6178f(0x193)]['pnl']+=_0x41d059,this['emit']('log',{'type':_0xc6178f(0x177),'message':'[HQX-2B]\x20Trade\x20result:\x20'+(_0x41d059>0x0?_0xc6178f(0x119):_0xc6178f(0x162))+'\x20$'+_0x41d059['toFixed'](0x2)});}['getBarHistory'](_0x24aeff){return this['barHistory']['get'](_0x24aeff)||[];}[_0x3c2c79(0x17c)](){return this['stats'];}[_0x3c2c79(0x18b)](_0x2af4f3){const _0x20a135=_0x3c2c79,_0xf3be6e=this[_0x20a135(0x117)]['get'](_0x2af4f3)||[],_0x20f361=this[_0x20a135(0x13b)][_0x20a135(0x14d)](_0x2af4f3)||[],_0x4a2ef7=this['swingPoints']['get'](_0x2af4f3)||[],_0x53eda4=this['currentBar'][_0x20a135(0x14d)](_0x2af4f3),_0x1bf284=_0xf3be6e[_0xf3be6e['length']-0x1],_0x2d0b8d=_0x1bf284?Date['now']()-_0x1bf284['timestamp']:null,_0x1c22ed=_0x20f361[_0x20a135(0x11c)](_0x138bfa=>_0x138bfa['type']===ZoneType['RESISTANCE'])['length'],_0x2a363f=_0x20f361['filter'](_0x5d761c=>_0x5d761c['type']===ZoneType['SUPPORT'])['length'];return{'healthy':_0xf3be6e[_0x20a135(0x197)]>=0x5,'barsTotal':_0xf3be6e['length'],'barsLast5Min':_0xf3be6e[_0x20a135(0x11c)](_0x5aca2d=>Date['now']()-_0x5aca2d['timestamp']<0x5*0x3c*0x3e8)['length'],'swingsTotal':_0x4a2ef7[_0x20a135(0x197)],'zonesResistance':_0x1c22ed,'zonesSupport':_0x2a363f,'zonesTotal':_0x20f361['length'],'currentBarTicks':_0x53eda4?_0x53eda4[_0x20a135(0x134)]:0x0,'isAggregating':_0x53eda4&&_0x53eda4[_0x20a135(0x134)]>0x0,'timeSinceLastBarMs':_0x2d0b8d,'lastSignalTime':this[_0x20a135(0x150)],'signalCooldownMs':this[_0x20a135(0x128)][_0x20a135(0x18e)]['cooldownMs'],'uptime':Date['now']()-(this['startTime']||Date['now']())};}['reset'](_0x204b27){const _0x2fe758=_0x3c2c79;this[_0x2fe758(0x117)][_0x2fe758(0x19f)](_0x204b27,[]),this[_0x2fe758(0x17e)]['set'](_0x204b27,[]),this[_0x2fe758(0x13b)]['set'](_0x204b27,[]),this[_0x2fe758(0x158)]['set'](_0x204b27,[]),this[_0x2fe758(0x13f)][_0x2fe758(0x188)](_0x204b27),this[_0x2fe758(0x1a2)](_0x2fe758(0x1ad),{'type':'info','message':'[HQX-2B]\x20Reset\x20state\x20for\x20'+_0x204b27});}['preloadBars'](_0x51174e,_0x50d3c4){const _0x1702ad=_0x3c2c79;if(!_0x50d3c4||_0x50d3c4['length']===0x0){this[_0x1702ad(0x1a2)](_0x1702ad(0x1ad),{'type':'debug','message':'[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload'});return;}!this[_0x1702ad(0x117)][_0x1702ad(0x1ae)](_0x51174e)&&this['initialize'](_0x51174e);const _0x26b1bc=[..._0x50d3c4]['sort']((_0x49cef0,_0x440a6f)=>_0x49cef0[_0x1702ad(0x184)]-_0x440a6f['timestamp']);this['emit']('log',{'type':'info','message':'[HQX-2B]\x20Preloading\x20'+_0x26b1bc[_0x1702ad(0x197)]+_0x1702ad(0x141)});let _0x46099c=0x0;for(const _0x6a6972 of _0x26b1bc){const _0x2d6015=this[_0x1702ad(0x133)](_0x51174e,_0x6a6972);if(_0x2d6015)_0x46099c++;}const _0x3bdbdc=this['barHistory'][_0x1702ad(0x14d)](_0x51174e)||[],_0x6235e9=this[_0x1702ad(0x17e)]['get'](_0x51174e)||[],_0x3c280b=this[_0x1702ad(0x13b)][_0x1702ad(0x14d)](_0x51174e)||[];this[_0x1702ad(0x1a2)]('log',{'type':'info','message':_0x1702ad(0x19b)+_0x3bdbdc[_0x1702ad(0x197)]+'\x20bars,\x20'+_0x6235e9[_0x1702ad(0x197)]+'\x20swings,\x20'+_0x3c280b[_0x1702ad(0x197)]+'\x20zones'}),_0x46099c>0x0&&this['emit']('log',{'type':'debug','message':'[HQX-2B]\x20'+_0x46099c+_0x1702ad(0x138)}),this[_0x1702ad(0x150)]=0x0;}}function _0x3286(_0x3044e3,_0x56310f){_0x3044e3=_0x3044e3-0x114;const _0x230694=_0x2306();let _0x32866b=_0x230694[_0x3044e3];return _0x32866b;}class HQX2BStrategy extends EventEmitter{constructor(_0x300ae8={}){const _0x5c848d=_0x3c2c79;super(),this[_0x5c848d(0x128)]=_0x300ae8,this[_0x5c848d(0x18a)]=new HQX2BLiquiditySweep(_0x300ae8),this['strategy']['on'](_0x5c848d(0x121),_0x570bcb=>this[_0x5c848d(0x1a2)]('signal',_0x570bcb)),this['strategy']['on'](_0x5c848d(0x1ad),_0x71898a=>this['emit']('log',_0x71898a));}['processTick'](_0x174544){const _0x302f2b=_0x3c2c79;return this[_0x302f2b(0x18a)][_0x302f2b(0x189)](_0x174544);}[_0x3c2c79(0x144)](_0x5c7d9c){const _0x4274bc=_0x3c2c79;return this[_0x4274bc(0x18a)]['onTick'](_0x5c7d9c);}[_0x3c2c79(0x143)](_0x163ba0){const _0x4f4246=_0x3c2c79;return this['strategy'][_0x4f4246(0x143)](_0x163ba0);}['processBar'](_0x1f5bd9,_0x2629d3){return this['strategy']['processBar'](_0x1f5bd9,_0x2629d3);}['initialize'](_0x3d64ff,_0x47305d,_0x604d79){return this['strategy']['initialize'](_0x3d64ff,_0x47305d,_0x604d79);}['getAnalysisState'](_0x5d93d8,_0x5dfcfb){const _0x2ba36d=_0x3c2c79;return this[_0x2ba36d(0x18a)]['getAnalysisState'](_0x5d93d8,_0x5dfcfb);}['recordTradeResult'](_0x3c2dc1){const _0x2cdbd6=_0x3c2c79;return this[_0x2cdbd6(0x18a)]['recordTradeResult'](_0x3c2dc1);}[_0x3c2c79(0x19c)](_0x411477){return this['strategy']['reset'](_0x411477);}['getStats'](){const _0x121bfc=_0x3c2c79;return this[_0x121bfc(0x18a)][_0x121bfc(0x17c)]();}[_0x3c2c79(0x186)](_0x3a9ae0){const _0x683ede=_0x3c2c79;return this[_0x683ede(0x18a)]['getBarHistory'](_0x3a9ae0);}[_0x3c2c79(0x132)](_0x477061,_0x5a6c68){return this['strategy']['preloadBars'](_0x477061,_0x5a6c68);}[_0x3c2c79(0x18b)](_0x450f8e){const _0x2af21b=_0x3c2c79;return this[_0x2af21b(0x18a)]['getHealthStatus'](_0x450f8e);}[_0x3c2c79(0x14a)](_0x4b30fc){return null;}}module[_0x3c2c79(0x15d)]={'HQX2BLiquiditySweep':HQX2BLiquiditySweep,'HQX2BStrategy':HQX2BStrategy,'M2':HQX2BStrategy,'S2':HQX2BLiquiditySweep,'OrderSide':OrderSide,'SignalStrength':SignalStrength,'SweepType':SweepType,'ZoneType':ZoneType,'DEFAULT_CONFIG':DEFAULT_CONFIG};
|
|
1
|
+
const _0x36ddf1=_0x4576;(function(_0x4667dd,_0x241d80){const _0x2a93c1=_0x4576,_0x8020ac=_0x4667dd();while(!![]){try{const _0x56b998=-parseInt(_0x2a93c1(0x261))/0x1*(parseInt(_0x2a93c1(0x1e6))/0x2)+parseInt(_0x2a93c1(0x26f))/0x3*(parseInt(_0x2a93c1(0x1f4))/0x4)+parseInt(_0x2a93c1(0x258))/0x5*(parseInt(_0x2a93c1(0x237))/0x6)+-parseInt(_0x2a93c1(0x263))/0x7+parseInt(_0x2a93c1(0x21d))/0x8+-parseInt(_0x2a93c1(0x21c))/0x9*(parseInt(_0x2a93c1(0x1f2))/0xa)+parseInt(_0x2a93c1(0x25f))/0xb;if(_0x56b998===_0x241d80)break;else _0x8020ac['push'](_0x8020ac['shift']());}catch(_0x590f10){_0x8020ac['push'](_0x8020ac['shift']());}}}(_0x230d,0x1c412));const EventEmitter=require(_0x36ddf1(0x230)),{v4:uuidv4}=require(_0x36ddf1(0x249)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':_0x36ddf1(0x274),'LOW_SWEEP':_0x36ddf1(0x236)},ZoneType={'RESISTANCE':'resistance','SUPPORT':_0x36ddf1(0x25e)},DEFAULT_CONFIG={'tickSize':0.25,'tickValue':0x5,'swing':{'lookbackBars':0x3,'minStrength':0x2,'confirmationBars':0x1},'zone':{'clusterToleranceTicks':0x4,'minTouches':0x2,'maxZoneAgeBars':0xc8,'maxZoneDistanceTicks':0x28,'cooldownBars':0xa},'sweep':{'minPenetrationTicks':0.5,'maxPenetrationTicks':0x8,'maxDurationBars':0x5,'minQualityScore':0.25,'minVolumeRatio':0.5,'minBodyRatio':0.1},'execution':{'stopTicks':0xa,'targetTicks':0x28,'breakevenTicks':0x4,'trailTriggerTicks':0x8,'trailDistanceTicks':0x4,'cooldownMs':0x3a98,'minHoldTimeMs':0x2710,'slippageTicks':0x1,'commissionPerSide':0x2},'session':{'enabled':![],'startHour':0x9,'startMinute':0x1e,'endHour':0x10,'endMinute':0x0,'timezone':_0x36ddf1(0x204)}};function _0x4576(_0x3d947b,_0x317c88){_0x3d947b=_0x3d947b-0x1de;const _0x230ddb=_0x230d();let _0x457641=_0x230ddb[_0x3d947b];return _0x457641;}function _0x230d(){const _0x4f6bd6=['generateSignal','toUpperCase','config','volume','get','[2B]\x20SWEEP\x20','trailTriggerTicks','\x20historical\x20signals\x20detected\x20(ignored)','t\x20|\x20Q:\x20','maxDurationBars','10ItpTCb','execution','4NmUbsF','emit','map','preloadBars','liquidityZones','isWithinSession','lookbackBars','activeSweeps','[HQX-2B]\x20Reset\x20state\x20for\x20','processTick','_mergeConfig','tickSize','t,\x20Trail=','penetrationTicks','strength','max','America/New_York','MODERATE','sort','getFullYear','trailDistanceTicks','tickValue','find','Collecting\x20data...\x20','x\x20|\x20Conf:','cooldownMs','stats','getHealthStatus','slice','session','durationBars','swing','shift','[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload','stopTicks','WEAK','priceLow','initialize','minQualityScore','getAnalysisState','457956MfgYDW','266520lKzKym','barIndex','[BAR]\x20#','debug','filter','VERY_STRONG','\x20@\x20','onTrade','min','x\x20|\x20Q:','currentBar','close','clusterToleranceTicks','type','splice','log','has','delete','onTick','events','lastUsedBarIndex','exitBarIndex','strategy','sweepType','\x20|\x20','low','54336fPThCu','startTime',',\x20value=','\x20|\x20Pen:\x20','signal','_generateSignal','qualityScore','targetTicks','getTimezoneOffset','lastSignalTime','length','_getVolumeRatio','[HQX-2B]\x20Trade\x20result:\x20','RESISTANCE','[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20(','[2B]\x20NEW\x20SWING\x20','isDST','containsPrice','uuid','timestamp','open','pnl','symbol','t,\x20BE=','swept','now','swingPoints','t,\x20Target=','/5\x20bars','2B\x20','getLevel','losses','\x20bars,\x20','65SrafdF','set','processBar',',\x20TF=1min','getStats','[HQX-2B]\x20','support','320485XeWFQx','barHistory','1SxceAZ','entryBarIndex','543403UKXeNl','tickCount','info','long','breakevenTicks','isValid','[HQX-2B]\x20Initialized\x20for\x20','_detectSweep','recordTradeResult','distance','volumeRatio','_tickCount','677199DAmbJe','priceHigh','[HQX-2B]\x20SIGNAL:\x20','zone','toFixed','high','HQX_2B_LIQUIDITY_SWEEP','\x20|\x20O:','_detectSwings','[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)','\x20L:','reset','\x20|\x20Pen:','touches','push','STRONG','\x20H:','LOSS','abs','SUPPORT','price','323336SIGKZv','getUTCHours'];_0x230d=function(){return _0x4f6bd6;};return _0x230d();}class SwingPoint{constructor(_0x1592ba,_0x18ce55,_0x13968e,_0x599da0,_0x26d882=0x1){const _0x6c76ab=_0x36ddf1;this[_0x6c76ab(0x22a)]=_0x1592ba,this['price']=_0x18ce55,this['barIndex']=_0x13968e,this[_0x6c76ab(0x24a)]=_0x599da0,this[_0x6c76ab(0x202)]=_0x26d882;}}class LiquidityZone{constructor(_0x2fd87e,_0x2163c8,_0x483e43,_0x35364a,_0x4224fa){const _0x5cbe91=_0x36ddf1;this['id']=uuidv4(),this['type']=_0x2fd87e,this['priceHigh']=_0x2163c8,this['priceLow']=_0x483e43,this['createdAt']=_0x35364a,this[_0x5cbe91(0x21e)]=_0x4224fa,this[_0x5cbe91(0x1de)]=0x1,this[_0x5cbe91(0x24f)]=![],this['sweptAt']=null,this['lastUsedBarIndex']=-0x3e7,this[_0x5cbe91(0x23d)]=0.5;}[_0x36ddf1(0x248)](_0x2b9b49,_0x21d562,_0x3dc3c1){const _0x2e573c=_0x21d562*_0x3dc3c1;return _0x2b9b49>=this['priceLow']-_0x2e573c&&_0x2b9b49<=this['priceHigh']+_0x2e573c;}[_0x36ddf1(0x255)](){return(this['priceHigh']+this['priceLow'])/0x2;}}class SweepEvent{constructor(_0x3b5055,_0x23fbc6,_0x21fec3,_0x4f2661,_0x4e5440){const _0x505b10=_0x36ddf1;this[_0x505b10(0x234)]=_0x3b5055,this['zone']=_0x23fbc6,this[_0x505b10(0x262)]=_0x21fec3,this['extremeBarIndex']=_0x4f2661,this['extremePrice']=_0x4e5440,this[_0x505b10(0x232)]=null,this[_0x505b10(0x268)]=![],this[_0x505b10(0x23d)]=0x0,this[_0x505b10(0x201)]=0x0,this['durationBars']=0x0,this['volumeRatio']=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x4abce8={}){const _0x65a5e4=_0x36ddf1;super(),this['config']=this['_mergeConfig'](DEFAULT_CONFIG,_0x4abce8),this['tickSize']=this[_0x65a5e4(0x1ea)]['tickSize'],this[_0x65a5e4(0x209)]=this['config'][_0x65a5e4(0x209)],this['barHistory']=new Map(),this[_0x65a5e4(0x251)]=new Map(),this['liquidityZones']=new Map(),this[_0x65a5e4(0x1fb)]=new Map(),this[_0x65a5e4(0x227)]=new Map(),this['barIntervalMs']=0xea60,this[_0x65a5e4(0x240)]=0x0,this['startTime']=Date[_0x65a5e4(0x250)](),this[_0x65a5e4(0x20e)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this['recentTrades']=[];}[_0x36ddf1(0x1fe)](_0x206f21,_0x472c07){const _0x2a86ca={..._0x206f21};for(const _0x91349c in _0x472c07){typeof _0x472c07[_0x91349c]==='object'&&!Array['isArray'](_0x472c07[_0x91349c])?_0x2a86ca[_0x91349c]={..._0x206f21[_0x91349c],..._0x472c07[_0x91349c]}:_0x2a86ca[_0x91349c]=_0x472c07[_0x91349c];}return _0x2a86ca;}[_0x36ddf1(0x1f9)](_0x17c4a5){const _0x206111=_0x36ddf1;if(!this[_0x206111(0x1ea)][_0x206111(0x211)]['enabled'])return!![];const _0x502016=new Date(_0x17c4a5),_0xa8a993=this[_0x206111(0x247)](_0x502016)?-0x4:-0x5,_0x1f96e4=_0x502016[_0x206111(0x1e7)](),_0x909cfc=_0x502016['getUTCMinutes'](),_0x1ab837=(_0x1f96e4+_0xa8a993+0x18)%0x18,{startHour:_0x450aac,startMinute:_0x260644,endHour:_0x2a8d3d,endMinute:_0x59048a}=this[_0x206111(0x1ea)][_0x206111(0x211)],_0x232832=_0x1ab837*0x3c+_0x909cfc,_0x155cfc=_0x450aac*0x3c+_0x260644,_0x1c4ffa=_0x2a8d3d*0x3c+_0x59048a;return _0x232832>=_0x155cfc&&_0x232832<_0x1c4ffa;}[_0x36ddf1(0x247)](_0x28b300){const _0x5045b3=_0x36ddf1,_0x4c51f6=new Date(_0x28b300[_0x5045b3(0x207)](),0x0,0x1),_0x17e49a=new Date(_0x28b300[_0x5045b3(0x207)](),0x6,0x1),_0x11430b=Math['max'](_0x4c51f6['getTimezoneOffset'](),_0x17e49a[_0x5045b3(0x23f)]());return _0x28b300['getTimezoneOffset']()<_0x11430b;}['initialize'](_0x232340,_0xc84093=0.25,_0x376ba4=0x5){const _0x5c4475=_0x36ddf1;this[_0x5c4475(0x1ff)]=_0xc84093,this['tickValue']=_0x376ba4,this['config'][_0x5c4475(0x1ff)]=_0xc84093,this[_0x5c4475(0x1ea)][_0x5c4475(0x209)]=_0x376ba4,this[_0x5c4475(0x260)]['set'](_0x232340,[]),this['swingPoints'][_0x5c4475(0x259)](_0x232340,[]),this[_0x5c4475(0x1f8)]['set'](_0x232340,[]),this[_0x5c4475(0x1fb)][_0x5c4475(0x259)](_0x232340,[]),this[_0x5c4475(0x227)]['delete'](_0x232340),this['emit']('log',{'type':_0x5c4475(0x265),'message':_0x5c4475(0x269)+_0x232340+':\x20tick='+_0xc84093+_0x5c4475(0x239)+_0x376ba4+_0x5c4475(0x25b)}),this[_0x5c4475(0x1f5)](_0x5c4475(0x22c),{'type':'info','message':'[HQX-2B]\x20Params:\x20Stop='+this[_0x5c4475(0x1ea)]['execution']['stopTicks']+_0x5c4475(0x252)+this['config']['execution'][_0x5c4475(0x23e)]+_0x5c4475(0x24e)+this[_0x5c4475(0x1ea)][_0x5c4475(0x1f3)]['breakevenTicks']+_0x5c4475(0x200)+this[_0x5c4475(0x1ea)]['execution'][_0x5c4475(0x1ee)]+'/'+this[_0x5c4475(0x1ea)][_0x5c4475(0x1f3)][_0x5c4475(0x208)]});}['processTick'](_0x35a37d){const _0x485dd7=_0x36ddf1,{contractId:_0x1a85ba,price:_0x455f16,volume:_0xc87232,timestamp:_0x479d32}=_0x35a37d,_0x27dd0c=_0x479d32||Date['now'](),_0xbddd5=_0xc87232||0x1;if(!this['isWithinSession'](_0x27dd0c))return null;if(!this[_0x485dd7(0x26e)])this['_tickCount']=0x0;this['_tickCount']++;let _0x5c15d8=this['currentBar'][_0x485dd7(0x1ec)](_0x1a85ba);const _0x36cf1c=Math['floor'](_0x27dd0c/this['barIntervalMs'])*this['barIntervalMs'];if(!_0x5c15d8||_0x5c15d8[_0x485dd7(0x238)]!==_0x36cf1c){if(_0x5c15d8){const _0x12bce8={'timestamp':_0x5c15d8[_0x485dd7(0x238)],'open':_0x5c15d8[_0x485dd7(0x24b)],'high':_0x5c15d8[_0x485dd7(0x274)],'low':_0x5c15d8['low'],'close':_0x5c15d8['close'],'volume':_0x5c15d8[_0x485dd7(0x1eb)]},_0x4c8496=this[_0x485dd7(0x260)][_0x485dd7(0x1ec)](_0x1a85ba)||[];this[_0x485dd7(0x1f5)]('log',{'type':'debug','message':_0x485dd7(0x21f)+(_0x4c8496['length']+0x1)+'\x20closed\x20@\x20'+_0x12bce8[_0x485dd7(0x228)]['toFixed'](0x2)+_0x485dd7(0x276)+_0x12bce8['open'][_0x485dd7(0x273)](0x2)+_0x485dd7(0x1e1)+_0x12bce8['high']['toFixed'](0x2)+_0x485dd7(0x279)+_0x12bce8[_0x485dd7(0x236)]['toFixed'](0x2)+'\x20Vol:'+_0x12bce8['volume']});const _0x26bec2=this['processBar'](_0x1a85ba,_0x12bce8);return this['currentBar']['set'](_0x1a85ba,{'startTime':_0x36cf1c,'open':_0x455f16,'high':_0x455f16,'low':_0x455f16,'close':_0x455f16,'volume':_0xbddd5}),_0x26bec2;}else return this[_0x485dd7(0x227)]['set'](_0x1a85ba,{'startTime':_0x36cf1c,'open':_0x455f16,'high':_0x455f16,'low':_0x455f16,'close':_0x455f16,'volume':_0xbddd5}),null;}else return _0x5c15d8['high']=Math['max'](_0x5c15d8[_0x485dd7(0x274)],_0x455f16),_0x5c15d8['low']=Math[_0x485dd7(0x225)](_0x5c15d8[_0x485dd7(0x236)],_0x455f16),_0x5c15d8['close']=_0x455f16,_0x5c15d8['volume']+=_0xbddd5,null;}[_0x36ddf1(0x22f)](_0x188f41){return this['processTick'](_0x188f41);}[_0x36ddf1(0x224)](_0x3f92b7){const _0x39a433=_0x36ddf1;return this['processTick']({'contractId':_0x3f92b7['contractId']||_0x3f92b7[_0x39a433(0x24d)],'price':_0x3f92b7[_0x39a433(0x1e5)],'volume':_0x3f92b7['size']||_0x3f92b7[_0x39a433(0x1eb)]||0x1,'timestamp':_0x3f92b7[_0x39a433(0x24a)]||Date[_0x39a433(0x250)]()});}['processBar'](_0x10f571,_0x19c591){const _0xbab4ef=_0x36ddf1;let _0x1735f7=this[_0xbab4ef(0x260)]['get'](_0x10f571);!_0x1735f7&&(this[_0xbab4ef(0x219)](_0x10f571),_0x1735f7=this['barHistory'][_0xbab4ef(0x1ec)](_0x10f571));_0x1735f7['push'](_0x19c591);if(_0x1735f7[_0xbab4ef(0x241)]>0x1f4)_0x1735f7['shift']();const _0x22c9a6=_0x1735f7[_0xbab4ef(0x241)]-0x1;if(_0x1735f7[_0xbab4ef(0x241)]<this[_0xbab4ef(0x1ea)]['swing'][_0xbab4ef(0x1fa)]*0x3)return null;const _0x56ef7d=this['swingPoints'][_0xbab4ef(0x1ec)](_0x10f571)[_0xbab4ef(0x241)];this['_detectSwings'](_0x10f571,_0x1735f7,_0x22c9a6);const _0x51339b=this[_0xbab4ef(0x251)]['get'](_0x10f571);if(_0x51339b['length']>_0x56ef7d){const _0xe007f4=_0x51339b[_0x51339b[_0xbab4ef(0x241)]-0x1];this['emit']('log',{'type':_0xbab4ef(0x220),'message':_0xbab4ef(0x246)+_0xe007f4['type'][_0xbab4ef(0x1e9)]()+'\x20@\x20'+_0xe007f4['price'][_0xbab4ef(0x273)](0x2)+'\x20|\x20Total:\x20'+_0x51339b['length']});}const _0x194f86=this[_0xbab4ef(0x26a)](_0x10f571,_0x1735f7,_0x22c9a6);_0x194f86&&this['emit'](_0xbab4ef(0x22c),{'type':'debug','message':_0xbab4ef(0x1ed)+_0x194f86[_0xbab4ef(0x234)]+'\x20|\x20Valid:\x20'+_0x194f86['isValid']+_0xbab4ef(0x23a)+_0x194f86['penetrationTicks']['toFixed'](0x1)+_0xbab4ef(0x1f0)+(_0x194f86['qualityScore']*0x64)['toFixed'](0x0)+'%'});const _0x4254f1=this[_0xbab4ef(0x1f8)][_0xbab4ef(0x1ec)](_0x10f571)['length'];this['_updateZones'](_0x10f571,_0x22c9a6);const _0x8a8b40=this[_0xbab4ef(0x1f8)]['get'](_0x10f571);if(_0x8a8b40[_0xbab4ef(0x241)]>_0x4254f1){const _0x55fd7e=_0x8a8b40[_0x8a8b40[_0xbab4ef(0x241)]-0x1];this['emit'](_0xbab4ef(0x22c),{'type':_0xbab4ef(0x220),'message':'[2B]\x20NEW\x20ZONE\x20'+_0x55fd7e['type'][_0xbab4ef(0x1e9)]()+_0xbab4ef(0x223)+_0x55fd7e[_0xbab4ef(0x255)]()['toFixed'](0x2)+'\x20|\x20Total:\x20'+_0x8a8b40[_0xbab4ef(0x241)]});}if(_0x194f86&&_0x194f86['isValid']){this[_0xbab4ef(0x1f5)](_0xbab4ef(0x22c),{'type':_0xbab4ef(0x220),'message':'[2B]\x20Calling\x20_generateSignal\x20for\x20'+_0x194f86[_0xbab4ef(0x234)]+'\x20sweep...'});const _0x5814ba=this[_0xbab4ef(0x23c)](_0x10f571,_0x19c591,_0x22c9a6,_0x194f86);return!_0x5814ba&&this[_0xbab4ef(0x1f5)](_0xbab4ef(0x22c),{'type':_0xbab4ef(0x220),'message':_0xbab4ef(0x278)}),_0x5814ba;}return null;}[_0x36ddf1(0x277)](_0x78b766,_0x5db3ee,_0x32d5c7){const _0x9fa81f=_0x36ddf1,_0x525c44=this['config'][_0x9fa81f(0x213)][_0x9fa81f(0x1fa)],_0x584abe=this[_0x9fa81f(0x1ea)]['swing']['minStrength'];if(_0x32d5c7<_0x525c44*0x2)return;const _0x4fe685=this[_0x9fa81f(0x251)][_0x9fa81f(0x1ec)](_0x78b766),_0x480bdd=_0x32d5c7-_0x525c44,_0x335fc2=_0x5db3ee[_0x480bdd];let _0xb35463=!![],_0x20cf3b=0x0;for(let _0x2fee22=_0x480bdd-_0x525c44;_0x2fee22<=_0x480bdd+_0x525c44;_0x2fee22++){if(_0x2fee22===_0x480bdd||_0x2fee22<0x0||_0x2fee22>=_0x5db3ee['length'])continue;if(_0x5db3ee[_0x2fee22]['high']>=_0x335fc2['high']){_0xb35463=![];break;}_0x20cf3b++;}if(_0xb35463&&_0x20cf3b>=_0x584abe){const _0x159325=_0x4fe685[_0x9fa81f(0x20a)](_0x420d7e=>_0x420d7e['barIndex']===_0x480bdd&&_0x420d7e[_0x9fa81f(0x22a)]===_0x9fa81f(0x274));!_0x159325&&_0x4fe685[_0x9fa81f(0x1df)](new SwingPoint('high',_0x335fc2[_0x9fa81f(0x274)],_0x480bdd,_0x335fc2[_0x9fa81f(0x24a)],_0x20cf3b));}let _0x3a2af4=!![],_0x452c3b=0x0;for(let _0x4188f3=_0x480bdd-_0x525c44;_0x4188f3<=_0x480bdd+_0x525c44;_0x4188f3++){if(_0x4188f3===_0x480bdd||_0x4188f3<0x0||_0x4188f3>=_0x5db3ee[_0x9fa81f(0x241)])continue;if(_0x5db3ee[_0x4188f3]['low']<=_0x335fc2[_0x9fa81f(0x236)]){_0x3a2af4=![];break;}_0x452c3b++;}if(_0x3a2af4&&_0x452c3b>=_0x584abe){const _0x13f0f2=_0x4fe685['find'](_0xe856e4=>_0xe856e4[_0x9fa81f(0x21e)]===_0x480bdd&&_0xe856e4['type']===_0x9fa81f(0x236));!_0x13f0f2&&_0x4fe685['push'](new SwingPoint(_0x9fa81f(0x236),_0x335fc2['low'],_0x480bdd,_0x335fc2[_0x9fa81f(0x24a)],_0x452c3b));}const _0x4dddf1=this['config']['zone']['maxZoneAgeBars'];while(_0x4fe685['length']>0x0&&_0x4fe685[0x0]['barIndex']<_0x32d5c7-_0x4dddf1){_0x4fe685[_0x9fa81f(0x214)]();}}['_updateZones'](_0x321e1c,_0x415a65){const _0x5405c4=_0x36ddf1,_0x3c5d3d=this[_0x5405c4(0x251)][_0x5405c4(0x1ec)](_0x321e1c),_0x335dda=this[_0x5405c4(0x1f8)]['get'](_0x321e1c),_0x2af153=this[_0x5405c4(0x1ea)][_0x5405c4(0x272)][_0x5405c4(0x229)]*this['tickSize'],_0x528fc6=this[_0x5405c4(0x1ea)][_0x5405c4(0x272)]['maxZoneAgeBars'];for(let _0x26f5bc=_0x335dda['length']-0x1;_0x26f5bc>=0x0;_0x26f5bc--){_0x415a65-_0x335dda[_0x26f5bc]['barIndex']>_0x528fc6&&_0x335dda[_0x5405c4(0x22b)](_0x26f5bc,0x1);}for(const _0x581ea5 of _0x3c5d3d){let _0x1d7eac=null;for(const _0x23e60c of _0x335dda){if(_0x23e60c[_0x5405c4(0x248)](_0x581ea5['price'],this[_0x5405c4(0x1ea)]['zone']['clusterToleranceTicks'],this['tickSize'])){_0x1d7eac=_0x23e60c;break;}}if(_0x1d7eac){_0x1d7eac[_0x5405c4(0x1de)]++;if(_0x581ea5['price']>_0x1d7eac[_0x5405c4(0x270)])_0x1d7eac['priceHigh']=_0x581ea5[_0x5405c4(0x1e5)];if(_0x581ea5[_0x5405c4(0x1e5)]<_0x1d7eac['priceLow'])_0x1d7eac[_0x5405c4(0x218)]=_0x581ea5[_0x5405c4(0x1e5)];_0x1d7eac['qualityScore']=Math[_0x5405c4(0x225)](0x1,0.3+_0x1d7eac['touches']*0.15);}else{const _0x4902fd=_0x581ea5[_0x5405c4(0x22a)]===_0x5405c4(0x274)?ZoneType['RESISTANCE']:ZoneType[_0x5405c4(0x1e4)],_0x4844d9=new LiquidityZone(_0x4902fd,_0x581ea5[_0x5405c4(0x1e5)]+_0x2af153/0x2,_0x581ea5[_0x5405c4(0x1e5)]-_0x2af153/0x2,_0x581ea5['timestamp'],_0x581ea5['barIndex']);_0x4844d9[_0x5405c4(0x23d)]=0.3+_0x581ea5['strength']*0.1,_0x335dda[_0x5405c4(0x1df)](_0x4844d9);}}}[_0x36ddf1(0x26a)](_0x3c6e08,_0x48e185,_0x344941){const _0x7c8711=_0x36ddf1,_0xe8b7fd=this[_0x7c8711(0x1f8)][_0x7c8711(0x1ec)](_0x3c6e08),_0x2559ae=_0x48e185[_0x344941],_0x45effa=_0x2559ae[_0x7c8711(0x228)],_0x1032f8=this[_0x7c8711(0x1ea)]['sweep'],_0x53ed14=this[_0x7c8711(0x1ea)]['zone'];for(const _0x4cdfcd of _0xe8b7fd){if(_0x4cdfcd[_0x7c8711(0x231)]>=0x0&&_0x344941-_0x4cdfcd['lastUsedBarIndex']<_0x53ed14['cooldownBars'])continue;const _0x178fd1=_0x4cdfcd['getLevel'](),_0x4570ab=Math[_0x7c8711(0x1e3)](_0x45effa-_0x178fd1)/this['tickSize'];if(_0x4570ab>_0x53ed14['maxZoneDistanceTicks'])continue;const _0x5e7be3=Math['max'](0x0,_0x344941-_0x1032f8[_0x7c8711(0x1f1)]*0x2);for(let _0x5aea88=_0x5e7be3;_0x5aea88<_0x344941;_0x5aea88++){const _0x167864=_0x48e185[_0x5aea88];if(_0x4cdfcd[_0x7c8711(0x22a)]===ZoneType['RESISTANCE']){const _0x18770a=(_0x167864['high']-_0x4cdfcd[_0x7c8711(0x270)])/this[_0x7c8711(0x1ff)];if(_0x18770a>=_0x1032f8['minPenetrationTicks']&&_0x18770a<=_0x1032f8['maxPenetrationTicks']){const _0xa2914d=Math[_0x7c8711(0x225)](_0x4cdfcd['priceHigh'],_0x4cdfcd[_0x7c8711(0x270)]+_0x18770a*this['tickSize']);if(_0x45effa<_0xa2914d+this['tickSize']*0x2){const _0x25dfce=_0x167864[_0x7c8711(0x274)]-_0x167864['low'],_0x28ddde=Math[_0x7c8711(0x1e3)](_0x167864['close']-_0x167864[_0x7c8711(0x24b)]),_0x35201c=_0x25dfce>0x0?_0x28ddde/_0x25dfce:0x0;if(_0x35201c>=_0x1032f8['minBodyRatio']){const _0x4fb85f=this[_0x7c8711(0x242)](_0x48e185,_0x5aea88,0x14);if(_0x4fb85f>=_0x1032f8['minVolumeRatio']){const _0x3bf922=new SweepEvent(SweepType['HIGH_SWEEP'],_0x4cdfcd,_0x5aea88,_0x5aea88,_0x167864['high']);_0x3bf922[_0x7c8711(0x232)]=_0x344941,_0x3bf922['penetrationTicks']=_0x18770a,_0x3bf922[_0x7c8711(0x212)]=_0x344941-_0x5aea88,_0x3bf922['volumeRatio']=_0x4fb85f,_0x3bf922[_0x7c8711(0x23d)]=this['_scoreSweep'](_0x3bf922,_0x35201c),_0x3bf922[_0x7c8711(0x268)]=_0x3bf922[_0x7c8711(0x23d)]>=_0x1032f8[_0x7c8711(0x21a)];if(_0x3bf922[_0x7c8711(0x268)])return _0x3bf922;}}}}}if(_0x4cdfcd['type']===ZoneType['SUPPORT']){const _0x57eb26=(_0x4cdfcd['priceLow']-_0x167864[_0x7c8711(0x236)])/this[_0x7c8711(0x1ff)];if(_0x57eb26>=_0x1032f8['minPenetrationTicks']&&_0x57eb26<=_0x1032f8['maxPenetrationTicks']){const _0x28d892=Math[_0x7c8711(0x203)](_0x4cdfcd['priceLow'],_0x4cdfcd[_0x7c8711(0x218)]-_0x57eb26*this['tickSize']);if(_0x45effa>_0x28d892-this['tickSize']*0x2){const _0x232040=_0x167864[_0x7c8711(0x274)]-_0x167864['low'],_0x58afbb=Math['abs'](_0x167864[_0x7c8711(0x228)]-_0x167864['open']),_0x2f322d=_0x232040>0x0?_0x58afbb/_0x232040:0x0;if(_0x2f322d>=_0x1032f8['minBodyRatio']){const _0x517977=this['_getVolumeRatio'](_0x48e185,_0x5aea88,0x14);if(_0x517977>=_0x1032f8['minVolumeRatio']){const _0x1ee2fa=new SweepEvent(SweepType['LOW_SWEEP'],_0x4cdfcd,_0x5aea88,_0x5aea88,_0x167864['low']);_0x1ee2fa['exitBarIndex']=_0x344941,_0x1ee2fa['penetrationTicks']=_0x57eb26,_0x1ee2fa[_0x7c8711(0x212)]=_0x344941-_0x5aea88,_0x1ee2fa[_0x7c8711(0x26d)]=_0x517977,_0x1ee2fa['qualityScore']=this['_scoreSweep'](_0x1ee2fa,_0x2f322d),_0x1ee2fa['isValid']=_0x1ee2fa['qualityScore']>=_0x1032f8[_0x7c8711(0x21a)];if(_0x1ee2fa[_0x7c8711(0x268)])return _0x1ee2fa;}}}}}}}return null;}[_0x36ddf1(0x242)](_0x2d006d,_0x361cbb,_0x22f879){const _0x20f00d=_0x36ddf1,_0x1f559a=Math[_0x20f00d(0x203)](0x0,_0x361cbb-_0x22f879),_0x2ddc6b=_0x2d006d[_0x20f00d(0x210)](_0x1f559a,_0x361cbb);if(_0x2ddc6b[_0x20f00d(0x241)]===0x0)return 0x1;const _0xdfe7da=_0x2ddc6b[_0x20f00d(0x1f6)](_0x1e5afa=>_0x1e5afa['volume'])[_0x20f00d(0x206)]((_0x422586,_0x48ff7f)=>_0x422586-_0x48ff7f),_0x4cfbe3=Math['floor'](_0xdfe7da[_0x20f00d(0x241)]/0x2),_0xc42bb9=_0xdfe7da[_0x4cfbe3]||0x1;return _0x2d006d[_0x361cbb][_0x20f00d(0x1eb)]/_0xc42bb9;}['_scoreSweep'](_0x1b1637,_0x571dde){const _0x28c084=_0x36ddf1;let _0x53f10c=0x0;const _0x2dd071=0x4,_0x2ff25b=Math['abs'](_0x1b1637['penetrationTicks']-_0x2dd071);return _0x53f10c+=Math['max'](0x0,0.3-_0x2ff25b*0.03),_0x53f10c+=Math['max'](0x0,0.25-_0x1b1637['durationBars']*0.05),_0x53f10c+=Math[_0x28c084(0x225)](0.25,_0x1b1637[_0x28c084(0x26d)]*0.1),_0x53f10c+=Math['min'](0.2,_0x571dde*0.4),Math[_0x28c084(0x225)](0x1,_0x53f10c);}[_0x36ddf1(0x23c)](_0x3d4107,_0x15c0b4,_0xf10647,_0x3d3948){const _0x51db38=_0x36ddf1,_0x306bc5=Date[_0x51db38(0x250)]()-this[_0x51db38(0x240)];if(_0x306bc5<this[_0x51db38(0x1ea)]['execution']['cooldownMs'])return this[_0x51db38(0x1f5)]('log',{'type':'debug','message':_0x51db38(0x245)+(_0x306bc5/0x3e8)[_0x51db38(0x273)](0x1)+'s\x20<\x20'+this[_0x51db38(0x1ea)]['execution']['cooldownMs']/0x3e8+'s)'}),null;const _0x18b075=this['config'][_0x51db38(0x1f3)],_0x37c8c2=_0x15c0b4[_0x51db38(0x228)],_0x18dd03=_0x3d3948['sweepType']===SweepType['HIGH_SWEEP']?'short':'long';let _0x2b23d9,_0x2252c8,_0x3d66f0,_0x38d382;_0x18dd03===_0x51db38(0x266)?(_0x2b23d9=_0x37c8c2-_0x18b075['stopTicks']*this['tickSize'],_0x2252c8=_0x37c8c2+_0x18b075['targetTicks']*this[_0x51db38(0x1ff)],_0x3d66f0=_0x37c8c2+_0x18b075[_0x51db38(0x267)]*this[_0x51db38(0x1ff)],_0x38d382=_0x37c8c2+_0x18b075['trailTriggerTicks']*this['tickSize']):(_0x2b23d9=_0x37c8c2+_0x18b075[_0x51db38(0x216)]*this[_0x51db38(0x1ff)],_0x2252c8=_0x37c8c2-_0x18b075[_0x51db38(0x23e)]*this['tickSize'],_0x3d66f0=_0x37c8c2-_0x18b075['breakevenTicks']*this['tickSize'],_0x38d382=_0x37c8c2-_0x18b075['trailTriggerTicks']*this['tickSize']);const _0x373efb=_0x18b075['targetTicks']/_0x18b075[_0x51db38(0x216)],_0x5d887b=Math['min'](0x1,_0x3d3948['qualityScore']*0.5+_0x3d3948[_0x51db38(0x272)]['qualityScore']*0.3+(_0x3d3948[_0x51db38(0x26d)]>1.5?0.2:_0x3d3948['volumeRatio']*0.1));let _0x3aafda=SignalStrength[_0x51db38(0x205)];if(_0x5d887b>=0.8)_0x3aafda=SignalStrength[_0x51db38(0x222)];else{if(_0x5d887b>=0.65)_0x3aafda=SignalStrength[_0x51db38(0x1e0)];else{if(_0x5d887b<0.5)_0x3aafda=SignalStrength[_0x51db38(0x217)];}}const _0x1d5804=0.5+(_0x5d887b-0.5)*0.4,_0x4efbca=_0x1d5804*Math['abs'](_0x2252c8-_0x37c8c2)-(0x1-_0x1d5804)*Math['abs'](_0x37c8c2-_0x2b23d9);_0x3d3948['zone'][_0x51db38(0x231)]=_0xf10647,_0x3d3948['zone']['swept']=!![],_0x3d3948[_0x51db38(0x272)]['sweptAt']=new Date(_0x15c0b4['timestamp']),this[_0x51db38(0x240)]=Date[_0x51db38(0x250)](),this[_0x51db38(0x20e)]['signals']++;const _0x2b2417={'id':uuidv4(),'timestamp':Date[_0x51db38(0x250)](),'symbol':_0x3d4107['split']('.')[0x0]||_0x3d4107,'contractId':_0x3d4107,'side':_0x18dd03===_0x51db38(0x266)?OrderSide['BID']:OrderSide['ASK'],'direction':_0x18dd03,'strategy':_0x51db38(0x275),'strength':_0x3aafda,'edge':_0x4efbca,'confidence':_0x5d887b,'entry':_0x37c8c2,'entryPrice':_0x37c8c2,'stopLoss':_0x2b23d9,'takeProfit':_0x2252c8,'riskReward':_0x373efb,'stopTicks':_0x18b075[_0x51db38(0x216)],'targetTicks':_0x18b075['targetTicks'],'breakevenTicks':_0x18b075[_0x51db38(0x267)],'trailTriggerTicks':_0x18b075['trailTriggerTicks'],'trailDistanceTicks':_0x18b075['trailDistanceTicks'],'beLevel':_0x3d66f0,'trailTrigger':_0x38d382,'sweepType':_0x3d3948['sweepType'],'penetrationTicks':_0x3d3948['penetrationTicks'],'sweepDurationBars':_0x3d3948[_0x51db38(0x212)],'sweepQuality':_0x3d3948['qualityScore'],'volumeRatio':_0x3d3948[_0x51db38(0x26d)],'zoneType':_0x3d3948[_0x51db38(0x272)]['type'],'zoneLevel':_0x3d3948[_0x51db38(0x272)]['getLevel'](),'zoneTouches':_0x3d3948['zone']['touches'],'zoneQuality':_0x3d3948[_0x51db38(0x272)][_0x51db38(0x23d)],'expires':Date[_0x51db38(0x250)]()+0xea60};return this[_0x51db38(0x1f5)](_0x51db38(0x23b),{'side':_0x18dd03==='long'?'buy':'sell','action':'open','reason':_0x51db38(0x254)+_0x3d3948[_0x51db38(0x234)]+_0x51db38(0x27b)+_0x3d3948['penetrationTicks'][_0x51db38(0x273)](0x1)+'t\x20|\x20Vol:'+_0x3d3948[_0x51db38(0x26d)][_0x51db38(0x273)](0x1)+_0x51db38(0x226)+(_0x3d3948[_0x51db38(0x23d)]*0x64)['toFixed'](0x0)+'%',..._0x2b2417}),this['emit']('log',{'type':'info','message':_0x51db38(0x271)+_0x18dd03['toUpperCase']()+_0x51db38(0x223)+_0x37c8c2[_0x51db38(0x273)](0x2)+_0x51db38(0x235)+_0x3d3948['sweepType']+_0x51db38(0x27b)+_0x3d3948[_0x51db38(0x201)]['toFixed'](0x1)+'t\x20Vol:'+_0x3d3948[_0x51db38(0x26d)][_0x51db38(0x273)](0x1)+_0x51db38(0x20c)+(_0x5d887b*0x64)[_0x51db38(0x273)](0x0)+'%'}),_0x2b2417;}['getAnalysisState'](_0x420729,_0x276313){const _0x1aae9c=_0x36ddf1,_0x5dc236=this[_0x1aae9c(0x260)]['get'](_0x420729)||[],_0x2989d8=this['liquidityZones']['get'](_0x420729)||[],_0x189868=this['swingPoints']['get'](_0x420729)||[];if(_0x5dc236['length']<0x5)return{'ready':![],'message':_0x1aae9c(0x20b)+_0x5dc236[_0x1aae9c(0x241)]+_0x1aae9c(0x253)};const _0x56d7cb=_0x2989d8['map'](_0x1ee02c=>({'zone':_0x1ee02c,'distance':Math['abs'](_0x276313-_0x1ee02c['getLevel']())}))['sort']((_0x46d4a9,_0x3b4c6e)=>_0x46d4a9['distance']-_0x3b4c6e[_0x1aae9c(0x26c)]),_0x43f4f3=_0x56d7cb[_0x1aae9c(0x20a)](_0x527ae9=>_0x527ae9[_0x1aae9c(0x272)][_0x1aae9c(0x22a)]===ZoneType[_0x1aae9c(0x244)]),_0x23124d=_0x56d7cb[_0x1aae9c(0x20a)](_0x19cecd=>_0x19cecd[_0x1aae9c(0x272)][_0x1aae9c(0x22a)]===ZoneType[_0x1aae9c(0x1e4)]);return{'ready':!![],'barsProcessed':_0x5dc236[_0x1aae9c(0x241)],'swingsDetected':_0x189868['length'],'activeZones':_0x2989d8[_0x1aae9c(0x241)],'nearestResistance':_0x43f4f3?_0x43f4f3[_0x1aae9c(0x272)]['getLevel']():null,'nearestSupport':_0x23124d?_0x23124d['zone'][_0x1aae9c(0x255)]():null,'stopTicks':this['config']['execution']['stopTicks'],'targetTicks':this['config']['execution']['targetTicks'],'strategy':'HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)'};}['recordTradeResult'](_0x4ed9d5){const _0x1a4eb4=_0x36ddf1;this['recentTrades'][_0x1a4eb4(0x1df)]({'netPnl':_0x4ed9d5,'timestamp':Date[_0x1a4eb4(0x250)]()});if(this['recentTrades'][_0x1a4eb4(0x241)]>0x64)this['recentTrades']['shift']();_0x4ed9d5>0x0?this[_0x1a4eb4(0x20e)]['wins']++:this[_0x1a4eb4(0x20e)][_0x1a4eb4(0x256)]++,this['stats']['trades']++,this[_0x1a4eb4(0x20e)][_0x1a4eb4(0x24c)]+=_0x4ed9d5,this[_0x1a4eb4(0x1f5)]('log',{'type':'debug','message':_0x1a4eb4(0x243)+(_0x4ed9d5>0x0?'WIN':_0x1a4eb4(0x1e2))+'\x20$'+_0x4ed9d5['toFixed'](0x2)});}['getBarHistory'](_0x513644){const _0x52eb9d=_0x36ddf1;return this[_0x52eb9d(0x260)][_0x52eb9d(0x1ec)](_0x513644)||[];}[_0x36ddf1(0x25c)](){return this['stats'];}[_0x36ddf1(0x20f)](_0x4f81ae){const _0x58b3ff=_0x36ddf1,_0xd5b309=this[_0x58b3ff(0x260)][_0x58b3ff(0x1ec)](_0x4f81ae)||[],_0x31b166=this['liquidityZones']['get'](_0x4f81ae)||[],_0x4b0f99=this['swingPoints']['get'](_0x4f81ae)||[],_0x1dec20=this[_0x58b3ff(0x227)][_0x58b3ff(0x1ec)](_0x4f81ae),_0x427ec4=_0xd5b309[_0xd5b309[_0x58b3ff(0x241)]-0x1],_0x4751fd=_0x427ec4?Date[_0x58b3ff(0x250)]()-_0x427ec4[_0x58b3ff(0x24a)]:null,_0x5a043d=_0x31b166[_0x58b3ff(0x221)](_0x470244=>_0x470244[_0x58b3ff(0x22a)]===ZoneType['RESISTANCE'])['length'],_0x4f8cea=_0x31b166[_0x58b3ff(0x221)](_0x7b171=>_0x7b171['type']===ZoneType[_0x58b3ff(0x1e4)])[_0x58b3ff(0x241)];return{'healthy':_0xd5b309['length']>=0x5,'barsTotal':_0xd5b309['length'],'barsLast5Min':_0xd5b309[_0x58b3ff(0x221)](_0x3778a0=>Date['now']()-_0x3778a0[_0x58b3ff(0x24a)]<0x5*0x3c*0x3e8)['length'],'swingsTotal':_0x4b0f99['length'],'zonesResistance':_0x5a043d,'zonesSupport':_0x4f8cea,'zonesTotal':_0x31b166[_0x58b3ff(0x241)],'currentBarTicks':_0x1dec20?_0x1dec20[_0x58b3ff(0x264)]:0x0,'isAggregating':_0x1dec20&&_0x1dec20['tickCount']>0x0,'timeSinceLastBarMs':_0x4751fd,'lastSignalTime':this[_0x58b3ff(0x240)],'signalCooldownMs':this['config']['execution'][_0x58b3ff(0x20d)],'uptime':Date['now']()-(this['startTime']||Date['now']())};}['reset'](_0x41f9dd){const _0x117fe9=_0x36ddf1;this[_0x117fe9(0x260)][_0x117fe9(0x259)](_0x41f9dd,[]),this['swingPoints']['set'](_0x41f9dd,[]),this['liquidityZones'][_0x117fe9(0x259)](_0x41f9dd,[]),this['activeSweeps']['set'](_0x41f9dd,[]),this[_0x117fe9(0x227)][_0x117fe9(0x22e)](_0x41f9dd),this[_0x117fe9(0x1f5)](_0x117fe9(0x22c),{'type':'info','message':_0x117fe9(0x1fc)+_0x41f9dd});}[_0x36ddf1(0x1f7)](_0x5cd986,_0x5ecb4e){const _0x5eb30b=_0x36ddf1;if(!_0x5ecb4e||_0x5ecb4e[_0x5eb30b(0x241)]===0x0){this[_0x5eb30b(0x1f5)](_0x5eb30b(0x22c),{'type':'debug','message':_0x5eb30b(0x215)});return;}!this[_0x5eb30b(0x260)][_0x5eb30b(0x22d)](_0x5cd986)&&this['initialize'](_0x5cd986);const _0x2f49df=[..._0x5ecb4e]['sort']((_0x3d791d,_0x88c9ea)=>_0x3d791d[_0x5eb30b(0x24a)]-_0x88c9ea[_0x5eb30b(0x24a)]);this[_0x5eb30b(0x1f5)]('log',{'type':_0x5eb30b(0x265),'message':'[HQX-2B]\x20Preloading\x20'+_0x2f49df['length']+'\x20historical\x20bars...'});let _0x14ee06=0x0;for(const _0x32107e of _0x2f49df){const _0x255aa5=this['processBar'](_0x5cd986,_0x32107e);if(_0x255aa5)_0x14ee06++;}const _0x2e26fd=this[_0x5eb30b(0x260)]['get'](_0x5cd986)||[],_0x4a2ec1=this[_0x5eb30b(0x251)][_0x5eb30b(0x1ec)](_0x5cd986)||[],_0x33c17c=this[_0x5eb30b(0x1f8)][_0x5eb30b(0x1ec)](_0x5cd986)||[];this[_0x5eb30b(0x1f5)](_0x5eb30b(0x22c),{'type':_0x5eb30b(0x265),'message':'[HQX-2B]\x20Preload\x20complete:\x20'+_0x2e26fd[_0x5eb30b(0x241)]+_0x5eb30b(0x257)+_0x4a2ec1['length']+'\x20swings,\x20'+_0x33c17c[_0x5eb30b(0x241)]+'\x20zones'}),_0x14ee06>0x0&&this['emit']('log',{'type':_0x5eb30b(0x220),'message':_0x5eb30b(0x25d)+_0x14ee06+_0x5eb30b(0x1ef)}),this[_0x5eb30b(0x240)]=0x0;}}class HQX2BStrategy extends EventEmitter{constructor(_0x97e940={}){const _0x1b5dc5=_0x36ddf1;super(),this[_0x1b5dc5(0x1ea)]=_0x97e940,this['strategy']=new HQX2BLiquiditySweep(_0x97e940),this[_0x1b5dc5(0x233)]['on']('signal',_0x1d8d38=>this[_0x1b5dc5(0x1f5)](_0x1b5dc5(0x23b),_0x1d8d38)),this['strategy']['on']('log',_0x12076c=>this[_0x1b5dc5(0x1f5)]('log',_0x12076c));}['processTick'](_0x508e60){const _0x28d934=_0x36ddf1;return this[_0x28d934(0x233)][_0x28d934(0x1fd)](_0x508e60);}[_0x36ddf1(0x22f)](_0x3ade14){const _0x950acd=_0x36ddf1;return this['strategy'][_0x950acd(0x22f)](_0x3ade14);}[_0x36ddf1(0x224)](_0x5c3cfb){const _0x471ed1=_0x36ddf1;return this[_0x471ed1(0x233)]['onTrade'](_0x5c3cfb);}[_0x36ddf1(0x25a)](_0x1d97ab,_0x23a447){const _0x5d85a5=_0x36ddf1;return this[_0x5d85a5(0x233)]['processBar'](_0x1d97ab,_0x23a447);}[_0x36ddf1(0x219)](_0x1a9ad6,_0x59d07b,_0x41d268){const _0x2eb6b4=_0x36ddf1;return this[_0x2eb6b4(0x233)][_0x2eb6b4(0x219)](_0x1a9ad6,_0x59d07b,_0x41d268);}['getAnalysisState'](_0x3a0dbb,_0x373dbb){const _0x30b2d5=_0x36ddf1;return this[_0x30b2d5(0x233)][_0x30b2d5(0x21b)](_0x3a0dbb,_0x373dbb);}['recordTradeResult'](_0x500053){const _0x37b72b=_0x36ddf1;return this['strategy'][_0x37b72b(0x26b)](_0x500053);}[_0x36ddf1(0x27a)](_0x54fb20){const _0x294bb6=_0x36ddf1;return this[_0x294bb6(0x233)][_0x294bb6(0x27a)](_0x54fb20);}['getStats'](){const _0x4f7afc=_0x36ddf1;return this['strategy'][_0x4f7afc(0x25c)]();}['getBarHistory'](_0x2cfd7d){return this['strategy']['getBarHistory'](_0x2cfd7d);}[_0x36ddf1(0x1f7)](_0x2f1a9a,_0x316a0b){return this['strategy']['preloadBars'](_0x2f1a9a,_0x316a0b);}['getHealthStatus'](_0x5441d6){const _0x1b6e7c=_0x36ddf1;return this[_0x1b6e7c(0x233)]['getHealthStatus'](_0x5441d6);}[_0x36ddf1(0x1e8)](_0x41baeb){return null;}}module['exports']={'HQX2BLiquiditySweep':HQX2BLiquiditySweep,'HQX2BStrategy':HQX2BStrategy,'M2':HQX2BStrategy,'S2':HQX2BLiquiditySweep,'OrderSide':OrderSide,'SignalStrength':SignalStrength,'SweepType':SweepType,'ZoneType':ZoneType,'DEFAULT_CONFIG':DEFAULT_CONFIG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x2f642f=_0xc24e;(function(_0x534985,_0x43b609){const _0x144ed8=_0xc24e,_0x4f2c1b=_0x534985();while(!![]){try{const _0x14585b=parseInt(_0x144ed8(0x1c1))/0x1+parseInt(_0x144ed8(0x209))/0x2*(parseInt(_0x144ed8(0x1d3))/0x3)+parseInt(_0x144ed8(0x1cd))/0x4+-parseInt(_0x144ed8(0x222))/0x5*(-parseInt(_0x144ed8(0x1c5))/0x6)+parseInt(_0x144ed8(0x1f9))/0x7*(parseInt(_0x144ed8(0x1fe))/0x8)+parseInt(_0x144ed8(0x20a))/0x9+-parseInt(_0x144ed8(0x1eb))/0xa*(parseInt(_0x144ed8(0x221))/0xb);if(_0x14585b===_0x43b609)break;else _0x4f2c1b['push'](_0x4f2c1b['shift']());}catch(_0x4967e7){_0x4f2c1b['push'](_0x4f2c1b['shift']());}}}(_0x48c6,0x5f6c4));const EventEmitter=require('events'),{v4:uuidv4}=require(_0x2f642f(0x1de)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};function _0xc24e(_0x283884,_0x5434b3){_0x283884=_0x283884-0x1c1;const _0x48c67c=_0x48c6();let _0xc24e09=_0x48c67c[_0x283884];return _0xc24e09;}class HQXUltraScalping extends EventEmitter{constructor(_0x2414d4={}){const _0x3f1b40=_0x2f642f;super(),this['tickSize']=_0x2414d4[_0x3f1b40(0x225)]||0.25,this['tickValue']=_0x2414d4[_0x3f1b40(0x1ec)]||0x5,this[_0x3f1b40(0x1f8)]=1.5,this[_0x3f1b40(0x1f0)]=0.5,this[_0x3f1b40(0x22b)]=0x32,this['vpinToxicThreshold']=0.7,this['kalmanProcessNoise']=0.01,this[_0x3f1b40(0x1ca)]=0.1,this[_0x3f1b40(0x214)]=0x64,this['ofiLookback']=0x14,this[_0x3f1b40(0x204)]=0x8,this['baseTargetTicks']=0x10,this[_0x3f1b40(0x207)]=0x4,this[_0x3f1b40(0x21b)]=0.5,this[_0x3f1b40(0x1d7)]=0.55,this[_0x3f1b40(0x1cf)]={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this['barHistory']=new Map(),this['priceBuffer']=new Map(),this[_0x3f1b40(0x228)]=new Map(),this[_0x3f1b40(0x1f5)]=new Map(),this[_0x3f1b40(0x1da)]=new Map(),this[_0x3f1b40(0x22c)]=[],this['winStreak']=0x0,this[_0x3f1b40(0x1c7)]=0x0,this['lastSignalTime']=0x0,this[_0x3f1b40(0x1d2)]=0x7530,this['minHoldTimeMs']=0x2710,this[_0x3f1b40(0x218)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}['initialize'](_0x399a09,_0x345ef3=0.25,_0x2b342b=0x5){const _0x22c560=_0x2f642f;this['tickSize']=_0x345ef3,this[_0x22c560(0x1ec)]=_0x2b342b,this['barHistory'][_0x22c560(0x1e4)](_0x399a09,[]),this['priceBuffer'][_0x22c560(0x1e4)](_0x399a09,[]),this['volumeBuffer']['set'](_0x399a09,[]),this[_0x22c560(0x1da)][_0x22c560(0x1e4)](_0x399a09,[]),this['kalmanStates'][_0x22c560(0x1e4)](_0x399a09,{'estimate':0x0,'errorCovariance':0x1}),this[_0x22c560(0x1e3)](_0x22c560(0x21c),{'type':_0x22c560(0x1fb),'message':'[HQX-UltraScalping]\x20Initialized\x20for\x20'+_0x399a09+_0x22c560(0x22f)+_0x345ef3+_0x22c560(0x227)+_0x2b342b}),this['emit']('log',{'type':_0x22c560(0x1fb),'message':'[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)'});}[_0x2f642f(0x1e7)](_0x75bef9){const _0x1da886=_0x2f642f,{contractId:_0x20709,price:_0x3c4554,volume:_0x59081c,side:_0x4553c2,timestamp:_0x329465}=_0x75bef9,_0x311f44={'timestamp':_0x329465||Date[_0x1da886(0x1d4)](),'open':_0x3c4554,'high':_0x3c4554,'low':_0x3c4554,'close':_0x3c4554,'volume':_0x59081c||0x1};return this[_0x1da886(0x1f7)](_0x20709,_0x311f44);}['onTick'](_0x2bb0ab){const _0x2f43a1=_0x2f642f;return this[_0x2f43a1(0x1e7)](_0x2bb0ab);}[_0x2f642f(0x1c3)](_0x409667){const _0x5b3a82=_0x2f642f;return this['processTick']({'contractId':_0x409667['contractId']||_0x409667['symbol'],'price':_0x409667['price'],'volume':_0x409667['size']||_0x409667[_0x5b3a82(0x20f)]||0x1,'side':_0x409667['side'],'timestamp':_0x409667['timestamp']||Date[_0x5b3a82(0x1d4)]()});}['processBar'](_0x26a6fa,_0x5b1f4c){const _0x4a78ef=_0x2f642f;let _0xf19f87=this[_0x4a78ef(0x1d6)]['get'](_0x26a6fa);!_0xf19f87&&(this['initialize'](_0x26a6fa),_0xf19f87=this[_0x4a78ef(0x1d6)][_0x4a78ef(0x21f)](_0x26a6fa));_0xf19f87[_0x4a78ef(0x202)](_0x5b1f4c);if(_0xf19f87['length']>0x1f4)_0xf19f87[_0x4a78ef(0x203)]();const _0x35caf7=this['priceBuffer'][_0x4a78ef(0x21f)](_0x26a6fa);_0x35caf7['push'](_0x5b1f4c[_0x4a78ef(0x1e0)]);if(_0x35caf7[_0x4a78ef(0x219)]>0xc8)_0x35caf7[_0x4a78ef(0x203)]();const _0x561b2f=this[_0x4a78ef(0x228)]['get'](_0x26a6fa),_0x572621=_0x5b1f4c[_0x4a78ef(0x210)]-_0x5b1f4c['low'];let _0x541019=_0x5b1f4c['volume']*0.5,_0x548299=_0x5b1f4c['volume']*0.5;if(_0x572621>0x0){const _0x34f7a3=(_0x5b1f4c['close']-_0x5b1f4c[_0x4a78ef(0x1cb)])/_0x572621;_0x541019=_0x5b1f4c[_0x4a78ef(0x20f)]*_0x34f7a3,_0x548299=_0x5b1f4c[_0x4a78ef(0x20f)]*(0x1-_0x34f7a3);}_0x561b2f['push']({'buy':_0x541019,'sell':_0x548299});if(_0x561b2f['length']>0x64)_0x561b2f['shift']();if(_0xf19f87[_0x4a78ef(0x219)]<0x32)return null;const _0x31da01=this['_computeZScore'](_0x35caf7),_0x56ba55=this[_0x4a78ef(0x1ce)](_0x561b2f),_0x2673a5=this['_computeKyleLambda'](_0xf19f87),_0x16f9fd=this['_applyKalmanFilter'](_0x26a6fa,_0x5b1f4c[_0x4a78ef(0x1e0)]),{regime:_0x412535,params:_0x116ada}=this['_detectVolatilityRegime'](_0x26a6fa,_0xf19f87),_0x4bf2f5=this[_0x4a78ef(0x1ee)](_0xf19f87);return this['_generateSignal'](_0x26a6fa,_0x5b1f4c[_0x4a78ef(0x1e0)],_0x31da01,_0x56ba55,_0x2673a5,_0x16f9fd,_0x412535,_0x116ada,_0x4bf2f5,_0xf19f87);}['_computeZScore'](_0x1161cd,_0x164df5=0x32){const _0x29e0cd=_0x2f642f;if(_0x1161cd[_0x29e0cd(0x219)]<_0x164df5)return 0x0;const _0xca41d6=_0x1161cd[_0x29e0cd(0x201)](-_0x164df5),_0x3d6b74=_0xca41d6[_0x29e0cd(0x21a)]((_0x438fb5,_0x5d2b28)=>_0x438fb5+_0x5d2b28,0x0)/_0x164df5,_0x3f2d03=_0xca41d6['reduce']((_0x31e357,_0xa39a04)=>_0x31e357+Math['pow'](_0xa39a04-_0x3d6b74,0x2),0x0)/_0x164df5,_0x56c7a2=Math['sqrt'](_0x3f2d03);if(_0x56c7a2<0.0001)return 0x0;const _0x101e32=_0x1161cd[_0x1161cd['length']-0x1];return(_0x101e32-_0x3d6b74)/_0x56c7a2;}[_0x2f642f(0x1ce)](_0x396c66){const _0x47d144=_0x2f642f;if(_0x396c66[_0x47d144(0x219)]<this['vpinWindow'])return 0.5;const _0x3437ba=_0x396c66['slice'](-this[_0x47d144(0x22b)]);let _0x2c7542=0x0,_0x5c01ab=0x0;for(const _0x448869 of _0x3437ba){_0x2c7542+=_0x448869['buy'],_0x5c01ab+=_0x448869[_0x47d144(0x200)];}const _0x430093=_0x2c7542+_0x5c01ab;if(_0x430093<0x1)return 0.5;return Math['abs'](_0x2c7542-_0x5c01ab)/_0x430093;}[_0x2f642f(0x20c)](_0x2ecd65){const _0x24d324=_0x2f642f;if(_0x2ecd65[_0x24d324(0x219)]<0x14)return 0x0;const _0x158b71=_0x2ecd65['slice'](-0x14),_0x25477e=[],_0xbe90ab=[];for(let _0x48142a=0x1;_0x48142a<_0x158b71['length'];_0x48142a++){_0x25477e[_0x24d324(0x202)](_0x158b71[_0x48142a][_0x24d324(0x1e0)]-_0x158b71[_0x48142a-0x1]['close']),_0xbe90ab[_0x24d324(0x202)](_0x158b71[_0x48142a]['volume']);}const _0x56e280=_0x25477e[_0x24d324(0x21a)]((_0x35b610,_0x11c18c)=>_0x35b610+_0x11c18c,0x0)/_0x25477e['length'],_0x294f35=_0xbe90ab['reduce']((_0x7fc270,_0x4ee76a)=>_0x7fc270+_0x4ee76a,0x0)/_0xbe90ab[_0x24d324(0x219)];let _0x5675fd=0x0,_0x302fd0=0x0;for(let _0x485f43=0x0;_0x485f43<_0x25477e[_0x24d324(0x219)];_0x485f43++){_0x5675fd+=(_0x25477e[_0x485f43]-_0x56e280)*(_0xbe90ab[_0x485f43]-_0x294f35),_0x302fd0+=Math['pow'](_0xbe90ab[_0x485f43]-_0x294f35,0x2);}_0x5675fd/=_0x25477e['length'],_0x302fd0/=_0x25477e[_0x24d324(0x219)];if(_0x302fd0<0.0001)return 0x0;return Math[_0x24d324(0x1e8)](_0x5675fd/_0x302fd0);}[_0x2f642f(0x1c4)](_0x30a1f0,_0x5665d3){const _0x1639e6=_0x2f642f;let _0x2ad690=this[_0x1639e6(0x1f5)]['get'](_0x30a1f0);if(!_0x2ad690)return _0x2ad690={'estimate':_0x5665d3,'errorCovariance':0x1},this[_0x1639e6(0x1f5)][_0x1639e6(0x1e4)](_0x30a1f0,_0x2ad690),_0x5665d3;const _0x1592b8=_0x2ad690[_0x1639e6(0x224)],_0x5d2221=_0x2ad690[_0x1639e6(0x1d9)]+this['kalmanProcessNoise'],_0x242476=_0x5d2221/(_0x5d2221+this['kalmanMeasurementNoise']),_0x206629=_0x1592b8+_0x242476*(_0x5665d3-_0x1592b8),_0x9d4e0d=(0x1-_0x242476)*_0x5d2221;return _0x2ad690['estimate']=_0x206629,_0x2ad690['errorCovariance']=_0x9d4e0d,_0x206629;}[_0x2f642f(0x1fc)](_0x114c0f,_0x36e0ae){const _0x42027e=_0x2f642f,_0x270f51=this['_calculateATR'](_0x36e0ae),_0x1bcad5=_0x270f51/this['tickSize'];let _0x327f56=this[_0x42027e(0x1da)][_0x42027e(0x21f)](_0x114c0f);!_0x327f56&&(_0x327f56=[],this['atrHistory']['set'](_0x114c0f,_0x327f56));_0x327f56['push'](_0x270f51);if(_0x327f56[_0x42027e(0x219)]>0x1f4)_0x327f56[_0x42027e(0x203)]();let _0x49426c=0.5;_0x327f56[_0x42027e(0x219)]>=0x14&&(_0x49426c=_0x327f56['filter'](_0x280a36=>_0x280a36<=_0x270f51)['length']/_0x327f56[_0x42027e(0x219)]);let _0x4f0473,_0x49115d;if(_0x49426c<0.25)_0x4f0473='low',_0x49115d={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x49426c<0.75?(_0x4f0473=_0x42027e(0x1fd),_0x49115d={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x4f0473=_0x42027e(0x210),_0x49115d={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x4f0473,'params':_0x49115d};}['_calculateATR'](_0x28314f,_0x3fc9b2=0xe){const _0x47e4f8=_0x2f642f;if(_0x28314f['length']<_0x3fc9b2+0x1)return 2.5;const _0x1252a8=[];for(let _0x1ec026=_0x28314f[_0x47e4f8(0x219)]-_0x3fc9b2;_0x1ec026<_0x28314f['length'];_0x1ec026++){const _0x2e3a81=_0x28314f[_0x1ec026],_0xc80a30=_0x28314f[_0x1ec026-0x1][_0x47e4f8(0x1e0)],_0x8e586d=Math['max'](_0x2e3a81['high']-_0x2e3a81['low'],Math[_0x47e4f8(0x1e8)](_0x2e3a81[_0x47e4f8(0x210)]-_0xc80a30),Math[_0x47e4f8(0x1e8)](_0x2e3a81['low']-_0xc80a30));_0x1252a8['push'](_0x8e586d);}return _0x1252a8['reduce']((_0x52e839,_0x2313d0)=>_0x52e839+_0x2313d0,0x0)/_0x1252a8['length'];}[_0x2f642f(0x1ee)](_0x52aaaa){const _0x12b781=_0x2f642f;if(_0x52aaaa['length']<this[_0x12b781(0x1fa)])return 0x0;const _0x58a42e=_0x52aaaa['slice'](-this['ofiLookback']);let _0x5e22c9=0x0,_0x3e4a54=0x0;for(const _0x3604d4 of _0x58a42e){const _0x564bb5=_0x3604d4['high']-_0x3604d4['low'];if(_0x564bb5>0x0){const _0x2252e8=(_0x3604d4[_0x12b781(0x1e0)]-_0x3604d4[_0x12b781(0x1cb)])/_0x564bb5;_0x5e22c9+=_0x2252e8*_0x3604d4['volume'],_0x3e4a54+=(0x1-_0x2252e8)*_0x3604d4['volume'];}}const _0x1a545c=_0x5e22c9+_0x3e4a54;if(_0x1a545c<0x1)return 0x0;return(_0x5e22c9-_0x3e4a54)/_0x1a545c;}[_0x2f642f(0x1e6)](_0x572768,_0x33d398,_0x5732c7,_0x285202,_0x1efeb9,_0x28e662,_0x37fb21,_0x3733a1,_0x58ba42,_0x240380){const _0x59ebe3=_0x2f642f,_0x95c4f8=Math[_0x59ebe3(0x1e8)](_0x5732c7);if(_0x95c4f8<_0x3733a1['zscoreThreshold'])return null;if(_0x285202>this['vpinToxicThreshold'])return null;let _0x270e0c;if(_0x5732c7<-_0x3733a1[_0x59ebe3(0x1d8)])_0x270e0c=_0x59ebe3(0x21d);else{if(_0x5732c7>_0x3733a1[_0x59ebe3(0x1d8)])_0x270e0c=_0x59ebe3(0x223);else return null;}const _0x1d3ef6=_0x270e0c==='long'&&_0x58ba42>0.1||_0x270e0c===_0x59ebe3(0x223)&&_0x58ba42<-0.1,_0x1fb89e=_0x33d398-_0x28e662,_0x3bf8d6=_0x270e0c===_0x59ebe3(0x21d)&&_0x1fb89e<0x0||_0x270e0c==='short'&&_0x1fb89e>0x0,_0x3c3886={'zscore':Math['min'](0x1,_0x95c4f8/0x4),'vpin':0x1-_0x285202,'kyleLambda':_0x1efeb9>0.001?0.5:0.8,'kalman':_0x3bf8d6?0.8:0.4,'volatility':_0x37fb21===_0x59ebe3(0x1fd)?0.8:_0x37fb21==='low'?0.7:0.6,'ofi':_0x1d3ef6?0.9:0.5,'composite':0x0};_0x3c3886[_0x59ebe3(0x1d0)]=_0x3c3886[_0x59ebe3(0x1cc)]*this[_0x59ebe3(0x1cf)]['zscore']+_0x3c3886['vpin']*this['weights']['vpin']+_0x3c3886[_0x59ebe3(0x20e)]*this['weights']['kyleLambda']+_0x3c3886['kalman']*this['weights']['kalman']+_0x3c3886[_0x59ebe3(0x1d1)]*this[_0x59ebe3(0x1cf)][_0x59ebe3(0x1d1)]+_0x3c3886['ofi']*this[_0x59ebe3(0x1cf)][_0x59ebe3(0x216)];const _0x3f8db7=Math['min'](0x1,_0x3c3886['composite']+_0x3733a1[_0x59ebe3(0x213)]);if(_0x3f8db7<this['minConfidence'])return null;if(Date['now']()-this['lastSignalTime']<this['cooldownMs'])return null;const _0x5bc68e=Math['round'](this['baseStopTicks']*_0x3733a1['stopMultiplier']),_0x768062=Math[_0x59ebe3(0x20b)](this[_0x59ebe3(0x22e)]*_0x3733a1['targetMultiplier']),_0x31307c=Math['max'](0x6,Math['min'](0xc,_0x5bc68e)),_0x206f74=Math['max'](_0x31307c*1.5,Math['min'](0x18,_0x768062));let _0x15c472,_0x11d4bb,_0x118339,_0x7e3ca2;_0x270e0c===_0x59ebe3(0x21d)?(_0x15c472=_0x33d398-_0x31307c*this['tickSize'],_0x11d4bb=_0x33d398+_0x206f74*this[_0x59ebe3(0x225)],_0x118339=_0x33d398+this['breakevenTicks']*this[_0x59ebe3(0x225)],_0x7e3ca2=_0x33d398+_0x206f74*this[_0x59ebe3(0x21b)]*this[_0x59ebe3(0x225)]):(_0x15c472=_0x33d398+_0x31307c*this['tickSize'],_0x11d4bb=_0x33d398-_0x206f74*this['tickSize'],_0x118339=_0x33d398-this['breakevenTicks']*this[_0x59ebe3(0x225)],_0x7e3ca2=_0x33d398-_0x206f74*this['profitLockPct']*this['tickSize']);const _0x52be1d=_0x206f74/_0x31307c,_0x72d77b=Math[_0x59ebe3(0x20b)](_0x206f74*0.5),_0x285a79=Math['round'](_0x31307c*0.4);let _0x28ac1c=SignalStrength[_0x59ebe3(0x208)];if(_0x3f8db7>=0.85)_0x28ac1c=SignalStrength['VERY_STRONG'];else{if(_0x3f8db7>=0.75)_0x28ac1c=SignalStrength['STRONG'];else{if(_0x3f8db7<0.6)_0x28ac1c=SignalStrength['WEAK'];}}const _0x2fd433=0.5+(_0x3f8db7-0.5)*0.4,_0x5483cb=_0x2fd433*Math['abs'](_0x11d4bb-_0x33d398)-(0x1-_0x2fd433)*Math[_0x59ebe3(0x1e8)](_0x33d398-_0x15c472);this[_0x59ebe3(0x1d5)]=Date[_0x59ebe3(0x1d4)](),this[_0x59ebe3(0x218)][_0x59ebe3(0x1f4)]++;const _0x4c8b68={'id':uuidv4(),'timestamp':Date[_0x59ebe3(0x1d4)](),'symbol':_0x572768['split']('.')[0x0]||_0x572768,'contractId':_0x572768,'side':_0x270e0c===_0x59ebe3(0x21d)?OrderSide[_0x59ebe3(0x1e2)]:OrderSide[_0x59ebe3(0x1c2)],'direction':_0x270e0c,'strategy':_0x59ebe3(0x1f2),'strength':_0x28ac1c,'edge':_0x5483cb,'confidence':_0x3f8db7,'entry':_0x33d398,'entryPrice':_0x33d398,'stopLoss':_0x15c472,'takeProfit':_0x11d4bb,'riskReward':_0x52be1d,'stopTicks':_0x31307c,'targetTicks':_0x206f74,'trailTriggerTicks':_0x72d77b,'trailDistanceTicks':_0x285a79,'beBreakeven':_0x118339,'profitLockLevel':_0x7e3ca2,'zScore':_0x5732c7,'zScoreExit':this['zscoreExitThreshold'],'vpinValue':_0x285202,'kyleLambda':_0x1efeb9,'kalmanEstimate':_0x28e662,'volatilityRegime':_0x37fb21,'ofiValue':_0x58ba42,'models':_0x3c3886,'orderFlowConfirmed':_0x1d3ef6,'kalmanConfirmed':_0x3bf8d6,'expires':Date['now']()+0xea60};return this[_0x59ebe3(0x1e3)](_0x59ebe3(0x229),{'side':_0x270e0c===_0x59ebe3(0x21d)?_0x59ebe3(0x217):'sell','action':_0x59ebe3(0x220),'reason':'Z='+_0x5732c7['toFixed'](0x2)+_0x59ebe3(0x1e5)+(_0x285202*0x64)['toFixed'](0x0)+'%,\x20OFI='+(_0x58ba42*0x64)[_0x59ebe3(0x1f6)](0x0)+_0x59ebe3(0x215)+(_0x3f8db7*0x64)['toFixed'](0x0)+'%',..._0x4c8b68}),this['emit']('log',{'type':_0x59ebe3(0x1fb),'message':'[HQX]\x20SIGNAL:\x20'+_0x270e0c['toUpperCase']()+'\x20@\x20'+_0x33d398[_0x59ebe3(0x1f6)](0x2)+'\x20|\x20Z:'+_0x5732c7['toFixed'](0x2)+'\x20VPIN:'+(_0x285202*0x64)[_0x59ebe3(0x1f6)](0x0)+_0x59ebe3(0x1ff)+(_0x58ba42*0x64)[_0x59ebe3(0x1f6)](0x0)+_0x59ebe3(0x21e)+_0x1efeb9['toFixed'](0x5)+'\x20Regime:'+_0x37fb21+_0x59ebe3(0x1df)+(_0x3f8db7*0x64)[_0x59ebe3(0x1f6)](0x0)+'%'}),_0x4c8b68;}['shouldExitByZScore'](_0x35553e){const _0x3100b2=_0x2f642f,_0x4d18f6=this[_0x3100b2(0x1dc)][_0x3100b2(0x21f)](_0x35553e);if(!_0x4d18f6||_0x4d18f6['length']<0x32)return![];const _0x25f249=this[_0x3100b2(0x22a)](_0x4d18f6);return Math['abs'](_0x25f249)<this[_0x3100b2(0x1f0)];}[_0x2f642f(0x226)](_0x20f79c){const _0x3967e1=_0x2f642f,_0x453533=this[_0x3967e1(0x1dc)]['get'](_0x20f79c),_0x43daf0=this['volumeBuffer']['get'](_0x20f79c),_0x1e60be=this[_0x3967e1(0x1d6)]['get'](_0x20f79c);if(!_0x453533||!_0x43daf0||!_0x1e60be||_0x1e60be['length']<0x32)return null;const _0x1a1dc9=this['_computeZScore'](_0x453533),_0x14c4da=this[_0x3967e1(0x1ce)](_0x43daf0),_0x39dceb=this[_0x3967e1(0x20c)](_0x1e60be),_0x4a2092=this['_computeOrderFlowImbalance'](_0x1e60be);return{'zscore':Math[_0x3967e1(0x1f3)](0x1,Math['abs'](_0x1a1dc9)/0x4),'vpin':0x1-_0x14c4da,'kyleLambda':_0x39dceb>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math[_0x3967e1(0x1e8)](_0x4a2092)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x1a1dc9,'vpin':_0x14c4da,'kyleLambda':_0x39dceb,'ofi':_0x4a2092}};}[_0x2f642f(0x1ef)](_0x15937a,_0x56b1e5){const _0x4e2ee8=_0x2f642f,_0x139953=this['barHistory']['get'](_0x15937a)||[];if(_0x139953[_0x4e2ee8(0x219)]<0x32)return{'ready':![],'message':_0x4e2ee8(0x206)+_0x139953[_0x4e2ee8(0x219)]+'/50\x20bars'};const _0x119888=this['priceBuffer'][_0x4e2ee8(0x21f)](_0x15937a)||[],_0x57c1cf=this[_0x4e2ee8(0x228)]['get'](_0x15937a)||[],_0x19f0b4=this[_0x4e2ee8(0x22a)](_0x119888),_0x921872=this[_0x4e2ee8(0x1ce)](_0x57c1cf),_0x5def40=this['_computeOrderFlowImbalance'](_0x139953),_0xc85c2b=this[_0x4e2ee8(0x20c)](_0x139953),{regime:_0x16c6d5,params:_0x1a43c5}=this['_detectVolatilityRegime'](_0x15937a,_0x139953);return{'ready':!![],'zScore':_0x19f0b4,'vpin':_0x921872,'ofi':_0x5def40,'kyleLambda':_0xc85c2b,'regime':_0x16c6d5,'stopTicks':Math['round'](this['baseStopTicks']*_0x1a43c5['stopMultiplier']),'targetTicks':Math['round'](this['baseTargetTicks']*_0x1a43c5[_0x4e2ee8(0x205)]),'threshold':_0x1a43c5['zscoreThreshold'],'barsProcessed':_0x139953['length'],'models':'6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)'};}[_0x2f642f(0x1db)](_0x34f4ee){const _0x27c887=_0x2f642f;this[_0x27c887(0x22c)][_0x27c887(0x202)]({'netPnl':_0x34f4ee,'timestamp':Date[_0x27c887(0x1d4)]()});if(this['recentTrades'][_0x27c887(0x219)]>0x64)this['recentTrades'][_0x27c887(0x203)]();_0x34f4ee>0x0?(this['winStreak']++,this[_0x27c887(0x1c7)]=0x0,this['stats']['wins']++):(this[_0x27c887(0x1c7)]++,this['winStreak']=0x0,this[_0x27c887(0x218)][_0x27c887(0x22d)]++),this['stats'][_0x27c887(0x20d)]++,this['stats'][_0x27c887(0x1f1)]+=_0x34f4ee,this['emit'](_0x27c887(0x21c),{'type':'debug','message':_0x27c887(0x1c8)+(_0x34f4ee>0x0?'WIN':_0x27c887(0x1ea))+'\x20$'+_0x34f4ee[_0x27c887(0x1f6)](0x2)+_0x27c887(0x1c9)+(_0x34f4ee>0x0?this['winStreak']:-this['lossStreak'])});}['getBarHistory'](_0x93968b){const _0x132087=_0x2f642f;return this['barHistory'][_0x132087(0x21f)](_0x93968b)||[];}[_0x2f642f(0x1ed)](){return this['stats'];}[_0x2f642f(0x1dd)](_0x5bcc92){const _0x58220e=_0x2f642f;this['barHistory'][_0x58220e(0x1e4)](_0x5bcc92,[]),this['priceBuffer']['set'](_0x5bcc92,[]),this['volumeBuffer']['set'](_0x5bcc92,[]),this[_0x58220e(0x1da)][_0x58220e(0x1e4)](_0x5bcc92,[]),this['kalmanStates']['set'](_0x5bcc92,{'estimate':0x0,'errorCovariance':0x1}),this[_0x58220e(0x1e3)]('log',{'type':'info','message':'[HQX-UltraScalping]\x20Reset\x20state\x20for\x20'+_0x5bcc92});}}class UltraScalpingStrategy extends EventEmitter{constructor(_0x1c68b9={}){const _0x27786d=_0x2f642f;super(),this['config']=_0x1c68b9,this[_0x27786d(0x211)]=new HQXUltraScalping(_0x1c68b9),this['strategy']['on'](_0x27786d(0x229),_0x26640d=>this['emit'](_0x27786d(0x229),_0x26640d)),this['strategy']['on']('log',_0x24647b=>this['emit']('log',_0x24647b));}[_0x2f642f(0x1e7)](_0x43265a){const _0x1c2d27=_0x2f642f;return this[_0x1c2d27(0x211)][_0x1c2d27(0x1e7)](_0x43265a);}['onTick'](_0x3d1505){return this['strategy']['onTick'](_0x3d1505);}['onTrade'](_0x4b9f05){const _0x62a743=_0x2f642f;return this[_0x62a743(0x211)][_0x62a743(0x1c3)](_0x4b9f05);}['processBar'](_0xfb06fb,_0x5935b6){return this['strategy']['processBar'](_0xfb06fb,_0x5935b6);}['initialize'](_0x38e2e1,_0x4aea8e,_0x3d4b0f){const _0x1997da=_0x2f642f;return this['strategy'][_0x1997da(0x212)](_0x38e2e1,_0x4aea8e,_0x3d4b0f);}[_0x2f642f(0x1ef)](_0x366f26,_0x32c33d){const _0x5074bc=_0x2f642f;return this[_0x5074bc(0x211)][_0x5074bc(0x1ef)](_0x366f26,_0x32c33d);}['recordTradeResult'](_0x1c8b45){const _0x49a1ad=_0x2f642f;return this[_0x49a1ad(0x211)]['recordTradeResult'](_0x1c8b45);}[_0x2f642f(0x1dd)](_0x5b64d8){const _0x250714=_0x2f642f;return this['strategy'][_0x250714(0x1dd)](_0x5b64d8);}['getStats'](){const _0x31780e=_0x2f642f;return this[_0x31780e(0x211)][_0x31780e(0x1ed)]();}['getBarHistory'](_0x48fbb3){const _0x40b812=_0x2f642f;return this[_0x40b812(0x211)][_0x40b812(0x1c6)](_0x48fbb3);}[_0x2f642f(0x226)](_0x3120e1){const _0x1c5a1e=_0x2f642f;return this['strategy'][_0x1c5a1e(0x226)](_0x3120e1);}['shouldExitByZScore'](_0x572f72){const _0x4a0aa1=_0x2f642f;return this['strategy'][_0x4a0aa1(0x1e1)](_0x572f72);}[_0x2f642f(0x1e9)](_0x1df7f7){return null;}}module['exports']={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};function _0x48c6(){const _0x147040=['reset','uuid','\x20|\x20Conf:','close','shouldExitByZScore','BID','emit','set',',\x20VPIN=','_generateSignal','processTick','abs','generateSignal','LOSS','10eDFdqK','tickValue','getStats','_computeOrderFlowImbalance','getAnalysisState','zscoreExitThreshold','pnl','HQX_ULTRA_SCALPING_6MODELS','min','signals','kalmanStates','toFixed','processBar','zscoreEntryThreshold','42OUKcWP','ofiLookback','info','_detectVolatilityRegime','normal','756384ICUZpV','%\x20OFI:','sell','slice','push','shift','baseStopTicks','targetMultiplier','Collecting\x20data...\x20','breakevenTicks','MODERATE','2JHluhv','1314171KXLtHF','round','_computeKyleLambda','trades','kyleLambda','volume','high','strategy','initialize','confidenceBonus','volatilityLookback','%,\x20cf=','ofi','buy','stats','length','reduce','profitLockPct','log','long','%\x20Kyle:','get','open','14929277lhfYna','1563010cOsStZ','short','estimate','tickSize','getModelValues',',\x20value=','volumeBuffer','signal','_computeZScore','vpinWindow','recentTrades','losses','baseTargetTicks',':\x20tick=','430726yXGdiw','ASK','onTrade','_applyKalmanFilter','6icBfld','getBarHistory','lossStreak','[HQX]\x20Trade\x20result:\x20',',\x20streak:\x20','kalmanMeasurementNoise','low','zscore','749528SyvYql','_computeVPIN','weights','composite','volatility','cooldownMs','312126MTruvf','now','lastSignalTime','barHistory','minConfidence','zscoreThreshold','errorCovariance','atrHistory','recordTradeResult','priceBuffer'];_0x48c6=function(){return _0x147040;};return _0x48c6();}
|
|
1
|
+
function _0x3345(_0x56629d,_0x322f3d){_0x56629d=_0x56629d-0x66;const _0x174987=_0x1749();let _0x33452d=_0x174987[_0x56629d];return _0x33452d;}function _0x1749(){const _0x1a5cc1=['stats','filter','low','kalman','getAnalysisState','round','getBarHistory','zscoreThreshold','getStats','/50\x20bars','breakevenTicks','long','3754849HJrzQG','signal','symbol','_computeKyleLambda','recordTradeResult','exports','2283596BrBbVD','get','recentTrades','8IvRMqH','_computeZScore','onTrade','4900508ddAIRv','baseTargetTicks','tickSize','info','VERY_STRONG','\x20|\x20Z:','timestamp',',\x20value=','processTick','shift','slice','confidenceBonus','volumeBuffer','vpin','tickValue','push','_detectVolatilityRegime','22597452BnaAGL','close','volatility','set','HQX_ULTRA_SCALPING_6MODELS','shouldExitByZScore','volume','LOSS','generateSignal','ofi','errorCovariance','186557gzHayF','max','reset','vpinWindow','minConfidence','WIN','price','composite','log','abs','_computeVPIN','\x20@\x20','kalmanMeasurementNoise','buy','kalmanProcessNoise','5IljWaD','strategy','atrHistory','pow','minHoldTimeMs','side','length','barHistory','pnl','lossStreak','reduce','%,\x20OFI=','estimate','kalmanStates','7764024allXzL','weights','high','zscoreExitThreshold','priceBuffer','STRONG','open','37374tZlrfZ','uuid','processBar','_generateSignal','zscore','[HQX]\x20SIGNAL:\x20','toFixed','cooldownMs','normal','min','onTick','now','signals','emit','toUpperCase','winStreak','initialize','[HQX-UltraScalping]\x20Reset\x20state\x20for\x20','profitLockPct'];_0x1749=function(){return _0x1a5cc1;};return _0x1749();}const _0x4ef43a=_0x3345;(function(_0x4dc972,_0xabcca7){const _0x4a3fc9=_0x3345,_0x48b6f6=_0x4dc972();while(!![]){try{const _0x451fe6=parseInt(_0x4a3fc9(0x97))/0x1+parseInt(_0x4a3fc9(0x75))/0x2+-parseInt(_0x4a3fc9(0xbb))/0x3+parseInt(_0x4a3fc9(0x7b))/0x4*(parseInt(_0x4a3fc9(0xa6))/0x5)+parseInt(_0x4a3fc9(0xb4))/0x6+-parseInt(_0x4a3fc9(0x6f))/0x7+parseInt(_0x4a3fc9(0x78))/0x8*(-parseInt(_0x4a3fc9(0x8c))/0x9);if(_0x451fe6===_0xabcca7)break;else _0x48b6f6['push'](_0x48b6f6['shift']());}catch(_0x5a2b14){_0x48b6f6['push'](_0x48b6f6['shift']());}}}(_0x1749,0xc0551));const EventEmitter=require('events'),{v4:uuidv4}=require(_0x4ef43a(0xbc)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};class HQXUltraScalping extends EventEmitter{constructor(_0x4ad112={}){const _0x284b93=_0x4ef43a;super(),this[_0x284b93(0x7d)]=_0x4ad112['tickSize']||0.25,this[_0x284b93(0x89)]=_0x4ad112[_0x284b93(0x89)]||0x5,this['zscoreEntryThreshold']=1.5,this[_0x284b93(0xb7)]=0.5,this['vpinWindow']=0x32,this['vpinToxicThreshold']=0.7,this[_0x284b93(0xa5)]=0.01,this[_0x284b93(0xa3)]=0.1,this['volatilityLookback']=0x64,this['ofiLookback']=0x14,this['baseStopTicks']=0x8,this['baseTargetTicks']=0x10,this['breakevenTicks']=0x4,this[_0x284b93(0xcd)]=0.5,this[_0x284b93(0x9b)]=0.55,this['weights']={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this[_0x284b93(0xad)]=new Map(),this[_0x284b93(0xb8)]=new Map(),this['volumeBuffer']=new Map(),this['kalmanStates']=new Map(),this[_0x284b93(0xa8)]=new Map(),this['recentTrades']=[],this[_0x284b93(0xca)]=0x0,this['lossStreak']=0x0,this['lastSignalTime']=0x0,this[_0x284b93(0xc2)]=0x7530,this[_0x284b93(0xaa)]=0x2710,this['stats']={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}['initialize'](_0x53ddf5,_0x92cc51=0.25,_0x527d53=0x5){const _0x38d11e=_0x4ef43a;this[_0x38d11e(0x7d)]=_0x92cc51,this['tickValue']=_0x527d53,this[_0x38d11e(0xad)]['set'](_0x53ddf5,[]),this['priceBuffer']['set'](_0x53ddf5,[]),this['volumeBuffer']['set'](_0x53ddf5,[]),this[_0x38d11e(0xa8)][_0x38d11e(0x8f)](_0x53ddf5,[]),this['kalmanStates']['set'](_0x53ddf5,{'estimate':0x0,'errorCovariance':0x1}),this[_0x38d11e(0xc8)](_0x38d11e(0x9f),{'type':_0x38d11e(0x7e),'message':'[HQX-UltraScalping]\x20Initialized\x20for\x20'+_0x53ddf5+':\x20tick='+_0x92cc51+_0x38d11e(0x82)+_0x527d53}),this['emit'](_0x38d11e(0x9f),{'type':_0x38d11e(0x7e),'message':'[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)'});}[_0x4ef43a(0x83)](_0x56ae0a){const _0x2c5c98=_0x4ef43a,{contractId:_0x4eb987,price:_0x2048f5,volume:_0x4b4e07,side:_0x1f44d4,timestamp:_0x4dc3b8}=_0x56ae0a,_0x4a137b={'timestamp':_0x4dc3b8||Date[_0x2c5c98(0xc6)](),'open':_0x2048f5,'high':_0x2048f5,'low':_0x2048f5,'close':_0x2048f5,'volume':_0x4b4e07||0x1};return this['processBar'](_0x4eb987,_0x4a137b);}[_0x4ef43a(0xc5)](_0x221c55){const _0x5cefb9=_0x4ef43a;return this[_0x5cefb9(0x83)](_0x221c55);}[_0x4ef43a(0x7a)](_0xda68b6){const _0x197f2c=_0x4ef43a;return this[_0x197f2c(0x83)]({'contractId':_0xda68b6['contractId']||_0xda68b6[_0x197f2c(0x71)],'price':_0xda68b6[_0x197f2c(0x9d)],'volume':_0xda68b6['size']||_0xda68b6['volume']||0x1,'side':_0xda68b6[_0x197f2c(0xab)],'timestamp':_0xda68b6[_0x197f2c(0x81)]||Date['now']()});}[_0x4ef43a(0xbd)](_0x4c94cb,_0x30f1b3){const _0xaafdc5=_0x4ef43a;let _0x1c8cb0=this['barHistory'][_0xaafdc5(0x76)](_0x4c94cb);!_0x1c8cb0&&(this[_0xaafdc5(0xcb)](_0x4c94cb),_0x1c8cb0=this[_0xaafdc5(0xad)][_0xaafdc5(0x76)](_0x4c94cb));_0x1c8cb0[_0xaafdc5(0x8a)](_0x30f1b3);if(_0x1c8cb0[_0xaafdc5(0xac)]>0x1f4)_0x1c8cb0['shift']();const _0x4ad596=this[_0xaafdc5(0xb8)][_0xaafdc5(0x76)](_0x4c94cb);_0x4ad596[_0xaafdc5(0x8a)](_0x30f1b3[_0xaafdc5(0x8d)]);if(_0x4ad596[_0xaafdc5(0xac)]>0xc8)_0x4ad596[_0xaafdc5(0x84)]();const _0x42c94b=this[_0xaafdc5(0x87)][_0xaafdc5(0x76)](_0x4c94cb),_0x558fed=_0x30f1b3[_0xaafdc5(0xb6)]-_0x30f1b3[_0xaafdc5(0xd0)];let _0x2e9b86=_0x30f1b3[_0xaafdc5(0x92)]*0.5,_0x3dd352=_0x30f1b3[_0xaafdc5(0x92)]*0.5;if(_0x558fed>0x0){const _0xd8c0b5=(_0x30f1b3[_0xaafdc5(0x8d)]-_0x30f1b3['low'])/_0x558fed;_0x2e9b86=_0x30f1b3[_0xaafdc5(0x92)]*_0xd8c0b5,_0x3dd352=_0x30f1b3[_0xaafdc5(0x92)]*(0x1-_0xd8c0b5);}_0x42c94b[_0xaafdc5(0x8a)]({'buy':_0x2e9b86,'sell':_0x3dd352});if(_0x42c94b[_0xaafdc5(0xac)]>0x64)_0x42c94b['shift']();if(_0x1c8cb0[_0xaafdc5(0xac)]<0x32)return null;const _0x552d05=this[_0xaafdc5(0x79)](_0x4ad596),_0x20d691=this[_0xaafdc5(0xa1)](_0x42c94b),_0xf28454=this['_computeKyleLambda'](_0x1c8cb0),_0x53b925=this['_applyKalmanFilter'](_0x4c94cb,_0x30f1b3[_0xaafdc5(0x8d)]),{regime:_0x48fe4f,params:_0x55fc9d}=this['_detectVolatilityRegime'](_0x4c94cb,_0x1c8cb0),_0x18dfd1=this['_computeOrderFlowImbalance'](_0x1c8cb0);return this[_0xaafdc5(0xbe)](_0x4c94cb,_0x30f1b3[_0xaafdc5(0x8d)],_0x552d05,_0x20d691,_0xf28454,_0x53b925,_0x48fe4f,_0x55fc9d,_0x18dfd1,_0x1c8cb0);}[_0x4ef43a(0x79)](_0xbbb256,_0x3162b7=0x32){const _0x1bbc6e=_0x4ef43a;if(_0xbbb256[_0x1bbc6e(0xac)]<_0x3162b7)return 0x0;const _0x2ae192=_0xbbb256['slice'](-_0x3162b7),_0xedab8=_0x2ae192['reduce']((_0x291c86,_0xef5c39)=>_0x291c86+_0xef5c39,0x0)/_0x3162b7,_0x208c69=_0x2ae192[_0x1bbc6e(0xb0)]((_0x2523f8,_0x398dd7)=>_0x2523f8+Math['pow'](_0x398dd7-_0xedab8,0x2),0x0)/_0x3162b7,_0x36a76d=Math['sqrt'](_0x208c69);if(_0x36a76d<0.0001)return 0x0;const _0x3baeca=_0xbbb256[_0xbbb256[_0x1bbc6e(0xac)]-0x1];return(_0x3baeca-_0xedab8)/_0x36a76d;}[_0x4ef43a(0xa1)](_0x2b1b43){const _0x4a4f3b=_0x4ef43a;if(_0x2b1b43['length']<this[_0x4a4f3b(0x9a)])return 0.5;const _0x21cc6d=_0x2b1b43['slice'](-this['vpinWindow']);let _0x1411b6=0x0,_0x447808=0x0;for(const _0x5b7299 of _0x21cc6d){_0x1411b6+=_0x5b7299[_0x4a4f3b(0xa4)],_0x447808+=_0x5b7299['sell'];}const _0x25879f=_0x1411b6+_0x447808;if(_0x25879f<0x1)return 0.5;return Math['abs'](_0x1411b6-_0x447808)/_0x25879f;}[_0x4ef43a(0x72)](_0x27a809){const _0x1c39de=_0x4ef43a;if(_0x27a809['length']<0x14)return 0x0;const _0x12be04=_0x27a809['slice'](-0x14),_0x40daf5=[],_0x337ef1=[];for(let _0x571c4c=0x1;_0x571c4c<_0x12be04['length'];_0x571c4c++){_0x40daf5['push'](_0x12be04[_0x571c4c]['close']-_0x12be04[_0x571c4c-0x1]['close']),_0x337ef1['push'](_0x12be04[_0x571c4c]['volume']);}const _0x58aaf9=_0x40daf5[_0x1c39de(0xb0)]((_0x16c838,_0x24e596)=>_0x16c838+_0x24e596,0x0)/_0x40daf5[_0x1c39de(0xac)],_0x4e1dc9=_0x337ef1[_0x1c39de(0xb0)]((_0x317d87,_0x46ee99)=>_0x317d87+_0x46ee99,0x0)/_0x337ef1[_0x1c39de(0xac)];let _0x111030=0x0,_0x2cca54=0x0;for(let _0x5789f5=0x0;_0x5789f5<_0x40daf5['length'];_0x5789f5++){_0x111030+=(_0x40daf5[_0x5789f5]-_0x58aaf9)*(_0x337ef1[_0x5789f5]-_0x4e1dc9),_0x2cca54+=Math[_0x1c39de(0xa9)](_0x337ef1[_0x5789f5]-_0x4e1dc9,0x2);}_0x111030/=_0x40daf5[_0x1c39de(0xac)],_0x2cca54/=_0x40daf5[_0x1c39de(0xac)];if(_0x2cca54<0.0001)return 0x0;return Math['abs'](_0x111030/_0x2cca54);}['_applyKalmanFilter'](_0x5cd40c,_0x2625a8){const _0x46c4fb=_0x4ef43a;let _0x56c246=this['kalmanStates'][_0x46c4fb(0x76)](_0x5cd40c);if(!_0x56c246)return _0x56c246={'estimate':_0x2625a8,'errorCovariance':0x1},this[_0x46c4fb(0xb3)]['set'](_0x5cd40c,_0x56c246),_0x2625a8;const _0x412093=_0x56c246['estimate'],_0x4320a2=_0x56c246['errorCovariance']+this[_0x46c4fb(0xa5)],_0x55b2b8=_0x4320a2/(_0x4320a2+this['kalmanMeasurementNoise']),_0x42e39a=_0x412093+_0x55b2b8*(_0x2625a8-_0x412093),_0x447455=(0x1-_0x55b2b8)*_0x4320a2;return _0x56c246[_0x46c4fb(0xb2)]=_0x42e39a,_0x56c246[_0x46c4fb(0x96)]=_0x447455,_0x42e39a;}[_0x4ef43a(0x8b)](_0x3f3eac,_0x2b9300){const _0x40ecee=_0x4ef43a,_0x5e925e=this['_calculateATR'](_0x2b9300),_0x2056e9=_0x5e925e/this['tickSize'];let _0x240aae=this[_0x40ecee(0xa8)]['get'](_0x3f3eac);!_0x240aae&&(_0x240aae=[],this[_0x40ecee(0xa8)]['set'](_0x3f3eac,_0x240aae));_0x240aae[_0x40ecee(0x8a)](_0x5e925e);if(_0x240aae[_0x40ecee(0xac)]>0x1f4)_0x240aae['shift']();let _0x5d3642=0.5;_0x240aae['length']>=0x14&&(_0x5d3642=_0x240aae[_0x40ecee(0xcf)](_0x4be640=>_0x4be640<=_0x5e925e)[_0x40ecee(0xac)]/_0x240aae[_0x40ecee(0xac)]);let _0x42ef13,_0x597f99;if(_0x5d3642<0.25)_0x42ef13=_0x40ecee(0xd0),_0x597f99={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x5d3642<0.75?(_0x42ef13=_0x40ecee(0xc3),_0x597f99={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x42ef13='high',_0x597f99={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x42ef13,'params':_0x597f99};}['_calculateATR'](_0x1162c2,_0x3ca5fd=0xe){const _0x31b723=_0x4ef43a;if(_0x1162c2['length']<_0x3ca5fd+0x1)return 2.5;const _0x25010f=[];for(let _0x14cc6a=_0x1162c2[_0x31b723(0xac)]-_0x3ca5fd;_0x14cc6a<_0x1162c2['length'];_0x14cc6a++){const _0x48867e=_0x1162c2[_0x14cc6a],_0x340a50=_0x1162c2[_0x14cc6a-0x1]['close'],_0x506341=Math['max'](_0x48867e['high']-_0x48867e['low'],Math[_0x31b723(0xa0)](_0x48867e[_0x31b723(0xb6)]-_0x340a50),Math[_0x31b723(0xa0)](_0x48867e['low']-_0x340a50));_0x25010f['push'](_0x506341);}return _0x25010f[_0x31b723(0xb0)]((_0x392c99,_0x4ee4d6)=>_0x392c99+_0x4ee4d6,0x0)/_0x25010f[_0x31b723(0xac)];}['_computeOrderFlowImbalance'](_0x37f53c){const _0x334246=_0x4ef43a;if(_0x37f53c[_0x334246(0xac)]<this['ofiLookback'])return 0x0;const _0x16427c=_0x37f53c[_0x334246(0x85)](-this['ofiLookback']);let _0x4a7638=0x0,_0x4a1973=0x0;for(const _0x3fdc64 of _0x16427c){const _0xeac481=_0x3fdc64[_0x334246(0xb6)]-_0x3fdc64[_0x334246(0xd0)];if(_0xeac481>0x0){const _0x23490d=(_0x3fdc64['close']-_0x3fdc64['low'])/_0xeac481;_0x4a7638+=_0x23490d*_0x3fdc64['volume'],_0x4a1973+=(0x1-_0x23490d)*_0x3fdc64[_0x334246(0x92)];}}const _0x33dc50=_0x4a7638+_0x4a1973;if(_0x33dc50<0x1)return 0x0;return(_0x4a7638-_0x4a1973)/_0x33dc50;}['_generateSignal'](_0x4359a6,_0x277d7f,_0x30e87a,_0x5a94e3,_0x2fe327,_0x9f43fb,_0x50cfb3,_0xf27a12,_0x5c808d,_0x24e541){const _0x599819=_0x4ef43a,_0x27ddc4=Math[_0x599819(0xa0)](_0x30e87a);if(_0x27ddc4<_0xf27a12['zscoreThreshold'])return null;if(_0x5a94e3>this['vpinToxicThreshold'])return null;let _0x27a2de;if(_0x30e87a<-_0xf27a12[_0x599819(0x6a)])_0x27a2de='long';else{if(_0x30e87a>_0xf27a12[_0x599819(0x6a)])_0x27a2de='short';else return null;}const _0x575132=_0x27a2de===_0x599819(0x6e)&&_0x5c808d>0.1||_0x27a2de==='short'&&_0x5c808d<-0.1,_0x574ea2=_0x277d7f-_0x9f43fb,_0x39c00d=_0x27a2de==='long'&&_0x574ea2<0x0||_0x27a2de==='short'&&_0x574ea2>0x0,_0x17d6d5={'zscore':Math[_0x599819(0xc4)](0x1,_0x27ddc4/0x4),'vpin':0x1-_0x5a94e3,'kyleLambda':_0x2fe327>0.001?0.5:0.8,'kalman':_0x39c00d?0.8:0.4,'volatility':_0x50cfb3===_0x599819(0xc3)?0.8:_0x50cfb3==='low'?0.7:0.6,'ofi':_0x575132?0.9:0.5,'composite':0x0};_0x17d6d5[_0x599819(0x9e)]=_0x17d6d5['zscore']*this['weights'][_0x599819(0xbf)]+_0x17d6d5[_0x599819(0x88)]*this['weights'][_0x599819(0x88)]+_0x17d6d5['kyleLambda']*this['weights']['kyleLambda']+_0x17d6d5[_0x599819(0x66)]*this['weights']['kalman']+_0x17d6d5['volatility']*this[_0x599819(0xb5)][_0x599819(0x8e)]+_0x17d6d5['ofi']*this[_0x599819(0xb5)][_0x599819(0x95)];const _0x2c2e0b=Math[_0x599819(0xc4)](0x1,_0x17d6d5[_0x599819(0x9e)]+_0xf27a12[_0x599819(0x86)]);if(_0x2c2e0b<this['minConfidence'])return null;if(Date[_0x599819(0xc6)]()-this['lastSignalTime']<this['cooldownMs'])return null;const _0x3b0e0d=Math[_0x599819(0x68)](this['baseStopTicks']*_0xf27a12['stopMultiplier']),_0x134055=Math[_0x599819(0x68)](this[_0x599819(0x7c)]*_0xf27a12['targetMultiplier']),_0x4b1088=Math[_0x599819(0x98)](0x6,Math['min'](0xc,_0x3b0e0d)),_0x3cc662=Math['max'](_0x4b1088*1.5,Math['min'](0x18,_0x134055));let _0x9a9a31,_0x577126,_0x469ecc,_0x3571f9;_0x27a2de==='long'?(_0x9a9a31=_0x277d7f-_0x4b1088*this[_0x599819(0x7d)],_0x577126=_0x277d7f+_0x3cc662*this[_0x599819(0x7d)],_0x469ecc=_0x277d7f+this[_0x599819(0x6d)]*this['tickSize'],_0x3571f9=_0x277d7f+_0x3cc662*this['profitLockPct']*this[_0x599819(0x7d)]):(_0x9a9a31=_0x277d7f+_0x4b1088*this['tickSize'],_0x577126=_0x277d7f-_0x3cc662*this['tickSize'],_0x469ecc=_0x277d7f-this['breakevenTicks']*this['tickSize'],_0x3571f9=_0x277d7f-_0x3cc662*this['profitLockPct']*this['tickSize']);const _0x5dd24d=_0x3cc662/_0x4b1088,_0x2ef93d=Math[_0x599819(0x68)](_0x3cc662*0.5),_0x9abe1d=Math[_0x599819(0x68)](_0x4b1088*0.4);let _0x44dbd2=SignalStrength['MODERATE'];if(_0x2c2e0b>=0.85)_0x44dbd2=SignalStrength[_0x599819(0x7f)];else{if(_0x2c2e0b>=0.75)_0x44dbd2=SignalStrength[_0x599819(0xb9)];else{if(_0x2c2e0b<0.6)_0x44dbd2=SignalStrength['WEAK'];}}const _0x11baa1=0.5+(_0x2c2e0b-0.5)*0.4,_0x389b0d=_0x11baa1*Math[_0x599819(0xa0)](_0x577126-_0x277d7f)-(0x1-_0x11baa1)*Math[_0x599819(0xa0)](_0x277d7f-_0x9a9a31);this['lastSignalTime']=Date['now'](),this['stats'][_0x599819(0xc7)]++;const _0x53adc9={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0x4359a6['split']('.')[0x0]||_0x4359a6,'contractId':_0x4359a6,'side':_0x27a2de===_0x599819(0x6e)?OrderSide['BID']:OrderSide['ASK'],'direction':_0x27a2de,'strategy':_0x599819(0x90),'strength':_0x44dbd2,'edge':_0x389b0d,'confidence':_0x2c2e0b,'entry':_0x277d7f,'entryPrice':_0x277d7f,'stopLoss':_0x9a9a31,'takeProfit':_0x577126,'riskReward':_0x5dd24d,'stopTicks':_0x4b1088,'targetTicks':_0x3cc662,'trailTriggerTicks':_0x2ef93d,'trailDistanceTicks':_0x9abe1d,'beBreakeven':_0x469ecc,'profitLockLevel':_0x3571f9,'zScore':_0x30e87a,'zScoreExit':this[_0x599819(0xb7)],'vpinValue':_0x5a94e3,'kyleLambda':_0x2fe327,'kalmanEstimate':_0x9f43fb,'volatilityRegime':_0x50cfb3,'ofiValue':_0x5c808d,'models':_0x17d6d5,'orderFlowConfirmed':_0x575132,'kalmanConfirmed':_0x39c00d,'expires':Date['now']()+0xea60};return this['emit']('signal',{'side':_0x27a2de==='long'?_0x599819(0xa4):'sell','action':_0x599819(0xba),'reason':'Z='+_0x30e87a[_0x599819(0xc1)](0x2)+',\x20VPIN='+(_0x5a94e3*0x64)['toFixed'](0x0)+_0x599819(0xb1)+(_0x5c808d*0x64)['toFixed'](0x0)+'%,\x20cf='+(_0x2c2e0b*0x64)['toFixed'](0x0)+'%',..._0x53adc9}),this[_0x599819(0xc8)](_0x599819(0x9f),{'type':'info','message':_0x599819(0xc0)+_0x27a2de[_0x599819(0xc9)]()+_0x599819(0xa2)+_0x277d7f['toFixed'](0x2)+_0x599819(0x80)+_0x30e87a[_0x599819(0xc1)](0x2)+'\x20VPIN:'+(_0x5a94e3*0x64)[_0x599819(0xc1)](0x0)+'%\x20OFI:'+(_0x5c808d*0x64)['toFixed'](0x0)+'%\x20Kyle:'+_0x2fe327['toFixed'](0x5)+'\x20Regime:'+_0x50cfb3+'\x20|\x20Conf:'+(_0x2c2e0b*0x64)[_0x599819(0xc1)](0x0)+'%'}),_0x53adc9;}[_0x4ef43a(0x91)](_0x26cd1c){const _0x5ee9d0=_0x4ef43a,_0x3abdd7=this['priceBuffer']['get'](_0x26cd1c);if(!_0x3abdd7||_0x3abdd7[_0x5ee9d0(0xac)]<0x32)return![];const _0x5234f1=this['_computeZScore'](_0x3abdd7);return Math[_0x5ee9d0(0xa0)](_0x5234f1)<this[_0x5ee9d0(0xb7)];}['getModelValues'](_0x100ad6){const _0x72c1a9=_0x4ef43a,_0x498e03=this['priceBuffer']['get'](_0x100ad6),_0x1df52e=this[_0x72c1a9(0x87)]['get'](_0x100ad6),_0x2fcdbb=this[_0x72c1a9(0xad)]['get'](_0x100ad6);if(!_0x498e03||!_0x1df52e||!_0x2fcdbb||_0x2fcdbb[_0x72c1a9(0xac)]<0x32)return null;const _0x58a68a=this[_0x72c1a9(0x79)](_0x498e03),_0x92f79f=this['_computeVPIN'](_0x1df52e),_0x40de93=this['_computeKyleLambda'](_0x2fcdbb),_0x2f710b=this['_computeOrderFlowImbalance'](_0x2fcdbb);return{'zscore':Math[_0x72c1a9(0xc4)](0x1,Math['abs'](_0x58a68a)/0x4),'vpin':0x1-_0x92f79f,'kyleLambda':_0x40de93>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math['abs'](_0x2f710b)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x58a68a,'vpin':_0x92f79f,'kyleLambda':_0x40de93,'ofi':_0x2f710b}};}['getAnalysisState'](_0x4ce2b0,_0x316d29){const _0x5a30cd=_0x4ef43a,_0x4d69d4=this['barHistory'][_0x5a30cd(0x76)](_0x4ce2b0)||[];if(_0x4d69d4[_0x5a30cd(0xac)]<0x32)return{'ready':![],'message':'Collecting\x20data...\x20'+_0x4d69d4[_0x5a30cd(0xac)]+_0x5a30cd(0x6c)};const _0x1ca627=this[_0x5a30cd(0xb8)][_0x5a30cd(0x76)](_0x4ce2b0)||[],_0x21297c=this['volumeBuffer']['get'](_0x4ce2b0)||[],_0x95eb25=this['_computeZScore'](_0x1ca627),_0x592c7b=this[_0x5a30cd(0xa1)](_0x21297c),_0x509d43=this['_computeOrderFlowImbalance'](_0x4d69d4),_0x4985ff=this[_0x5a30cd(0x72)](_0x4d69d4),{regime:_0x85649c,params:_0x481443}=this[_0x5a30cd(0x8b)](_0x4ce2b0,_0x4d69d4);return{'ready':!![],'zScore':_0x95eb25,'vpin':_0x592c7b,'ofi':_0x509d43,'kyleLambda':_0x4985ff,'regime':_0x85649c,'stopTicks':Math[_0x5a30cd(0x68)](this['baseStopTicks']*_0x481443['stopMultiplier']),'targetTicks':Math[_0x5a30cd(0x68)](this[_0x5a30cd(0x7c)]*_0x481443['targetMultiplier']),'threshold':_0x481443[_0x5a30cd(0x6a)],'barsProcessed':_0x4d69d4[_0x5a30cd(0xac)],'models':'6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)'};}[_0x4ef43a(0x73)](_0x4697d4){const _0x5aed51=_0x4ef43a;this[_0x5aed51(0x77)][_0x5aed51(0x8a)]({'netPnl':_0x4697d4,'timestamp':Date[_0x5aed51(0xc6)]()});if(this[_0x5aed51(0x77)][_0x5aed51(0xac)]>0x64)this[_0x5aed51(0x77)]['shift']();_0x4697d4>0x0?(this[_0x5aed51(0xca)]++,this[_0x5aed51(0xaf)]=0x0,this[_0x5aed51(0xce)]['wins']++):(this[_0x5aed51(0xaf)]++,this['winStreak']=0x0,this['stats']['losses']++),this['stats']['trades']++,this[_0x5aed51(0xce)][_0x5aed51(0xae)]+=_0x4697d4,this[_0x5aed51(0xc8)]('log',{'type':'debug','message':'[HQX]\x20Trade\x20result:\x20'+(_0x4697d4>0x0?_0x5aed51(0x9c):_0x5aed51(0x93))+'\x20$'+_0x4697d4['toFixed'](0x2)+',\x20streak:\x20'+(_0x4697d4>0x0?this[_0x5aed51(0xca)]:-this['lossStreak'])});}[_0x4ef43a(0x69)](_0x2ce69e){const _0x2d6ea3=_0x4ef43a;return this['barHistory'][_0x2d6ea3(0x76)](_0x2ce69e)||[];}['getStats'](){return this['stats'];}[_0x4ef43a(0x99)](_0x41adc0){const _0x183b0d=_0x4ef43a;this[_0x183b0d(0xad)][_0x183b0d(0x8f)](_0x41adc0,[]),this['priceBuffer'][_0x183b0d(0x8f)](_0x41adc0,[]),this['volumeBuffer'][_0x183b0d(0x8f)](_0x41adc0,[]),this['atrHistory'][_0x183b0d(0x8f)](_0x41adc0,[]),this['kalmanStates'][_0x183b0d(0x8f)](_0x41adc0,{'estimate':0x0,'errorCovariance':0x1}),this['emit']('log',{'type':_0x183b0d(0x7e),'message':_0x183b0d(0xcc)+_0x41adc0});}}class UltraScalpingStrategy extends EventEmitter{constructor(_0x46e0c0={}){const _0xd0678e=_0x4ef43a;super(),this['config']=_0x46e0c0,this[_0xd0678e(0xa7)]=new HQXUltraScalping(_0x46e0c0),this['strategy']['on']('signal',_0x474537=>this[_0xd0678e(0xc8)](_0xd0678e(0x70),_0x474537)),this['strategy']['on']('log',_0x70e918=>this[_0xd0678e(0xc8)](_0xd0678e(0x9f),_0x70e918));}['processTick'](_0x3efffa){const _0x313177=_0x4ef43a;return this['strategy'][_0x313177(0x83)](_0x3efffa);}[_0x4ef43a(0xc5)](_0x3f7186){const _0x31dc6c=_0x4ef43a;return this[_0x31dc6c(0xa7)]['onTick'](_0x3f7186);}['onTrade'](_0x975762){const _0x661b68=_0x4ef43a;return this[_0x661b68(0xa7)][_0x661b68(0x7a)](_0x975762);}['processBar'](_0x696d58,_0x22131b){const _0x492215=_0x4ef43a;return this[_0x492215(0xa7)][_0x492215(0xbd)](_0x696d58,_0x22131b);}['initialize'](_0x2857f7,_0x150854,_0x5351a2){const _0x725959=_0x4ef43a;return this[_0x725959(0xa7)]['initialize'](_0x2857f7,_0x150854,_0x5351a2);}[_0x4ef43a(0x67)](_0x1237ca,_0x387bc3){const _0x5ad357=_0x4ef43a;return this['strategy'][_0x5ad357(0x67)](_0x1237ca,_0x387bc3);}[_0x4ef43a(0x73)](_0x2e2f31){const _0x3a74bf=_0x4ef43a;return this[_0x3a74bf(0xa7)]['recordTradeResult'](_0x2e2f31);}[_0x4ef43a(0x99)](_0x4e01ef){const _0x450d1e=_0x4ef43a;return this['strategy'][_0x450d1e(0x99)](_0x4e01ef);}[_0x4ef43a(0x6b)](){const _0x325341=_0x4ef43a;return this[_0x325341(0xa7)]['getStats']();}[_0x4ef43a(0x69)](_0x21a9b2){return this['strategy']['getBarHistory'](_0x21a9b2);}['getModelValues'](_0x47590e){return this['strategy']['getModelValues'](_0x47590e);}[_0x4ef43a(0x91)](_0x50e997){const _0x13b852=_0x4ef43a;return this[_0x13b852(0xa7)]['shouldExitByZScore'](_0x50e997);}[_0x4ef43a(0x94)](_0x32664f){return null;}}module[_0x4ef43a(0x74)]={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};
|
package/package.json
CHANGED
package/src/lib/data.js
CHANGED
|
@@ -388,6 +388,10 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
388
388
|
if (!rithmicCredentials) {
|
|
389
389
|
throw new Error('Rithmic credentials not available');
|
|
390
390
|
}
|
|
391
|
+
// Disconnect service's TICKER_PLANT to avoid conflict (Rithmic allows only 1 TICKER connection per user)
|
|
392
|
+
if (service.disconnectTicker) {
|
|
393
|
+
await service.disconnectTicker();
|
|
394
|
+
}
|
|
391
395
|
await marketFeed.connect(rithmicCredentials);
|
|
392
396
|
await marketFeed.subscribe(symbolCode, contract.exchange || 'CME');
|
|
393
397
|
|
|
@@ -207,6 +207,12 @@ class RithmicService extends EventEmitter {
|
|
|
207
207
|
|
|
208
208
|
async connectTicker(username, password) {
|
|
209
209
|
try {
|
|
210
|
+
// Clean up existing connection first
|
|
211
|
+
if (this.tickerConn) {
|
|
212
|
+
this.tickerConn.removeAllListeners();
|
|
213
|
+
try { await this.tickerConn.disconnect(); } catch (_) {}
|
|
214
|
+
}
|
|
215
|
+
|
|
210
216
|
this.tickerConn = new RithmicConnection();
|
|
211
217
|
|
|
212
218
|
const config = {
|
|
@@ -220,12 +226,8 @@ class RithmicService extends EventEmitter {
|
|
|
220
226
|
|
|
221
227
|
await this.tickerConn.connect(config);
|
|
222
228
|
|
|
223
|
-
//
|
|
224
|
-
|
|
225
|
-
if (this.credentials && code !== 1000) {
|
|
226
|
-
setTimeout(() => this.connectTicker(this.credentials.username, this.credentials.password), 3000);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
+
// NO auto-reconnect for tickerConn - it's only used for contract search
|
|
230
|
+
// MarketDataFeed handles its own TICKER_PLANT connection for algo trading
|
|
229
231
|
|
|
230
232
|
return new Promise((resolve) => {
|
|
231
233
|
const timeout = setTimeout(() => {
|
|
@@ -251,6 +253,17 @@ class RithmicService extends EventEmitter {
|
|
|
251
253
|
return false;
|
|
252
254
|
}
|
|
253
255
|
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Disconnect TICKER_PLANT to allow MarketDataFeed to use it exclusively
|
|
259
|
+
*/
|
|
260
|
+
async disconnectTicker() {
|
|
261
|
+
if (this.tickerConn) {
|
|
262
|
+
this.tickerConn.removeAllListeners();
|
|
263
|
+
try { await this.tickerConn.disconnect(); } catch (_) {}
|
|
264
|
+
this.tickerConn = null;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
254
267
|
|
|
255
268
|
// ==================== DELEGATED METHODS ====================
|
|
256
269
|
|