hedgequantx 2.9.131 → 2.9.132
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
|
-
function _0x3c3f(){const _0x46117a=['lastSignalTime','getFullYear','\x20historical\x20bars...','tickValue','_updateZones','maxZoneAgeBars','tickSize','isValid','signals','SUPPORT','length','enabled','t,\x20Trail=','getStats','recentTrades','symbol','_getVolumeRatio','x\x20|\x20Conf:','close','exitBarIndex','low',':\x20tick=','_tickCount','barHistory','entryBarIndex','priceLow','priceHigh','processBar','minBodyRatio','onTick','activeSweeps','\x20@\x20','long','emit','liquidityZones','\x20closed\x20@\x20','clusterToleranceTicks','HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)','America/New_York','s\x20<\x20','trailDistanceTicks','\x20H:','isArray','uuid','cooldownBars','open','signal','get','barIndex','stats','contractId','getLevel','resistance','durationBars','filter','config','preloadBars','\x20|\x20O:','x\x20|\x20Q:','t,\x20Target=','[2B]\x20NEW\x20SWING\x20','minPenetrationTicks','\x20|\x20Bar\x20','maxDurationBars','price','type','BID','toUpperCase','_detectSwings','shift','short','3402636llhlyn','\x20|\x20Valid:\x20','min','penetrationTicks','now','wins','swept','HIGH_SWEEP','\x20zones','stopTicks','timestamp','sweepType','size','breakevenTicks','qualityScore','2B\x20','[SWING]\x20NEW\x20HIGH\x20@\x20','_mergeConfig','\x20|\x20Total:\x20','t,\x20BE=','extremePrice','set','find','10737041vgMdXj','high','[2B]\x20SWEEP\x20','\x20|\x20Pen:','floor','support','\x20swings,\x20','lookbackBars','info','reset','MODERATE','log','[SWING]\x20NEW\x20LOW\x20@\x20','[HQX-2B]\x20Initialized\x20for\x20','session','minStrength','26162992hJuefX','54HXgmBP','volume','[HQX-2B]\x20Reset\x20state\x20for\x20','sort','abs','[HQX-2B]\x20Trade\x20result:\x20','execution','68438ysmZZa','\x20L:','getBarHistory','push','lastUsedBarIndex','323357hZOlZD','trailTriggerTicks','targetTicks','_scoreSweep','swing','swingPoints','7839295fiKrBO','[BAR]\x20#','startTime','volumeRatio','LOW_SWEEP','touches','[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)','toFixed','debug','getTimezoneOffset','currentBar','minVolumeRatio','_detectSweep','\x20historical\x20signals\x20detected\x20(ignored)','barIntervalMs','WIN','Collecting\x20data...\x20','53204MyKQeC','distance','zone','strategy','processTick','getHealthStatus','max','strength','RESISTANCE','[2B]\x20NEW\x20ZONE\x20'];_0x3c3f=function(){return _0x46117a;};return _0x3c3f();}function _0x21a1(_0x212681,_0xebdd1f){_0x212681=_0x212681-0x134;const _0x3c3f23=_0x3c3f();let _0x21a1d7=_0x3c3f23[_0x212681];return _0x21a1d7;}const _0x2b7f26=_0x21a1;(function(_0x34201e,_0x46ebca){const _0x3608db=_0x21a1,_0x2b8f76=_0x34201e();while(!![]){try{const _0x52ce90=parseInt(_0x3608db(0x160))/0x1+parseInt(_0x3608db(0x15b))/0x2+-parseInt(_0x3608db(0x154))/0x3*(-parseInt(_0x3608db(0x177))/0x4)+parseInt(_0x3608db(0x166))/0x5+parseInt(_0x3608db(0x1c8))/0x6+parseInt(_0x3608db(0x143))/0x7+-parseInt(_0x3608db(0x153))/0x8;if(_0x52ce90===_0x46ebca)break;else _0x2b8f76['push'](_0x2b8f76['shift']());}catch(_0x4935c9){_0x2b8f76['push'](_0x2b8f76['shift']());}}}(_0x3c3f,0xf3078));const EventEmitter=require('events'),{v4:uuidv4}=require(_0x2b7f26(0x1ac)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':'high','LOW_SWEEP':_0x2b7f26(0x195)},ZoneType={'RESISTANCE':_0x2b7f26(0x1b5),'SUPPORT':_0x2b7f26(0x148)},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':_0x2b7f26(0x1a7)}};class SwingPoint{constructor(_0xf0e236,_0x4f7e3a,_0x35704e,_0x179ee7,_0x3b2e8a=0x1){const _0x43a524=_0x2b7f26;this[_0x43a524(0x1c2)]=_0xf0e236,this['price']=_0x4f7e3a,this[_0x43a524(0x1b1)]=_0x35704e,this[_0x43a524(0x136)]=_0x179ee7,this['strength']=_0x3b2e8a;}}class LiquidityZone{constructor(_0x49e7e9,_0x1262c8,_0x1e3e37,_0x466614,_0xbae350){const _0x31182c=_0x2b7f26;this['id']=uuidv4(),this[_0x31182c(0x1c2)]=_0x49e7e9,this['priceHigh']=_0x1262c8,this['priceLow']=_0x1e3e37,this['createdAt']=_0x466614,this[_0x31182c(0x1b1)]=_0xbae350,this['touches']=0x1,this['swept']=![],this['sweptAt']=null,this['lastUsedBarIndex']=-0x3e7,this['qualityScore']=0.5;}['containsPrice'](_0x23d7f5,_0x1b2ec0,_0x2c2dd0){const _0xba3b4e=_0x2b7f26,_0x135abd=_0x1b2ec0*_0x2c2dd0;return _0x23d7f5>=this['priceLow']-_0x135abd&&_0x23d7f5<=this[_0xba3b4e(0x19b)]+_0x135abd;}['getLevel'](){const _0x3a5acc=_0x2b7f26;return(this[_0x3a5acc(0x19b)]+this[_0x3a5acc(0x19a)])/0x2;}}class SweepEvent{constructor(_0x53015d,_0x1812a1,_0x4cb18e,_0x9d3d34,_0x22a75d){const _0x3d52cb=_0x2b7f26;this[_0x3d52cb(0x137)]=_0x53015d,this[_0x3d52cb(0x179)]=_0x1812a1,this[_0x3d52cb(0x199)]=_0x4cb18e,this['extremeBarIndex']=_0x9d3d34,this[_0x3d52cb(0x140)]=_0x22a75d,this[_0x3d52cb(0x194)]=null,this[_0x3d52cb(0x188)]=![],this['qualityScore']=0x0,this['penetrationTicks']=0x0,this['durationBars']=0x0,this[_0x3d52cb(0x169)]=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x4e94a6={}){const _0x4414f4=_0x2b7f26;super(),this[_0x4414f4(0x1b8)]=this[_0x4414f4(0x13d)](DEFAULT_CONFIG,_0x4e94a6),this[_0x4414f4(0x187)]=this['config']['tickSize'],this['tickValue']=this[_0x4414f4(0x1b8)][_0x4414f4(0x184)],this['barHistory']=new Map(),this[_0x4414f4(0x165)]=new Map(),this[_0x4414f4(0x1a3)]=new Map(),this['activeSweeps']=new Map(),this['currentBar']=new Map(),this[_0x4414f4(0x174)]=0xea60,this['lastSignalTime']=0x0,this[_0x4414f4(0x168)]=Date['now'](),this[_0x4414f4(0x1b2)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this[_0x4414f4(0x18f)]=[];}['_mergeConfig'](_0x533215,_0x2b1aa7){const _0x35336f=_0x2b7f26,_0x3a939b={..._0x533215};for(const _0x4442a7 in _0x2b1aa7){typeof _0x2b1aa7[_0x4442a7]==='object'&&!Array[_0x35336f(0x1ab)](_0x2b1aa7[_0x4442a7])?_0x3a939b[_0x4442a7]={..._0x533215[_0x4442a7],..._0x2b1aa7[_0x4442a7]}:_0x3a939b[_0x4442a7]=_0x2b1aa7[_0x4442a7];}return _0x3a939b;}['isWithinSession'](_0x67c104){const _0x20325a=_0x2b7f26;if(!this['config'][_0x20325a(0x151)][_0x20325a(0x18c)])return!![];const _0x5d4431=new Date(_0x67c104),_0x5024f3=this['isDST'](_0x5d4431)?-0x4:-0x5,_0x49dd08=_0x5d4431['getUTCHours'](),_0x1e0bf6=_0x5d4431['getUTCMinutes'](),_0x4e6dd3=(_0x49dd08+_0x5024f3+0x18)%0x18,{startHour:_0x1d30ba,startMinute:_0x371c1c,endHour:_0x35ddc2,endMinute:_0x667736}=this[_0x20325a(0x1b8)][_0x20325a(0x151)],_0x1f1875=_0x4e6dd3*0x3c+_0x1e0bf6,_0x3ab779=_0x1d30ba*0x3c+_0x371c1c,_0x37a76b=_0x35ddc2*0x3c+_0x667736;return _0x1f1875>=_0x3ab779&&_0x1f1875<_0x37a76b;}['isDST'](_0x3849b9){const _0x986235=_0x2b7f26,_0x386a1a=new Date(_0x3849b9[_0x986235(0x182)](),0x0,0x1),_0x2ab044=new Date(_0x3849b9[_0x986235(0x182)](),0x6,0x1),_0x5f132d=Math['max'](_0x386a1a[_0x986235(0x16f)](),_0x2ab044[_0x986235(0x16f)]());return _0x3849b9['getTimezoneOffset']()<_0x5f132d;}['initialize'](_0x5b49f2,_0x1e887d=0.25,_0x1a1603=0x5){const _0x584914=_0x2b7f26;this['tickSize']=_0x1e887d,this['tickValue']=_0x1a1603,this[_0x584914(0x1b8)]['tickSize']=_0x1e887d,this['config'][_0x584914(0x184)]=_0x1a1603,this[_0x584914(0x198)][_0x584914(0x141)](_0x5b49f2,[]),this['swingPoints']['set'](_0x5b49f2,[]),this['liquidityZones']['set'](_0x5b49f2,[]),this[_0x584914(0x19f)]['set'](_0x5b49f2,[]),this[_0x584914(0x170)]['delete'](_0x5b49f2),this['emit']('log',{'type':'info','message':_0x584914(0x150)+_0x5b49f2+_0x584914(0x196)+_0x1e887d+',\x20value='+_0x1a1603+',\x20TF=1min'}),this[_0x584914(0x1a2)](_0x584914(0x14e),{'type':_0x584914(0x14b),'message':'[HQX-2B]\x20Params:\x20Stop='+this['config']['execution']['stopTicks']+_0x584914(0x1bc)+this['config'][_0x584914(0x15a)][_0x584914(0x162)]+_0x584914(0x13f)+this['config'][_0x584914(0x15a)][_0x584914(0x139)]+_0x584914(0x18d)+this['config'][_0x584914(0x15a)][_0x584914(0x161)]+'/'+this['config'][_0x584914(0x15a)][_0x584914(0x1a9)]});}[_0x2b7f26(0x17b)](_0x15adae){const _0x492a22=_0x2b7f26,{contractId:_0xd91c87,price:_0x470291,volume:_0x56b393,timestamp:_0xf8c6c5}=_0x15adae,_0x41511c=_0xf8c6c5||Date[_0x492a22(0x1cc)](),_0x1bf693=_0x56b393||0x1;if(!this['isWithinSession'](_0x41511c))return null;if(!this[_0x492a22(0x197)])this['_tickCount']=0x0;this[_0x492a22(0x197)]++;let _0x353b5c=this['currentBar']['get'](_0xd91c87);const _0x4fa15c=Math[_0x492a22(0x147)](_0x41511c/this['barIntervalMs'])*this[_0x492a22(0x174)];if(!_0x353b5c||_0x353b5c['startTime']!==_0x4fa15c){if(_0x353b5c){const _0x2a41bc={'timestamp':_0x353b5c['startTime'],'open':_0x353b5c['open'],'high':_0x353b5c[_0x492a22(0x144)],'low':_0x353b5c[_0x492a22(0x195)],'close':_0x353b5c[_0x492a22(0x193)],'volume':_0x353b5c[_0x492a22(0x155)]},_0x560d4e=this['barHistory']['get'](_0xd91c87)||[];this[_0x492a22(0x1a2)]('log',{'type':'debug','message':_0x492a22(0x167)+(_0x560d4e['length']+0x1)+_0x492a22(0x1a4)+_0x2a41bc[_0x492a22(0x193)]['toFixed'](0x2)+_0x492a22(0x1ba)+_0x2a41bc['open']['toFixed'](0x2)+_0x492a22(0x1aa)+_0x2a41bc[_0x492a22(0x144)]['toFixed'](0x2)+_0x492a22(0x15c)+_0x2a41bc['low'][_0x492a22(0x16d)](0x2)+'\x20Vol:'+_0x2a41bc[_0x492a22(0x155)]});const _0x2894bd=this[_0x492a22(0x19c)](_0xd91c87,_0x2a41bc);return this['currentBar'][_0x492a22(0x141)](_0xd91c87,{'startTime':_0x4fa15c,'open':_0x470291,'high':_0x470291,'low':_0x470291,'close':_0x470291,'volume':_0x1bf693}),_0x2894bd;}else return this[_0x492a22(0x170)]['set'](_0xd91c87,{'startTime':_0x4fa15c,'open':_0x470291,'high':_0x470291,'low':_0x470291,'close':_0x470291,'volume':_0x1bf693}),null;}else return _0x353b5c[_0x492a22(0x144)]=Math['max'](_0x353b5c['high'],_0x470291),_0x353b5c[_0x492a22(0x195)]=Math[_0x492a22(0x1ca)](_0x353b5c[_0x492a22(0x195)],_0x470291),_0x353b5c['close']=_0x470291,_0x353b5c['volume']+=_0x1bf693,null;}['onTick'](_0x321c3a){const _0x1d8ba3=_0x2b7f26;return this[_0x1d8ba3(0x17b)](_0x321c3a);}['onTrade'](_0x1b7389){const _0x993456=_0x2b7f26;return this['processTick']({'contractId':_0x1b7389[_0x993456(0x1b3)]||_0x1b7389[_0x993456(0x190)],'price':_0x1b7389['price'],'volume':_0x1b7389[_0x993456(0x138)]||_0x1b7389['volume']||0x1,'timestamp':_0x1b7389[_0x993456(0x136)]||Date['now']()});}['processBar'](_0x1a7a65,_0x164133){const _0x22bd32=_0x2b7f26;let _0x418086=this['barHistory'][_0x22bd32(0x1b0)](_0x1a7a65);!_0x418086&&(this['initialize'](_0x1a7a65),_0x418086=this['barHistory']['get'](_0x1a7a65));_0x418086['push'](_0x164133);if(_0x418086['length']>0x1f4)_0x418086[_0x22bd32(0x1c6)]();const _0x242f18=_0x418086[_0x22bd32(0x18b)]-0x1;if(_0x418086['length']<this[_0x22bd32(0x1b8)][_0x22bd32(0x164)][_0x22bd32(0x14a)]*0x3)return null;const _0x789f49=this[_0x22bd32(0x165)][_0x22bd32(0x1b0)](_0x1a7a65)['length'];this[_0x22bd32(0x1c5)](_0x1a7a65,_0x418086,_0x242f18);const _0x395caf=this['swingPoints']['get'](_0x1a7a65);if(_0x395caf[_0x22bd32(0x18b)]>_0x789f49){const _0x108e48=_0x395caf[_0x395caf['length']-0x1];this[_0x22bd32(0x1a2)]('log',{'type':_0x22bd32(0x16e),'message':_0x22bd32(0x1bd)+_0x108e48['type']['toUpperCase']()+'\x20@\x20'+_0x108e48[_0x22bd32(0x1c1)][_0x22bd32(0x16d)](0x2)+'\x20|\x20Total:\x20'+_0x395caf[_0x22bd32(0x18b)]});}const _0x175b47=this[_0x22bd32(0x172)](_0x1a7a65,_0x418086,_0x242f18);_0x175b47&&this[_0x22bd32(0x1a2)](_0x22bd32(0x14e),{'type':_0x22bd32(0x16e),'message':_0x22bd32(0x145)+_0x175b47[_0x22bd32(0x137)]+_0x22bd32(0x1c9)+_0x175b47['isValid']+'\x20|\x20Pen:\x20'+_0x175b47[_0x22bd32(0x1cb)]['toFixed'](0x1)+'t\x20|\x20Q:\x20'+(_0x175b47[_0x22bd32(0x13a)]*0x64)[_0x22bd32(0x16d)](0x0)+'%'});const _0x6a1a3e=this['liquidityZones']['get'](_0x1a7a65)[_0x22bd32(0x18b)];this['_updateZones'](_0x1a7a65,_0x242f18);const _0x5cad77=this['liquidityZones'][_0x22bd32(0x1b0)](_0x1a7a65);if(_0x5cad77[_0x22bd32(0x18b)]>_0x6a1a3e){const _0xbf1da6=_0x5cad77[_0x5cad77['length']-0x1];this['emit'](_0x22bd32(0x14e),{'type':'debug','message':_0x22bd32(0x180)+_0xbf1da6['type'][_0x22bd32(0x1c4)]()+_0x22bd32(0x1a0)+_0xbf1da6[_0x22bd32(0x1b4)]()['toFixed'](0x2)+_0x22bd32(0x13e)+_0x5cad77[_0x22bd32(0x18b)]});}if(_0x175b47&&_0x175b47[_0x22bd32(0x188)]){this['emit'](_0x22bd32(0x14e),{'type':_0x22bd32(0x16e),'message':'[2B]\x20Calling\x20_generateSignal\x20for\x20'+_0x175b47['sweepType']+'\x20sweep...'});const _0x13a970=this['_generateSignal'](_0x1a7a65,_0x164133,_0x242f18,_0x175b47);return!_0x13a970&&this[_0x22bd32(0x1a2)]('log',{'type':'debug','message':_0x22bd32(0x16c)}),_0x13a970;}return null;}['_detectSwings'](_0x544fec,_0x16a019,_0x273844){const _0x1b2bde=_0x2b7f26,_0x3a9928=this['config'][_0x1b2bde(0x164)]['lookbackBars'],_0x4bbfb7=this[_0x1b2bde(0x1b8)]['swing'][_0x1b2bde(0x152)];if(_0x273844<_0x3a9928*0x2)return;const _0x4e701f=this['swingPoints']['get'](_0x544fec),_0x140017=_0x273844-_0x3a9928,_0x257771=_0x16a019[_0x140017];_0x273844%0x5===0x0&&this[_0x1b2bde(0x1a2)]('log',{'type':'debug','message':'[SWING]\x20Checking\x20pivot\x20at\x20bar\x20'+_0x140017+'\x20|\x20H:'+_0x257771['high']['toFixed'](0x2)+_0x1b2bde(0x15c)+_0x257771[_0x1b2bde(0x195)][_0x1b2bde(0x16d)](0x2)+'\x20|\x20Total\x20swings:\x20'+_0x4e701f[_0x1b2bde(0x18b)]});let _0x280935=!![],_0x521908=0x0;for(let _0x1a6853=_0x140017-_0x3a9928;_0x1a6853<=_0x140017+_0x3a9928;_0x1a6853++){if(_0x1a6853===_0x140017||_0x1a6853<0x0||_0x1a6853>=_0x16a019[_0x1b2bde(0x18b)])continue;if(_0x16a019[_0x1a6853][_0x1b2bde(0x144)]>=_0x257771[_0x1b2bde(0x144)]){_0x280935=![];break;}_0x521908++;}if(_0x280935&&_0x521908>=_0x4bbfb7){const _0x5bed70=_0x4e701f[_0x1b2bde(0x142)](_0x337342=>_0x337342[_0x1b2bde(0x1b1)]===_0x140017&&_0x337342['type']===_0x1b2bde(0x144));!_0x5bed70&&(_0x4e701f['push'](new SwingPoint('high',_0x257771['high'],_0x140017,_0x257771[_0x1b2bde(0x136)],_0x521908)),this[_0x1b2bde(0x1a2)]('log',{'type':_0x1b2bde(0x16e),'message':_0x1b2bde(0x13c)+_0x257771[_0x1b2bde(0x144)]['toFixed'](0x2)+'\x20|\x20Bar\x20'+_0x140017+'\x20|\x20Strength:\x20'+_0x521908}));}let _0x26d6ea=!![],_0x4b3dfc=0x0;for(let _0x4227e3=_0x140017-_0x3a9928;_0x4227e3<=_0x140017+_0x3a9928;_0x4227e3++){if(_0x4227e3===_0x140017||_0x4227e3<0x0||_0x4227e3>=_0x16a019[_0x1b2bde(0x18b)])continue;if(_0x16a019[_0x4227e3][_0x1b2bde(0x195)]<=_0x257771['low']){_0x26d6ea=![];break;}_0x4b3dfc++;}if(_0x26d6ea&&_0x4b3dfc>=_0x4bbfb7){const _0x25746a=_0x4e701f[_0x1b2bde(0x142)](_0xedd508=>_0xedd508[_0x1b2bde(0x1b1)]===_0x140017&&_0xedd508[_0x1b2bde(0x1c2)]==='low');!_0x25746a&&(_0x4e701f[_0x1b2bde(0x15e)](new SwingPoint('low',_0x257771[_0x1b2bde(0x195)],_0x140017,_0x257771['timestamp'],_0x4b3dfc)),this[_0x1b2bde(0x1a2)]('log',{'type':'debug','message':_0x1b2bde(0x14f)+_0x257771['low'][_0x1b2bde(0x16d)](0x2)+_0x1b2bde(0x1bf)+_0x140017+'\x20|\x20Strength:\x20'+_0x4b3dfc}));}const _0x4aec4c=this['config']['zone']['maxZoneAgeBars'];while(_0x4e701f[_0x1b2bde(0x18b)]>0x0&&_0x4e701f[0x0]['barIndex']<_0x273844-_0x4aec4c){_0x4e701f[_0x1b2bde(0x1c6)]();}}[_0x2b7f26(0x185)](_0x196629,_0x2bfee0){const _0x31d1b0=_0x2b7f26,_0x25fba2=this['swingPoints'][_0x31d1b0(0x1b0)](_0x196629),_0x119925=this['liquidityZones']['get'](_0x196629),_0x3adb61=this['config']['zone']['clusterToleranceTicks']*this['tickSize'],_0x5e7d4e=this['config'][_0x31d1b0(0x179)][_0x31d1b0(0x186)];for(let _0x553991=_0x119925[_0x31d1b0(0x18b)]-0x1;_0x553991>=0x0;_0x553991--){_0x2bfee0-_0x119925[_0x553991][_0x31d1b0(0x1b1)]>_0x5e7d4e&&_0x119925['splice'](_0x553991,0x1);}for(const _0x451aa4 of _0x25fba2){let _0x38f244=null;for(const _0x5c15cc of _0x119925){if(_0x5c15cc['containsPrice'](_0x451aa4['price'],this[_0x31d1b0(0x1b8)]['zone'][_0x31d1b0(0x1a5)],this[_0x31d1b0(0x187)])){_0x38f244=_0x5c15cc;break;}}if(_0x38f244){_0x38f244[_0x31d1b0(0x16b)]++;if(_0x451aa4['price']>_0x38f244[_0x31d1b0(0x19b)])_0x38f244['priceHigh']=_0x451aa4[_0x31d1b0(0x1c1)];if(_0x451aa4['price']<_0x38f244[_0x31d1b0(0x19a)])_0x38f244[_0x31d1b0(0x19a)]=_0x451aa4['price'];_0x38f244['qualityScore']=Math[_0x31d1b0(0x1ca)](0x1,0.3+_0x38f244['touches']*0.15);}else{const _0x8620a6=_0x451aa4[_0x31d1b0(0x1c2)]===_0x31d1b0(0x144)?ZoneType['RESISTANCE']:ZoneType['SUPPORT'],_0xff29f5=new LiquidityZone(_0x8620a6,_0x451aa4['price']+_0x3adb61/0x2,_0x451aa4[_0x31d1b0(0x1c1)]-_0x3adb61/0x2,_0x451aa4['timestamp'],_0x451aa4[_0x31d1b0(0x1b1)]);_0xff29f5['qualityScore']=0.3+_0x451aa4[_0x31d1b0(0x17e)]*0.1,_0x119925['push'](_0xff29f5);}}}[_0x2b7f26(0x172)](_0x253098,_0x476147,_0x3b7b82){const _0x4d84aa=_0x2b7f26,_0x1f77d3=this[_0x4d84aa(0x1a3)]['get'](_0x253098),_0x5ee966=_0x476147[_0x3b7b82],_0x207ef8=_0x5ee966['close'],_0x177358=this['config']['sweep'],_0x3a40d3=this[_0x4d84aa(0x1b8)][_0x4d84aa(0x179)];for(const _0x2b4579 of _0x1f77d3){if(_0x2b4579['lastUsedBarIndex']>=0x0&&_0x3b7b82-_0x2b4579[_0x4d84aa(0x15f)]<_0x3a40d3[_0x4d84aa(0x1ad)])continue;const _0x48383d=_0x2b4579['getLevel'](),_0x55cbb9=Math[_0x4d84aa(0x158)](_0x207ef8-_0x48383d)/this['tickSize'];if(_0x55cbb9>_0x3a40d3['maxZoneDistanceTicks'])continue;const _0x3d2830=Math[_0x4d84aa(0x17d)](0x0,_0x3b7b82-_0x177358[_0x4d84aa(0x1c0)]*0x2);for(let _0x4f10fa=_0x3d2830;_0x4f10fa<_0x3b7b82;_0x4f10fa++){const _0x3ca6b8=_0x476147[_0x4f10fa];if(_0x2b4579['type']===ZoneType[_0x4d84aa(0x17f)]){const _0x67dbd=(_0x3ca6b8[_0x4d84aa(0x144)]-_0x2b4579['priceHigh'])/this['tickSize'];if(_0x67dbd>=_0x177358[_0x4d84aa(0x1be)]&&_0x67dbd<=_0x177358['maxPenetrationTicks']){const _0x51bc6f=Math['min'](_0x2b4579[_0x4d84aa(0x19b)],_0x2b4579['priceHigh']+_0x67dbd*this[_0x4d84aa(0x187)]);if(_0x207ef8<_0x51bc6f+this[_0x4d84aa(0x187)]*0x2){const _0x27a18e=_0x3ca6b8[_0x4d84aa(0x144)]-_0x3ca6b8[_0x4d84aa(0x195)],_0x56b9d0=Math['abs'](_0x3ca6b8[_0x4d84aa(0x193)]-_0x3ca6b8[_0x4d84aa(0x1ae)]),_0x456d0c=_0x27a18e>0x0?_0x56b9d0/_0x27a18e:0x0;if(_0x456d0c>=_0x177358['minBodyRatio']){const _0x3dd38c=this['_getVolumeRatio'](_0x476147,_0x4f10fa,0x14);if(_0x3dd38c>=_0x177358[_0x4d84aa(0x171)]){const _0x46adbf=new SweepEvent(SweepType[_0x4d84aa(0x1cf)],_0x2b4579,_0x4f10fa,_0x4f10fa,_0x3ca6b8['high']);_0x46adbf[_0x4d84aa(0x194)]=_0x3b7b82,_0x46adbf[_0x4d84aa(0x1cb)]=_0x67dbd,_0x46adbf['durationBars']=_0x3b7b82-_0x4f10fa,_0x46adbf[_0x4d84aa(0x169)]=_0x3dd38c,_0x46adbf[_0x4d84aa(0x13a)]=this['_scoreSweep'](_0x46adbf,_0x456d0c),_0x46adbf['isValid']=_0x46adbf['qualityScore']>=_0x177358['minQualityScore'];if(_0x46adbf['isValid'])return _0x46adbf;}}}}}if(_0x2b4579['type']===ZoneType[_0x4d84aa(0x18a)]){const _0x24bc95=(_0x2b4579['priceLow']-_0x3ca6b8['low'])/this[_0x4d84aa(0x187)];if(_0x24bc95>=_0x177358['minPenetrationTicks']&&_0x24bc95<=_0x177358['maxPenetrationTicks']){const _0x521aa4=Math[_0x4d84aa(0x17d)](_0x2b4579[_0x4d84aa(0x19a)],_0x2b4579['priceLow']-_0x24bc95*this[_0x4d84aa(0x187)]);if(_0x207ef8>_0x521aa4-this['tickSize']*0x2){const _0x42dd6c=_0x3ca6b8['high']-_0x3ca6b8[_0x4d84aa(0x195)],_0x4ccfeb=Math['abs'](_0x3ca6b8['close']-_0x3ca6b8['open']),_0x40bdb1=_0x42dd6c>0x0?_0x4ccfeb/_0x42dd6c:0x0;if(_0x40bdb1>=_0x177358[_0x4d84aa(0x19d)]){const _0x4ab1f4=this[_0x4d84aa(0x191)](_0x476147,_0x4f10fa,0x14);if(_0x4ab1f4>=_0x177358[_0x4d84aa(0x171)]){const _0x2bd8cb=new SweepEvent(SweepType[_0x4d84aa(0x16a)],_0x2b4579,_0x4f10fa,_0x4f10fa,_0x3ca6b8[_0x4d84aa(0x195)]);_0x2bd8cb['exitBarIndex']=_0x3b7b82,_0x2bd8cb[_0x4d84aa(0x1cb)]=_0x24bc95,_0x2bd8cb[_0x4d84aa(0x1b6)]=_0x3b7b82-_0x4f10fa,_0x2bd8cb['volumeRatio']=_0x4ab1f4,_0x2bd8cb[_0x4d84aa(0x13a)]=this['_scoreSweep'](_0x2bd8cb,_0x40bdb1),_0x2bd8cb['isValid']=_0x2bd8cb[_0x4d84aa(0x13a)]>=_0x177358['minQualityScore'];if(_0x2bd8cb[_0x4d84aa(0x188)])return _0x2bd8cb;}}}}}}}return null;}[_0x2b7f26(0x191)](_0x4757d5,_0x561020,_0x2a0d77){const _0x4b9126=_0x2b7f26,_0x40ed60=Math['max'](0x0,_0x561020-_0x2a0d77),_0x5ae0b1=_0x4757d5['slice'](_0x40ed60,_0x561020);if(_0x5ae0b1[_0x4b9126(0x18b)]===0x0)return 0x1;const _0xb09338=_0x5ae0b1['map'](_0x33c439=>_0x33c439[_0x4b9126(0x155)])[_0x4b9126(0x157)]((_0x49cb58,_0x287067)=>_0x49cb58-_0x287067),_0x1a3351=Math['floor'](_0xb09338[_0x4b9126(0x18b)]/0x2),_0x21aa93=_0xb09338[_0x1a3351]||0x1;return _0x4757d5[_0x561020][_0x4b9126(0x155)]/_0x21aa93;}[_0x2b7f26(0x163)](_0x4bc7e6,_0xcaadd6){const _0x4cb679=_0x2b7f26;let _0x322112=0x0;const _0x4b611b=0x4,_0x5a7039=Math['abs'](_0x4bc7e6['penetrationTicks']-_0x4b611b);return _0x322112+=Math['max'](0x0,0.3-_0x5a7039*0.03),_0x322112+=Math[_0x4cb679(0x17d)](0x0,0.25-_0x4bc7e6[_0x4cb679(0x1b6)]*0.05),_0x322112+=Math['min'](0.25,_0x4bc7e6[_0x4cb679(0x169)]*0.1),_0x322112+=Math[_0x4cb679(0x1ca)](0.2,_0xcaadd6*0.4),Math[_0x4cb679(0x1ca)](0x1,_0x322112);}['_generateSignal'](_0x56e5a8,_0x554186,_0xde732f,_0x3aa309){const _0x4a1b55=_0x2b7f26,_0xaee65a=Date['now']()-this['lastSignalTime'];if(_0xaee65a<this['config'][_0x4a1b55(0x15a)]['cooldownMs'])return this['emit']('log',{'type':_0x4a1b55(0x16e),'message':'[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20('+(_0xaee65a/0x3e8)[_0x4a1b55(0x16d)](0x1)+_0x4a1b55(0x1a8)+this[_0x4a1b55(0x1b8)]['execution']['cooldownMs']/0x3e8+'s)'}),null;const _0x12d293=this['config'][_0x4a1b55(0x15a)],_0x127e27=_0x554186[_0x4a1b55(0x193)],_0x24fdda=_0x3aa309[_0x4a1b55(0x137)]===SweepType[_0x4a1b55(0x1cf)]?_0x4a1b55(0x1c7):_0x4a1b55(0x1a1);let _0x36ad11,_0x426361,_0x53fc6c,_0x114aa9;_0x24fdda===_0x4a1b55(0x1a1)?(_0x36ad11=_0x127e27-_0x12d293[_0x4a1b55(0x135)]*this['tickSize'],_0x426361=_0x127e27+_0x12d293[_0x4a1b55(0x162)]*this['tickSize'],_0x53fc6c=_0x127e27+_0x12d293[_0x4a1b55(0x139)]*this[_0x4a1b55(0x187)],_0x114aa9=_0x127e27+_0x12d293[_0x4a1b55(0x161)]*this[_0x4a1b55(0x187)]):(_0x36ad11=_0x127e27+_0x12d293['stopTicks']*this['tickSize'],_0x426361=_0x127e27-_0x12d293[_0x4a1b55(0x162)]*this['tickSize'],_0x53fc6c=_0x127e27-_0x12d293['breakevenTicks']*this[_0x4a1b55(0x187)],_0x114aa9=_0x127e27-_0x12d293['trailTriggerTicks']*this['tickSize']);const _0x411a58=_0x12d293['targetTicks']/_0x12d293[_0x4a1b55(0x135)],_0x2ebe71=Math[_0x4a1b55(0x1ca)](0x1,_0x3aa309[_0x4a1b55(0x13a)]*0.5+_0x3aa309['zone'][_0x4a1b55(0x13a)]*0.3+(_0x3aa309[_0x4a1b55(0x169)]>1.5?0.2:_0x3aa309[_0x4a1b55(0x169)]*0.1));let _0x3bb9d5=SignalStrength[_0x4a1b55(0x14d)];if(_0x2ebe71>=0.8)_0x3bb9d5=SignalStrength['VERY_STRONG'];else{if(_0x2ebe71>=0.65)_0x3bb9d5=SignalStrength['STRONG'];else{if(_0x2ebe71<0.5)_0x3bb9d5=SignalStrength['WEAK'];}}const _0x33b12d=0.5+(_0x2ebe71-0.5)*0.4,_0x4b76ad=_0x33b12d*Math['abs'](_0x426361-_0x127e27)-(0x1-_0x33b12d)*Math['abs'](_0x127e27-_0x36ad11);_0x3aa309['zone'][_0x4a1b55(0x15f)]=_0xde732f,_0x3aa309[_0x4a1b55(0x179)][_0x4a1b55(0x1ce)]=!![],_0x3aa309['zone']['sweptAt']=new Date(_0x554186['timestamp']),this['lastSignalTime']=Date[_0x4a1b55(0x1cc)](),this['stats'][_0x4a1b55(0x189)]++;const _0x18b7f0={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0x56e5a8['split']('.')[0x0]||_0x56e5a8,'contractId':_0x56e5a8,'side':_0x24fdda==='long'?OrderSide[_0x4a1b55(0x1c3)]:OrderSide['ASK'],'direction':_0x24fdda,'strategy':'HQX_2B_LIQUIDITY_SWEEP','strength':_0x3bb9d5,'edge':_0x4b76ad,'confidence':_0x2ebe71,'entry':_0x127e27,'entryPrice':_0x127e27,'stopLoss':_0x36ad11,'takeProfit':_0x426361,'riskReward':_0x411a58,'stopTicks':_0x12d293['stopTicks'],'targetTicks':_0x12d293[_0x4a1b55(0x162)],'breakevenTicks':_0x12d293['breakevenTicks'],'trailTriggerTicks':_0x12d293[_0x4a1b55(0x161)],'trailDistanceTicks':_0x12d293['trailDistanceTicks'],'beLevel':_0x53fc6c,'trailTrigger':_0x114aa9,'sweepType':_0x3aa309[_0x4a1b55(0x137)],'penetrationTicks':_0x3aa309[_0x4a1b55(0x1cb)],'sweepDurationBars':_0x3aa309['durationBars'],'sweepQuality':_0x3aa309['qualityScore'],'volumeRatio':_0x3aa309[_0x4a1b55(0x169)],'zoneType':_0x3aa309[_0x4a1b55(0x179)][_0x4a1b55(0x1c2)],'zoneLevel':_0x3aa309[_0x4a1b55(0x179)][_0x4a1b55(0x1b4)](),'zoneTouches':_0x3aa309[_0x4a1b55(0x179)]['touches'],'zoneQuality':_0x3aa309['zone'][_0x4a1b55(0x13a)],'expires':Date['now']()+0xea60};return this[_0x4a1b55(0x1a2)](_0x4a1b55(0x1af),{'side':_0x24fdda===_0x4a1b55(0x1a1)?'buy':'sell','action':_0x4a1b55(0x1ae),'reason':_0x4a1b55(0x13b)+_0x3aa309['sweepType']+_0x4a1b55(0x146)+_0x3aa309[_0x4a1b55(0x1cb)][_0x4a1b55(0x16d)](0x1)+'t\x20|\x20Vol:'+_0x3aa309[_0x4a1b55(0x169)]['toFixed'](0x1)+_0x4a1b55(0x1bb)+(_0x3aa309[_0x4a1b55(0x13a)]*0x64)['toFixed'](0x0)+'%',..._0x18b7f0}),this['emit']('log',{'type':_0x4a1b55(0x14b),'message':'[HQX-2B]\x20SIGNAL:\x20'+_0x24fdda['toUpperCase']()+_0x4a1b55(0x1a0)+_0x127e27['toFixed'](0x2)+'\x20|\x20'+_0x3aa309['sweepType']+'\x20|\x20Pen:'+_0x3aa309[_0x4a1b55(0x1cb)]['toFixed'](0x1)+'t\x20Vol:'+_0x3aa309[_0x4a1b55(0x169)][_0x4a1b55(0x16d)](0x1)+_0x4a1b55(0x192)+(_0x2ebe71*0x64)[_0x4a1b55(0x16d)](0x0)+'%'}),_0x18b7f0;}['getAnalysisState'](_0xb2426f,_0x298d64){const _0x23c7ed=_0x2b7f26,_0x31042d=this[_0x23c7ed(0x198)][_0x23c7ed(0x1b0)](_0xb2426f)||[],_0x3dd533=this[_0x23c7ed(0x1a3)][_0x23c7ed(0x1b0)](_0xb2426f)||[],_0x109922=this[_0x23c7ed(0x165)][_0x23c7ed(0x1b0)](_0xb2426f)||[];if(_0x31042d['length']<0x5)return{'ready':![],'message':_0x23c7ed(0x176)+_0x31042d[_0x23c7ed(0x18b)]+'/5\x20bars'};const _0x49cdc3=_0x3dd533['map'](_0x56409e=>({'zone':_0x56409e,'distance':Math['abs'](_0x298d64-_0x56409e['getLevel']())}))[_0x23c7ed(0x157)]((_0x39b439,_0x9f00c2)=>_0x39b439[_0x23c7ed(0x178)]-_0x9f00c2['distance']),_0x23e6cd=_0x49cdc3['find'](_0x399241=>_0x399241[_0x23c7ed(0x179)][_0x23c7ed(0x1c2)]===ZoneType[_0x23c7ed(0x17f)]),_0x58dc5e=_0x49cdc3['find'](_0x27617b=>_0x27617b[_0x23c7ed(0x179)]['type']===ZoneType[_0x23c7ed(0x18a)]);return{'ready':!![],'barsProcessed':_0x31042d[_0x23c7ed(0x18b)],'swingsDetected':_0x109922[_0x23c7ed(0x18b)],'activeZones':_0x3dd533[_0x23c7ed(0x18b)],'nearestResistance':_0x23e6cd?_0x23e6cd[_0x23c7ed(0x179)][_0x23c7ed(0x1b4)]():null,'nearestSupport':_0x58dc5e?_0x58dc5e[_0x23c7ed(0x179)]['getLevel']():null,'stopTicks':this[_0x23c7ed(0x1b8)]['execution'][_0x23c7ed(0x135)],'targetTicks':this[_0x23c7ed(0x1b8)][_0x23c7ed(0x15a)][_0x23c7ed(0x162)],'strategy':_0x23c7ed(0x1a6)};}['recordTradeResult'](_0x2d3fde){const _0x150ef0=_0x2b7f26;this['recentTrades']['push']({'netPnl':_0x2d3fde,'timestamp':Date['now']()});if(this['recentTrades']['length']>0x64)this['recentTrades'][_0x150ef0(0x1c6)]();_0x2d3fde>0x0?this['stats'][_0x150ef0(0x1cd)]++:this[_0x150ef0(0x1b2)]['losses']++,this['stats']['trades']++,this[_0x150ef0(0x1b2)]['pnl']+=_0x2d3fde,this[_0x150ef0(0x1a2)](_0x150ef0(0x14e),{'type':'debug','message':_0x150ef0(0x159)+(_0x2d3fde>0x0?_0x150ef0(0x175):'LOSS')+'\x20$'+_0x2d3fde[_0x150ef0(0x16d)](0x2)});}['getBarHistory'](_0x1ee8c3){const _0x2b034b=_0x2b7f26;return this[_0x2b034b(0x198)][_0x2b034b(0x1b0)](_0x1ee8c3)||[];}[_0x2b7f26(0x18e)](){return this['stats'];}[_0x2b7f26(0x17c)](_0x3bb748){const _0x22a336=_0x2b7f26,_0x6894c7=this['barHistory']['get'](_0x3bb748)||[],_0x3b3daf=this['liquidityZones']['get'](_0x3bb748)||[],_0x59f5cf=this[_0x22a336(0x165)][_0x22a336(0x1b0)](_0x3bb748)||[],_0x5b4451=this[_0x22a336(0x170)]['get'](_0x3bb748),_0xfe68f1=_0x6894c7[_0x6894c7['length']-0x1],_0x4a3504=_0xfe68f1?Date[_0x22a336(0x1cc)]()-_0xfe68f1[_0x22a336(0x136)]:null,_0x565141=_0x3b3daf[_0x22a336(0x1b7)](_0x42e970=>_0x42e970[_0x22a336(0x1c2)]===ZoneType[_0x22a336(0x17f)])[_0x22a336(0x18b)],_0x14f03a=_0x3b3daf[_0x22a336(0x1b7)](_0x2ce0ca=>_0x2ce0ca['type']===ZoneType['SUPPORT'])[_0x22a336(0x18b)];return{'healthy':_0x6894c7[_0x22a336(0x18b)]>=0x5,'barsTotal':_0x6894c7['length'],'barsLast5Min':_0x6894c7[_0x22a336(0x1b7)](_0x1846d9=>Date[_0x22a336(0x1cc)]()-_0x1846d9['timestamp']<0x5*0x3c*0x3e8)['length'],'swingsTotal':_0x59f5cf[_0x22a336(0x18b)],'zonesResistance':_0x565141,'zonesSupport':_0x14f03a,'zonesTotal':_0x3b3daf[_0x22a336(0x18b)],'currentBarTicks':_0x5b4451?_0x5b4451['tickCount']:0x0,'isAggregating':_0x5b4451&&_0x5b4451['tickCount']>0x0,'timeSinceLastBarMs':_0x4a3504,'lastSignalTime':this['lastSignalTime'],'signalCooldownMs':this['config']['execution']['cooldownMs'],'uptime':Date['now']()-(this[_0x22a336(0x168)]||Date[_0x22a336(0x1cc)]())};}[_0x2b7f26(0x14c)](_0x5b62e2){const _0x126715=_0x2b7f26;this[_0x126715(0x198)]['set'](_0x5b62e2,[]),this[_0x126715(0x165)]['set'](_0x5b62e2,[]),this['liquidityZones']['set'](_0x5b62e2,[]),this[_0x126715(0x19f)][_0x126715(0x141)](_0x5b62e2,[]),this[_0x126715(0x170)]['delete'](_0x5b62e2),this[_0x126715(0x1a2)](_0x126715(0x14e),{'type':'info','message':_0x126715(0x156)+_0x5b62e2});}[_0x2b7f26(0x1b9)](_0x36cb98,_0x116ea5){const _0x313be6=_0x2b7f26;if(!_0x116ea5||_0x116ea5['length']===0x0){this[_0x313be6(0x1a2)](_0x313be6(0x14e),{'type':_0x313be6(0x16e),'message':'[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload'});return;}!this['barHistory']['has'](_0x36cb98)&&this['initialize'](_0x36cb98);const _0x2d7ec2=[..._0x116ea5]['sort']((_0x191a64,_0x53dbc1)=>_0x191a64[_0x313be6(0x136)]-_0x53dbc1[_0x313be6(0x136)]);this['emit'](_0x313be6(0x14e),{'type':'info','message':'[HQX-2B]\x20Preloading\x20'+_0x2d7ec2[_0x313be6(0x18b)]+_0x313be6(0x183)});let _0x4bc60d=0x0;for(const _0x3b14c0 of _0x2d7ec2){const _0x216325=this['processBar'](_0x36cb98,_0x3b14c0);if(_0x216325)_0x4bc60d++;}const _0x3874b2=this['barHistory']['get'](_0x36cb98)||[],_0x3cb9a2=this['swingPoints'][_0x313be6(0x1b0)](_0x36cb98)||[],_0x44de21=this[_0x313be6(0x1a3)]['get'](_0x36cb98)||[];this['emit']('log',{'type':'info','message':'[HQX-2B]\x20Preload\x20complete:\x20'+_0x3874b2[_0x313be6(0x18b)]+'\x20bars,\x20'+_0x3cb9a2['length']+_0x313be6(0x149)+_0x44de21['length']+_0x313be6(0x134)}),_0x4bc60d>0x0&&this[_0x313be6(0x1a2)](_0x313be6(0x14e),{'type':_0x313be6(0x16e),'message':'[HQX-2B]\x20'+_0x4bc60d+_0x313be6(0x173)}),this[_0x313be6(0x181)]=0x0;}}class HQX2BStrategy extends EventEmitter{constructor(_0x1795ae={}){const _0x1172ce=_0x2b7f26;super(),this[_0x1172ce(0x1b8)]=_0x1795ae,this['strategy']=new HQX2BLiquiditySweep(_0x1795ae),this[_0x1172ce(0x17a)]['on']('signal',_0x3b318a=>this['emit'](_0x1172ce(0x1af),_0x3b318a)),this['strategy']['on']('log',_0x215b6f=>this[_0x1172ce(0x1a2)](_0x1172ce(0x14e),_0x215b6f));}[_0x2b7f26(0x17b)](_0x3c7e01){return this['strategy']['processTick'](_0x3c7e01);}[_0x2b7f26(0x19e)](_0x330c1c){const _0x3e6a28=_0x2b7f26;return this['strategy'][_0x3e6a28(0x19e)](_0x330c1c);}['onTrade'](_0x2bcae9){return this['strategy']['onTrade'](_0x2bcae9);}['processBar'](_0x33780f,_0x4571de){const _0x2fc38=_0x2b7f26;return this[_0x2fc38(0x17a)]['processBar'](_0x33780f,_0x4571de);}['initialize'](_0x37548e,_0x1f0b9b,_0x5771c8){const _0xadbebc=_0x2b7f26;return this[_0xadbebc(0x17a)]['initialize'](_0x37548e,_0x1f0b9b,_0x5771c8);}['getAnalysisState'](_0x167eff,_0x2422d2){return this['strategy']['getAnalysisState'](_0x167eff,_0x2422d2);}['recordTradeResult'](_0x18dd00){return this['strategy']['recordTradeResult'](_0x18dd00);}[_0x2b7f26(0x14c)](_0x48b033){const _0x428681=_0x2b7f26;return this['strategy'][_0x428681(0x14c)](_0x48b033);}['getStats'](){const _0x514c13=_0x2b7f26;return this['strategy'][_0x514c13(0x18e)]();}[_0x2b7f26(0x15d)](_0x33d969){const _0x39227a=_0x2b7f26;return this[_0x39227a(0x17a)]['getBarHistory'](_0x33d969);}['preloadBars'](_0x176233,_0x5e588e){const _0x40bc9b=_0x2b7f26;return this['strategy'][_0x40bc9b(0x1b9)](_0x176233,_0x5e588e);}[_0x2b7f26(0x17c)](_0x2bffe7){const _0x26930e=_0x2b7f26;return this[_0x26930e(0x17a)][_0x26930e(0x17c)](_0x2bffe7);}['generateSignal'](_0x4cde76){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
|
+
const _0x325534=_0x308d;function _0x458a(){const _0x135827=['trailTriggerTicks','volume','LOW_SWEEP','strength','type','[HQX-2B]\x20Params:\x20Stop=','onTrade','lastSignalTime','emit','breakevenTicks','toUpperCase','now','\x20historical\x20bars...','MODERATE','getTimezoneOffset','[HQX-2B]\x20Trade\x20result:\x20','80PoUNPP','symbol','priceHigh','VERY_STRONG','_getVolumeRatio','initialize','high','short','LOSS','_scoreSweep','stopTicks','[2B]\x20NEW\x20SWING\x20','getLevel','strategy','isWithinSession','maxDurationBars','getStats','onTick','open','1786hzXrvl','t,\x20Target=','barHistory','sweepType','barIndex','100oidmXU','toFixed','maxPenetrationTicks','clusterToleranceTicks','losses','delete','minBodyRatio','_updateZones','config','Collecting\x20data...\x20','t\x20|\x20Q:\x20','getAnalysisState','swing','processTick','max','isValid','set','isDST','activeSweeps','filter','getBarHistory','containsPrice','swingPoints','min','2172291QAHcXe','\x20bars,\x20','1563426waWEEZ','price','extremePrice','push','map','info','\x20historical\x20signals\x20detected\x20(ignored)','getHealthStatus','RESISTANCE','distance','events','[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20(','get','length','debug','\x20swings,\x20','trailDistanceTicks','SUPPORT','durationBars','\x20|\x20Total:\x20','size','\x20|\x20Pen:','exports','recentTrades','lastUsedBarIndex','minPenetrationTicks','has','createdAt','714aydevi','3701248hltWzf','\x20@\x20','qualityScore','stats','[HQX-2B]\x20','\x20closed\x20@\x20','getFullYear','exitBarIndex','penetrationTicks','x\x20|\x20Conf:','enabled','reset','\x20|\x20O:','[BAR]\x20#','timestamp','7667244fpRZbM',',\x20TF=1min','cooldownMs','currentBar','buy','entryBarIndex','execution','111235MXKzJW','[HQX-2B]\x20Initialized\x20for\x20','barIntervalMs','liquidityZones','log','low','_mergeConfig','\x20zones','minStrength','43590wUbTks','HIGH_SWEEP','split','preloadBars','562LuBumE','zone','\x20|\x20Pen:\x20','isArray','tickValue','swept','HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)','sort','shift','abs','\x20Vol:','startTime','_tickCount','targetTicks','session','splice','\x20|\x20Valid:\x20','close','recordTradeResult','tickSize','minVolumeRatio','contractId','\x20|\x20H:','long','signal','t,\x20Trail=','priceLow','\x20|\x20Bar\x20','processBar','\x20|\x20',',\x20value=','volumeRatio'];_0x458a=function(){return _0x135827;};return _0x458a();}(function(_0x4cba4c,_0x5bafd1){const _0x20086d=_0x308d,_0xae3ec0=_0x4cba4c();while(!![]){try{const _0x39a617=parseInt(_0x20086d(0xf5))/0x1*(parseInt(_0x20086d(0xb2))/0x2)+parseInt(_0x20086d(0x114))/0x3+parseInt(_0x20086d(0xe2))/0x4*(parseInt(_0x20086d(0xa5))/0x5)+-parseInt(_0x20086d(0xae))/0x6*(-parseInt(_0x20086d(0x130))/0x7)+-parseInt(_0x20086d(0x131))/0x8+parseInt(_0x20086d(0x9e))/0x9+parseInt(_0x20086d(0xfa))/0xa*(-parseInt(_0x20086d(0x112))/0xb);if(_0x39a617===_0x5bafd1)break;else _0xae3ec0['push'](_0xae3ec0['shift']());}catch(_0x5d7031){_0xae3ec0['push'](_0xae3ec0['shift']());}}}(_0x458a,0x98344));function _0x308d(_0x1d34d0,_0x3ce471){_0x1d34d0=_0x1d34d0-0x98;const _0x458ad8=_0x458a();let _0x308dc4=_0x458ad8[_0x1d34d0];return _0x308dc4;}const EventEmitter=require(_0x325534(0x11e)),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':_0x325534(0xe8),'LOW_SWEEP':_0x325534(0xaa)},ZoneType={'RESISTANCE':'resistance','SUPPORT':'support'},DEFAULT_CONFIG={'tickSize':0.25,'tickValue':0x5,'swing':{'lookbackBars':0x2,'minStrength':0x1,'confirmationBars':0x1},'zone':{'clusterToleranceTicks':0x6,'minTouches':0x1,'maxZoneAgeBars':0xc8,'maxZoneDistanceTicks':0x3c,'cooldownBars':0x5},'sweep':{'minPenetrationTicks':0.25,'maxPenetrationTicks':0xc,'maxDurationBars':0x3,'minQualityScore':0.15,'minVolumeRatio':0.3,'minBodyRatio':0.05},'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(_0x209a3a,_0x10be40,_0x4e3471,_0x278125,_0x73c79f=0x1){const _0xcada4c=_0x325534;this['type']=_0x209a3a,this['price']=_0x10be40,this[_0xcada4c(0xf9)]=_0x4e3471,this['timestamp']=_0x278125,this['strength']=_0x73c79f;}}class LiquidityZone{constructor(_0x22bc94,_0x4d8634,_0x5ca1c5,_0x1b646b,_0x4eeedf){const _0x270b3e=_0x325534;this['id']=uuidv4(),this[_0x270b3e(0xd6)]=_0x22bc94,this['priceHigh']=_0x4d8634,this['priceLow']=_0x5ca1c5,this[_0x270b3e(0x12f)]=_0x1b646b,this[_0x270b3e(0xf9)]=_0x4eeedf,this['touches']=0x1,this[_0x270b3e(0xb7)]=![],this['sweptAt']=null,this['lastUsedBarIndex']=-0x3e7,this['qualityScore']=0.5;}['containsPrice'](_0x321fd9,_0x39d734,_0x1baff3){const _0x234d0e=_0x39d734*_0x1baff3;return _0x321fd9>=this['priceLow']-_0x234d0e&&_0x321fd9<=this['priceHigh']+_0x234d0e;}['getLevel'](){const _0x419978=_0x325534;return(this['priceHigh']+this[_0x419978(0xcc)])/0x2;}}class SweepEvent{constructor(_0x5a946e,_0xe6d476,_0x40b2e1,_0x1f7ada,_0x301a65){const _0x5a8e6b=_0x325534;this[_0x5a8e6b(0xf8)]=_0x5a946e,this[_0x5a8e6b(0xb3)]=_0xe6d476,this[_0x5a8e6b(0xa3)]=_0x40b2e1,this['extremeBarIndex']=_0x1f7ada,this[_0x5a8e6b(0x116)]=_0x301a65,this[_0x5a8e6b(0x138)]=null,this[_0x5a8e6b(0x109)]=![],this[_0x5a8e6b(0x133)]=0x0,this[_0x5a8e6b(0x139)]=0x0,this['durationBars']=0x0,this[_0x5a8e6b(0xd1)]=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x4e18be={}){const _0x235b93=_0x325534;super(),this['config']=this[_0x235b93(0xab)](DEFAULT_CONFIG,_0x4e18be),this[_0x235b93(0xc5)]=this[_0x235b93(0x102)][_0x235b93(0xc5)],this[_0x235b93(0xb6)]=this['config']['tickValue'],this[_0x235b93(0xf7)]=new Map(),this['swingPoints']=new Map(),this[_0x235b93(0xa8)]=new Map(),this[_0x235b93(0x10c)]=new Map(),this['currentBar']=new Map(),this[_0x235b93(0xa7)]=0xea60,this[_0x235b93(0xd9)]=0x0,this[_0x235b93(0xbd)]=Date['now'](),this['stats']={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this[_0x235b93(0x12b)]=[];}[_0x325534(0xab)](_0x192878,_0x25f1c3){const _0x2fdb05=_0x325534,_0x4822e3={..._0x192878};for(const _0xa346f3 in _0x25f1c3){typeof _0x25f1c3[_0xa346f3]==='object'&&!Array[_0x2fdb05(0xb5)](_0x25f1c3[_0xa346f3])?_0x4822e3[_0xa346f3]={..._0x192878[_0xa346f3],..._0x25f1c3[_0xa346f3]}:_0x4822e3[_0xa346f3]=_0x25f1c3[_0xa346f3];}return _0x4822e3;}[_0x325534(0xf0)](_0x2eba64){const _0x1de0bb=_0x325534;if(!this[_0x1de0bb(0x102)][_0x1de0bb(0xc0)][_0x1de0bb(0x99)])return!![];const _0x399bb1=new Date(_0x2eba64),_0x3189d9=this[_0x1de0bb(0x10b)](_0x399bb1)?-0x4:-0x5,_0x153277=_0x399bb1['getUTCHours'](),_0x21b0d4=_0x399bb1['getUTCMinutes'](),_0x3c2f63=(_0x153277+_0x3189d9+0x18)%0x18,{startHour:_0x2aebdb,startMinute:_0x40ef55,endHour:_0x2ca589,endMinute:_0x5559c4}=this['config']['session'],_0x4e0185=_0x3c2f63*0x3c+_0x21b0d4,_0x151b5a=_0x2aebdb*0x3c+_0x40ef55,_0x2396eb=_0x2ca589*0x3c+_0x5559c4;return _0x4e0185>=_0x151b5a&&_0x4e0185<_0x2396eb;}[_0x325534(0x10b)](_0x205910){const _0x3e44d4=_0x325534,_0x5361b4=new Date(_0x205910[_0x3e44d4(0x137)](),0x0,0x1),_0x46c4f2=new Date(_0x205910['getFullYear'](),0x6,0x1),_0x1cff37=Math[_0x3e44d4(0x108)](_0x5361b4[_0x3e44d4(0xe0)](),_0x46c4f2[_0x3e44d4(0xe0)]());return _0x205910[_0x3e44d4(0xe0)]()<_0x1cff37;}['initialize'](_0x6ed6fd,_0x4df0ea=0.25,_0x2d172a=0x5){const _0x1b4635=_0x325534;this[_0x1b4635(0xc5)]=_0x4df0ea,this[_0x1b4635(0xb6)]=_0x2d172a,this['config'][_0x1b4635(0xc5)]=_0x4df0ea,this['config'][_0x1b4635(0xb6)]=_0x2d172a,this[_0x1b4635(0xf7)]['set'](_0x6ed6fd,[]),this[_0x1b4635(0x110)]['set'](_0x6ed6fd,[]),this['liquidityZones'][_0x1b4635(0x10a)](_0x6ed6fd,[]),this['activeSweeps']['set'](_0x6ed6fd,[]),this[_0x1b4635(0xa1)]['delete'](_0x6ed6fd),this[_0x1b4635(0xda)](_0x1b4635(0xa9),{'type':'info','message':_0x1b4635(0xa6)+_0x6ed6fd+':\x20tick='+_0x4df0ea+_0x1b4635(0xd0)+_0x2d172a+_0x1b4635(0x9f)}),this[_0x1b4635(0xda)](_0x1b4635(0xa9),{'type':'info','message':_0x1b4635(0xd7)+this['config'][_0x1b4635(0xa4)][_0x1b4635(0xec)]+_0x1b4635(0xf6)+this['config'][_0x1b4635(0xa4)]['targetTicks']+'t,\x20BE='+this['config']['execution']['breakevenTicks']+_0x1b4635(0xcb)+this['config'][_0x1b4635(0xa4)]['trailTriggerTicks']+'/'+this[_0x1b4635(0x102)][_0x1b4635(0xa4)][_0x1b4635(0x124)]});}[_0x325534(0x107)](_0x4691a0){const _0x32c57d=_0x325534,{contractId:_0x1edd94,price:_0x403520,volume:_0x5cde77,timestamp:_0x166e80}=_0x4691a0,_0x39f8c0=_0x166e80||Date[_0x32c57d(0xdd)](),_0x3e7178=_0x5cde77||0x1;if(!this['isWithinSession'](_0x39f8c0))return null;if(!this[_0x32c57d(0xbe)])this[_0x32c57d(0xbe)]=0x0;this[_0x32c57d(0xbe)]++;let _0xd983d7=this['currentBar'][_0x32c57d(0x120)](_0x1edd94);const _0x364715=Math['floor'](_0x39f8c0/this[_0x32c57d(0xa7)])*this['barIntervalMs'];if(!_0xd983d7||_0xd983d7['startTime']!==_0x364715){if(_0xd983d7){const _0x33d8ce={'timestamp':_0xd983d7[_0x32c57d(0xbd)],'open':_0xd983d7[_0x32c57d(0xf4)],'high':_0xd983d7['high'],'low':_0xd983d7[_0x32c57d(0xaa)],'close':_0xd983d7[_0x32c57d(0xc3)],'volume':_0xd983d7[_0x32c57d(0xd3)]},_0x22e17e=this['barHistory']['get'](_0x1edd94)||[];this[_0x32c57d(0xda)](_0x32c57d(0xa9),{'type':_0x32c57d(0x122),'message':_0x32c57d(0x9c)+(_0x22e17e[_0x32c57d(0x121)]+0x1)+_0x32c57d(0x136)+_0x33d8ce[_0x32c57d(0xc3)][_0x32c57d(0xfb)](0x2)+_0x32c57d(0x9b)+_0x33d8ce['open'][_0x32c57d(0xfb)](0x2)+'\x20H:'+_0x33d8ce['high'][_0x32c57d(0xfb)](0x2)+'\x20L:'+_0x33d8ce[_0x32c57d(0xaa)][_0x32c57d(0xfb)](0x2)+_0x32c57d(0xbc)+_0x33d8ce['volume']});const _0x240546=this['processBar'](_0x1edd94,_0x33d8ce);return this['currentBar'][_0x32c57d(0x10a)](_0x1edd94,{'startTime':_0x364715,'open':_0x403520,'high':_0x403520,'low':_0x403520,'close':_0x403520,'volume':_0x3e7178}),_0x240546;}else return this[_0x32c57d(0xa1)][_0x32c57d(0x10a)](_0x1edd94,{'startTime':_0x364715,'open':_0x403520,'high':_0x403520,'low':_0x403520,'close':_0x403520,'volume':_0x3e7178}),null;}else return _0xd983d7[_0x32c57d(0xe8)]=Math[_0x32c57d(0x108)](_0xd983d7['high'],_0x403520),_0xd983d7['low']=Math['min'](_0xd983d7[_0x32c57d(0xaa)],_0x403520),_0xd983d7[_0x32c57d(0xc3)]=_0x403520,_0xd983d7[_0x32c57d(0xd3)]+=_0x3e7178,null;}[_0x325534(0xf3)](_0x4fc6a7){const _0x3bfe5e=_0x325534;return this[_0x3bfe5e(0x107)](_0x4fc6a7);}[_0x325534(0xd8)](_0x5c5ae3){const _0x6d103=_0x325534;return this[_0x6d103(0x107)]({'contractId':_0x5c5ae3[_0x6d103(0xc7)]||_0x5c5ae3[_0x6d103(0xe3)],'price':_0x5c5ae3['price'],'volume':_0x5c5ae3[_0x6d103(0x128)]||_0x5c5ae3[_0x6d103(0xd3)]||0x1,'timestamp':_0x5c5ae3['timestamp']||Date['now']()});}['processBar'](_0x36d1d9,_0x81c06c){const _0x4b3ecf=_0x325534;let _0x2552b6=this['barHistory'][_0x4b3ecf(0x120)](_0x36d1d9);!_0x2552b6&&(this[_0x4b3ecf(0xe7)](_0x36d1d9),_0x2552b6=this[_0x4b3ecf(0xf7)][_0x4b3ecf(0x120)](_0x36d1d9));_0x2552b6[_0x4b3ecf(0x117)](_0x81c06c);if(_0x2552b6[_0x4b3ecf(0x121)]>0x1f4)_0x2552b6[_0x4b3ecf(0xba)]();const _0x28f329=_0x2552b6['length']-0x1;if(_0x2552b6[_0x4b3ecf(0x121)]<this[_0x4b3ecf(0x102)][_0x4b3ecf(0x106)]['lookbackBars']*0x3)return null;const _0x19678d=this['swingPoints'][_0x4b3ecf(0x120)](_0x36d1d9)[_0x4b3ecf(0x121)];this['_detectSwings'](_0x36d1d9,_0x2552b6,_0x28f329);const _0x140e76=this['swingPoints']['get'](_0x36d1d9);if(_0x140e76['length']>_0x19678d){const _0x482760=_0x140e76[_0x140e76['length']-0x1];this['emit']('log',{'type':'debug','message':_0x4b3ecf(0xed)+_0x482760[_0x4b3ecf(0xd6)]['toUpperCase']()+_0x4b3ecf(0x132)+_0x482760[_0x4b3ecf(0x115)][_0x4b3ecf(0xfb)](0x2)+_0x4b3ecf(0x127)+_0x140e76['length']});}const _0x134d9b=this['_detectSweep'](_0x36d1d9,_0x2552b6,_0x28f329);_0x134d9b&&this['emit'](_0x4b3ecf(0xa9),{'type':'debug','message':'[2B]\x20SWEEP\x20'+_0x134d9b['sweepType']+_0x4b3ecf(0xc2)+_0x134d9b[_0x4b3ecf(0x109)]+_0x4b3ecf(0xb4)+_0x134d9b[_0x4b3ecf(0x139)]['toFixed'](0x1)+_0x4b3ecf(0x104)+(_0x134d9b[_0x4b3ecf(0x133)]*0x64)['toFixed'](0x0)+'%'});const _0x142917=this[_0x4b3ecf(0xa8)]['get'](_0x36d1d9)[_0x4b3ecf(0x121)];this[_0x4b3ecf(0x101)](_0x36d1d9,_0x28f329);const _0x2b00ad=this['liquidityZones']['get'](_0x36d1d9);if(_0x2b00ad['length']>_0x142917){const _0x5d62ad=_0x2b00ad[_0x2b00ad[_0x4b3ecf(0x121)]-0x1];this[_0x4b3ecf(0xda)](_0x4b3ecf(0xa9),{'type':_0x4b3ecf(0x122),'message':'[2B]\x20NEW\x20ZONE\x20'+_0x5d62ad[_0x4b3ecf(0xd6)][_0x4b3ecf(0xdc)]()+'\x20@\x20'+_0x5d62ad[_0x4b3ecf(0xee)]()['toFixed'](0x2)+'\x20|\x20Total:\x20'+_0x2b00ad[_0x4b3ecf(0x121)]});}if(_0x134d9b&&_0x134d9b[_0x4b3ecf(0x109)]){this['emit']('log',{'type':'debug','message':'[2B]\x20Calling\x20_generateSignal\x20for\x20'+_0x134d9b[_0x4b3ecf(0xf8)]+'\x20sweep...'});const _0x460a38=this['_generateSignal'](_0x36d1d9,_0x81c06c,_0x28f329,_0x134d9b);return!_0x460a38&&this[_0x4b3ecf(0xda)](_0x4b3ecf(0xa9),{'type':'debug','message':'[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)'}),_0x460a38;}return null;}['_detectSwings'](_0x3352dd,_0x4352e6,_0x261c82){const _0xa27a06=_0x325534,_0x4b1004=this['config'][_0xa27a06(0x106)]['lookbackBars'],_0x1c182f=this['config'][_0xa27a06(0x106)][_0xa27a06(0xad)];if(_0x261c82<_0x4b1004*0x2)return;const _0x2b8d73=this[_0xa27a06(0x110)]['get'](_0x3352dd),_0x813756=_0x261c82-_0x4b1004,_0x47d72f=_0x4352e6[_0x813756];_0x261c82%0x5===0x0&&this[_0xa27a06(0xda)]('log',{'type':_0xa27a06(0x122),'message':'[SWING]\x20Checking\x20pivot\x20at\x20bar\x20'+_0x813756+_0xa27a06(0xc8)+_0x47d72f['high']['toFixed'](0x2)+'\x20L:'+_0x47d72f[_0xa27a06(0xaa)][_0xa27a06(0xfb)](0x2)+'\x20|\x20Total\x20swings:\x20'+_0x2b8d73['length']});let _0xd121b6=!![],_0x25dfa4=0x0;for(let _0x53f5ac=_0x813756-_0x4b1004;_0x53f5ac<=_0x813756+_0x4b1004;_0x53f5ac++){if(_0x53f5ac===_0x813756||_0x53f5ac<0x0||_0x53f5ac>=_0x4352e6['length'])continue;if(_0x4352e6[_0x53f5ac][_0xa27a06(0xe8)]>=_0x47d72f[_0xa27a06(0xe8)]){_0xd121b6=![];break;}_0x25dfa4++;}if(_0xd121b6&&_0x25dfa4>=_0x1c182f){const _0x1c82b0=_0x2b8d73['find'](_0xa3381a=>_0xa3381a[_0xa27a06(0xf9)]===_0x813756&&_0xa3381a['type']===_0xa27a06(0xe8));!_0x1c82b0&&(_0x2b8d73['push'](new SwingPoint('high',_0x47d72f['high'],_0x813756,_0x47d72f['timestamp'],_0x25dfa4)),this[_0xa27a06(0xda)](_0xa27a06(0xa9),{'type':_0xa27a06(0x122),'message':'[SWING]\x20NEW\x20HIGH\x20@\x20'+_0x47d72f['high'][_0xa27a06(0xfb)](0x2)+_0xa27a06(0xcd)+_0x813756+'\x20|\x20Strength:\x20'+_0x25dfa4}));}let _0x4091c8=!![],_0x4ccdf6=0x0;for(let _0x5b6490=_0x813756-_0x4b1004;_0x5b6490<=_0x813756+_0x4b1004;_0x5b6490++){if(_0x5b6490===_0x813756||_0x5b6490<0x0||_0x5b6490>=_0x4352e6['length'])continue;if(_0x4352e6[_0x5b6490]['low']<=_0x47d72f['low']){_0x4091c8=![];break;}_0x4ccdf6++;}if(_0x4091c8&&_0x4ccdf6>=_0x1c182f){const _0x4e1bbc=_0x2b8d73['find'](_0x165c6a=>_0x165c6a['barIndex']===_0x813756&&_0x165c6a[_0xa27a06(0xd6)]==='low');!_0x4e1bbc&&(_0x2b8d73['push'](new SwingPoint(_0xa27a06(0xaa),_0x47d72f['low'],_0x813756,_0x47d72f['timestamp'],_0x4ccdf6)),this['emit'](_0xa27a06(0xa9),{'type':'debug','message':'[SWING]\x20NEW\x20LOW\x20@\x20'+_0x47d72f['low']['toFixed'](0x2)+'\x20|\x20Bar\x20'+_0x813756+'\x20|\x20Strength:\x20'+_0x4ccdf6}));}const _0x402858=this['config']['zone']['maxZoneAgeBars'];while(_0x2b8d73['length']>0x0&&_0x2b8d73[0x0][_0xa27a06(0xf9)]<_0x261c82-_0x402858){_0x2b8d73['shift']();}}[_0x325534(0x101)](_0x149871,_0x2fcdaa){const _0x34673f=_0x325534,_0x2cc478=this['swingPoints'][_0x34673f(0x120)](_0x149871),_0x267f93=this['liquidityZones'][_0x34673f(0x120)](_0x149871),_0x43f227=this[_0x34673f(0x102)][_0x34673f(0xb3)]['clusterToleranceTicks']*this[_0x34673f(0xc5)],_0x58b24e=this[_0x34673f(0x102)][_0x34673f(0xb3)]['maxZoneAgeBars'];for(let _0x453fa1=_0x267f93['length']-0x1;_0x453fa1>=0x0;_0x453fa1--){_0x2fcdaa-_0x267f93[_0x453fa1]['barIndex']>_0x58b24e&&_0x267f93[_0x34673f(0xc1)](_0x453fa1,0x1);}for(const _0x3beb56 of _0x2cc478){let _0x4592ad=null;for(const _0x87bc70 of _0x267f93){if(_0x87bc70[_0x34673f(0x10f)](_0x3beb56[_0x34673f(0x115)],this['config'][_0x34673f(0xb3)][_0x34673f(0xfd)],this[_0x34673f(0xc5)])){_0x4592ad=_0x87bc70;break;}}if(_0x4592ad){_0x4592ad['touches']++;if(_0x3beb56['price']>_0x4592ad[_0x34673f(0xe4)])_0x4592ad['priceHigh']=_0x3beb56[_0x34673f(0x115)];if(_0x3beb56['price']<_0x4592ad[_0x34673f(0xcc)])_0x4592ad[_0x34673f(0xcc)]=_0x3beb56[_0x34673f(0x115)];_0x4592ad['qualityScore']=Math[_0x34673f(0x111)](0x1,0.3+_0x4592ad['touches']*0.15);}else{const _0x3777dc=_0x3beb56[_0x34673f(0xd6)]===_0x34673f(0xe8)?ZoneType['RESISTANCE']:ZoneType[_0x34673f(0x125)],_0x12753a=new LiquidityZone(_0x3777dc,_0x3beb56[_0x34673f(0x115)]+_0x43f227/0x2,_0x3beb56[_0x34673f(0x115)]-_0x43f227/0x2,_0x3beb56[_0x34673f(0x9d)],_0x3beb56['barIndex']);_0x12753a['qualityScore']=0.3+_0x3beb56[_0x34673f(0xd5)]*0.1,_0x267f93['push'](_0x12753a);}}}['_detectSweep'](_0x569806,_0x10afdd,_0x5a314f){const _0x411b7b=_0x325534,_0x4d5605=this[_0x411b7b(0xa8)]['get'](_0x569806),_0x3c9006=_0x10afdd[_0x5a314f],_0x4185c7=_0x3c9006[_0x411b7b(0xc3)],_0x52df7c=this['config']['sweep'],_0x3fdae0=this[_0x411b7b(0x102)][_0x411b7b(0xb3)];for(const _0x438117 of _0x4d5605){if(_0x438117[_0x411b7b(0x12c)]>=0x0&&_0x5a314f-_0x438117[_0x411b7b(0x12c)]<_0x3fdae0['cooldownBars'])continue;const _0x17dd89=_0x438117[_0x411b7b(0xee)](),_0x10f7d9=Math[_0x411b7b(0xbb)](_0x4185c7-_0x17dd89)/this[_0x411b7b(0xc5)];if(_0x10f7d9>_0x3fdae0['maxZoneDistanceTicks'])continue;const _0x3bfd19=Math[_0x411b7b(0x108)](0x0,_0x5a314f-_0x52df7c[_0x411b7b(0xf1)]*0x2);for(let _0x5229b8=_0x3bfd19;_0x5229b8<_0x5a314f;_0x5229b8++){const _0x5d40c9=_0x10afdd[_0x5229b8];if(_0x438117['type']===ZoneType[_0x411b7b(0x11c)]){const _0x109ba9=(_0x5d40c9['high']-_0x438117[_0x411b7b(0xe4)])/this[_0x411b7b(0xc5)];if(_0x109ba9>=_0x52df7c['minPenetrationTicks']&&_0x109ba9<=_0x52df7c[_0x411b7b(0xfc)]){const _0x28d8b4=Math[_0x411b7b(0x111)](_0x438117[_0x411b7b(0xe4)],_0x438117[_0x411b7b(0xe4)]+_0x109ba9*this['tickSize']);if(_0x4185c7<_0x28d8b4+this['tickSize']*0x2){const _0x533df8=_0x5d40c9[_0x411b7b(0xe8)]-_0x5d40c9[_0x411b7b(0xaa)],_0x5a9038=Math['abs'](_0x5d40c9[_0x411b7b(0xc3)]-_0x5d40c9[_0x411b7b(0xf4)]),_0x3830d7=_0x533df8>0x0?_0x5a9038/_0x533df8:0x0;if(_0x3830d7>=_0x52df7c[_0x411b7b(0x100)]){const _0x12fa01=this[_0x411b7b(0xe6)](_0x10afdd,_0x5229b8,0x14);if(_0x12fa01>=_0x52df7c[_0x411b7b(0xc6)]){const _0x4fbf0f=new SweepEvent(SweepType[_0x411b7b(0xaf)],_0x438117,_0x5229b8,_0x5229b8,_0x5d40c9[_0x411b7b(0xe8)]);_0x4fbf0f['exitBarIndex']=_0x5a314f,_0x4fbf0f[_0x411b7b(0x139)]=_0x109ba9,_0x4fbf0f['durationBars']=_0x5a314f-_0x5229b8,_0x4fbf0f['volumeRatio']=_0x12fa01,_0x4fbf0f[_0x411b7b(0x133)]=this[_0x411b7b(0xeb)](_0x4fbf0f,_0x3830d7),_0x4fbf0f[_0x411b7b(0x109)]=_0x4fbf0f['qualityScore']>=_0x52df7c['minQualityScore'];if(_0x4fbf0f[_0x411b7b(0x109)])return _0x4fbf0f;}}}}}if(_0x438117[_0x411b7b(0xd6)]===ZoneType['SUPPORT']){const _0x19689a=(_0x438117['priceLow']-_0x5d40c9[_0x411b7b(0xaa)])/this[_0x411b7b(0xc5)];if(_0x19689a>=_0x52df7c[_0x411b7b(0x12d)]&&_0x19689a<=_0x52df7c['maxPenetrationTicks']){const _0x2a61af=Math['max'](_0x438117['priceLow'],_0x438117[_0x411b7b(0xcc)]-_0x19689a*this['tickSize']);if(_0x4185c7>_0x2a61af-this['tickSize']*0x2){const _0x34dc1f=_0x5d40c9['high']-_0x5d40c9[_0x411b7b(0xaa)],_0xccffee=Math['abs'](_0x5d40c9[_0x411b7b(0xc3)]-_0x5d40c9[_0x411b7b(0xf4)]),_0x57beed=_0x34dc1f>0x0?_0xccffee/_0x34dc1f:0x0;if(_0x57beed>=_0x52df7c[_0x411b7b(0x100)]){const _0x145aa3=this['_getVolumeRatio'](_0x10afdd,_0x5229b8,0x14);if(_0x145aa3>=_0x52df7c['minVolumeRatio']){const _0x9d8590=new SweepEvent(SweepType[_0x411b7b(0xd4)],_0x438117,_0x5229b8,_0x5229b8,_0x5d40c9[_0x411b7b(0xaa)]);_0x9d8590[_0x411b7b(0x138)]=_0x5a314f,_0x9d8590['penetrationTicks']=_0x19689a,_0x9d8590[_0x411b7b(0x126)]=_0x5a314f-_0x5229b8,_0x9d8590['volumeRatio']=_0x145aa3,_0x9d8590[_0x411b7b(0x133)]=this[_0x411b7b(0xeb)](_0x9d8590,_0x57beed),_0x9d8590['isValid']=_0x9d8590[_0x411b7b(0x133)]>=_0x52df7c['minQualityScore'];if(_0x9d8590[_0x411b7b(0x109)])return _0x9d8590;}}}}}}}return null;}[_0x325534(0xe6)](_0x4025d9,_0x51497f,_0x5d0021){const _0x54c5cf=_0x325534,_0x4ace2c=Math[_0x54c5cf(0x108)](0x0,_0x51497f-_0x5d0021),_0x1cf267=_0x4025d9['slice'](_0x4ace2c,_0x51497f);if(_0x1cf267['length']===0x0)return 0x1;const _0x3125cb=_0x1cf267[_0x54c5cf(0x118)](_0x54554d=>_0x54554d[_0x54c5cf(0xd3)])[_0x54c5cf(0xb9)]((_0xcf6dd3,_0x1efa56)=>_0xcf6dd3-_0x1efa56),_0x11d446=Math['floor'](_0x3125cb[_0x54c5cf(0x121)]/0x2),_0x3189b6=_0x3125cb[_0x11d446]||0x1;return _0x4025d9[_0x51497f]['volume']/_0x3189b6;}[_0x325534(0xeb)](_0x2f55b4,_0x32dc57){const _0x278521=_0x325534;let _0x5a9c53=0x0;const _0xfe5abe=0x4,_0x540105=Math[_0x278521(0xbb)](_0x2f55b4['penetrationTicks']-_0xfe5abe);return _0x5a9c53+=Math[_0x278521(0x108)](0x0,0.3-_0x540105*0.03),_0x5a9c53+=Math[_0x278521(0x108)](0x0,0.25-_0x2f55b4['durationBars']*0.05),_0x5a9c53+=Math['min'](0.25,_0x2f55b4['volumeRatio']*0.1),_0x5a9c53+=Math['min'](0.2,_0x32dc57*0.4),Math['min'](0x1,_0x5a9c53);}['_generateSignal'](_0x41ae03,_0x5b42fc,_0x3bf308,_0x36d1c0){const _0x5d2b67=_0x325534,_0x3f05b5=Date[_0x5d2b67(0xdd)]()-this['lastSignalTime'];if(_0x3f05b5<this['config'][_0x5d2b67(0xa4)]['cooldownMs'])return this['emit'](_0x5d2b67(0xa9),{'type':'debug','message':_0x5d2b67(0x11f)+(_0x3f05b5/0x3e8)['toFixed'](0x1)+'s\x20<\x20'+this['config'][_0x5d2b67(0xa4)][_0x5d2b67(0xa0)]/0x3e8+'s)'}),null;const _0x4955f9=this[_0x5d2b67(0x102)]['execution'],_0x1f426b=_0x5b42fc['close'],_0x100aa0=_0x36d1c0['sweepType']===SweepType['HIGH_SWEEP']?_0x5d2b67(0xe9):_0x5d2b67(0xc9);let _0x2861ee,_0x35e125,_0x38561e,_0x4bdd6a;_0x100aa0==='long'?(_0x2861ee=_0x1f426b-_0x4955f9[_0x5d2b67(0xec)]*this['tickSize'],_0x35e125=_0x1f426b+_0x4955f9['targetTicks']*this[_0x5d2b67(0xc5)],_0x38561e=_0x1f426b+_0x4955f9[_0x5d2b67(0xdb)]*this[_0x5d2b67(0xc5)],_0x4bdd6a=_0x1f426b+_0x4955f9['trailTriggerTicks']*this['tickSize']):(_0x2861ee=_0x1f426b+_0x4955f9[_0x5d2b67(0xec)]*this[_0x5d2b67(0xc5)],_0x35e125=_0x1f426b-_0x4955f9['targetTicks']*this[_0x5d2b67(0xc5)],_0x38561e=_0x1f426b-_0x4955f9[_0x5d2b67(0xdb)]*this[_0x5d2b67(0xc5)],_0x4bdd6a=_0x1f426b-_0x4955f9[_0x5d2b67(0xd2)]*this[_0x5d2b67(0xc5)]);const _0x2621ca=_0x4955f9['targetTicks']/_0x4955f9[_0x5d2b67(0xec)],_0x4e713d=Math[_0x5d2b67(0x111)](0x1,_0x36d1c0['qualityScore']*0.5+_0x36d1c0['zone']['qualityScore']*0.3+(_0x36d1c0['volumeRatio']>1.5?0.2:_0x36d1c0['volumeRatio']*0.1));let _0x567d21=SignalStrength[_0x5d2b67(0xdf)];if(_0x4e713d>=0.8)_0x567d21=SignalStrength[_0x5d2b67(0xe5)];else{if(_0x4e713d>=0.65)_0x567d21=SignalStrength['STRONG'];else{if(_0x4e713d<0.5)_0x567d21=SignalStrength['WEAK'];}}const _0x2c5256=0.5+(_0x4e713d-0.5)*0.4,_0x19cf9a=_0x2c5256*Math[_0x5d2b67(0xbb)](_0x35e125-_0x1f426b)-(0x1-_0x2c5256)*Math['abs'](_0x1f426b-_0x2861ee);_0x36d1c0[_0x5d2b67(0xb3)][_0x5d2b67(0x12c)]=_0x3bf308,_0x36d1c0['zone']['swept']=!![],_0x36d1c0[_0x5d2b67(0xb3)]['sweptAt']=new Date(_0x5b42fc[_0x5d2b67(0x9d)]),this['lastSignalTime']=Date['now'](),this[_0x5d2b67(0x134)]['signals']++;const _0x21bd98={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0x41ae03[_0x5d2b67(0xb0)]('.')[0x0]||_0x41ae03,'contractId':_0x41ae03,'side':_0x100aa0==='long'?OrderSide['BID']:OrderSide['ASK'],'direction':_0x100aa0,'strategy':'HQX_2B_LIQUIDITY_SWEEP','strength':_0x567d21,'edge':_0x19cf9a,'confidence':_0x4e713d,'entry':_0x1f426b,'entryPrice':_0x1f426b,'stopLoss':_0x2861ee,'takeProfit':_0x35e125,'riskReward':_0x2621ca,'stopTicks':_0x4955f9[_0x5d2b67(0xec)],'targetTicks':_0x4955f9[_0x5d2b67(0xbf)],'breakevenTicks':_0x4955f9[_0x5d2b67(0xdb)],'trailTriggerTicks':_0x4955f9['trailTriggerTicks'],'trailDistanceTicks':_0x4955f9['trailDistanceTicks'],'beLevel':_0x38561e,'trailTrigger':_0x4bdd6a,'sweepType':_0x36d1c0[_0x5d2b67(0xf8)],'penetrationTicks':_0x36d1c0['penetrationTicks'],'sweepDurationBars':_0x36d1c0['durationBars'],'sweepQuality':_0x36d1c0['qualityScore'],'volumeRatio':_0x36d1c0['volumeRatio'],'zoneType':_0x36d1c0['zone'][_0x5d2b67(0xd6)],'zoneLevel':_0x36d1c0[_0x5d2b67(0xb3)]['getLevel'](),'zoneTouches':_0x36d1c0[_0x5d2b67(0xb3)]['touches'],'zoneQuality':_0x36d1c0[_0x5d2b67(0xb3)][_0x5d2b67(0x133)],'expires':Date['now']()+0xea60};return this[_0x5d2b67(0xda)](_0x5d2b67(0xca),{'side':_0x100aa0===_0x5d2b67(0xc9)?_0x5d2b67(0xa2):'sell','action':_0x5d2b67(0xf4),'reason':'2B\x20'+_0x36d1c0['sweepType']+'\x20|\x20Pen:'+_0x36d1c0[_0x5d2b67(0x139)]['toFixed'](0x1)+'t\x20|\x20Vol:'+_0x36d1c0[_0x5d2b67(0xd1)][_0x5d2b67(0xfb)](0x1)+'x\x20|\x20Q:'+(_0x36d1c0['qualityScore']*0x64)['toFixed'](0x0)+'%',..._0x21bd98}),this[_0x5d2b67(0xda)](_0x5d2b67(0xa9),{'type':'info','message':'[HQX-2B]\x20SIGNAL:\x20'+_0x100aa0['toUpperCase']()+'\x20@\x20'+_0x1f426b['toFixed'](0x2)+_0x5d2b67(0xcf)+_0x36d1c0[_0x5d2b67(0xf8)]+_0x5d2b67(0x129)+_0x36d1c0['penetrationTicks'][_0x5d2b67(0xfb)](0x1)+'t\x20Vol:'+_0x36d1c0['volumeRatio']['toFixed'](0x1)+_0x5d2b67(0x98)+(_0x4e713d*0x64)['toFixed'](0x0)+'%'}),_0x21bd98;}[_0x325534(0x105)](_0x547907,_0x6e492e){const _0x5471b9=_0x325534,_0x473af6=this['barHistory']['get'](_0x547907)||[],_0x3df5c3=this['liquidityZones'][_0x5471b9(0x120)](_0x547907)||[],_0xb3a105=this['swingPoints']['get'](_0x547907)||[];if(_0x473af6[_0x5471b9(0x121)]<0x3)return{'ready':![],'message':_0x5471b9(0x103)+_0x473af6[_0x5471b9(0x121)]+'/3\x20bars'};const _0xcc2703=_0x3df5c3['map'](_0x16e3d8=>({'zone':_0x16e3d8,'distance':Math['abs'](_0x6e492e-_0x16e3d8['getLevel']())}))[_0x5471b9(0xb9)]((_0x4c9114,_0x3bd713)=>_0x4c9114['distance']-_0x3bd713[_0x5471b9(0x11d)]),_0x2cda5a=_0xcc2703['find'](_0x4964b2=>_0x4964b2[_0x5471b9(0xb3)][_0x5471b9(0xd6)]===ZoneType['RESISTANCE']),_0x3b6222=_0xcc2703['find'](_0x2a5e22=>_0x2a5e22['zone']['type']===ZoneType['SUPPORT']);return{'ready':!![],'barsProcessed':_0x473af6['length'],'swingsDetected':_0xb3a105[_0x5471b9(0x121)],'activeZones':_0x3df5c3['length'],'nearestResistance':_0x2cda5a?_0x2cda5a['zone']['getLevel']():null,'nearestSupport':_0x3b6222?_0x3b6222['zone']['getLevel']():null,'stopTicks':this[_0x5471b9(0x102)]['execution']['stopTicks'],'targetTicks':this[_0x5471b9(0x102)]['execution']['targetTicks'],'strategy':_0x5471b9(0xb8)};}[_0x325534(0xc4)](_0x36d10f){const _0x319a75=_0x325534;this[_0x319a75(0x12b)][_0x319a75(0x117)]({'netPnl':_0x36d10f,'timestamp':Date[_0x319a75(0xdd)]()});if(this['recentTrades'][_0x319a75(0x121)]>0x64)this['recentTrades']['shift']();_0x36d10f>0x0?this[_0x319a75(0x134)]['wins']++:this['stats'][_0x319a75(0xfe)]++,this['stats']['trades']++,this['stats']['pnl']+=_0x36d10f,this['emit'](_0x319a75(0xa9),{'type':'debug','message':_0x319a75(0xe1)+(_0x36d10f>0x0?'WIN':_0x319a75(0xea))+'\x20$'+_0x36d10f['toFixed'](0x2)});}[_0x325534(0x10e)](_0x29640c){const _0xb10092=_0x325534;return this[_0xb10092(0xf7)][_0xb10092(0x120)](_0x29640c)||[];}['getStats'](){const _0x4211e2=_0x325534;return this[_0x4211e2(0x134)];}['getHealthStatus'](_0x5a8f90){const _0x359f64=_0x325534,_0x4ef6be=this[_0x359f64(0xf7)][_0x359f64(0x120)](_0x5a8f90)||[],_0x36a55d=this[_0x359f64(0xa8)][_0x359f64(0x120)](_0x5a8f90)||[],_0x1f548c=this[_0x359f64(0x110)]['get'](_0x5a8f90)||[],_0x16e62b=this[_0x359f64(0xa1)]['get'](_0x5a8f90),_0x3e6da2=_0x4ef6be[_0x4ef6be[_0x359f64(0x121)]-0x1],_0x31ddce=_0x3e6da2?Date['now']()-_0x3e6da2['timestamp']:null,_0x1219e3=_0x36a55d['filter'](_0x3b640b=>_0x3b640b['type']===ZoneType['RESISTANCE'])['length'],_0x40103d=_0x36a55d[_0x359f64(0x10d)](_0x3087a0=>_0x3087a0['type']===ZoneType[_0x359f64(0x125)])[_0x359f64(0x121)];return{'healthy':_0x4ef6be['length']>=0x5,'barsTotal':_0x4ef6be['length'],'barsLast5Min':_0x4ef6be[_0x359f64(0x10d)](_0x55e09a=>Date['now']()-_0x55e09a[_0x359f64(0x9d)]<0x5*0x3c*0x3e8)[_0x359f64(0x121)],'swingsTotal':_0x1f548c['length'],'zonesResistance':_0x1219e3,'zonesSupport':_0x40103d,'zonesTotal':_0x36a55d['length'],'currentBarTicks':_0x16e62b?_0x16e62b['tickCount']:0x0,'isAggregating':_0x16e62b&&_0x16e62b['tickCount']>0x0,'timeSinceLastBarMs':_0x31ddce,'lastSignalTime':this[_0x359f64(0xd9)],'signalCooldownMs':this[_0x359f64(0x102)]['execution']['cooldownMs'],'uptime':Date['now']()-(this[_0x359f64(0xbd)]||Date['now']())};}['reset'](_0x55f4c1){const _0x2ffb76=_0x325534;this[_0x2ffb76(0xf7)][_0x2ffb76(0x10a)](_0x55f4c1,[]),this['swingPoints']['set'](_0x55f4c1,[]),this[_0x2ffb76(0xa8)]['set'](_0x55f4c1,[]),this[_0x2ffb76(0x10c)][_0x2ffb76(0x10a)](_0x55f4c1,[]),this[_0x2ffb76(0xa1)][_0x2ffb76(0xff)](_0x55f4c1),this[_0x2ffb76(0xda)](_0x2ffb76(0xa9),{'type':'info','message':'[HQX-2B]\x20Reset\x20state\x20for\x20'+_0x55f4c1});}[_0x325534(0xb1)](_0x4a1fbd,_0x3adb26){const _0x5e3fdd=_0x325534;if(!_0x3adb26||_0x3adb26[_0x5e3fdd(0x121)]===0x0){this[_0x5e3fdd(0xda)]('log',{'type':'debug','message':'[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload'});return;}!this['barHistory'][_0x5e3fdd(0x12e)](_0x4a1fbd)&&this['initialize'](_0x4a1fbd);const _0x3a0d19=[..._0x3adb26][_0x5e3fdd(0xb9)]((_0x2cc5c9,_0x12f3f5)=>_0x2cc5c9[_0x5e3fdd(0x9d)]-_0x12f3f5[_0x5e3fdd(0x9d)]);this['emit'](_0x5e3fdd(0xa9),{'type':_0x5e3fdd(0x119),'message':'[HQX-2B]\x20Preloading\x20'+_0x3a0d19[_0x5e3fdd(0x121)]+_0x5e3fdd(0xde)});let _0x138c10=0x0;for(const _0x406f6b of _0x3a0d19){const _0x7742ea=this[_0x5e3fdd(0xce)](_0x4a1fbd,_0x406f6b);if(_0x7742ea)_0x138c10++;}const _0x50d4ad=this['barHistory'][_0x5e3fdd(0x120)](_0x4a1fbd)||[],_0x5bf6c4=this['swingPoints']['get'](_0x4a1fbd)||[],_0x2584b7=this['liquidityZones']['get'](_0x4a1fbd)||[];this[_0x5e3fdd(0xda)]('log',{'type':'info','message':'[HQX-2B]\x20Preload\x20complete:\x20'+_0x50d4ad['length']+_0x5e3fdd(0x113)+_0x5bf6c4['length']+_0x5e3fdd(0x123)+_0x2584b7[_0x5e3fdd(0x121)]+_0x5e3fdd(0xac)}),_0x138c10>0x0&&this[_0x5e3fdd(0xda)]('log',{'type':'debug','message':_0x5e3fdd(0x135)+_0x138c10+_0x5e3fdd(0x11a)}),this[_0x5e3fdd(0xd9)]=0x0;}}class HQX2BStrategy extends EventEmitter{constructor(_0x86b111={}){const _0x4e13bd=_0x325534;super(),this[_0x4e13bd(0x102)]=_0x86b111,this['strategy']=new HQX2BLiquiditySweep(_0x86b111),this['strategy']['on']('signal',_0x2cafe4=>this['emit']('signal',_0x2cafe4)),this['strategy']['on'](_0x4e13bd(0xa9),_0x4f1fd6=>this['emit']('log',_0x4f1fd6));}[_0x325534(0x107)](_0x3381cb){return this['strategy']['processTick'](_0x3381cb);}[_0x325534(0xf3)](_0xfc5468){const _0x4a9c91=_0x325534;return this[_0x4a9c91(0xef)]['onTick'](_0xfc5468);}[_0x325534(0xd8)](_0xf835c1){const _0x5ceaa3=_0x325534;return this['strategy'][_0x5ceaa3(0xd8)](_0xf835c1);}[_0x325534(0xce)](_0x4dc798,_0x2979fb){const _0x4f364e=_0x325534;return this['strategy'][_0x4f364e(0xce)](_0x4dc798,_0x2979fb);}[_0x325534(0xe7)](_0x4a4a7e,_0x199f01,_0x2c4233){const _0x229614=_0x325534;return this[_0x229614(0xef)][_0x229614(0xe7)](_0x4a4a7e,_0x199f01,_0x2c4233);}['getAnalysisState'](_0x25a629,_0x346c94){const _0x147dd8=_0x325534;return this[_0x147dd8(0xef)][_0x147dd8(0x105)](_0x25a629,_0x346c94);}[_0x325534(0xc4)](_0x10b600){const _0x4a436e=_0x325534;return this['strategy'][_0x4a436e(0xc4)](_0x10b600);}[_0x325534(0x9a)](_0x280d61){const _0x360ec0=_0x325534;return this[_0x360ec0(0xef)]['reset'](_0x280d61);}['getStats'](){const _0x3f5b4b=_0x325534;return this['strategy'][_0x3f5b4b(0xf2)]();}[_0x325534(0x10e)](_0x4aec03){const _0x20b85d=_0x325534;return this['strategy'][_0x20b85d(0x10e)](_0x4aec03);}[_0x325534(0xb1)](_0x521b97,_0x623b2a){const _0x5c52b3=_0x325534;return this['strategy'][_0x5c52b3(0xb1)](_0x521b97,_0x623b2a);}[_0x325534(0x11b)](_0x2a470f){const _0x115e1b=_0x325534;return this[_0x115e1b(0xef)]['getHealthStatus'](_0x2a470f);}['generateSignal'](_0x47b147){return null;}}module[_0x325534(0x12a)]={'HQX2BLiquiditySweep':HQX2BLiquiditySweep,'HQX2BStrategy':HQX2BStrategy,'M2':HQX2BStrategy,'S2':HQX2BLiquiditySweep,'OrderSide':OrderSide,'SignalStrength':SignalStrength,'SweepType':SweepType,'ZoneType':ZoneType,'DEFAULT_CONFIG':DEFAULT_CONFIG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x3f38f4=_0x30a6;(function(_0x3c3e69,_0x1223f4){const _0x5e8f56=_0x30a6,_0xb5f6d7=_0x3c3e69();while(!![]){try{const _0x303347=-parseInt(_0x5e8f56(0x127))/0x1*(parseInt(_0x5e8f56(0x104))/0x2)+-parseInt(_0x5e8f56(0x113))/0x3+parseInt(_0x5e8f56(0x14b))/0x4+-parseInt(_0x5e8f56(0x126))/0x5+parseInt(_0x5e8f56(0xfa))/0x6+-parseInt(_0x5e8f56(0x139))/0x7*(-parseInt(_0x5e8f56(0x155))/0x8)+parseInt(_0x5e8f56(0x144))/0x9*(-parseInt(_0x5e8f56(0x159))/0xa);if(_0x303347===_0x1223f4)break;else _0xb5f6d7['push'](_0xb5f6d7['shift']());}catch(_0x5e1db9){_0xb5f6d7['push'](_0xb5f6d7['shift']());}}}(_0x492e,0xf0c16));const EventEmitter=require(_0x3f38f4(0x117)),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};class HQXUltraScalping extends EventEmitter{constructor(_0x3c54c6={}){const _0x5be687=_0x3f38f4;super(),this[_0x5be687(0x132)]=_0x3c54c6[_0x5be687(0x132)]||0.25,this['tickValue']=_0x3c54c6[_0x5be687(0xff)]||0x5,this[_0x5be687(0x10e)]=1.5,this[_0x5be687(0x135)]=0.5,this['vpinWindow']=0x32,this[_0x5be687(0x152)]=0.7,this[_0x5be687(0x14d)]=0.01,this['kalmanMeasurementNoise']=0.1,this[_0x5be687(0x140)]=0x64,this['ofiLookback']=0x14,this['baseStopTicks']=0x8,this[_0x5be687(0x120)]=0x10,this['breakevenTicks']=0x4,this['profitLockPct']=0.5,this['minConfidence']=0.55,this[_0x5be687(0x10a)]={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this[_0x5be687(0xfb)]=new Map(),this['priceBuffer']=new Map(),this['volumeBuffer']=new Map(),this['kalmanStates']=new Map(),this[_0x5be687(0x146)]=new Map(),this['recentTrades']=[],this[_0x5be687(0x142)]=0x0,this[_0x5be687(0x122)]=0x0,this[_0x5be687(0x145)]=0x0,this[_0x5be687(0x108)]=0x7530,this[_0x5be687(0x158)]=0x2710,this['stats']={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}[_0x3f38f4(0x136)](_0x464eb7,_0x5a9dff=0.25,_0x2fc97c=0x5){const _0x564b59=_0x3f38f4;this[_0x564b59(0x132)]=_0x5a9dff,this['tickValue']=_0x2fc97c,this['barHistory']['set'](_0x464eb7,[]),this[_0x564b59(0x11c)]['set'](_0x464eb7,[]),this[_0x564b59(0x125)][_0x564b59(0x11e)](_0x464eb7,[]),this['atrHistory'][_0x564b59(0x11e)](_0x464eb7,[]),this[_0x564b59(0x134)]['set'](_0x464eb7,{'estimate':0x0,'errorCovariance':0x1}),this['emit']('log',{'type':_0x564b59(0x13e),'message':'[HQX-UltraScalping]\x20Initialized\x20for\x20'+_0x464eb7+_0x564b59(0x11a)+_0x5a9dff+',\x20value='+_0x2fc97c}),this['emit'](_0x564b59(0x12f),{'type':'info','message':'[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)'});}['processTick'](_0x2d5017){const {contractId:_0x28f845,price:_0x88f637,volume:_0x7efaf6,side:_0x391eaf,timestamp:_0x3a6445}=_0x2d5017,_0x5e6b0b={'timestamp':_0x3a6445||Date['now'](),'open':_0x88f637,'high':_0x88f637,'low':_0x88f637,'close':_0x88f637,'volume':_0x7efaf6||0x1};return this['processBar'](_0x28f845,_0x5e6b0b);}[_0x3f38f4(0x105)](_0xa459d5){const _0x322b9e=_0x3f38f4;return this[_0x322b9e(0x130)](_0xa459d5);}['onTrade'](_0x5cf3bf){const _0xd0316b=_0x3f38f4;return this['processTick']({'contractId':_0x5cf3bf['contractId']||_0x5cf3bf['symbol'],'price':_0x5cf3bf['price'],'volume':_0x5cf3bf['size']||_0x5cf3bf['volume']||0x1,'side':_0x5cf3bf['side'],'timestamp':_0x5cf3bf[_0xd0316b(0x14c)]||Date[_0xd0316b(0x141)]()});}['processBar'](_0x50cd75,_0x58e8e3){const _0x4c230d=_0x3f38f4;let _0x590f41=this[_0x4c230d(0xfb)]['get'](_0x50cd75);!_0x590f41&&(this['initialize'](_0x50cd75),_0x590f41=this[_0x4c230d(0xfb)]['get'](_0x50cd75));_0x590f41[_0x4c230d(0x115)](_0x58e8e3);if(_0x590f41[_0x4c230d(0xf6)]>0x1f4)_0x590f41[_0x4c230d(0x10c)]();const _0x524a2d=this['priceBuffer'][_0x4c230d(0x10d)](_0x50cd75);_0x524a2d[_0x4c230d(0x115)](_0x58e8e3[_0x4c230d(0x150)]);if(_0x524a2d['length']>0xc8)_0x524a2d[_0x4c230d(0x10c)]();const _0xd29926=this['volumeBuffer']['get'](_0x50cd75),_0x55ca76=_0x58e8e3['high']-_0x58e8e3[_0x4c230d(0x13a)];let _0x2823ba=_0x58e8e3['volume']*0.5,_0x3a9aae=_0x58e8e3[_0x4c230d(0x119)]*0.5;if(_0x55ca76>0x0){const _0x362c99=(_0x58e8e3[_0x4c230d(0x150)]-_0x58e8e3[_0x4c230d(0x13a)])/_0x55ca76;_0x2823ba=_0x58e8e3['volume']*_0x362c99,_0x3a9aae=_0x58e8e3['volume']*(0x1-_0x362c99);}_0xd29926['push']({'buy':_0x2823ba,'sell':_0x3a9aae});if(_0xd29926['length']>0x64)_0xd29926[_0x4c230d(0x10c)]();if(_0x590f41[_0x4c230d(0xf6)]<0x32)return null;const _0x1325ba=this['_computeZScore'](_0x524a2d),_0x571dd6=this['_computeVPIN'](_0xd29926),_0x3b2656=this['_computeKyleLambda'](_0x590f41),_0x4756eb=this[_0x4c230d(0x147)](_0x50cd75,_0x58e8e3['close']),{regime:_0x2d97c8,params:_0x2a0174}=this[_0x4c230d(0x11d)](_0x50cd75,_0x590f41),_0x5047bc=this[_0x4c230d(0x13d)](_0x590f41);return this['_generateSignal'](_0x50cd75,_0x58e8e3['close'],_0x1325ba,_0x571dd6,_0x3b2656,_0x4756eb,_0x2d97c8,_0x2a0174,_0x5047bc,_0x590f41);}['_computeZScore'](_0x7deb7,_0x58db7a=0x32){const _0x414084=_0x3f38f4;if(_0x7deb7[_0x414084(0xf6)]<_0x58db7a)return 0x0;const _0x2e1682=_0x7deb7[_0x414084(0xf9)](-_0x58db7a),_0x318644=_0x2e1682[_0x414084(0xfe)]((_0xac1064,_0x2adf11)=>_0xac1064+_0x2adf11,0x0)/_0x58db7a,_0x254ca1=_0x2e1682[_0x414084(0xfe)]((_0x33805b,_0x2ed0d1)=>_0x33805b+Math['pow'](_0x2ed0d1-_0x318644,0x2),0x0)/_0x58db7a,_0x42d35e=Math['sqrt'](_0x254ca1);if(_0x42d35e<0.0001)return 0x0;const _0x88f22d=_0x7deb7[_0x7deb7['length']-0x1];return(_0x88f22d-_0x318644)/_0x42d35e;}[_0x3f38f4(0x157)](_0x211fb8){const _0x2b9432=_0x3f38f4;if(_0x211fb8['length']<this[_0x2b9432(0x137)])return 0.5;const _0x81e4de=_0x211fb8['slice'](-this[_0x2b9432(0x137)]);let _0x270492=0x0,_0x4a3949=0x0;for(const _0x36179f of _0x81e4de){_0x270492+=_0x36179f[_0x2b9432(0x129)],_0x4a3949+=_0x36179f[_0x2b9432(0x138)];}const _0x44a161=_0x270492+_0x4a3949;if(_0x44a161<0x1)return 0.5;return Math[_0x2b9432(0x12c)](_0x270492-_0x4a3949)/_0x44a161;}[_0x3f38f4(0x12e)](_0x2bb288){const _0x21dc46=_0x3f38f4;if(_0x2bb288[_0x21dc46(0xf6)]<0x14)return 0x0;const _0x114e7e=_0x2bb288[_0x21dc46(0xf9)](-0x14),_0x580449=[],_0x4d1abc=[];for(let _0x25a48c=0x1;_0x25a48c<_0x114e7e['length'];_0x25a48c++){_0x580449[_0x21dc46(0x115)](_0x114e7e[_0x25a48c][_0x21dc46(0x150)]-_0x114e7e[_0x25a48c-0x1]['close']),_0x4d1abc['push'](_0x114e7e[_0x25a48c][_0x21dc46(0x119)]);}const _0x1eed1c=_0x580449[_0x21dc46(0xfe)]((_0x551e0b,_0x79e264)=>_0x551e0b+_0x79e264,0x0)/_0x580449[_0x21dc46(0xf6)],_0x5d6f31=_0x4d1abc[_0x21dc46(0xfe)]((_0x19105f,_0x474e55)=>_0x19105f+_0x474e55,0x0)/_0x4d1abc[_0x21dc46(0xf6)];let _0x5bcef2=0x0,_0x52b84d=0x0;for(let _0x21c761=0x0;_0x21c761<_0x580449[_0x21dc46(0xf6)];_0x21c761++){_0x5bcef2+=(_0x580449[_0x21c761]-_0x1eed1c)*(_0x4d1abc[_0x21c761]-_0x5d6f31),_0x52b84d+=Math[_0x21dc46(0x154)](_0x4d1abc[_0x21c761]-_0x5d6f31,0x2);}_0x5bcef2/=_0x580449[_0x21dc46(0xf6)],_0x52b84d/=_0x580449['length'];if(_0x52b84d<0.0001)return 0x0;return Math['abs'](_0x5bcef2/_0x52b84d);}[_0x3f38f4(0x147)](_0xe221fa,_0x8dbb94){const _0x4dc809=_0x3f38f4;let _0x332c4e=this[_0x4dc809(0x134)][_0x4dc809(0x10d)](_0xe221fa);if(!_0x332c4e)return _0x332c4e={'estimate':_0x8dbb94,'errorCovariance':0x1},this[_0x4dc809(0x134)]['set'](_0xe221fa,_0x332c4e),_0x8dbb94;const _0x238ea1=_0x332c4e[_0x4dc809(0x128)],_0x2ce695=_0x332c4e['errorCovariance']+this['kalmanProcessNoise'],_0x1fb9a6=_0x2ce695/(_0x2ce695+this['kalmanMeasurementNoise']),_0x418ab9=_0x238ea1+_0x1fb9a6*(_0x8dbb94-_0x238ea1),_0xce5b9e=(0x1-_0x1fb9a6)*_0x2ce695;return _0x332c4e['estimate']=_0x418ab9,_0x332c4e[_0x4dc809(0x143)]=_0xce5b9e,_0x418ab9;}[_0x3f38f4(0x11d)](_0x26bd7b,_0x1640fe){const _0x34b40f=_0x3f38f4,_0x2726dd=this[_0x34b40f(0xf4)](_0x1640fe),_0x2b9bfe=_0x2726dd/this[_0x34b40f(0x132)];let _0x5b3cb2=this['atrHistory'][_0x34b40f(0x10d)](_0x26bd7b);!_0x5b3cb2&&(_0x5b3cb2=[],this['atrHistory'][_0x34b40f(0x11e)](_0x26bd7b,_0x5b3cb2));_0x5b3cb2[_0x34b40f(0x115)](_0x2726dd);if(_0x5b3cb2['length']>0x1f4)_0x5b3cb2[_0x34b40f(0x10c)]();let _0x4550ab=0.5;_0x5b3cb2[_0x34b40f(0xf6)]>=0x14&&(_0x4550ab=_0x5b3cb2[_0x34b40f(0x14f)](_0x389c46=>_0x389c46<=_0x2726dd)[_0x34b40f(0xf6)]/_0x5b3cb2['length']);let _0x322a81,_0x12da5f;if(_0x4550ab<0.25)_0x322a81='low',_0x12da5f={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x4550ab<0.75?(_0x322a81=_0x34b40f(0x13f),_0x12da5f={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x322a81=_0x34b40f(0xf3),_0x12da5f={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x322a81,'params':_0x12da5f};}[_0x3f38f4(0xf4)](_0x18e3e6,_0x4a2b73=0xe){const _0x212453=_0x3f38f4;if(_0x18e3e6[_0x212453(0xf6)]<_0x4a2b73+0x1)return 2.5;const _0x29de65=[];for(let _0x489b71=_0x18e3e6[_0x212453(0xf6)]-_0x4a2b73;_0x489b71<_0x18e3e6[_0x212453(0xf6)];_0x489b71++){const _0x2e0a47=_0x18e3e6[_0x489b71],_0x26dbf2=_0x18e3e6[_0x489b71-0x1]['close'],_0x3a3455=Math['max'](_0x2e0a47[_0x212453(0xf3)]-_0x2e0a47[_0x212453(0x13a)],Math['abs'](_0x2e0a47[_0x212453(0xf3)]-_0x26dbf2),Math['abs'](_0x2e0a47[_0x212453(0x13a)]-_0x26dbf2));_0x29de65['push'](_0x3a3455);}return _0x29de65[_0x212453(0xfe)]((_0xad4b3f,_0x5d77c7)=>_0xad4b3f+_0x5d77c7,0x0)/_0x29de65['length'];}[_0x3f38f4(0x13d)](_0x537d02){const _0x452547=_0x3f38f4;if(_0x537d02['length']<this['ofiLookback'])return 0x0;const _0xa1e75b=_0x537d02['slice'](-this['ofiLookback']);let _0xf2e98=0x0,_0x1a00ce=0x0;for(const _0x46657 of _0xa1e75b){const _0x1aeaaf=_0x46657[_0x452547(0xf3)]-_0x46657[_0x452547(0x13a)];if(_0x1aeaaf>0x0){const _0x3ad9ad=(_0x46657[_0x452547(0x150)]-_0x46657['low'])/_0x1aeaaf;_0xf2e98+=_0x3ad9ad*_0x46657[_0x452547(0x119)],_0x1a00ce+=(0x1-_0x3ad9ad)*_0x46657['volume'];}}const _0x54c894=_0xf2e98+_0x1a00ce;if(_0x54c894<0x1)return 0x0;return(_0xf2e98-_0x1a00ce)/_0x54c894;}[_0x3f38f4(0x14a)](_0x507b98,_0x3263f1,_0x2faa63,_0x1fab76,_0x3da40e,_0x596d19,_0x51c2b6,_0x52e7c0,_0x5b469b,_0x10653a){const _0x2ddf32=_0x3f38f4,_0x2441b5=Math['abs'](_0x2faa63);if(_0x2441b5<_0x52e7c0['zscoreThreshold'])return null;if(_0x1fab76>this['vpinToxicThreshold'])return null;let _0x1242ea;if(_0x2faa63<-_0x52e7c0['zscoreThreshold'])_0x1242ea='long';else{if(_0x2faa63>_0x52e7c0['zscoreThreshold'])_0x1242ea=_0x2ddf32(0xf7);else return null;}const _0x7db943=_0x1242ea===_0x2ddf32(0xfd)&&_0x5b469b>0.1||_0x1242ea===_0x2ddf32(0xf7)&&_0x5b469b<-0.1,_0x50fa47=_0x3263f1-_0x596d19,_0x1895a4=_0x1242ea===_0x2ddf32(0xfd)&&_0x50fa47<0x0||_0x1242ea===_0x2ddf32(0xf7)&&_0x50fa47>0x0,_0x4afb8d={'zscore':Math[_0x2ddf32(0x12b)](0x1,_0x2441b5/0x4),'vpin':0x1-_0x1fab76,'kyleLambda':_0x3da40e>0.001?0.5:0.8,'kalman':_0x1895a4?0.8:0.4,'volatility':_0x51c2b6===_0x2ddf32(0x13f)?0.8:_0x51c2b6==='low'?0.7:0.6,'ofi':_0x7db943?0.9:0.5,'composite':0x0};_0x4afb8d[_0x2ddf32(0xf5)]=_0x4afb8d['zscore']*this[_0x2ddf32(0x10a)]['zscore']+_0x4afb8d['vpin']*this[_0x2ddf32(0x10a)]['vpin']+_0x4afb8d['kyleLambda']*this['weights'][_0x2ddf32(0x106)]+_0x4afb8d['kalman']*this['weights'][_0x2ddf32(0x124)]+_0x4afb8d['volatility']*this['weights'][_0x2ddf32(0x15a)]+_0x4afb8d['ofi']*this['weights'][_0x2ddf32(0x15d)];const _0x256dc9=Math['min'](0x1,_0x4afb8d[_0x2ddf32(0xf5)]+_0x52e7c0[_0x2ddf32(0x156)]);if(_0x256dc9<this[_0x2ddf32(0x15c)])return null;if(Date['now']()-this['lastSignalTime']<this[_0x2ddf32(0x108)])return null;const _0x1ccb91=Math['round'](this[_0x2ddf32(0x15b)]*_0x52e7c0[_0x2ddf32(0x103)]),_0x5cc624=Math['round'](this['baseTargetTicks']*_0x52e7c0[_0x2ddf32(0x112)]),_0x44d2b0=Math[_0x2ddf32(0x10f)](0x6,Math['min'](0xc,_0x1ccb91)),_0x367001=Math['max'](_0x44d2b0*1.5,Math['min'](0x18,_0x5cc624));let _0x4408b9,_0x454d41,_0x1bfe33,_0x1d89bf;_0x1242ea==='long'?(_0x4408b9=_0x3263f1-_0x44d2b0*this['tickSize'],_0x454d41=_0x3263f1+_0x367001*this[_0x2ddf32(0x132)],_0x1bfe33=_0x3263f1+this[_0x2ddf32(0x14e)]*this[_0x2ddf32(0x132)],_0x1d89bf=_0x3263f1+_0x367001*this[_0x2ddf32(0xfc)]*this['tickSize']):(_0x4408b9=_0x3263f1+_0x44d2b0*this['tickSize'],_0x454d41=_0x3263f1-_0x367001*this['tickSize'],_0x1bfe33=_0x3263f1-this['breakevenTicks']*this[_0x2ddf32(0x132)],_0x1d89bf=_0x3263f1-_0x367001*this['profitLockPct']*this[_0x2ddf32(0x132)]);const _0x2df7f9=_0x367001/_0x44d2b0,_0x3e5215=Math[_0x2ddf32(0x133)](_0x367001*0.5),_0x19d283=Math['round'](_0x44d2b0*0.4);let _0x48825d=SignalStrength[_0x2ddf32(0x118)];if(_0x256dc9>=0.85)_0x48825d=SignalStrength[_0x2ddf32(0x13c)];else{if(_0x256dc9>=0.75)_0x48825d=SignalStrength['STRONG'];else{if(_0x256dc9<0.6)_0x48825d=SignalStrength['WEAK'];}}const _0x496c28=0.5+(_0x256dc9-0.5)*0.4,_0x21c395=_0x496c28*Math[_0x2ddf32(0x12c)](_0x454d41-_0x3263f1)-(0x1-_0x496c28)*Math[_0x2ddf32(0x12c)](_0x3263f1-_0x4408b9);this['lastSignalTime']=Date[_0x2ddf32(0x141)](),this[_0x2ddf32(0x11f)]['signals']++;const _0x253fba={'id':uuidv4(),'timestamp':Date[_0x2ddf32(0x141)](),'symbol':_0x507b98['split']('.')[0x0]||_0x507b98,'contractId':_0x507b98,'side':_0x1242ea==='long'?OrderSide['BID']:OrderSide['ASK'],'direction':_0x1242ea,'strategy':'HQX_ULTRA_SCALPING_6MODELS','strength':_0x48825d,'edge':_0x21c395,'confidence':_0x256dc9,'entry':_0x3263f1,'entryPrice':_0x3263f1,'stopLoss':_0x4408b9,'takeProfit':_0x454d41,'riskReward':_0x2df7f9,'stopTicks':_0x44d2b0,'targetTicks':_0x367001,'trailTriggerTicks':_0x3e5215,'trailDistanceTicks':_0x19d283,'beBreakeven':_0x1bfe33,'profitLockLevel':_0x1d89bf,'zScore':_0x2faa63,'zScoreExit':this[_0x2ddf32(0x135)],'vpinValue':_0x1fab76,'kyleLambda':_0x3da40e,'kalmanEstimate':_0x596d19,'volatilityRegime':_0x51c2b6,'ofiValue':_0x5b469b,'models':_0x4afb8d,'orderFlowConfirmed':_0x7db943,'kalmanConfirmed':_0x1895a4,'expires':Date[_0x2ddf32(0x141)]()+0xea60};return this['emit'](_0x2ddf32(0x10b),{'side':_0x1242ea===_0x2ddf32(0xfd)?_0x2ddf32(0x129):'sell','action':'open','reason':'Z='+_0x2faa63['toFixed'](0x2)+_0x2ddf32(0x121)+(_0x1fab76*0x64)[_0x2ddf32(0x151)](0x0)+_0x2ddf32(0x111)+(_0x5b469b*0x64)['toFixed'](0x0)+'%,\x20cf='+(_0x256dc9*0x64)[_0x2ddf32(0x151)](0x0)+'%',..._0x253fba}),this['emit'](_0x2ddf32(0x12f),{'type':_0x2ddf32(0x13e),'message':_0x2ddf32(0x123)+_0x1242ea[_0x2ddf32(0x100)]()+'\x20@\x20'+_0x3263f1[_0x2ddf32(0x151)](0x2)+'\x20|\x20Z:'+_0x2faa63[_0x2ddf32(0x151)](0x2)+'\x20VPIN:'+(_0x1fab76*0x64)[_0x2ddf32(0x151)](0x0)+'%\x20OFI:'+(_0x5b469b*0x64)['toFixed'](0x0)+'%\x20Kyle:'+_0x3da40e['toFixed'](0x5)+'\x20Regime:'+_0x51c2b6+'\x20|\x20Conf:'+(_0x256dc9*0x64)['toFixed'](0x0)+'%'}),_0x253fba;}[_0x3f38f4(0x107)](_0x3f100d){const _0x59d96e=_0x3f38f4,_0x464578=this[_0x59d96e(0x11c)][_0x59d96e(0x10d)](_0x3f100d);if(!_0x464578||_0x464578['length']<0x32)return![];const _0x3aa107=this[_0x59d96e(0x12a)](_0x464578);return Math[_0x59d96e(0x12c)](_0x3aa107)<this['zscoreExitThreshold'];}[_0x3f38f4(0xf8)](_0x3ca54b){const _0x127579=_0x3f38f4,_0x27b100=this['priceBuffer']['get'](_0x3ca54b),_0x27c0d3=this['volumeBuffer'][_0x127579(0x10d)](_0x3ca54b),_0x1af95c=this[_0x127579(0xfb)]['get'](_0x3ca54b);if(!_0x27b100||!_0x27c0d3||!_0x1af95c||_0x1af95c[_0x127579(0xf6)]<0x32)return null;const _0x596ec7=this['_computeZScore'](_0x27b100),_0x28214d=this[_0x127579(0x157)](_0x27c0d3),_0x4606b6=this['_computeKyleLambda'](_0x1af95c),_0x1d2055=this['_computeOrderFlowImbalance'](_0x1af95c);return{'zscore':Math['min'](0x1,Math['abs'](_0x596ec7)/0x4),'vpin':0x1-_0x28214d,'kyleLambda':_0x4606b6>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math['abs'](_0x1d2055)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x596ec7,'vpin':_0x28214d,'kyleLambda':_0x4606b6,'ofi':_0x1d2055}};}['getAnalysisState'](_0x1b5736,_0x2a931f){const _0x4e564d=_0x3f38f4,_0xb68db1=this['barHistory']['get'](_0x1b5736)||[];if(_0xb68db1[_0x4e564d(0xf6)]<0x32)return{'ready':![],'message':'Collecting\x20data...\x20'+_0xb68db1[_0x4e564d(0xf6)]+'/50\x20bars'};const _0x5592fa=this['priceBuffer']['get'](_0x1b5736)||[],_0x449d36=this['volumeBuffer']['get'](_0x1b5736)||[],_0x3e3124=this['_computeZScore'](_0x5592fa),_0x57a88c=this[_0x4e564d(0x157)](_0x449d36),_0x2e7e00=this[_0x4e564d(0x13d)](_0xb68db1),_0x5cb4e9=this['_computeKyleLambda'](_0xb68db1),{regime:_0x1035a4,params:_0x4b10bc}=this[_0x4e564d(0x11d)](_0x1b5736,_0xb68db1);return{'ready':!![],'zScore':_0x3e3124,'vpin':_0x57a88c,'ofi':_0x2e7e00,'kyleLambda':_0x5cb4e9,'regime':_0x1035a4,'stopTicks':Math['round'](this['baseStopTicks']*_0x4b10bc[_0x4e564d(0x103)]),'targetTicks':Math[_0x4e564d(0x133)](this['baseTargetTicks']*_0x4b10bc['targetMultiplier']),'threshold':_0x4b10bc['zscoreThreshold'],'barsProcessed':_0xb68db1[_0x4e564d(0xf6)],'models':'6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)'};}[_0x3f38f4(0x12d)](_0x450d04){const _0x52acbd=_0x3f38f4;this[_0x52acbd(0x116)]['push']({'netPnl':_0x450d04,'timestamp':Date[_0x52acbd(0x141)]()});if(this['recentTrades']['length']>0x64)this['recentTrades']['shift']();_0x450d04>0x0?(this[_0x52acbd(0x142)]++,this['lossStreak']=0x0,this[_0x52acbd(0x11f)]['wins']++):(this[_0x52acbd(0x122)]++,this['winStreak']=0x0,this['stats'][_0x52acbd(0xf2)]++),this[_0x52acbd(0x11f)][_0x52acbd(0x149)]++,this['stats']['pnl']+=_0x450d04,this['emit'](_0x52acbd(0x12f),{'type':_0x52acbd(0x102),'message':'[HQX]\x20Trade\x20result:\x20'+(_0x450d04>0x0?'WIN':'LOSS')+'\x20$'+_0x450d04['toFixed'](0x2)+',\x20streak:\x20'+(_0x450d04>0x0?this['winStreak']:-this[_0x52acbd(0x122)])});}['getBarHistory'](_0x2909f8){const _0x462d7e=_0x3f38f4;return this[_0x462d7e(0xfb)]['get'](_0x2909f8)||[];}['getStats'](){const _0x5987ba=_0x3f38f4;return this[_0x5987ba(0x11f)];}['reset'](_0x2f1c56){const _0x3a12f5=_0x3f38f4;this['barHistory'][_0x3a12f5(0x11e)](_0x2f1c56,[]),this['priceBuffer']['set'](_0x2f1c56,[]),this['volumeBuffer']['set'](_0x2f1c56,[]),this['atrHistory'][_0x3a12f5(0x11e)](_0x2f1c56,[]),this[_0x3a12f5(0x134)]['set'](_0x2f1c56,{'estimate':0x0,'errorCovariance':0x1}),this[_0x3a12f5(0x114)](_0x3a12f5(0x12f),{'type':'info','message':_0x3a12f5(0x153)+_0x2f1c56});}}function _0x492e(){const _0x223a4b=['long','reduce','tickValue','toUpperCase','onTrade','debug','stopMultiplier','96702fpQzch','onTick','kyleLambda','shouldExitByZScore','cooldownMs','getAnalysisState','weights','signal','shift','get','zscoreEntryThreshold','max','getStats','%,\x20OFI=','targetMultiplier','1411050IMIQCo','emit','push','recentTrades','events','MODERATE','volume',':\x20tick=','getBarHistory','priceBuffer','_detectVolatilityRegime','set','stats','baseTargetTicks',',\x20VPIN=','lossStreak','[HQX]\x20SIGNAL:\x20','kalman','volumeBuffer','3286540CgzlHt','12ZmjSmH','estimate','buy','_computeZScore','min','abs','recordTradeResult','_computeKyleLambda','log','processTick','strategy','tickSize','round','kalmanStates','zscoreExitThreshold','initialize','vpinWindow','sell','12355JODrZy','low','processBar','VERY_STRONG','_computeOrderFlowImbalance','info','normal','volatilityLookback','now','winStreak','errorCovariance','207iZSoLF','lastSignalTime','atrHistory','_applyKalmanFilter','reset','trades','_generateSignal','7487032MEshvr','timestamp','kalmanProcessNoise','breakevenTicks','filter','close','toFixed','vpinToxicThreshold','[HQX-UltraScalping]\x20Reset\x20state\x20for\x20','pow','8288qXISxq','confidenceBonus','_computeVPIN','minHoldTimeMs','1069340CnLiZe','volatility','baseStopTicks','minConfidence','ofi','losses','high','_calculateATR','composite','length','short','getModelValues','slice','8719128UInoaM','barHistory','profitLockPct'];_0x492e=function(){return _0x223a4b;};return _0x492e();}function _0x30a6(_0x385a7b,_0x44cee7){_0x385a7b=_0x385a7b-0xf2;const _0x492e31=_0x492e();let _0x30a6e4=_0x492e31[_0x385a7b];return _0x30a6e4;}class UltraScalpingStrategy extends EventEmitter{constructor(_0x5b81aa={}){const _0x45add5=_0x3f38f4;super(),this['config']=_0x5b81aa,this[_0x45add5(0x131)]=new HQXUltraScalping(_0x5b81aa),this[_0x45add5(0x131)]['on'](_0x45add5(0x10b),_0x136f3b=>this['emit']('signal',_0x136f3b)),this['strategy']['on']('log',_0x222daa=>this[_0x45add5(0x114)]('log',_0x222daa));}['processTick'](_0x17aa81){const _0x40989e=_0x3f38f4;return this[_0x40989e(0x131)][_0x40989e(0x130)](_0x17aa81);}[_0x3f38f4(0x105)](_0xb2a0d3){const _0x13c7ae=_0x3f38f4;return this['strategy'][_0x13c7ae(0x105)](_0xb2a0d3);}[_0x3f38f4(0x101)](_0x47cc66){return this['strategy']['onTrade'](_0x47cc66);}[_0x3f38f4(0x13b)](_0x1fec33,_0x2b69c5){const _0x6a528a=_0x3f38f4;return this[_0x6a528a(0x131)][_0x6a528a(0x13b)](_0x1fec33,_0x2b69c5);}['initialize'](_0x2aeb31,_0x5e8a23,_0x1364cb){return this['strategy']['initialize'](_0x2aeb31,_0x5e8a23,_0x1364cb);}[_0x3f38f4(0x109)](_0x2e5e45,_0x52fb80){return this['strategy']['getAnalysisState'](_0x2e5e45,_0x52fb80);}[_0x3f38f4(0x12d)](_0x40c722){const _0x537a0c=_0x3f38f4;return this[_0x537a0c(0x131)]['recordTradeResult'](_0x40c722);}['reset'](_0x5d82c7){const _0x32c500=_0x3f38f4;return this[_0x32c500(0x131)][_0x32c500(0x148)](_0x5d82c7);}[_0x3f38f4(0x110)](){return this['strategy']['getStats']();}[_0x3f38f4(0x11b)](_0x20cecd){return this['strategy']['getBarHistory'](_0x20cecd);}[_0x3f38f4(0xf8)](_0x5c9f6d){return this['strategy']['getModelValues'](_0x5c9f6d);}[_0x3f38f4(0x107)](_0x3f5e7c){const _0x167e98=_0x3f38f4;return this[_0x167e98(0x131)]['shouldExitByZScore'](_0x3f5e7c);}['generateSignal'](_0x139b38){return null;}}module['exports']={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};
|
|
1
|
+
const _0x2023a7=_0x41d2;(function(_0xe58ba7,_0x259ef7){const _0x25cf42=_0x41d2,_0x57ee1f=_0xe58ba7();while(!![]){try{const _0x416926=-parseInt(_0x25cf42(0x12d))/0x1+-parseInt(_0x25cf42(0x138))/0x2+-parseInt(_0x25cf42(0xe7))/0x3*(-parseInt(_0x25cf42(0x150))/0x4)+parseInt(_0x25cf42(0x144))/0x5+parseInt(_0x25cf42(0x132))/0x6*(-parseInt(_0x25cf42(0x125))/0x7)+-parseInt(_0x25cf42(0x111))/0x8+-parseInt(_0x25cf42(0x131))/0x9*(-parseInt(_0x25cf42(0x12b))/0xa);if(_0x416926===_0x259ef7)break;else _0x57ee1f['push'](_0x57ee1f['shift']());}catch(_0x16eb56){_0x57ee1f['push'](_0x57ee1f['shift']());}}}(_0x2bdc,0x5bd86));const EventEmitter=require(_0x2023a7(0x10f)),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};class HQXUltraScalping extends EventEmitter{constructor(_0x3b427a={}){const _0x20a631=_0x2023a7;super(),this['tickSize']=_0x3b427a['tickSize']||0.25,this[_0x20a631(0x129)]=_0x3b427a[_0x20a631(0x129)]||0x5,this[_0x20a631(0x102)]=1.5,this['zscoreExitThreshold']=0.5,this['vpinWindow']=0x32,this['vpinToxicThreshold']=0.7,this[_0x20a631(0x121)]=0.01,this['kalmanMeasurementNoise']=0.1,this[_0x20a631(0xe5)]=0x64,this[_0x20a631(0x14d)]=0x14,this['baseStopTicks']=0x8,this['baseTargetTicks']=0x10,this['breakevenTicks']=0x4,this[_0x20a631(0x13c)]=0.5,this[_0x20a631(0x120)]=0.55,this[_0x20a631(0x127)]={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this[_0x20a631(0xfe)]=new Map(),this[_0x20a631(0x115)]=new Map(),this['volumeBuffer']=new Map(),this['kalmanStates']=new Map(),this['atrHistory']=new Map(),this[_0x20a631(0x105)]=[],this[_0x20a631(0x13e)]=0x0,this['lossStreak']=0x0,this[_0x20a631(0xe3)]=0x0,this['cooldownMs']=0x7530,this[_0x20a631(0xe6)]=0x2710,this['stats']={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}['initialize'](_0x18a03d,_0x1da83b=0.25,_0x41c908=0x5){const _0x56a49b=_0x2023a7;this[_0x56a49b(0x124)]=_0x1da83b,this[_0x56a49b(0x129)]=_0x41c908,this[_0x56a49b(0xfe)]['set'](_0x18a03d,[]),this[_0x56a49b(0x115)][_0x56a49b(0x126)](_0x18a03d,[]),this['volumeBuffer']['set'](_0x18a03d,[]),this['atrHistory'][_0x56a49b(0x126)](_0x18a03d,[]),this[_0x56a49b(0x10e)][_0x56a49b(0x126)](_0x18a03d,{'estimate':0x0,'errorCovariance':0x1}),this[_0x56a49b(0xea)](_0x56a49b(0x147),{'type':_0x56a49b(0x128),'message':'[HQX-UltraScalping]\x20Initialized\x20for\x20'+_0x18a03d+_0x56a49b(0x10a)+_0x1da83b+_0x56a49b(0xfd)+_0x41c908}),this['emit']('log',{'type':_0x56a49b(0x128),'message':'[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)'});}[_0x2023a7(0xe4)](_0x3f133a){const _0x5de93b=_0x2023a7,{contractId:_0x3e303f,price:_0x344888,volume:_0x39befb,side:_0x14f1b6,timestamp:_0x405942}=_0x3f133a,_0x30ec10={'timestamp':_0x405942||Date[_0x5de93b(0x156)](),'open':_0x344888,'high':_0x344888,'low':_0x344888,'close':_0x344888,'volume':_0x39befb||0x1};return this['processBar'](_0x3e303f,_0x30ec10);}['onTick'](_0x27e1fa){return this['processTick'](_0x27e1fa);}['onTrade'](_0x4d60d6){const _0x37ea35=_0x2023a7;return this[_0x37ea35(0xe4)]({'contractId':_0x4d60d6[_0x37ea35(0x13a)]||_0x4d60d6['symbol'],'price':_0x4d60d6[_0x37ea35(0x13d)],'volume':_0x4d60d6['size']||_0x4d60d6['volume']||0x1,'side':_0x4d60d6['side'],'timestamp':_0x4d60d6[_0x37ea35(0x113)]||Date['now']()});}['processBar'](_0x571956,_0xa5b7a3){const _0x2df866=_0x2023a7;let _0x527b8d=this[_0x2df866(0xfe)][_0x2df866(0xf0)](_0x571956);!_0x527b8d&&(this[_0x2df866(0xf2)](_0x571956),_0x527b8d=this[_0x2df866(0xfe)]['get'](_0x571956));_0x527b8d[_0x2df866(0x140)](_0xa5b7a3);if(_0x527b8d['length']>0x1f4)_0x527b8d['shift']();const _0x122fde=this[_0x2df866(0x115)]['get'](_0x571956);_0x122fde[_0x2df866(0x140)](_0xa5b7a3['close']);if(_0x122fde[_0x2df866(0x110)]>0xc8)_0x122fde[_0x2df866(0x10b)]();const _0xeda77c=this[_0x2df866(0xec)][_0x2df866(0xf0)](_0x571956),_0x46a912=_0xa5b7a3[_0x2df866(0x14c)]-_0xa5b7a3[_0x2df866(0x12a)];let _0x3ace07=_0xa5b7a3[_0x2df866(0x157)]*0.5,_0x2767fd=_0xa5b7a3[_0x2df866(0x157)]*0.5;if(_0x46a912>0x0){const _0x42c1e4=(_0xa5b7a3['close']-_0xa5b7a3[_0x2df866(0x12a)])/_0x46a912;_0x3ace07=_0xa5b7a3[_0x2df866(0x157)]*_0x42c1e4,_0x2767fd=_0xa5b7a3[_0x2df866(0x157)]*(0x1-_0x42c1e4);}_0xeda77c[_0x2df866(0x140)]({'buy':_0x3ace07,'sell':_0x2767fd});if(_0xeda77c['length']>0x64)_0xeda77c[_0x2df866(0x10b)]();if(_0x527b8d[_0x2df866(0x110)]<0x32)return null;const _0x22aff5=this['_computeZScore'](_0x122fde),_0x5a89c6=this[_0x2df866(0x155)](_0xeda77c),_0x5408bd=this['_computeKyleLambda'](_0x527b8d),_0x2a4a7f=this['_applyKalmanFilter'](_0x571956,_0xa5b7a3['close']),{regime:_0x413d16,params:_0x59c837}=this[_0x2df866(0x142)](_0x571956,_0x527b8d),_0x424377=this['_computeOrderFlowImbalance'](_0x527b8d);return this[_0x2df866(0xee)](_0x571956,_0xa5b7a3['close'],_0x22aff5,_0x5a89c6,_0x5408bd,_0x2a4a7f,_0x413d16,_0x59c837,_0x424377,_0x527b8d);}['_computeZScore'](_0x3594f9,_0x1987c2=0x32){const _0x595351=_0x2023a7;if(_0x3594f9['length']<_0x1987c2)return 0x0;const _0x57c16b=_0x3594f9[_0x595351(0xfa)](-_0x1987c2),_0x13ead0=_0x57c16b[_0x595351(0x10c)]((_0x504c6f,_0x4ea2dc)=>_0x504c6f+_0x4ea2dc,0x0)/_0x1987c2,_0x1e9866=_0x57c16b['reduce']((_0x54947a,_0x2e0032)=>_0x54947a+Math[_0x595351(0x12c)](_0x2e0032-_0x13ead0,0x2),0x0)/_0x1987c2,_0x21f5db=Math['sqrt'](_0x1e9866);if(_0x21f5db<0.0001)return 0x0;const _0x11a339=_0x3594f9[_0x3594f9[_0x595351(0x110)]-0x1];return(_0x11a339-_0x13ead0)/_0x21f5db;}['_computeVPIN'](_0x54ce35){const _0x24f0b3=_0x2023a7;if(_0x54ce35['length']<this['vpinWindow'])return 0.5;const _0x3a0cbb=_0x54ce35[_0x24f0b3(0xfa)](-this[_0x24f0b3(0xf1)]);let _0x477d71=0x0,_0x58b0c5=0x0;for(const _0x4904d6 of _0x3a0cbb){_0x477d71+=_0x4904d6[_0x24f0b3(0x13b)],_0x58b0c5+=_0x4904d6['sell'];}const _0x323518=_0x477d71+_0x58b0c5;if(_0x323518<0x1)return 0.5;return Math[_0x24f0b3(0xf9)](_0x477d71-_0x58b0c5)/_0x323518;}['_computeKyleLambda'](_0x32b91e){const _0x4fcb29=_0x2023a7;if(_0x32b91e[_0x4fcb29(0x110)]<0x14)return 0x0;const _0x4725fd=_0x32b91e['slice'](-0x14),_0x13f172=[],_0x349eb8=[];for(let _0x236424=0x1;_0x236424<_0x4725fd[_0x4fcb29(0x110)];_0x236424++){_0x13f172['push'](_0x4725fd[_0x236424][_0x4fcb29(0x11f)]-_0x4725fd[_0x236424-0x1]['close']),_0x349eb8[_0x4fcb29(0x140)](_0x4725fd[_0x236424]['volume']);}const _0x8f81df=_0x13f172['reduce']((_0x12ef9f,_0x3daef1)=>_0x12ef9f+_0x3daef1,0x0)/_0x13f172['length'],_0x31063e=_0x349eb8['reduce']((_0x47659b,_0x44048f)=>_0x47659b+_0x44048f,0x0)/_0x349eb8['length'];let _0x17bba6=0x0,_0x4864f7=0x0;for(let _0x198f64=0x0;_0x198f64<_0x13f172['length'];_0x198f64++){_0x17bba6+=(_0x13f172[_0x198f64]-_0x8f81df)*(_0x349eb8[_0x198f64]-_0x31063e),_0x4864f7+=Math[_0x4fcb29(0x12c)](_0x349eb8[_0x198f64]-_0x31063e,0x2);}_0x17bba6/=_0x13f172['length'],_0x4864f7/=_0x13f172['length'];if(_0x4864f7<0.0001)return 0x0;return Math['abs'](_0x17bba6/_0x4864f7);}[_0x2023a7(0x107)](_0xb60e1b,_0xda3591){const _0x9197d9=_0x2023a7;let _0x53d719=this[_0x9197d9(0x10e)][_0x9197d9(0xf0)](_0xb60e1b);if(!_0x53d719)return _0x53d719={'estimate':_0xda3591,'errorCovariance':0x1},this[_0x9197d9(0x10e)][_0x9197d9(0x126)](_0xb60e1b,_0x53d719),_0xda3591;const _0x2c6290=_0x53d719[_0x9197d9(0x136)],_0x243402=_0x53d719['errorCovariance']+this['kalmanProcessNoise'],_0x19b234=_0x243402/(_0x243402+this[_0x9197d9(0x14f)]),_0x5bd76f=_0x2c6290+_0x19b234*(_0xda3591-_0x2c6290),_0xa004b7=(0x1-_0x19b234)*_0x243402;return _0x53d719[_0x9197d9(0x136)]=_0x5bd76f,_0x53d719['errorCovariance']=_0xa004b7,_0x5bd76f;}['_detectVolatilityRegime'](_0x2b638a,_0x1f48bd){const _0x4817fd=_0x2023a7,_0x513335=this[_0x4817fd(0x119)](_0x1f48bd),_0x34d306=_0x513335/this['tickSize'];let _0x479683=this[_0x4817fd(0xf3)]['get'](_0x2b638a);!_0x479683&&(_0x479683=[],this[_0x4817fd(0xf3)][_0x4817fd(0x126)](_0x2b638a,_0x479683));_0x479683['push'](_0x513335);if(_0x479683[_0x4817fd(0x110)]>0x1f4)_0x479683[_0x4817fd(0x10b)]();let _0x1cce76=0.5;_0x479683['length']>=0x14&&(_0x1cce76=_0x479683['filter'](_0x3a3f72=>_0x3a3f72<=_0x513335)['length']/_0x479683[_0x4817fd(0x110)]);let _0x53ce01,_0x12e374;if(_0x1cce76<0.25)_0x53ce01='low',_0x12e374={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x1cce76<0.75?(_0x53ce01='normal',_0x12e374={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x53ce01='high',_0x12e374={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x53ce01,'params':_0x12e374};}['_calculateATR'](_0x513292,_0xb442dd=0xe){const _0x4a7779=_0x2023a7;if(_0x513292['length']<_0xb442dd+0x1)return 2.5;const _0x2a02fb=[];for(let _0x572d11=_0x513292[_0x4a7779(0x110)]-_0xb442dd;_0x572d11<_0x513292[_0x4a7779(0x110)];_0x572d11++){const _0x1acc7d=_0x513292[_0x572d11],_0x4f0707=_0x513292[_0x572d11-0x1][_0x4a7779(0x11f)],_0x52051a=Math[_0x4a7779(0x106)](_0x1acc7d['high']-_0x1acc7d['low'],Math[_0x4a7779(0xf9)](_0x1acc7d[_0x4a7779(0x14c)]-_0x4f0707),Math[_0x4a7779(0xf9)](_0x1acc7d['low']-_0x4f0707));_0x2a02fb['push'](_0x52051a);}return _0x2a02fb[_0x4a7779(0x10c)]((_0x5b377f,_0x580a4e)=>_0x5b377f+_0x580a4e,0x0)/_0x2a02fb['length'];}[_0x2023a7(0x158)](_0x4bb32b){const _0x1ee37b=_0x2023a7;if(_0x4bb32b['length']<this['ofiLookback'])return 0x0;const _0x1b396c=_0x4bb32b[_0x1ee37b(0xfa)](-this[_0x1ee37b(0x14d)]);let _0x30305d=0x0,_0x272570=0x0;for(const _0x3df72b of _0x1b396c){const _0x57fbe7=_0x3df72b['high']-_0x3df72b[_0x1ee37b(0x12a)];if(_0x57fbe7>0x0){const _0x296e40=(_0x3df72b[_0x1ee37b(0x11f)]-_0x3df72b[_0x1ee37b(0x12a)])/_0x57fbe7;_0x30305d+=_0x296e40*_0x3df72b[_0x1ee37b(0x157)],_0x272570+=(0x1-_0x296e40)*_0x3df72b['volume'];}}const _0x176b28=_0x30305d+_0x272570;if(_0x176b28<0x1)return 0x0;return(_0x30305d-_0x272570)/_0x176b28;}['_generateSignal'](_0x4fb3e9,_0x220cf5,_0x1e6ccf,_0x2bbeb5,_0x2b682d,_0x47bba5,_0x509952,_0x1249e1,_0x266d29,_0x11237c){const _0x2d195d=_0x2023a7,_0x18789e=Math[_0x2d195d(0xf9)](_0x1e6ccf);if(_0x18789e<_0x1249e1[_0x2d195d(0x14a)])return null;if(_0x2bbeb5>this[_0x2d195d(0xe9)])return null;let _0x22d619;if(_0x1e6ccf<-_0x1249e1[_0x2d195d(0x14a)])_0x22d619=_0x2d195d(0x139);else{if(_0x1e6ccf>_0x1249e1['zscoreThreshold'])_0x22d619=_0x2d195d(0x101);else return null;}const _0x5c3459=_0x22d619===_0x2d195d(0x139)&&_0x266d29>0.1||_0x22d619==='short'&&_0x266d29<-0.1,_0x571e21=_0x220cf5-_0x47bba5,_0x2ae862=_0x22d619===_0x2d195d(0x139)&&_0x571e21<0x0||_0x22d619==='short'&&_0x571e21>0x0,_0x2d7efd={'zscore':Math['min'](0x1,_0x18789e/0x4),'vpin':0x1-_0x2bbeb5,'kyleLambda':_0x2b682d>0.001?0.5:0.8,'kalman':_0x2ae862?0.8:0.4,'volatility':_0x509952===_0x2d195d(0x11b)?0.8:_0x509952==='low'?0.7:0.6,'ofi':_0x5c3459?0.9:0.5,'composite':0x0};_0x2d7efd[_0x2d195d(0x14e)]=_0x2d7efd['zscore']*this['weights']['zscore']+_0x2d7efd['vpin']*this['weights'][_0x2d195d(0x152)]+_0x2d7efd['kyleLambda']*this[_0x2d195d(0x127)]['kyleLambda']+_0x2d7efd[_0x2d195d(0xf4)]*this[_0x2d195d(0x127)][_0x2d195d(0xf4)]+_0x2d7efd[_0x2d195d(0x145)]*this['weights'][_0x2d195d(0x145)]+_0x2d7efd['ofi']*this[_0x2d195d(0x127)]['ofi'];const _0x27f4fa=Math[_0x2d195d(0x12e)](0x1,_0x2d7efd[_0x2d195d(0x14e)]+_0x1249e1['confidenceBonus']);if(_0x27f4fa<this['minConfidence'])return null;if(Date[_0x2d195d(0x156)]()-this[_0x2d195d(0xe3)]<this[_0x2d195d(0x143)])return null;const _0x10e5ae=Math['round'](this['baseStopTicks']*_0x1249e1['stopMultiplier']),_0x10c48e=Math[_0x2d195d(0xf8)](this['baseTargetTicks']*_0x1249e1[_0x2d195d(0x117)]),_0x3713e8=Math[_0x2d195d(0x106)](0x6,Math[_0x2d195d(0x12e)](0xc,_0x10e5ae)),_0x1c5aec=Math[_0x2d195d(0x106)](_0x3713e8*1.5,Math[_0x2d195d(0x12e)](0x18,_0x10c48e));let _0x59030b,_0x2670c0,_0x1219df,_0x36f57f;_0x22d619===_0x2d195d(0x139)?(_0x59030b=_0x220cf5-_0x3713e8*this['tickSize'],_0x2670c0=_0x220cf5+_0x1c5aec*this[_0x2d195d(0x124)],_0x1219df=_0x220cf5+this[_0x2d195d(0x114)]*this['tickSize'],_0x36f57f=_0x220cf5+_0x1c5aec*this[_0x2d195d(0x13c)]*this['tickSize']):(_0x59030b=_0x220cf5+_0x3713e8*this['tickSize'],_0x2670c0=_0x220cf5-_0x1c5aec*this['tickSize'],_0x1219df=_0x220cf5-this[_0x2d195d(0x114)]*this['tickSize'],_0x36f57f=_0x220cf5-_0x1c5aec*this['profitLockPct']*this['tickSize']);const _0x3452f2=_0x1c5aec/_0x3713e8,_0x4d1e88=Math[_0x2d195d(0xf8)](_0x1c5aec*0.5),_0x5b6191=Math[_0x2d195d(0xf8)](_0x3713e8*0.4);let _0x41df5f=SignalStrength['MODERATE'];if(_0x27f4fa>=0.85)_0x41df5f=SignalStrength[_0x2d195d(0x141)];else{if(_0x27f4fa>=0.75)_0x41df5f=SignalStrength[_0x2d195d(0xe8)];else{if(_0x27f4fa<0.6)_0x41df5f=SignalStrength['WEAK'];}}const _0xb5601=0.5+(_0x27f4fa-0.5)*0.4,_0x1274ea=_0xb5601*Math[_0x2d195d(0xf9)](_0x2670c0-_0x220cf5)-(0x1-_0xb5601)*Math[_0x2d195d(0xf9)](_0x220cf5-_0x59030b);this['lastSignalTime']=Date[_0x2d195d(0x156)](),this['stats'][_0x2d195d(0x146)]++;const _0x5e288c={'id':uuidv4(),'timestamp':Date[_0x2d195d(0x156)](),'symbol':_0x4fb3e9[_0x2d195d(0x153)]('.')[0x0]||_0x4fb3e9,'contractId':_0x4fb3e9,'side':_0x22d619===_0x2d195d(0x139)?OrderSide[_0x2d195d(0x159)]:OrderSide['ASK'],'direction':_0x22d619,'strategy':'HQX_ULTRA_SCALPING_6MODELS','strength':_0x41df5f,'edge':_0x1274ea,'confidence':_0x27f4fa,'entry':_0x220cf5,'entryPrice':_0x220cf5,'stopLoss':_0x59030b,'takeProfit':_0x2670c0,'riskReward':_0x3452f2,'stopTicks':_0x3713e8,'targetTicks':_0x1c5aec,'trailTriggerTicks':_0x4d1e88,'trailDistanceTicks':_0x5b6191,'beBreakeven':_0x1219df,'profitLockLevel':_0x36f57f,'zScore':_0x1e6ccf,'zScoreExit':this[_0x2d195d(0x13f)],'vpinValue':_0x2bbeb5,'kyleLambda':_0x2b682d,'kalmanEstimate':_0x47bba5,'volatilityRegime':_0x509952,'ofiValue':_0x266d29,'models':_0x2d7efd,'orderFlowConfirmed':_0x5c3459,'kalmanConfirmed':_0x2ae862,'expires':Date[_0x2d195d(0x156)]()+0xea60};return this[_0x2d195d(0xea)](_0x2d195d(0x109),{'side':_0x22d619==='long'?_0x2d195d(0x13b):'sell','action':_0x2d195d(0x11d),'reason':'Z='+_0x1e6ccf[_0x2d195d(0x122)](0x2)+_0x2d195d(0x116)+(_0x2bbeb5*0x64)[_0x2d195d(0x122)](0x0)+'%,\x20OFI='+(_0x266d29*0x64)['toFixed'](0x0)+_0x2d195d(0x135)+(_0x27f4fa*0x64)[_0x2d195d(0x122)](0x0)+'%',..._0x5e288c}),this[_0x2d195d(0xea)]('log',{'type':_0x2d195d(0x128),'message':'[HQX]\x20SIGNAL:\x20'+_0x22d619[_0x2d195d(0x100)]()+_0x2d195d(0x103)+_0x220cf5['toFixed'](0x2)+_0x2d195d(0x134)+_0x1e6ccf[_0x2d195d(0x122)](0x2)+_0x2d195d(0xef)+(_0x2bbeb5*0x64)[_0x2d195d(0x122)](0x0)+'%\x20OFI:'+(_0x266d29*0x64)[_0x2d195d(0x122)](0x0)+'%\x20Kyle:'+_0x2b682d['toFixed'](0x5)+_0x2d195d(0xf5)+_0x509952+'\x20|\x20Conf:'+(_0x27f4fa*0x64)[_0x2d195d(0x122)](0x0)+'%'}),_0x5e288c;}['shouldExitByZScore'](_0x467e1c){const _0x2f512b=_0x2023a7,_0xd7b508=this['priceBuffer']['get'](_0x467e1c);if(!_0xd7b508||_0xd7b508['length']<0x32)return![];const _0x31187d=this['_computeZScore'](_0xd7b508);return Math[_0x2f512b(0xf9)](_0x31187d)<this[_0x2f512b(0x13f)];}[_0x2023a7(0x137)](_0x26d0f0){const _0x57597c=_0x2023a7,_0x5b7349=this[_0x57597c(0x115)]['get'](_0x26d0f0),_0x4df43c=this[_0x57597c(0xec)][_0x57597c(0xf0)](_0x26d0f0),_0x177c00=this['barHistory']['get'](_0x26d0f0);if(!_0x5b7349||!_0x4df43c||!_0x177c00||_0x177c00[_0x57597c(0x110)]<0x32)return null;const _0x78496f=this['_computeZScore'](_0x5b7349),_0xc6f03=this[_0x57597c(0x155)](_0x4df43c),_0x2b2f40=this['_computeKyleLambda'](_0x177c00),_0x113dfb=this['_computeOrderFlowImbalance'](_0x177c00);return{'zscore':Math['min'](0x1,Math[_0x57597c(0xf9)](_0x78496f)/0x4),'vpin':0x1-_0xc6f03,'kyleLambda':_0x2b2f40>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math['abs'](_0x113dfb)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x78496f,'vpin':_0xc6f03,'kyleLambda':_0x2b2f40,'ofi':_0x113dfb}};}[_0x2023a7(0x154)](_0x2f0855,_0x1a7ead){const _0x17090b=_0x2023a7,_0x191da4=this[_0x17090b(0xfe)]['get'](_0x2f0855)||[];if(_0x191da4['length']<0x32)return{'ready':![],'message':_0x17090b(0x118)+_0x191da4[_0x17090b(0x110)]+_0x17090b(0xfc)};const _0x4fb90f=this[_0x17090b(0x115)][_0x17090b(0xf0)](_0x2f0855)||[],_0x467441=this['volumeBuffer']['get'](_0x2f0855)||[],_0x319965=this[_0x17090b(0x123)](_0x4fb90f),_0x561a96=this[_0x17090b(0x155)](_0x467441),_0x11f4d7=this['_computeOrderFlowImbalance'](_0x191da4),_0x54d4f2=this['_computeKyleLambda'](_0x191da4),{regime:_0xa1f46b,params:_0x177a6a}=this['_detectVolatilityRegime'](_0x2f0855,_0x191da4);return{'ready':!![],'zScore':_0x319965,'vpin':_0x561a96,'ofi':_0x11f4d7,'kyleLambda':_0x54d4f2,'regime':_0xa1f46b,'stopTicks':Math['round'](this[_0x17090b(0xeb)]*_0x177a6a['stopMultiplier']),'targetTicks':Math['round'](this[_0x17090b(0xf7)]*_0x177a6a[_0x17090b(0x117)]),'threshold':_0x177a6a['zscoreThreshold'],'barsProcessed':_0x191da4['length'],'models':'6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)'};}[_0x2023a7(0x149)](_0x43cdea){const _0x5ef64f=_0x2023a7;this[_0x5ef64f(0x105)]['push']({'netPnl':_0x43cdea,'timestamp':Date['now']()});if(this[_0x5ef64f(0x105)]['length']>0x64)this['recentTrades'][_0x5ef64f(0x10b)]();_0x43cdea>0x0?(this[_0x5ef64f(0x13e)]++,this[_0x5ef64f(0x148)]=0x0,this[_0x5ef64f(0xff)][_0x5ef64f(0x10d)]++):(this[_0x5ef64f(0x148)]++,this['winStreak']=0x0,this[_0x5ef64f(0xff)][_0x5ef64f(0x130)]++),this[_0x5ef64f(0xff)][_0x5ef64f(0x112)]++,this[_0x5ef64f(0xff)][_0x5ef64f(0xed)]+=_0x43cdea,this['emit']('log',{'type':_0x5ef64f(0x14b),'message':'[HQX]\x20Trade\x20result:\x20'+(_0x43cdea>0x0?_0x5ef64f(0x11a):'LOSS')+'\x20$'+_0x43cdea[_0x5ef64f(0x122)](0x2)+_0x5ef64f(0x11c)+(_0x43cdea>0x0?this['winStreak']:-this[_0x5ef64f(0x148)])});}['getBarHistory'](_0x5dc5c1){const _0x2732db=_0x2023a7;return this[_0x2732db(0xfe)]['get'](_0x5dc5c1)||[];}['getStats'](){const _0x32cc1d=_0x2023a7;return this[_0x32cc1d(0xff)];}['reset'](_0x24ac37){const _0x5724c6=_0x2023a7;this[_0x5724c6(0xfe)]['set'](_0x24ac37,[]),this[_0x5724c6(0x115)][_0x5724c6(0x126)](_0x24ac37,[]),this['volumeBuffer'][_0x5724c6(0x126)](_0x24ac37,[]),this['atrHistory'][_0x5724c6(0x126)](_0x24ac37,[]),this[_0x5724c6(0x10e)][_0x5724c6(0x126)](_0x24ac37,{'estimate':0x0,'errorCovariance':0x1}),this['emit']('log',{'type':'info','message':'[HQX-UltraScalping]\x20Reset\x20state\x20for\x20'+_0x24ac37});}}function _0x41d2(_0x4e3bf3,_0x54ae4b){_0x4e3bf3=_0x4e3bf3-0xe3;const _0x2bdca3=_0x2bdc();let _0x41d2c8=_0x2bdca3[_0x4e3bf3];return _0x41d2c8;}class UltraScalpingStrategy extends EventEmitter{constructor(_0x2ab4f8={}){const _0x47e567=_0x2023a7;super(),this['config']=_0x2ab4f8,this['strategy']=new HQXUltraScalping(_0x2ab4f8),this[_0x47e567(0x11e)]['on'](_0x47e567(0x109),_0x48c2b3=>this['emit'](_0x47e567(0x109),_0x48c2b3)),this['strategy']['on'](_0x47e567(0x147),_0x46b484=>this['emit'](_0x47e567(0x147),_0x46b484));}['processTick'](_0x3e479e){const _0x58cb92=_0x2023a7;return this[_0x58cb92(0x11e)][_0x58cb92(0xe4)](_0x3e479e);}['onTick'](_0x2f555f){const _0x35af9a=_0x2023a7;return this['strategy'][_0x35af9a(0x12f)](_0x2f555f);}['onTrade'](_0x376a4a){const _0x2e2a24=_0x2023a7;return this['strategy'][_0x2e2a24(0xfb)](_0x376a4a);}['processBar'](_0x22066c,_0x543350){const _0x428d8e=_0x2023a7;return this[_0x428d8e(0x11e)][_0x428d8e(0x151)](_0x22066c,_0x543350);}['initialize'](_0x13e7d7,_0x46cda3,_0x5cec6e){return this['strategy']['initialize'](_0x13e7d7,_0x46cda3,_0x5cec6e);}['getAnalysisState'](_0x490eae,_0x1afc25){const _0x45b1d9=_0x2023a7;return this[_0x45b1d9(0x11e)][_0x45b1d9(0x154)](_0x490eae,_0x1afc25);}[_0x2023a7(0x149)](_0x5bec52){return this['strategy']['recordTradeResult'](_0x5bec52);}['reset'](_0x114e79){const _0x348766=_0x2023a7;return this['strategy'][_0x348766(0x133)](_0x114e79);}['getStats'](){const _0xbee9fa=_0x2023a7;return this[_0xbee9fa(0x11e)][_0xbee9fa(0x104)]();}['getBarHistory'](_0x3d707){const _0x4abef7=_0x2023a7;return this['strategy'][_0x4abef7(0xf6)](_0x3d707);}[_0x2023a7(0x137)](_0x5abeab){const _0x4a9ebf=_0x2023a7;return this['strategy'][_0x4a9ebf(0x137)](_0x5abeab);}[_0x2023a7(0x108)](_0x3cda40){const _0x2d1cc8=_0x2023a7;return this[_0x2d1cc8(0x11e)][_0x2d1cc8(0x108)](_0x3cda40);}['generateSignal'](_0x2383b9){return null;}}module['exports']={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};function _0x2bdc(){const _0x3417c4=['volatilityLookback','minHoldTimeMs','711tIExVh','STRONG','vpinToxicThreshold','emit','baseStopTicks','volumeBuffer','pnl','_generateSignal','\x20VPIN:','get','vpinWindow','initialize','atrHistory','kalman','\x20Regime:','getBarHistory','baseTargetTicks','round','abs','slice','onTrade','/50\x20bars',',\x20value=','barHistory','stats','toUpperCase','short','zscoreEntryThreshold','\x20@\x20','getStats','recentTrades','max','_applyKalmanFilter','shouldExitByZScore','signal',':\x20tick=','shift','reduce','wins','kalmanStates','events','length','355624SKrifv','trades','timestamp','breakevenTicks','priceBuffer',',\x20VPIN=','targetMultiplier','Collecting\x20data...\x20','_calculateATR','WIN','normal',',\x20streak:\x20','open','strategy','close','minConfidence','kalmanProcessNoise','toFixed','_computeZScore','tickSize','819FnLiWe','set','weights','info','tickValue','low','329230hMpPZm','pow','131875ZFWxEm','min','onTick','losses','90pUOBeK','5154WkNrmG','reset','\x20|\x20Z:','%,\x20cf=','estimate','getModelValues','947906AFLwKx','long','contractId','buy','profitLockPct','price','winStreak','zscoreExitThreshold','push','VERY_STRONG','_detectVolatilityRegime','cooldownMs','465755ICaoUP','volatility','signals','log','lossStreak','recordTradeResult','zscoreThreshold','debug','high','ofiLookback','composite','kalmanMeasurementNoise','11892lLuCUM','processBar','vpin','split','getAnalysisState','_computeVPIN','now','volume','_computeOrderFlowImbalance','BID','lastSignalTime','processTick'];_0x2bdc=function(){return _0x3417c4;};return _0x2bdc();}
|
package/package.json
CHANGED
|
@@ -395,11 +395,22 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
395
395
|
await marketFeed.connect(rithmicCredentials);
|
|
396
396
|
await marketFeed.subscribe(symbolCode, contract.exchange || 'CME');
|
|
397
397
|
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
398
|
+
// Load historical bars for instant warmup
|
|
399
|
+
if (strategy.preloadBars) {
|
|
400
|
+
ui.addLog('system', 'Loading historical data...');
|
|
401
|
+
try {
|
|
402
|
+
const histBars = await marketFeed.getHistoricalBars(symbolCode, contract.exchange || 'CME', 30);
|
|
403
|
+
if (histBars && histBars.length > 0) {
|
|
404
|
+
strategy.preloadBars(contractId, histBars);
|
|
405
|
+
ui.addLog('system', `Loaded ${histBars.length} historical bars - ready to trade!`);
|
|
406
|
+
sessionLogger.log('HISTORY', `Preloaded ${histBars.length} bars`);
|
|
407
|
+
} else {
|
|
408
|
+
ui.addLog('system', 'No history available - warming up with live data...');
|
|
409
|
+
}
|
|
410
|
+
} catch (histErr) {
|
|
411
|
+
ui.addLog('system', `History load failed: ${histErr.message} - using live data`);
|
|
412
|
+
sessionLogger.log('HISTORY', `Failed: ${histErr.message}`);
|
|
413
|
+
}
|
|
403
414
|
}
|
|
404
415
|
} catch (e) {
|
|
405
416
|
ui.addLog('error', `Failed to connect: ${e.message}`);
|