hedgequantx 2.9.112 → 2.9.114
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 +1 -1
- package/dist/lib/m/ultra-scalping.js +1 -1
- package/package.json +1 -1
- package/src/lib/data.js +78 -32
- package/src/pages/algo/algo-executor.js +5 -16
package/dist/lib/m/hqx-2b.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const _0x35c3f9=_0x1213;(function(_0x5a92d1,_0x1139f3){const _0x22ba11=_0x1213,_0x230781=_0x5a92d1();while(!![]){try{const _0x2cf85f=-parseInt(_0x22ba11(0x93))/0x1+-parseInt(_0x22ba11(0xfa))/0x2*(parseInt(_0x22ba11(0x90))/0x3)+parseInt(_0x22ba11(0xde))/0x4+-parseInt(_0x22ba11(0x102))/0x5*(-parseInt(_0x22ba11(0x104))/0x6)+parseInt(_0x22ba11(0xf8))/0x7+parseInt(_0x22ba11(0x8a))/0x8*(parseInt(_0x22ba11(0xa8))/0x9)+-parseInt(_0x22ba11(0xb8))/0xa*(parseInt(_0x22ba11(0xba))/0xb);if(_0x2cf85f===_0x1139f3)break;else _0x230781['push'](_0x230781['shift']());}catch(_0x30be0f){_0x230781['push'](_0x230781['shift']());}}}(_0x292f,0x419db));const EventEmitter=require('events'),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':_0x35c3f9(0xf1),'LOW_SWEEP':_0x35c3f9(0xa6)},ZoneType={'RESISTANCE':'resistance','SUPPORT':'support'},DEFAULT_CONFIG={'tickSize':0.25,'tickValue':0x5,'swing':{'lookbackBars':0x1,'minStrength':0x1,'confirmationBars':0x1},'zone':{'clusterToleranceTicks':0x8,'minTouches':0x1,'maxZoneAgeBars':0x1f4,'maxZoneDistanceTicks':0x50,'cooldownBars':0x3},'sweep':{'minPenetrationTicks':0.25,'maxPenetrationTicks':0x14,'maxDurationBars':0xa,'minQualityScore':0.1,'minVolumeRatio':0.3,'minBodyRatio':0.05},'execution':{'stopTicks':0xa,'targetTicks':0x28,'breakevenTicks':0x4,'trailTriggerTicks':0x8,'trailDistanceTicks':0x4,'cooldownMs':0x1388,'minHoldTimeMs':0x1388,'slippageTicks':0x1,'commissionPerSide':0x2},'session':{'enabled':![],'startHour':0x9,'startMinute':0x1e,'endHour':0x10,'endMinute':0x0,'timezone':'America/New_York'}};class SwingPoint{constructor(_0x1eecdf,_0x58ff28,_0x33e0bf,_0x7e23c5,_0xe9347b=0x1){const _0x34c47=_0x35c3f9;this['type']=_0x1eecdf,this[_0x34c47(0xf6)]=_0x58ff28,this['barIndex']=_0x33e0bf,this[_0x34c47(0xbc)]=_0x7e23c5,this['strength']=_0xe9347b;}}function _0x1213(_0x3442c7,_0x50c81f){_0x3442c7=_0x3442c7-0x80;const _0x292f2e=_0x292f();let _0x1213e9=_0x292f2e[_0x3442c7];return _0x1213e9;}class LiquidityZone{constructor(_0x5da593,_0x32f3a4,_0x265081,_0x5a4140,_0x4480aa){const _0x498aa6=_0x35c3f9;this['id']=uuidv4(),this['type']=_0x5da593,this['priceHigh']=_0x32f3a4,this['priceLow']=_0x265081,this['createdAt']=_0x5a4140,this['barIndex']=_0x4480aa,this[_0x498aa6(0xbb)]=0x1,this['swept']=![],this['sweptAt']=null,this[_0x498aa6(0xef)]=-0x3e7,this['qualityScore']=0.5;}['containsPrice'](_0x17337f,_0x4be430,_0x4d5c88){const _0x4e9e01=_0x4be430*_0x4d5c88;return _0x17337f>=this['priceLow']-_0x4e9e01&&_0x17337f<=this['priceHigh']+_0x4e9e01;}[_0x35c3f9(0x9d)](){const _0x10c831=_0x35c3f9;return(this['priceHigh']+this[_0x10c831(0xc6)])/0x2;}}class SweepEvent{constructor(_0x18ec93,_0x1d6b95,_0x1c85fd,_0x2fd25e,_0x351687){const _0x381c2c=_0x35c3f9;this[_0x381c2c(0xdd)]=_0x18ec93,this[_0x381c2c(0x9b)]=_0x1d6b95,this['entryBarIndex']=_0x1c85fd,this['extremeBarIndex']=_0x2fd25e,this['extremePrice']=_0x351687,this[_0x381c2c(0x10a)]=null,this['isValid']=![],this['qualityScore']=0x0,this[_0x381c2c(0xb4)]=0x0,this['durationBars']=0x0,this['volumeRatio']=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x7a51bb={}){const _0x5b058b=_0x35c3f9;super(),this['config']=this['_mergeConfig'](DEFAULT_CONFIG,_0x7a51bb),this[_0x5b058b(0xb0)]=this[_0x5b058b(0xeb)]['tickSize'],this['tickValue']=this[_0x5b058b(0xeb)]['tickValue'],this['barHistory']=new Map(),this[_0x5b058b(0xa1)]=new Map(),this[_0x5b058b(0xec)]=new Map(),this[_0x5b058b(0xe0)]=new Map(),this['currentBar']=new Map(),this[_0x5b058b(0xb5)]=0xea60,this['lastSignalTime']=0x0,this['startTime']=Date['now'](),this['stats']={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this['recentTrades']=[];}[_0x35c3f9(0x109)](_0x37cc11,_0x31987d){const _0x5c80e1={..._0x37cc11};for(const _0x58d258 in _0x31987d){typeof _0x31987d[_0x58d258]==='object'&&!Array['isArray'](_0x31987d[_0x58d258])?_0x5c80e1[_0x58d258]={..._0x37cc11[_0x58d258],..._0x31987d[_0x58d258]}:_0x5c80e1[_0x58d258]=_0x31987d[_0x58d258];}return _0x5c80e1;}[_0x35c3f9(0xa9)](_0x6773c8){const _0x166696=_0x35c3f9;if(!this[_0x166696(0xeb)]['session'][_0x166696(0xc7)])return!![];const _0xea2e88=new Date(_0x6773c8),_0x14a391=this[_0x166696(0x10b)](_0xea2e88)?-0x4:-0x5,_0x23a53d=_0xea2e88['getUTCHours'](),_0x30ae54=_0xea2e88['getUTCMinutes'](),_0x76c7b7=(_0x23a53d+_0x14a391+0x18)%0x18,{startHour:_0x54add7,startMinute:_0x307d80,endHour:_0x34bb18,endMinute:_0x5e1934}=this[_0x166696(0xeb)]['session'],_0x7be9c1=_0x76c7b7*0x3c+_0x30ae54,_0x15a916=_0x54add7*0x3c+_0x307d80,_0x5e9d91=_0x34bb18*0x3c+_0x5e1934;return _0x7be9c1>=_0x15a916&&_0x7be9c1<_0x5e9d91;}[_0x35c3f9(0x10b)](_0x4a125a){const _0x5ded77=_0x35c3f9,_0x5c124d=new Date(_0x4a125a['getFullYear'](),0x0,0x1),_0x1d9edd=new Date(_0x4a125a['getFullYear'](),0x6,0x1),_0x28f042=Math['max'](_0x5c124d[_0x5ded77(0xf0)](),_0x1d9edd['getTimezoneOffset']());return _0x4a125a['getTimezoneOffset']()<_0x28f042;}['initialize'](_0x358109,_0x5c84bd=0.25,_0x4a3120=0x5){const _0x17b070=_0x35c3f9;this['tickSize']=_0x5c84bd,this['tickValue']=_0x4a3120,this[_0x17b070(0xeb)][_0x17b070(0xb0)]=_0x5c84bd,this['config']['tickValue']=_0x4a3120,this['barHistory']['set'](_0x358109,[]),this['swingPoints']['set'](_0x358109,[]),this['liquidityZones'][_0x17b070(0x8d)](_0x358109,[]),this['activeSweeps']['set'](_0x358109,[]),this[_0x17b070(0xda)]['delete'](_0x358109),this[_0x17b070(0xdf)]('log',{'type':_0x17b070(0xcd),'message':'[HQX-2B]\x20Initialized\x20for\x20'+_0x358109+':\x20tick='+_0x5c84bd+_0x17b070(0xd4)+_0x4a3120+_0x17b070(0x91)}),this['emit'](_0x17b070(0xfd),{'type':_0x17b070(0xcd),'message':'[HQX-2B]\x20Params:\x20Stop='+this[_0x17b070(0xeb)][_0x17b070(0x9c)][_0x17b070(0xc9)]+'t,\x20Target='+this['config']['execution']['targetTicks']+'t,\x20BE='+this[_0x17b070(0xeb)][_0x17b070(0x9c)]['breakevenTicks']+'t,\x20Trail='+this[_0x17b070(0xeb)]['execution']['trailTriggerTicks']+'/'+this[_0x17b070(0xeb)][_0x17b070(0x9c)][_0x17b070(0xcb)]});}[_0x35c3f9(0xcc)](_0x38f024){const _0xd521d1=_0x35c3f9,{contractId:_0x398490,price:_0x1b9514,volume:_0x4085e5,timestamp:_0x46a2dd}=_0x38f024,_0x1f57bc=_0x46a2dd||Date['now'](),_0x1d25fd=_0x4085e5||0x1;if(!this[_0xd521d1(0xa9)](_0x1f57bc))return null;let _0x52e6e0=this[_0xd521d1(0xda)][_0xd521d1(0xa2)](_0x398490);const _0x35fc7a=Math['floor'](_0x1f57bc/this[_0xd521d1(0xb5)])*this['barIntervalMs'];if(!_0x52e6e0||_0x52e6e0[_0xd521d1(0xd8)]!==_0x35fc7a){if(_0x52e6e0){const _0x7fb52e={'timestamp':_0x52e6e0['startTime'],'open':_0x52e6e0[_0xd521d1(0x80)],'high':_0x52e6e0[_0xd521d1(0xf1)],'low':_0x52e6e0['low'],'close':_0x52e6e0[_0xd521d1(0xbf)],'volume':_0x52e6e0['volume']},_0x4f8795=this[_0xd521d1(0xad)](_0x398490,_0x7fb52e);return this[_0xd521d1(0xda)][_0xd521d1(0x8d)](_0x398490,{'startTime':_0x35fc7a,'open':_0x1b9514,'high':_0x1b9514,'low':_0x1b9514,'close':_0x1b9514,'volume':_0x1d25fd}),_0x4f8795;}else return this[_0xd521d1(0xda)]['set'](_0x398490,{'startTime':_0x35fc7a,'open':_0x1b9514,'high':_0x1b9514,'low':_0x1b9514,'close':_0x1b9514,'volume':_0x1d25fd}),null;}else return _0x52e6e0['high']=Math['max'](_0x52e6e0[_0xd521d1(0xf1)],_0x1b9514),_0x52e6e0[_0xd521d1(0xa6)]=Math['min'](_0x52e6e0['low'],_0x1b9514),_0x52e6e0['close']=_0x1b9514,_0x52e6e0['volume']+=_0x1d25fd,null;}[_0x35c3f9(0x92)](_0x56df0d){return this['processTick'](_0x56df0d);}['onTrade'](_0x452b74){const _0x1685ec=_0x35c3f9;return this[_0x1685ec(0xcc)]({'contractId':_0x452b74['contractId']||_0x452b74[_0x1685ec(0xfe)],'price':_0x452b74['price'],'volume':_0x452b74['size']||_0x452b74['volume']||0x1,'timestamp':_0x452b74[_0x1685ec(0xbc)]||Date['now']()});}['processBar'](_0x5ef24e,_0x415499){const _0x1e4892=_0x35c3f9;let _0x528b72=this['barHistory'][_0x1e4892(0xa2)](_0x5ef24e);!_0x528b72&&(this[_0x1e4892(0x86)](_0x5ef24e),_0x528b72=this[_0x1e4892(0xca)]['get'](_0x5ef24e));_0x528b72[_0x1e4892(0x10e)](_0x415499);if(_0x528b72[_0x1e4892(0xb1)]>0x1f4)_0x528b72['shift']();const _0x5d799c=_0x528b72[_0x1e4892(0xb1)]-0x1;if(_0x528b72['length']<this[_0x1e4892(0xeb)]['swing']['lookbackBars']*0x3)return null;const _0x465836=this['swingPoints']['get'](_0x5ef24e)['length'];this[_0x1e4892(0xa4)](_0x5ef24e,_0x528b72,_0x5d799c);const _0x39c2fb=this[_0x1e4892(0xa1)]['get'](_0x5ef24e);if(_0x39c2fb[_0x1e4892(0xb1)]>_0x465836){const _0x75feb0=_0x39c2fb[_0x39c2fb[_0x1e4892(0xb1)]-0x1];this['emit'](_0x1e4892(0xfd),{'type':_0x1e4892(0xb3),'message':'[2B]\x20NEW\x20SWING\x20'+_0x75feb0[_0x1e4892(0xa3)][_0x1e4892(0xe8)]()+_0x1e4892(0x110)+_0x75feb0['price'][_0x1e4892(0x108)](0x2)+'\x20|\x20Total:\x20'+_0x39c2fb[_0x1e4892(0xb1)]});}const _0x1532e7=this['_detectSweep'](_0x5ef24e,_0x528b72,_0x5d799c);_0x1532e7&&this[_0x1e4892(0xdf)]('log',{'type':_0x1e4892(0xb3),'message':'[2B]\x20SWEEP\x20'+_0x1532e7[_0x1e4892(0xdd)]+_0x1e4892(0x101)+_0x1532e7[_0x1e4892(0xf7)]+_0x1e4892(0xd9)+_0x1532e7['penetrationTicks']['toFixed'](0x1)+'t\x20|\x20Q:\x20'+(_0x1532e7[_0x1e4892(0xd7)]*0x64)[_0x1e4892(0x108)](0x0)+'%'});const _0xb61e=this['liquidityZones']['get'](_0x5ef24e)[_0x1e4892(0xb1)];this['_updateZones'](_0x5ef24e,_0x5d799c);const _0x5ed14f=this['liquidityZones'][_0x1e4892(0xa2)](_0x5ef24e);if(_0x5ed14f[_0x1e4892(0xb1)]>_0xb61e){const _0x8dfeab=_0x5ed14f[_0x5ed14f['length']-0x1];this[_0x1e4892(0xdf)]('log',{'type':'debug','message':_0x1e4892(0xdb)+_0x8dfeab['type']['toUpperCase']()+_0x1e4892(0x110)+_0x8dfeab[_0x1e4892(0x9d)]()[_0x1e4892(0x108)](0x2)+_0x1e4892(0xe9)+_0x5ed14f[_0x1e4892(0xb1)]});}if(_0x1532e7&&_0x1532e7['isValid']){this[_0x1e4892(0xdf)]('log',{'type':'debug','message':_0x1e4892(0xaf)+_0x1532e7[_0x1e4892(0xdd)]+'\x20sweep...'});const _0x1a5e56=this[_0x1e4892(0xe4)](_0x5ef24e,_0x415499,_0x5d799c,_0x1532e7);return!_0x1a5e56&&this[_0x1e4892(0xdf)]('log',{'type':_0x1e4892(0xb3),'message':_0x1e4892(0x84)}),_0x1a5e56;}return null;}[_0x35c3f9(0xa4)](_0x1e8fcb,_0xceb5c8,_0x52be00){const _0x519dd4=_0x35c3f9,_0x3254b1=this[_0x519dd4(0xeb)][_0x519dd4(0xea)][_0x519dd4(0x96)],_0xf8c08=this[_0x519dd4(0xeb)]['swing'][_0x519dd4(0x9e)];if(_0x52be00<_0x3254b1*0x2)return;const _0x47f007=this[_0x519dd4(0xa1)][_0x519dd4(0xa2)](_0x1e8fcb),_0x4e9df2=_0x52be00-_0x3254b1,_0x552914=_0xceb5c8[_0x4e9df2];let _0x8c01ac=!![],_0xa0e1ea=0x0;for(let _0x3af1a7=_0x4e9df2-_0x3254b1;_0x3af1a7<=_0x4e9df2+_0x3254b1;_0x3af1a7++){if(_0x3af1a7===_0x4e9df2||_0x3af1a7<0x0||_0x3af1a7>=_0xceb5c8['length'])continue;if(_0xceb5c8[_0x3af1a7]['high']>=_0x552914[_0x519dd4(0xf1)]){_0x8c01ac=![];break;}_0xa0e1ea++;}if(_0x8c01ac&&_0xa0e1ea>=_0xf8c08){const _0x51cb36=_0x47f007['find'](_0x2c235e=>_0x2c235e['barIndex']===_0x4e9df2&&_0x2c235e['type']===_0x519dd4(0xf1));!_0x51cb36&&_0x47f007[_0x519dd4(0x10e)](new SwingPoint('high',_0x552914['high'],_0x4e9df2,_0x552914[_0x519dd4(0xbc)],_0xa0e1ea));}let _0xaa19f5=!![],_0xb32331=0x0;for(let _0x458333=_0x4e9df2-_0x3254b1;_0x458333<=_0x4e9df2+_0x3254b1;_0x458333++){if(_0x458333===_0x4e9df2||_0x458333<0x0||_0x458333>=_0xceb5c8['length'])continue;if(_0xceb5c8[_0x458333]['low']<=_0x552914[_0x519dd4(0xa6)]){_0xaa19f5=![];break;}_0xb32331++;}if(_0xaa19f5&&_0xb32331>=_0xf8c08){const _0x5719de=_0x47f007[_0x519dd4(0xfb)](_0x33a653=>_0x33a653['barIndex']===_0x4e9df2&&_0x33a653[_0x519dd4(0xa3)]==='low');!_0x5719de&&_0x47f007['push'](new SwingPoint(_0x519dd4(0xa6),_0x552914['low'],_0x4e9df2,_0x552914[_0x519dd4(0xbc)],_0xb32331));}const _0x22d2ba=this[_0x519dd4(0xeb)]['zone'][_0x519dd4(0xc8)];while(_0x47f007['length']>0x0&&_0x47f007[0x0][_0x519dd4(0x97)]<_0x52be00-_0x22d2ba){_0x47f007['shift']();}}[_0x35c3f9(0x103)](_0x5879a9,_0x2bbe16){const _0x16f859=_0x35c3f9,_0x9c80f0=this['swingPoints']['get'](_0x5879a9),_0x2cc6ef=this[_0x16f859(0xec)]['get'](_0x5879a9),_0x58da1c=this[_0x16f859(0xeb)][_0x16f859(0x9b)]['clusterToleranceTicks']*this['tickSize'],_0x1c78ae=this[_0x16f859(0xeb)][_0x16f859(0x9b)]['maxZoneAgeBars'];for(let _0x28554d=_0x2cc6ef[_0x16f859(0xb1)]-0x1;_0x28554d>=0x0;_0x28554d--){_0x2bbe16-_0x2cc6ef[_0x28554d]['barIndex']>_0x1c78ae&&_0x2cc6ef['splice'](_0x28554d,0x1);}for(const _0x45b6f6 of _0x9c80f0){let _0x47c564=null;for(const _0x1865c5 of _0x2cc6ef){if(_0x1865c5[_0x16f859(0xdc)](_0x45b6f6[_0x16f859(0xf6)],this[_0x16f859(0xeb)][_0x16f859(0x9b)]['clusterToleranceTicks'],this['tickSize'])){_0x47c564=_0x1865c5;break;}}if(_0x47c564){_0x47c564['touches']++;if(_0x45b6f6['price']>_0x47c564['priceHigh'])_0x47c564[_0x16f859(0x10c)]=_0x45b6f6[_0x16f859(0xf6)];if(_0x45b6f6['price']<_0x47c564['priceLow'])_0x47c564['priceLow']=_0x45b6f6[_0x16f859(0xf6)];_0x47c564['qualityScore']=Math[_0x16f859(0xe3)](0x1,0.3+_0x47c564['touches']*0.15);}else{const _0x13f68b=_0x45b6f6[_0x16f859(0xa3)]===_0x16f859(0xf1)?ZoneType[_0x16f859(0x105)]:ZoneType[_0x16f859(0xf4)],_0x4b09fa=new LiquidityZone(_0x13f68b,_0x45b6f6['price']+_0x58da1c/0x2,_0x45b6f6['price']-_0x58da1c/0x2,_0x45b6f6['timestamp'],_0x45b6f6[_0x16f859(0x97)]);_0x4b09fa['qualityScore']=0.3+_0x45b6f6['strength']*0.1,_0x2cc6ef['push'](_0x4b09fa);}}}['_detectSweep'](_0x24d067,_0xcadc1f,_0xb88e3c){const _0x284223=_0x35c3f9,_0x2b48d2=this[_0x284223(0xec)][_0x284223(0xa2)](_0x24d067),_0x433b81=_0xcadc1f[_0xb88e3c],_0x1740ce=_0x433b81['close'],_0xee2e48=this[_0x284223(0xeb)][_0x284223(0x88)],_0x283be=this[_0x284223(0xeb)]['zone'];for(const _0x16ef69 of _0x2b48d2){if(_0x16ef69['lastUsedBarIndex']>=0x0&&_0xb88e3c-_0x16ef69[_0x284223(0xef)]<_0x283be['cooldownBars'])continue;const _0x1bd0f9=_0x16ef69['getLevel'](),_0x100a33=Math[_0x284223(0x9a)](_0x1740ce-_0x1bd0f9)/this[_0x284223(0xb0)];if(_0x100a33>_0x283be['maxZoneDistanceTicks'])continue;const _0x135e8d=Math['max'](0x0,_0xb88e3c-_0xee2e48[_0x284223(0x82)]*0x2);for(let _0x484352=_0x135e8d;_0x484352<_0xb88e3c;_0x484352++){const _0x5bbec1=_0xcadc1f[_0x484352];if(_0x16ef69['type']===ZoneType[_0x284223(0x105)]){const _0x1daf48=(_0x5bbec1['high']-_0x16ef69['priceHigh'])/this['tickSize'];if(_0x1daf48>=_0xee2e48[_0x284223(0xd5)]&&_0x1daf48<=_0xee2e48[_0x284223(0x8b)]){const _0x862f19=Math[_0x284223(0xe3)](_0x16ef69['priceHigh'],_0x16ef69['priceHigh']+_0x1daf48*this[_0x284223(0xb0)]);if(_0x1740ce<_0x862f19+this['tickSize']*0x2){const _0xf41082=_0x5bbec1[_0x284223(0xf1)]-_0x5bbec1['low'],_0x43e325=Math[_0x284223(0x9a)](_0x5bbec1[_0x284223(0xbf)]-_0x5bbec1[_0x284223(0x80)]),_0x3bf102=_0xf41082>0x0?_0x43e325/_0xf41082:0x0;if(_0x3bf102>=_0xee2e48['minBodyRatio']){const _0x15884=this[_0x284223(0x94)](_0xcadc1f,_0x484352,0x14);if(_0x15884>=_0xee2e48[_0x284223(0x8e)]){const _0xc52efa=new SweepEvent(SweepType['HIGH_SWEEP'],_0x16ef69,_0x484352,_0x484352,_0x5bbec1['high']);_0xc52efa[_0x284223(0x10a)]=_0xb88e3c,_0xc52efa['penetrationTicks']=_0x1daf48,_0xc52efa[_0x284223(0xd6)]=_0xb88e3c-_0x484352,_0xc52efa['volumeRatio']=_0x15884,_0xc52efa['qualityScore']=this['_scoreSweep'](_0xc52efa,_0x3bf102),_0xc52efa['isValid']=_0xc52efa[_0x284223(0xd7)]>=_0xee2e48['minQualityScore'];if(_0xc52efa['isValid'])return _0xc52efa;}}}}}if(_0x16ef69['type']===ZoneType[_0x284223(0xf4)]){const _0x3bab33=(_0x16ef69['priceLow']-_0x5bbec1[_0x284223(0xa6)])/this[_0x284223(0xb0)];if(_0x3bab33>=_0xee2e48['minPenetrationTicks']&&_0x3bab33<=_0xee2e48[_0x284223(0x8b)]){const _0x1e9e19=Math[_0x284223(0xb9)](_0x16ef69['priceLow'],_0x16ef69[_0x284223(0xc6)]-_0x3bab33*this[_0x284223(0xb0)]);if(_0x1740ce>_0x1e9e19-this['tickSize']*0x2){const _0x3f32d7=_0x5bbec1[_0x284223(0xf1)]-_0x5bbec1[_0x284223(0xa6)],_0x22d77b=Math[_0x284223(0x9a)](_0x5bbec1['close']-_0x5bbec1[_0x284223(0x80)]),_0x57bc3d=_0x3f32d7>0x0?_0x22d77b/_0x3f32d7:0x0;if(_0x57bc3d>=_0xee2e48[_0x284223(0xee)]){const _0x114936=this[_0x284223(0x94)](_0xcadc1f,_0x484352,0x14);if(_0x114936>=_0xee2e48['minVolumeRatio']){const _0x4c8edc=new SweepEvent(SweepType['LOW_SWEEP'],_0x16ef69,_0x484352,_0x484352,_0x5bbec1['low']);_0x4c8edc['exitBarIndex']=_0xb88e3c,_0x4c8edc['penetrationTicks']=_0x3bab33,_0x4c8edc[_0x284223(0xd6)]=_0xb88e3c-_0x484352,_0x4c8edc[_0x284223(0xc3)]=_0x114936,_0x4c8edc[_0x284223(0xd7)]=this[_0x284223(0xd3)](_0x4c8edc,_0x57bc3d),_0x4c8edc[_0x284223(0xf7)]=_0x4c8edc['qualityScore']>=_0xee2e48['minQualityScore'];if(_0x4c8edc[_0x284223(0xf7)])return _0x4c8edc;}}}}}}}return null;}['_getVolumeRatio'](_0x635ee1,_0x570516,_0x1710db){const _0xf02ec6=_0x35c3f9,_0x2b456b=Math['max'](0x0,_0x570516-_0x1710db),_0x355bd7=_0x635ee1['slice'](_0x2b456b,_0x570516);if(_0x355bd7['length']===0x0)return 0x1;const _0x1469a1=_0x355bd7['map'](_0x3282e0=>_0x3282e0['volume'])[_0xf02ec6(0xa5)]((_0x4e482f,_0x2e0c65)=>_0x4e482f-_0x2e0c65),_0x49b88c=Math[_0xf02ec6(0xe7)](_0x1469a1['length']/0x2),_0x18b39c=_0x1469a1[_0x49b88c]||0x1;return _0x635ee1[_0x570516][_0xf02ec6(0xc5)]/_0x18b39c;}[_0x35c3f9(0xd3)](_0x19db72,_0x361733){const _0x1dfdde=_0x35c3f9;let _0x22e617=0x0;const _0x1da3a4=0x4,_0x2aa434=Math['abs'](_0x19db72[_0x1dfdde(0xb4)]-_0x1da3a4);return _0x22e617+=Math[_0x1dfdde(0xb9)](0x0,0.3-_0x2aa434*0.03),_0x22e617+=Math['max'](0x0,0.25-_0x19db72['durationBars']*0.05),_0x22e617+=Math[_0x1dfdde(0xe3)](0.25,_0x19db72['volumeRatio']*0.1),_0x22e617+=Math[_0x1dfdde(0xe3)](0.2,_0x361733*0.4),Math[_0x1dfdde(0xe3)](0x1,_0x22e617);}[_0x35c3f9(0xe4)](_0x2a8d22,_0x5c148e,_0x19b712,_0x399ca6){const _0x4f34e7=_0x35c3f9,_0xbbec6e=Date['now']()-this['lastSignalTime'];if(_0xbbec6e<this['config']['execution'][_0x4f34e7(0x100)])return this[_0x4f34e7(0xdf)](_0x4f34e7(0xfd),{'type':_0x4f34e7(0xb3),'message':'[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20('+(_0xbbec6e/0x3e8)['toFixed'](0x1)+'s\x20<\x20'+this[_0x4f34e7(0xeb)]['execution'][_0x4f34e7(0x100)]/0x3e8+'s)'}),null;const _0xfebdf5=this[_0x4f34e7(0xeb)][_0x4f34e7(0x9c)],_0x2da01c=_0x5c148e[_0x4f34e7(0xbf)],_0xee442b=_0x399ca6[_0x4f34e7(0xdd)]===SweepType['HIGH_SWEEP']?_0x4f34e7(0xf9):_0x4f34e7(0xfc);let _0x5d19e0,_0x439324,_0x89dde8,_0x3ac884;_0xee442b==='long'?(_0x5d19e0=_0x2da01c-_0xfebdf5[_0x4f34e7(0xc9)]*this['tickSize'],_0x439324=_0x2da01c+_0xfebdf5[_0x4f34e7(0x95)]*this[_0x4f34e7(0xb0)],_0x89dde8=_0x2da01c+_0xfebdf5['breakevenTicks']*this[_0x4f34e7(0xb0)],_0x3ac884=_0x2da01c+_0xfebdf5[_0x4f34e7(0xd2)]*this[_0x4f34e7(0xb0)]):(_0x5d19e0=_0x2da01c+_0xfebdf5['stopTicks']*this[_0x4f34e7(0xb0)],_0x439324=_0x2da01c-_0xfebdf5['targetTicks']*this[_0x4f34e7(0xb0)],_0x89dde8=_0x2da01c-_0xfebdf5[_0x4f34e7(0x87)]*this['tickSize'],_0x3ac884=_0x2da01c-_0xfebdf5['trailTriggerTicks']*this['tickSize']);const _0x1c0a7a=_0xfebdf5['targetTicks']/_0xfebdf5[_0x4f34e7(0xc9)],_0x4ccae4=Math[_0x4f34e7(0xe3)](0x1,_0x399ca6[_0x4f34e7(0xd7)]*0.5+_0x399ca6[_0x4f34e7(0x9b)]['qualityScore']*0.3+(_0x399ca6[_0x4f34e7(0xc3)]>1.5?0.2:_0x399ca6[_0x4f34e7(0xc3)]*0.1));let _0x5526f8=SignalStrength['MODERATE'];if(_0x4ccae4>=0.8)_0x5526f8=SignalStrength['VERY_STRONG'];else{if(_0x4ccae4>=0.65)_0x5526f8=SignalStrength[_0x4f34e7(0xae)];else{if(_0x4ccae4<0.5)_0x5526f8=SignalStrength[_0x4f34e7(0x10d)];}}const _0x4527f5=0.5+(_0x4ccae4-0.5)*0.4,_0x25b7a4=_0x4527f5*Math[_0x4f34e7(0x9a)](_0x439324-_0x2da01c)-(0x1-_0x4527f5)*Math[_0x4f34e7(0x9a)](_0x2da01c-_0x5d19e0);_0x399ca6['zone'][_0x4f34e7(0xef)]=_0x19b712,_0x399ca6['zone']['swept']=!![],_0x399ca6['zone']['sweptAt']=new Date(_0x5c148e['timestamp']),this[_0x4f34e7(0x10f)]=Date[_0x4f34e7(0x85)](),this['stats']['signals']++;const _0x12cc67={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0x2a8d22['split']('.')[0x0]||_0x2a8d22,'contractId':_0x2a8d22,'side':_0xee442b==='long'?OrderSide['BID']:OrderSide[_0x4f34e7(0xa7)],'direction':_0xee442b,'strategy':_0x4f34e7(0xb7),'strength':_0x5526f8,'edge':_0x25b7a4,'confidence':_0x4ccae4,'entry':_0x2da01c,'entryPrice':_0x2da01c,'stopLoss':_0x5d19e0,'takeProfit':_0x439324,'riskReward':_0x1c0a7a,'stopTicks':_0xfebdf5[_0x4f34e7(0xc9)],'targetTicks':_0xfebdf5[_0x4f34e7(0x95)],'breakevenTicks':_0xfebdf5[_0x4f34e7(0x87)],'trailTriggerTicks':_0xfebdf5['trailTriggerTicks'],'trailDistanceTicks':_0xfebdf5[_0x4f34e7(0xcb)],'beLevel':_0x89dde8,'trailTrigger':_0x3ac884,'sweepType':_0x399ca6[_0x4f34e7(0xdd)],'penetrationTicks':_0x399ca6[_0x4f34e7(0xb4)],'sweepDurationBars':_0x399ca6['durationBars'],'sweepQuality':_0x399ca6[_0x4f34e7(0xd7)],'volumeRatio':_0x399ca6[_0x4f34e7(0xc3)],'zoneType':_0x399ca6['zone'][_0x4f34e7(0xa3)],'zoneLevel':_0x399ca6[_0x4f34e7(0x9b)][_0x4f34e7(0x9d)](),'zoneTouches':_0x399ca6[_0x4f34e7(0x9b)]['touches'],'zoneQuality':_0x399ca6[_0x4f34e7(0x9b)][_0x4f34e7(0xd7)],'expires':Date['now']()+0xea60};return this['emit']('signal',{'side':_0xee442b===_0x4f34e7(0xfc)?_0x4f34e7(0xc4):_0x4f34e7(0xb6),'action':_0x4f34e7(0x80),'reason':'2B\x20'+_0x399ca6['sweepType']+'\x20|\x20Pen:'+_0x399ca6[_0x4f34e7(0xb4)][_0x4f34e7(0x108)](0x1)+_0x4f34e7(0x98)+_0x399ca6['volumeRatio']['toFixed'](0x1)+_0x4f34e7(0xf3)+(_0x399ca6[_0x4f34e7(0xd7)]*0x64)['toFixed'](0x0)+'%',..._0x12cc67}),this[_0x4f34e7(0xdf)](_0x4f34e7(0xfd),{'type':_0x4f34e7(0xcd),'message':'[HQX-2B]\x20SIGNAL:\x20'+_0xee442b['toUpperCase']()+'\x20@\x20'+_0x2da01c['toFixed'](0x2)+_0x4f34e7(0x9f)+_0x399ca6['sweepType']+_0x4f34e7(0xf2)+_0x399ca6['penetrationTicks'][_0x4f34e7(0x108)](0x1)+_0x4f34e7(0xe5)+_0x399ca6[_0x4f34e7(0xc3)][_0x4f34e7(0x108)](0x1)+'x\x20|\x20Conf:'+(_0x4ccae4*0x64)[_0x4f34e7(0x108)](0x0)+'%'}),_0x12cc67;}[_0x35c3f9(0xd0)](_0x17b619,_0x4debb2){const _0x166fd0=_0x35c3f9,_0x54056a=this[_0x166fd0(0xca)][_0x166fd0(0xa2)](_0x17b619)||[],_0x473cff=this[_0x166fd0(0xec)]['get'](_0x17b619)||[],_0x286742=this['swingPoints'][_0x166fd0(0xa2)](_0x17b619)||[];if(_0x54056a['length']<0x5)return{'ready':![],'message':'Collecting\x20data...\x20'+_0x54056a['length']+'/5\x20bars'};const _0x2f61ce=_0x473cff[_0x166fd0(0xa0)](_0x5554c0=>({'zone':_0x5554c0,'distance':Math['abs'](_0x4debb2-_0x5554c0[_0x166fd0(0x9d)]())}))['sort']((_0x188fff,_0x1df62a)=>_0x188fff[_0x166fd0(0xc2)]-_0x1df62a['distance']),_0x31cbd1=_0x2f61ce['find'](_0x434379=>_0x434379[_0x166fd0(0x9b)]['type']===ZoneType[_0x166fd0(0x105)]),_0x57c3d4=_0x2f61ce[_0x166fd0(0xfb)](_0x2a5f9c=>_0x2a5f9c[_0x166fd0(0x9b)]['type']===ZoneType[_0x166fd0(0xf4)]);return{'ready':!![],'barsProcessed':_0x54056a['length'],'swingsDetected':_0x286742['length'],'activeZones':_0x473cff[_0x166fd0(0xb1)],'nearestResistance':_0x31cbd1?_0x31cbd1[_0x166fd0(0x9b)][_0x166fd0(0x9d)]():null,'nearestSupport':_0x57c3d4?_0x57c3d4['zone'][_0x166fd0(0x9d)]():null,'stopTicks':this['config']['execution'][_0x166fd0(0xc9)],'targetTicks':this[_0x166fd0(0xeb)]['execution']['targetTicks'],'strategy':_0x166fd0(0x107)};}[_0x35c3f9(0xf5)](_0x1002e3){const _0x458b0a=_0x35c3f9;this[_0x458b0a(0xcf)]['push']({'netPnl':_0x1002e3,'timestamp':Date['now']()});if(this['recentTrades']['length']>0x64)this[_0x458b0a(0xcf)][_0x458b0a(0x111)]();_0x1002e3>0x0?this[_0x458b0a(0x99)]['wins']++:this['stats'][_0x458b0a(0xed)]++,this['stats'][_0x458b0a(0xce)]++,this[_0x458b0a(0x99)]['pnl']+=_0x1002e3,this['emit'](_0x458b0a(0xfd),{'type':'debug','message':_0x458b0a(0xab)+(_0x1002e3>0x0?'WIN':'LOSS')+'\x20$'+_0x1002e3[_0x458b0a(0x108)](0x2)});}[_0x35c3f9(0x89)](_0x4cd541){const _0x1bff52=_0x35c3f9;return this['barHistory'][_0x1bff52(0xa2)](_0x4cd541)||[];}['getStats'](){const _0x3ddc28=_0x35c3f9;return this[_0x3ddc28(0x99)];}[_0x35c3f9(0xe2)](_0x4c6dc5){const _0x37201e=_0x35c3f9,_0xb8fc6b=this['barHistory'][_0x37201e(0xa2)](_0x4c6dc5)||[],_0x158f67=this[_0x37201e(0xec)]['get'](_0x4c6dc5)||[],_0x281f1e=this[_0x37201e(0xa1)]['get'](_0x4c6dc5)||[],_0x33d38d=this[_0x37201e(0xda)][_0x37201e(0xa2)](_0x4c6dc5),_0x9d3c78=_0xb8fc6b[_0xb8fc6b['length']-0x1],_0x1ec71d=_0x9d3c78?Date['now']()-_0x9d3c78['timestamp']:null,_0x391e40=_0x158f67[_0x37201e(0xc0)](_0x44ae27=>_0x44ae27[_0x37201e(0xa3)]===ZoneType['RESISTANCE'])['length'],_0x2c3816=_0x158f67[_0x37201e(0xc0)](_0x504fbf=>_0x504fbf['type']===ZoneType[_0x37201e(0xf4)])[_0x37201e(0xb1)];return{'healthy':_0xb8fc6b['length']>=0x5,'barsTotal':_0xb8fc6b[_0x37201e(0xb1)],'barsLast5Min':_0xb8fc6b['filter'](_0x1f2233=>Date[_0x37201e(0x85)]()-_0x1f2233[_0x37201e(0xbc)]<0x5*0x3c*0x3e8)['length'],'swingsTotal':_0x281f1e['length'],'zonesResistance':_0x391e40,'zonesSupport':_0x2c3816,'zonesTotal':_0x158f67[_0x37201e(0xb1)],'currentBarTicks':_0x33d38d?_0x33d38d[_0x37201e(0x81)]:0x0,'isAggregating':_0x33d38d&&_0x33d38d['tickCount']>0x0,'timeSinceLastBarMs':_0x1ec71d,'lastSignalTime':this[_0x37201e(0x10f)],'signalCooldownMs':this[_0x37201e(0xeb)][_0x37201e(0x9c)]['cooldownMs'],'uptime':Date['now']()-(this['startTime']||Date[_0x37201e(0x85)]())};}[_0x35c3f9(0xac)](_0x393a10){const _0x3c464f=_0x35c3f9;this[_0x3c464f(0xca)][_0x3c464f(0x8d)](_0x393a10,[]),this[_0x3c464f(0xa1)]['set'](_0x393a10,[]),this[_0x3c464f(0xec)][_0x3c464f(0x8d)](_0x393a10,[]),this[_0x3c464f(0xe0)]['set'](_0x393a10,[]),this[_0x3c464f(0xda)][_0x3c464f(0xe1)](_0x393a10),this['emit']('log',{'type':_0x3c464f(0xcd),'message':_0x3c464f(0xbd)+_0x393a10});}['preloadBars'](_0x3ca1c9,_0x3a9d2e){const _0x575ac5=_0x35c3f9;if(!_0x3a9d2e||_0x3a9d2e[_0x575ac5(0xb1)]===0x0){this[_0x575ac5(0xdf)](_0x575ac5(0xfd),{'type':'debug','message':'[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload'});return;}!this['barHistory'][_0x575ac5(0xe6)](_0x3ca1c9)&&this['initialize'](_0x3ca1c9);const _0x4af3bf=[..._0x3a9d2e]['sort']((_0x144159,_0x52e966)=>_0x144159['timestamp']-_0x52e966[_0x575ac5(0xbc)]);this[_0x575ac5(0xdf)](_0x575ac5(0xfd),{'type':'info','message':_0x575ac5(0xb2)+_0x4af3bf['length']+'\x20historical\x20bars...'});let _0xaa7e8c=0x0;for(const _0x10ebbf of _0x4af3bf){const _0x53ea3a=this['processBar'](_0x3ca1c9,_0x10ebbf);if(_0x53ea3a)_0xaa7e8c++;}const _0x3c9c95=this[_0x575ac5(0xca)][_0x575ac5(0xa2)](_0x3ca1c9)||[],_0x2de561=this[_0x575ac5(0xa1)][_0x575ac5(0xa2)](_0x3ca1c9)||[],_0x13cf29=this[_0x575ac5(0xec)][_0x575ac5(0xa2)](_0x3ca1c9)||[];this['emit']('log',{'type':'info','message':_0x575ac5(0x8f)+_0x3c9c95['length']+'\x20bars,\x20'+_0x2de561[_0x575ac5(0xb1)]+_0x575ac5(0x106)+_0x13cf29['length']+_0x575ac5(0xff)}),_0xaa7e8c>0x0&&this[_0x575ac5(0xdf)](_0x575ac5(0xfd),{'type':_0x575ac5(0xb3),'message':'[HQX-2B]\x20'+_0xaa7e8c+_0x575ac5(0xbe)}),this[_0x575ac5(0x10f)]=0x0;}}class HQX2BStrategy extends EventEmitter{constructor(_0x10a243={}){const _0x546e51=_0x35c3f9;super(),this['config']=_0x10a243,this['strategy']=new HQX2BLiquiditySweep(_0x10a243),this['strategy']['on'](_0x546e51(0x8c),_0x5c2709=>this['emit'](_0x546e51(0x8c),_0x5c2709)),this[_0x546e51(0xd1)]['on']('log',_0x5648d5=>this[_0x546e51(0xdf)](_0x546e51(0xfd),_0x5648d5));}['processTick'](_0x10f7d5){const _0x1b4911=_0x35c3f9;return this[_0x1b4911(0xd1)][_0x1b4911(0xcc)](_0x10f7d5);}['onTick'](_0x383881){const _0x3977be=_0x35c3f9;return this[_0x3977be(0xd1)][_0x3977be(0x92)](_0x383881);}['onTrade'](_0x4ff93b){const _0x355fc9=_0x35c3f9;return this['strategy'][_0x355fc9(0x83)](_0x4ff93b);}[_0x35c3f9(0xad)](_0x2553c4,_0x503ca2){const _0x30c7db=_0x35c3f9;return this[_0x30c7db(0xd1)]['processBar'](_0x2553c4,_0x503ca2);}[_0x35c3f9(0x86)](_0x47d982,_0x35e189,_0x5efba8){const _0x399739=_0x35c3f9;return this['strategy'][_0x399739(0x86)](_0x47d982,_0x35e189,_0x5efba8);}['getAnalysisState'](_0x3fbaae,_0x116f5e){const _0x3dbd07=_0x35c3f9;return this['strategy'][_0x3dbd07(0xd0)](_0x3fbaae,_0x116f5e);}['recordTradeResult'](_0x3d2f84){const _0xf0d2f2=_0x35c3f9;return this[_0xf0d2f2(0xd1)]['recordTradeResult'](_0x3d2f84);}[_0x35c3f9(0xac)](_0x165c6f){const _0x312ca2=_0x35c3f9;return this[_0x312ca2(0xd1)][_0x312ca2(0xac)](_0x165c6f);}[_0x35c3f9(0xaa)](){const _0x4c2d05=_0x35c3f9;return this[_0x4c2d05(0xd1)][_0x4c2d05(0xaa)]();}['getBarHistory'](_0x3861d6){const _0x1954e8=_0x35c3f9;return this[_0x1954e8(0xd1)]['getBarHistory'](_0x3861d6);}['preloadBars'](_0xee10f3,_0x1f6eb6){const _0x2bfb17=_0x35c3f9;return this[_0x2bfb17(0xd1)][_0x2bfb17(0xc1)](_0xee10f3,_0x1f6eb6);}['getHealthStatus'](_0x595bcf){return this['strategy']['getHealthStatus'](_0x595bcf);}['generateSignal'](_0x43ae7c){return null;}}function _0x292f(){const _0x473352=['stopTicks','barHistory','trailDistanceTicks','processTick','info','trades','recentTrades','getAnalysisState','strategy','trailTriggerTicks','_scoreSweep',',\x20value=','minPenetrationTicks','durationBars','qualityScore','startTime','\x20|\x20Pen:\x20','currentBar','[2B]\x20NEW\x20ZONE\x20','containsPrice','sweepType','520440QcdvfG','emit','activeSweeps','delete','getHealthStatus','min','_generateSignal','t\x20Vol:','has','floor','toUpperCase','\x20|\x20Total:\x20','swing','config','liquidityZones','losses','minBodyRatio','lastUsedBarIndex','getTimezoneOffset','high','\x20|\x20Pen:','x\x20|\x20Q:','SUPPORT','recordTradeResult','price','isValid','506009OtBYxG','short','7322HZZBiP','find','long','log','symbol','\x20zones','cooldownMs','\x20|\x20Valid:\x20','405cyrcaB','_updateZones','22362BFkLZq','RESISTANCE','\x20swings,\x20','HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)','toFixed','_mergeConfig','exitBarIndex','isDST','priceHigh','WEAK','push','lastSignalTime','\x20@\x20','shift','open','tickCount','maxDurationBars','onTrade','[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)','now','initialize','breakevenTicks','sweep','getBarHistory','8SASPzp','maxPenetrationTicks','signal','set','minVolumeRatio','[HQX-2B]\x20Preload\x20complete:\x20','78LIuqWK',',\x20TF=1min','onTick','153301iOLlhy','_getVolumeRatio','targetTicks','lookbackBars','barIndex','t\x20|\x20Vol:','stats','abs','zone','execution','getLevel','minStrength','\x20|\x20','map','swingPoints','get','type','_detectSwings','sort','low','ASK','3520674lqejxI','isWithinSession','getStats','[HQX-2B]\x20Trade\x20result:\x20','reset','processBar','STRONG','[2B]\x20Calling\x20_generateSignal\x20for\x20','tickSize','length','[HQX-2B]\x20Preloading\x20','debug','penetrationTicks','barIntervalMs','sell','HQX_2B_LIQUIDITY_SWEEP','10PeZcEr','max','4160420EHYCWW','touches','timestamp','[HQX-2B]\x20Reset\x20state\x20for\x20','\x20historical\x20signals\x20detected\x20(ignored)','close','filter','preloadBars','distance','volumeRatio','buy','volume','priceLow','enabled','maxZoneAgeBars'];_0x292f=function(){return _0x473352;};return _0x292f();}module['exports']={'HQX2BLiquiditySweep':HQX2BLiquiditySweep,'HQX2BStrategy':HQX2BStrategy,'M2':HQX2BStrategy,'S2':HQX2BLiquiditySweep,'OrderSide':OrderSide,'SignalStrength':SignalStrength,'SweepType':SweepType,'ZoneType':ZoneType,'DEFAULT_CONFIG':DEFAULT_CONFIG};
|
|
1
|
+
const _0x2226ad=_0x5493;(function(_0x3164cd,_0x18254c){const _0x118c05=_0x5493,_0x107604=_0x3164cd();while(!![]){try{const _0x20984d=-parseInt(_0x118c05(0x181))/0x1+parseInt(_0x118c05(0x17b))/0x2*(-parseInt(_0x118c05(0x15f))/0x3)+parseInt(_0x118c05(0x15c))/0x4+-parseInt(_0x118c05(0x196))/0x5*(parseInt(_0x118c05(0x176))/0x6)+parseInt(_0x118c05(0x163))/0x7+-parseInt(_0x118c05(0x14f))/0x8*(-parseInt(_0x118c05(0x10e))/0x9)+parseInt(_0x118c05(0x191))/0xa;if(_0x20984d===_0x18254c)break;else _0x107604['push'](_0x107604['shift']());}catch(_0x251b2e){_0x107604['push'](_0x107604['shift']());}}}(_0x2bcb,0xe1d4c));const EventEmitter=require(_0x2226ad(0x18d)),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4},SweepType={'HIGH_SWEEP':'high','LOW_SWEEP':_0x2226ad(0x187)},ZoneType={'RESISTANCE':'resistance','SUPPORT':_0x2226ad(0xff)},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':_0x2226ad(0x14e)}};class SwingPoint{constructor(_0x59e60c,_0x14f1d1,_0x572f37,_0x4f9712,_0x4a3ee6=0x1){const _0x4b09b9=_0x2226ad;this['type']=_0x59e60c,this[_0x4b09b9(0x16e)]=_0x14f1d1,this[_0x4b09b9(0x122)]=_0x572f37,this[_0x4b09b9(0x16b)]=_0x4f9712,this[_0x4b09b9(0x170)]=_0x4a3ee6;}}function _0x2bcb(){const _0x1b269f=['support','priceHigh','_mergeConfig','startTime','short','minVolumeRatio','abs','delete','x\x20|\x20Q:','getStats','stopTicks','swept','trades','minPenetrationTicks','floor','720SDhNCg','initialize','generateSignal','\x20swings,\x20','t,\x20Trail=','toFixed','min','object','t\x20|\x20Q:\x20','set','zone','sweepType','_updateZones','getAnalysisState','extremePrice','minQualityScore','minBodyRatio','breakevenTicks','onTick','STRONG','barIndex','symbol','getLevel','[HQX-2B]\x20Initialized\x20for\x20','ASK','tickCount','t\x20Vol:','lastSignalTime','RESISTANCE','penetrationTicks','HQX-2B\x20Liquidity\x20Sweep\x20(Optimized)','swing','[2B]\x20SWEEP\x20','sort','2B\x20','\x20historical\x20signals\x20detected\x20(ignored)','stats','get','getTimezoneOffset','\x20|\x20','\x20|\x20Total:\x20','createdAt','[2B]\x20NEW\x20SWING\x20','size','_scoreSweep','execution','filter','t\x20|\x20Vol:','SUPPORT','[HQX-2B]\x20SIGNAL:\x20','emit','distance','activeSweeps','\x20|\x20Pen:','containsPrice',',\x20value=','map','high','signals','isValid','toUpperCase','x\x20|\x20Conf:','cooldownBars','tickSize','America/New_York','67288VIMerE','maxZoneAgeBars','[2B]\x20Calling\x20_generateSignal\x20for\x20','[2B]\x20_generateSignal\x20returned\x20null\x20(likely\x20cooldown)','barHistory','has','exports','find','currentBar','long','strategy','config','lookbackBars','3646276MEfkjV','VERY_STRONG','/5\x20bars','3uEvZLE','getBarHistory','sweep','trailDistanceTicks','6764716YVLaMt','isArray','recordTradeResult','reset','\x20@\x20','info','targetTicks','volumeRatio','timestamp','now','recentTrades','price','liquidityZones','strength','\x20sweep...','close','maxPenetrationTicks','swingPoints','max','6DowIar','buy','isDST','maxDurationBars','LOW_SWEEP','860972HjFEBe','processBar','debug','shift','split','HIGH_SWEEP','818206Hyckgg','push','priceLow','_detectSwings','tickValue','getHealthStatus','low','qualityScore','_generateSignal','s\x20<\x20','type','exitBarIndex','events','\x20bars,\x20','[HQX-2B]\x20Trade\x20result:\x20','lastUsedBarIndex','14618930kBITOV','getUTCMinutes','minStrength','processTick','_getVolumeRatio','9195170ZSyzHn','log','length','MODERATE','onTrade','durationBars','touches','sweptAt'];_0x2bcb=function(){return _0x1b269f;};return _0x2bcb();}class LiquidityZone{constructor(_0x1e8846,_0x1a07ee,_0x2b6c4d,_0x13e46b,_0xcac9ce){const _0x2da023=_0x2226ad;this['id']=uuidv4(),this[_0x2da023(0x18b)]=_0x1e8846,this[_0x2da023(0x100)]=_0x1a07ee,this['priceLow']=_0x2b6c4d,this[_0x2da023(0x137)]=_0x13e46b,this[_0x2da023(0x122)]=_0xcac9ce,this[_0x2da023(0xfd)]=0x1,this['swept']=![],this[_0x2da023(0xfe)]=null,this['lastUsedBarIndex']=-0x3e7,this[_0x2da023(0x188)]=0.5;}['containsPrice'](_0x164bbe,_0xe31ab9,_0x4241e5){const _0x2107f6=_0x2226ad,_0x137c53=_0xe31ab9*_0x4241e5;return _0x164bbe>=this[_0x2107f6(0x183)]-_0x137c53&&_0x164bbe<=this[_0x2107f6(0x100)]+_0x137c53;}['getLevel'](){const _0x508fcf=_0x2226ad;return(this[_0x508fcf(0x100)]+this[_0x508fcf(0x183)])/0x2;}}class SweepEvent{constructor(_0x227a5a,_0x2b13cc,_0x5b9902,_0x526305,_0x232bdc){const _0x538ed1=_0x2226ad;this['sweepType']=_0x227a5a,this[_0x538ed1(0x118)]=_0x2b13cc,this['entryBarIndex']=_0x5b9902,this['extremeBarIndex']=_0x526305,this[_0x538ed1(0x11c)]=_0x232bdc,this['exitBarIndex']=null,this['isValid']=![],this['qualityScore']=0x0,this['penetrationTicks']=0x0,this[_0x538ed1(0xfc)]=0x0,this['volumeRatio']=0x1;}}class HQX2BLiquiditySweep extends EventEmitter{constructor(_0x4d1d40={}){const _0x2fdd2d=_0x2226ad;super(),this['config']=this[_0x2fdd2d(0x101)](DEFAULT_CONFIG,_0x4d1d40),this[_0x2fdd2d(0x14d)]=this['config']['tickSize'],this[_0x2fdd2d(0x185)]=this['config'][_0x2fdd2d(0x185)],this[_0x2fdd2d(0x153)]=new Map(),this['swingPoints']=new Map(),this['liquidityZones']=new Map(),this[_0x2fdd2d(0x142)]=new Map(),this['currentBar']=new Map(),this['barIntervalMs']=0xea60,this[_0x2fdd2d(0x129)]=0x0,this['startTime']=Date['now'](),this[_0x2fdd2d(0x132)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0},this[_0x2fdd2d(0x16d)]=[];}[_0x2226ad(0x101)](_0x3ee334,_0x2771a2){const _0xfc6a9d=_0x2226ad,_0x17a108={..._0x3ee334};for(const _0x126432 in _0x2771a2){typeof _0x2771a2[_0x126432]===_0xfc6a9d(0x115)&&!Array[_0xfc6a9d(0x164)](_0x2771a2[_0x126432])?_0x17a108[_0x126432]={..._0x3ee334[_0x126432],..._0x2771a2[_0x126432]}:_0x17a108[_0x126432]=_0x2771a2[_0x126432];}return _0x17a108;}['isWithinSession'](_0x4c7b4c){const _0xc7454a=_0x2226ad;if(!this['config']['session']['enabled'])return!![];const _0x48b7c0=new Date(_0x4c7b4c),_0x4630dd=this['isDST'](_0x48b7c0)?-0x4:-0x5,_0x2817c8=_0x48b7c0['getUTCHours'](),_0x52a89f=_0x48b7c0[_0xc7454a(0x192)](),_0x32da9c=(_0x2817c8+_0x4630dd+0x18)%0x18,{startHour:_0xa1a975,startMinute:_0x5cfaa5,endHour:_0x15fbf2,endMinute:_0x483615}=this[_0xc7454a(0x15a)]['session'],_0x1f73ad=_0x32da9c*0x3c+_0x52a89f,_0x546645=_0xa1a975*0x3c+_0x5cfaa5,_0x4fa06d=_0x15fbf2*0x3c+_0x483615;return _0x1f73ad>=_0x546645&&_0x1f73ad<_0x4fa06d;}[_0x2226ad(0x178)](_0x56bf15){const _0x1b882d=_0x2226ad,_0x29b21e=new Date(_0x56bf15['getFullYear'](),0x0,0x1),_0x5a7436=new Date(_0x56bf15['getFullYear'](),0x6,0x1),_0x3a68ee=Math[_0x1b882d(0x175)](_0x29b21e[_0x1b882d(0x134)](),_0x5a7436['getTimezoneOffset']());return _0x56bf15['getTimezoneOffset']()<_0x3a68ee;}['initialize'](_0x36523e,_0x2a6f4e=0.25,_0x3a5f8c=0x5){const _0x5e65bc=_0x2226ad;this[_0x5e65bc(0x14d)]=_0x2a6f4e,this[_0x5e65bc(0x185)]=_0x3a5f8c,this[_0x5e65bc(0x15a)][_0x5e65bc(0x14d)]=_0x2a6f4e,this[_0x5e65bc(0x15a)]['tickValue']=_0x3a5f8c,this['barHistory'][_0x5e65bc(0x117)](_0x36523e,[]),this['swingPoints'][_0x5e65bc(0x117)](_0x36523e,[]),this['liquidityZones'][_0x5e65bc(0x117)](_0x36523e,[]),this['activeSweeps'][_0x5e65bc(0x117)](_0x36523e,[]),this['currentBar'][_0x5e65bc(0x106)](_0x36523e),this['emit']('log',{'type':'info','message':_0x5e65bc(0x125)+_0x36523e+':\x20tick='+_0x2a6f4e+_0x5e65bc(0x145)+_0x3a5f8c+',\x20TF=1min'}),this['emit']('log',{'type':_0x5e65bc(0x168),'message':'[HQX-2B]\x20Params:\x20Stop='+this['config'][_0x5e65bc(0x13b)][_0x5e65bc(0x109)]+'t,\x20Target='+this[_0x5e65bc(0x15a)]['execution'][_0x5e65bc(0x169)]+'t,\x20BE='+this['config'][_0x5e65bc(0x13b)]['breakevenTicks']+_0x5e65bc(0x112)+this[_0x5e65bc(0x15a)][_0x5e65bc(0x13b)]['trailTriggerTicks']+'/'+this[_0x5e65bc(0x15a)]['execution']['trailDistanceTicks']});}['processTick'](_0x8ef9cf){const _0x2f53b8=_0x2226ad,{contractId:_0x39a3f6,price:_0x2a601e,volume:_0x1fb204,timestamp:_0x1c3298}=_0x8ef9cf,_0x48519a=_0x1c3298||Date['now'](),_0x37452d=_0x1fb204||0x1;if(!this['isWithinSession'](_0x48519a))return null;let _0x15df30=this[_0x2f53b8(0x157)][_0x2f53b8(0x133)](_0x39a3f6);const _0x1cc1f4=Math[_0x2f53b8(0x10d)](_0x48519a/this['barIntervalMs'])*this['barIntervalMs'];if(!_0x15df30||_0x15df30[_0x2f53b8(0x102)]!==_0x1cc1f4){if(_0x15df30){const _0x4aed75={'timestamp':_0x15df30['startTime'],'open':_0x15df30['open'],'high':_0x15df30[_0x2f53b8(0x147)],'low':_0x15df30[_0x2f53b8(0x187)],'close':_0x15df30[_0x2f53b8(0x172)],'volume':_0x15df30['volume']},_0x117a19=this[_0x2f53b8(0x17c)](_0x39a3f6,_0x4aed75);return this[_0x2f53b8(0x157)]['set'](_0x39a3f6,{'startTime':_0x1cc1f4,'open':_0x2a601e,'high':_0x2a601e,'low':_0x2a601e,'close':_0x2a601e,'volume':_0x37452d}),_0x117a19;}else return this[_0x2f53b8(0x157)][_0x2f53b8(0x117)](_0x39a3f6,{'startTime':_0x1cc1f4,'open':_0x2a601e,'high':_0x2a601e,'low':_0x2a601e,'close':_0x2a601e,'volume':_0x37452d}),null;}else return _0x15df30[_0x2f53b8(0x147)]=Math[_0x2f53b8(0x175)](_0x15df30[_0x2f53b8(0x147)],_0x2a601e),_0x15df30[_0x2f53b8(0x187)]=Math[_0x2f53b8(0x114)](_0x15df30[_0x2f53b8(0x187)],_0x2a601e),_0x15df30[_0x2f53b8(0x172)]=_0x2a601e,_0x15df30['volume']+=_0x37452d,null;}[_0x2226ad(0x120)](_0xae5a58){const _0x2386f8=_0x2226ad;return this[_0x2386f8(0x194)](_0xae5a58);}[_0x2226ad(0xfb)](_0x462cd5){const _0x2d6908=_0x2226ad;return this['processTick']({'contractId':_0x462cd5['contractId']||_0x462cd5[_0x2d6908(0x123)],'price':_0x462cd5['price'],'volume':_0x462cd5[_0x2d6908(0x139)]||_0x462cd5['volume']||0x1,'timestamp':_0x462cd5[_0x2d6908(0x16b)]||Date[_0x2d6908(0x16c)]()});}['processBar'](_0x43ecf5,_0x446316){const _0x37e259=_0x2226ad;let _0x49c5b7=this[_0x37e259(0x153)][_0x37e259(0x133)](_0x43ecf5);!_0x49c5b7&&(this[_0x37e259(0x10f)](_0x43ecf5),_0x49c5b7=this[_0x37e259(0x153)]['get'](_0x43ecf5));_0x49c5b7[_0x37e259(0x182)](_0x446316);if(_0x49c5b7['length']>0x1f4)_0x49c5b7['shift']();const _0x16390a=_0x49c5b7['length']-0x1;if(_0x49c5b7['length']<this['config'][_0x37e259(0x12d)][_0x37e259(0x15b)]*0x3)return null;const _0x5049b0=this[_0x37e259(0x174)]['get'](_0x43ecf5)['length'];this[_0x37e259(0x184)](_0x43ecf5,_0x49c5b7,_0x16390a);const _0x46ef47=this['swingPoints']['get'](_0x43ecf5);if(_0x46ef47[_0x37e259(0xf9)]>_0x5049b0){const _0xef9edb=_0x46ef47[_0x46ef47['length']-0x1];this[_0x37e259(0x140)]('log',{'type':_0x37e259(0x17d),'message':_0x37e259(0x138)+_0xef9edb['type'][_0x37e259(0x14a)]()+_0x37e259(0x167)+_0xef9edb[_0x37e259(0x16e)][_0x37e259(0x113)](0x2)+_0x37e259(0x136)+_0x46ef47['length']});}const _0x434899=this['_detectSweep'](_0x43ecf5,_0x49c5b7,_0x16390a);_0x434899&&this['emit'](_0x37e259(0xf8),{'type':'debug','message':_0x37e259(0x12e)+_0x434899[_0x37e259(0x119)]+'\x20|\x20Valid:\x20'+_0x434899[_0x37e259(0x149)]+'\x20|\x20Pen:\x20'+_0x434899['penetrationTicks'][_0x37e259(0x113)](0x1)+_0x37e259(0x116)+(_0x434899['qualityScore']*0x64)[_0x37e259(0x113)](0x0)+'%'});const _0x587482=this['liquidityZones']['get'](_0x43ecf5)['length'];this[_0x37e259(0x11a)](_0x43ecf5,_0x16390a);const _0x4c9978=this['liquidityZones'][_0x37e259(0x133)](_0x43ecf5);if(_0x4c9978[_0x37e259(0xf9)]>_0x587482){const _0x173527=_0x4c9978[_0x4c9978['length']-0x1];this['emit']('log',{'type':_0x37e259(0x17d),'message':'[2B]\x20NEW\x20ZONE\x20'+_0x173527[_0x37e259(0x18b)]['toUpperCase']()+'\x20@\x20'+_0x173527['getLevel']()['toFixed'](0x2)+'\x20|\x20Total:\x20'+_0x4c9978['length']});}if(_0x434899&&_0x434899['isValid']){this['emit']('log',{'type':_0x37e259(0x17d),'message':_0x37e259(0x151)+_0x434899[_0x37e259(0x119)]+_0x37e259(0x171)});const _0x375001=this[_0x37e259(0x189)](_0x43ecf5,_0x446316,_0x16390a,_0x434899);return!_0x375001&&this[_0x37e259(0x140)](_0x37e259(0xf8),{'type':'debug','message':_0x37e259(0x152)}),_0x375001;}return null;}[_0x2226ad(0x184)](_0x470039,_0x198d24,_0x4edf0d){const _0x5c535f=_0x2226ad,_0x537de4=this[_0x5c535f(0x15a)]['swing'][_0x5c535f(0x15b)],_0x57642e=this['config']['swing'][_0x5c535f(0x193)];if(_0x4edf0d<_0x537de4*0x2)return;const _0x552a37=this['swingPoints'][_0x5c535f(0x133)](_0x470039),_0x435671=_0x4edf0d-_0x537de4,_0xc44619=_0x198d24[_0x435671];let _0x5e927d=!![],_0x2c0330=0x0;for(let _0x519573=_0x435671-_0x537de4;_0x519573<=_0x435671+_0x537de4;_0x519573++){if(_0x519573===_0x435671||_0x519573<0x0||_0x519573>=_0x198d24[_0x5c535f(0xf9)])continue;if(_0x198d24[_0x519573][_0x5c535f(0x147)]>=_0xc44619[_0x5c535f(0x147)]){_0x5e927d=![];break;}_0x2c0330++;}if(_0x5e927d&&_0x2c0330>=_0x57642e){const _0x4813aa=_0x552a37[_0x5c535f(0x156)](_0x3d30d4=>_0x3d30d4['barIndex']===_0x435671&&_0x3d30d4[_0x5c535f(0x18b)]===_0x5c535f(0x147));!_0x4813aa&&_0x552a37['push'](new SwingPoint('high',_0xc44619['high'],_0x435671,_0xc44619[_0x5c535f(0x16b)],_0x2c0330));}let _0x3a5286=!![],_0x579aae=0x0;for(let _0x59d8b7=_0x435671-_0x537de4;_0x59d8b7<=_0x435671+_0x537de4;_0x59d8b7++){if(_0x59d8b7===_0x435671||_0x59d8b7<0x0||_0x59d8b7>=_0x198d24['length'])continue;if(_0x198d24[_0x59d8b7][_0x5c535f(0x187)]<=_0xc44619[_0x5c535f(0x187)]){_0x3a5286=![];break;}_0x579aae++;}if(_0x3a5286&&_0x579aae>=_0x57642e){const _0x43a754=_0x552a37[_0x5c535f(0x156)](_0x41d8d5=>_0x41d8d5['barIndex']===_0x435671&&_0x41d8d5['type']===_0x5c535f(0x187));!_0x43a754&&_0x552a37[_0x5c535f(0x182)](new SwingPoint(_0x5c535f(0x187),_0xc44619[_0x5c535f(0x187)],_0x435671,_0xc44619['timestamp'],_0x579aae));}const _0x1dd3a2=this[_0x5c535f(0x15a)]['zone'][_0x5c535f(0x150)];while(_0x552a37[_0x5c535f(0xf9)]>0x0&&_0x552a37[0x0]['barIndex']<_0x4edf0d-_0x1dd3a2){_0x552a37[_0x5c535f(0x17e)]();}}['_updateZones'](_0x587c46,_0x3af955){const _0x4cb03b=_0x2226ad,_0x188b3b=this[_0x4cb03b(0x174)]['get'](_0x587c46),_0x51f799=this['liquidityZones']['get'](_0x587c46),_0x2cd457=this['config'][_0x4cb03b(0x118)]['clusterToleranceTicks']*this['tickSize'],_0x415796=this['config']['zone']['maxZoneAgeBars'];for(let _0x9d4634=_0x51f799['length']-0x1;_0x9d4634>=0x0;_0x9d4634--){_0x3af955-_0x51f799[_0x9d4634][_0x4cb03b(0x122)]>_0x415796&&_0x51f799['splice'](_0x9d4634,0x1);}for(const _0x31d426 of _0x188b3b){let _0x1e7d5f=null;for(const _0x4441cd of _0x51f799){if(_0x4441cd[_0x4cb03b(0x144)](_0x31d426['price'],this[_0x4cb03b(0x15a)]['zone']['clusterToleranceTicks'],this[_0x4cb03b(0x14d)])){_0x1e7d5f=_0x4441cd;break;}}if(_0x1e7d5f){_0x1e7d5f['touches']++;if(_0x31d426['price']>_0x1e7d5f['priceHigh'])_0x1e7d5f['priceHigh']=_0x31d426['price'];if(_0x31d426[_0x4cb03b(0x16e)]<_0x1e7d5f['priceLow'])_0x1e7d5f[_0x4cb03b(0x183)]=_0x31d426['price'];_0x1e7d5f[_0x4cb03b(0x188)]=Math[_0x4cb03b(0x114)](0x1,0.3+_0x1e7d5f[_0x4cb03b(0xfd)]*0.15);}else{const _0x11076e=_0x31d426['type']==='high'?ZoneType['RESISTANCE']:ZoneType['SUPPORT'],_0x3e48e3=new LiquidityZone(_0x11076e,_0x31d426['price']+_0x2cd457/0x2,_0x31d426['price']-_0x2cd457/0x2,_0x31d426[_0x4cb03b(0x16b)],_0x31d426['barIndex']);_0x3e48e3['qualityScore']=0.3+_0x31d426['strength']*0.1,_0x51f799['push'](_0x3e48e3);}}}['_detectSweep'](_0x548dba,_0x3a2b26,_0x466e97){const _0x59da80=_0x2226ad,_0x15efaa=this[_0x59da80(0x16f)]['get'](_0x548dba),_0x14a821=_0x3a2b26[_0x466e97],_0x1e40d0=_0x14a821['close'],_0x4e5b89=this[_0x59da80(0x15a)][_0x59da80(0x161)],_0x3461a8=this['config'][_0x59da80(0x118)];for(const _0x5a96e0 of _0x15efaa){if(_0x5a96e0[_0x59da80(0x190)]>=0x0&&_0x466e97-_0x5a96e0['lastUsedBarIndex']<_0x3461a8[_0x59da80(0x14c)])continue;const _0x45f697=_0x5a96e0[_0x59da80(0x124)](),_0x8e582a=Math['abs'](_0x1e40d0-_0x45f697)/this['tickSize'];if(_0x8e582a>_0x3461a8['maxZoneDistanceTicks'])continue;const _0x1249bc=Math['max'](0x0,_0x466e97-_0x4e5b89[_0x59da80(0x179)]*0x2);for(let _0x299086=_0x1249bc;_0x299086<_0x466e97;_0x299086++){const _0x3c948b=_0x3a2b26[_0x299086];if(_0x5a96e0['type']===ZoneType['RESISTANCE']){const _0x4eb723=(_0x3c948b['high']-_0x5a96e0['priceHigh'])/this['tickSize'];if(_0x4eb723>=_0x4e5b89[_0x59da80(0x10c)]&&_0x4eb723<=_0x4e5b89[_0x59da80(0x173)]){const _0x5c4896=Math['min'](_0x5a96e0[_0x59da80(0x100)],_0x5a96e0['priceHigh']+_0x4eb723*this['tickSize']);if(_0x1e40d0<_0x5c4896+this['tickSize']*0x2){const _0x48e778=_0x3c948b['high']-_0x3c948b[_0x59da80(0x187)],_0x527c4d=Math['abs'](_0x3c948b[_0x59da80(0x172)]-_0x3c948b['open']),_0x2475c1=_0x48e778>0x0?_0x527c4d/_0x48e778:0x0;if(_0x2475c1>=_0x4e5b89[_0x59da80(0x11e)]){const _0x691589=this[_0x59da80(0x195)](_0x3a2b26,_0x299086,0x14);if(_0x691589>=_0x4e5b89[_0x59da80(0x104)]){const _0xdbd3e5=new SweepEvent(SweepType['HIGH_SWEEP'],_0x5a96e0,_0x299086,_0x299086,_0x3c948b['high']);_0xdbd3e5['exitBarIndex']=_0x466e97,_0xdbd3e5[_0x59da80(0x12b)]=_0x4eb723,_0xdbd3e5['durationBars']=_0x466e97-_0x299086,_0xdbd3e5[_0x59da80(0x16a)]=_0x691589,_0xdbd3e5[_0x59da80(0x188)]=this[_0x59da80(0x13a)](_0xdbd3e5,_0x2475c1),_0xdbd3e5[_0x59da80(0x149)]=_0xdbd3e5[_0x59da80(0x188)]>=_0x4e5b89[_0x59da80(0x11d)];if(_0xdbd3e5['isValid'])return _0xdbd3e5;}}}}}if(_0x5a96e0[_0x59da80(0x18b)]===ZoneType[_0x59da80(0x13e)]){const _0x26b60a=(_0x5a96e0[_0x59da80(0x183)]-_0x3c948b['low'])/this[_0x59da80(0x14d)];if(_0x26b60a>=_0x4e5b89['minPenetrationTicks']&&_0x26b60a<=_0x4e5b89['maxPenetrationTicks']){const _0x2fd14e=Math[_0x59da80(0x175)](_0x5a96e0[_0x59da80(0x183)],_0x5a96e0[_0x59da80(0x183)]-_0x26b60a*this[_0x59da80(0x14d)]);if(_0x1e40d0>_0x2fd14e-this[_0x59da80(0x14d)]*0x2){const _0x12237c=_0x3c948b[_0x59da80(0x147)]-_0x3c948b['low'],_0x494225=Math['abs'](_0x3c948b[_0x59da80(0x172)]-_0x3c948b['open']),_0x2abe21=_0x12237c>0x0?_0x494225/_0x12237c:0x0;if(_0x2abe21>=_0x4e5b89[_0x59da80(0x11e)]){const _0x2270e1=this['_getVolumeRatio'](_0x3a2b26,_0x299086,0x14);if(_0x2270e1>=_0x4e5b89[_0x59da80(0x104)]){const _0x2bf6e5=new SweepEvent(SweepType[_0x59da80(0x17a)],_0x5a96e0,_0x299086,_0x299086,_0x3c948b[_0x59da80(0x187)]);_0x2bf6e5[_0x59da80(0x18c)]=_0x466e97,_0x2bf6e5[_0x59da80(0x12b)]=_0x26b60a,_0x2bf6e5[_0x59da80(0xfc)]=_0x466e97-_0x299086,_0x2bf6e5[_0x59da80(0x16a)]=_0x2270e1,_0x2bf6e5['qualityScore']=this['_scoreSweep'](_0x2bf6e5,_0x2abe21),_0x2bf6e5[_0x59da80(0x149)]=_0x2bf6e5['qualityScore']>=_0x4e5b89['minQualityScore'];if(_0x2bf6e5[_0x59da80(0x149)])return _0x2bf6e5;}}}}}}}return null;}['_getVolumeRatio'](_0x431ebe,_0x405f79,_0x3318a4){const _0x9ca874=_0x2226ad,_0x3cb0df=Math['max'](0x0,_0x405f79-_0x3318a4),_0x599986=_0x431ebe['slice'](_0x3cb0df,_0x405f79);if(_0x599986[_0x9ca874(0xf9)]===0x0)return 0x1;const _0x31eb5a=_0x599986[_0x9ca874(0x146)](_0x32968a=>_0x32968a['volume'])['sort']((_0x26951c,_0x4bee72)=>_0x26951c-_0x4bee72),_0x46f83d=Math['floor'](_0x31eb5a[_0x9ca874(0xf9)]/0x2),_0x37f5c5=_0x31eb5a[_0x46f83d]||0x1;return _0x431ebe[_0x405f79]['volume']/_0x37f5c5;}['_scoreSweep'](_0x578282,_0x32af82){const _0x6e9f36=_0x2226ad;let _0x2a826e=0x0;const _0x11af70=0x4,_0x53c8a9=Math['abs'](_0x578282['penetrationTicks']-_0x11af70);return _0x2a826e+=Math[_0x6e9f36(0x175)](0x0,0.3-_0x53c8a9*0.03),_0x2a826e+=Math[_0x6e9f36(0x175)](0x0,0.25-_0x578282[_0x6e9f36(0xfc)]*0.05),_0x2a826e+=Math[_0x6e9f36(0x114)](0.25,_0x578282[_0x6e9f36(0x16a)]*0.1),_0x2a826e+=Math[_0x6e9f36(0x114)](0.2,_0x32af82*0.4),Math[_0x6e9f36(0x114)](0x1,_0x2a826e);}['_generateSignal'](_0x423f9e,_0x360210,_0x3b3dca,_0x327d13){const _0x4984de=_0x2226ad,_0x2963fa=Date[_0x4984de(0x16c)]()-this['lastSignalTime'];if(_0x2963fa<this[_0x4984de(0x15a)]['execution']['cooldownMs'])return this[_0x4984de(0x140)](_0x4984de(0xf8),{'type':'debug','message':'[2B]\x20Signal\x20blocked\x20by\x20cooldown\x20('+(_0x2963fa/0x3e8)[_0x4984de(0x113)](0x1)+_0x4984de(0x18a)+this[_0x4984de(0x15a)][_0x4984de(0x13b)]['cooldownMs']/0x3e8+'s)'}),null;const _0x47f30d=this['config']['execution'],_0x1fa02f=_0x360210['close'],_0x33dbd6=_0x327d13[_0x4984de(0x119)]===SweepType[_0x4984de(0x180)]?_0x4984de(0x103):'long';let _0x2fb87d,_0x2201bc,_0x5487cc,_0x205818;_0x33dbd6===_0x4984de(0x158)?(_0x2fb87d=_0x1fa02f-_0x47f30d['stopTicks']*this['tickSize'],_0x2201bc=_0x1fa02f+_0x47f30d['targetTicks']*this['tickSize'],_0x5487cc=_0x1fa02f+_0x47f30d[_0x4984de(0x11f)]*this['tickSize'],_0x205818=_0x1fa02f+_0x47f30d['trailTriggerTicks']*this['tickSize']):(_0x2fb87d=_0x1fa02f+_0x47f30d[_0x4984de(0x109)]*this['tickSize'],_0x2201bc=_0x1fa02f-_0x47f30d[_0x4984de(0x169)]*this['tickSize'],_0x5487cc=_0x1fa02f-_0x47f30d['breakevenTicks']*this[_0x4984de(0x14d)],_0x205818=_0x1fa02f-_0x47f30d['trailTriggerTicks']*this[_0x4984de(0x14d)]);const _0x260923=_0x47f30d['targetTicks']/_0x47f30d[_0x4984de(0x109)],_0x1ba117=Math['min'](0x1,_0x327d13['qualityScore']*0.5+_0x327d13[_0x4984de(0x118)]['qualityScore']*0.3+(_0x327d13['volumeRatio']>1.5?0.2:_0x327d13['volumeRatio']*0.1));let _0x4d1151=SignalStrength[_0x4984de(0xfa)];if(_0x1ba117>=0.8)_0x4d1151=SignalStrength[_0x4984de(0x15d)];else{if(_0x1ba117>=0.65)_0x4d1151=SignalStrength[_0x4984de(0x121)];else{if(_0x1ba117<0.5)_0x4d1151=SignalStrength['WEAK'];}}const _0x46fd47=0.5+(_0x1ba117-0.5)*0.4,_0x24c1ff=_0x46fd47*Math[_0x4984de(0x105)](_0x2201bc-_0x1fa02f)-(0x1-_0x46fd47)*Math[_0x4984de(0x105)](_0x1fa02f-_0x2fb87d);_0x327d13['zone']['lastUsedBarIndex']=_0x3b3dca,_0x327d13['zone'][_0x4984de(0x10a)]=!![],_0x327d13[_0x4984de(0x118)]['sweptAt']=new Date(_0x360210['timestamp']),this['lastSignalTime']=Date['now'](),this[_0x4984de(0x132)][_0x4984de(0x148)]++;const _0xedee86={'id':uuidv4(),'timestamp':Date[_0x4984de(0x16c)](),'symbol':_0x423f9e[_0x4984de(0x17f)]('.')[0x0]||_0x423f9e,'contractId':_0x423f9e,'side':_0x33dbd6===_0x4984de(0x158)?OrderSide['BID']:OrderSide[_0x4984de(0x126)],'direction':_0x33dbd6,'strategy':'HQX_2B_LIQUIDITY_SWEEP','strength':_0x4d1151,'edge':_0x24c1ff,'confidence':_0x1ba117,'entry':_0x1fa02f,'entryPrice':_0x1fa02f,'stopLoss':_0x2fb87d,'takeProfit':_0x2201bc,'riskReward':_0x260923,'stopTicks':_0x47f30d['stopTicks'],'targetTicks':_0x47f30d[_0x4984de(0x169)],'breakevenTicks':_0x47f30d[_0x4984de(0x11f)],'trailTriggerTicks':_0x47f30d['trailTriggerTicks'],'trailDistanceTicks':_0x47f30d[_0x4984de(0x162)],'beLevel':_0x5487cc,'trailTrigger':_0x205818,'sweepType':_0x327d13[_0x4984de(0x119)],'penetrationTicks':_0x327d13[_0x4984de(0x12b)],'sweepDurationBars':_0x327d13[_0x4984de(0xfc)],'sweepQuality':_0x327d13['qualityScore'],'volumeRatio':_0x327d13[_0x4984de(0x16a)],'zoneType':_0x327d13[_0x4984de(0x118)]['type'],'zoneLevel':_0x327d13['zone'][_0x4984de(0x124)](),'zoneTouches':_0x327d13[_0x4984de(0x118)][_0x4984de(0xfd)],'zoneQuality':_0x327d13[_0x4984de(0x118)]['qualityScore'],'expires':Date['now']()+0xea60};return this[_0x4984de(0x140)]('signal',{'side':_0x33dbd6==='long'?_0x4984de(0x177):'sell','action':'open','reason':_0x4984de(0x130)+_0x327d13[_0x4984de(0x119)]+_0x4984de(0x143)+_0x327d13['penetrationTicks'][_0x4984de(0x113)](0x1)+_0x4984de(0x13d)+_0x327d13[_0x4984de(0x16a)]['toFixed'](0x1)+_0x4984de(0x107)+(_0x327d13['qualityScore']*0x64)[_0x4984de(0x113)](0x0)+'%',..._0xedee86}),this['emit'](_0x4984de(0xf8),{'type':_0x4984de(0x168),'message':_0x4984de(0x13f)+_0x33dbd6['toUpperCase']()+_0x4984de(0x167)+_0x1fa02f['toFixed'](0x2)+_0x4984de(0x135)+_0x327d13['sweepType']+'\x20|\x20Pen:'+_0x327d13['penetrationTicks']['toFixed'](0x1)+_0x4984de(0x128)+_0x327d13['volumeRatio']['toFixed'](0x1)+_0x4984de(0x14b)+(_0x1ba117*0x64)['toFixed'](0x0)+'%'}),_0xedee86;}[_0x2226ad(0x11b)](_0x16b3bc,_0x1b05d4){const _0x4840c5=_0x2226ad,_0x221f90=this['barHistory']['get'](_0x16b3bc)||[],_0x5b7bcf=this[_0x4840c5(0x16f)][_0x4840c5(0x133)](_0x16b3bc)||[],_0x12d727=this[_0x4840c5(0x174)]['get'](_0x16b3bc)||[];if(_0x221f90[_0x4840c5(0xf9)]<0x5)return{'ready':![],'message':'Collecting\x20data...\x20'+_0x221f90[_0x4840c5(0xf9)]+_0x4840c5(0x15e)};const _0x4fcd54=_0x5b7bcf[_0x4840c5(0x146)](_0xc6234e=>({'zone':_0xc6234e,'distance':Math['abs'](_0x1b05d4-_0xc6234e['getLevel']())}))['sort']((_0x44bea7,_0x301fd2)=>_0x44bea7['distance']-_0x301fd2[_0x4840c5(0x141)]),_0x143ff4=_0x4fcd54[_0x4840c5(0x156)](_0x52997b=>_0x52997b['zone']['type']===ZoneType['RESISTANCE']),_0x1362e5=_0x4fcd54['find'](_0x12595c=>_0x12595c['zone'][_0x4840c5(0x18b)]===ZoneType['SUPPORT']);return{'ready':!![],'barsProcessed':_0x221f90['length'],'swingsDetected':_0x12d727['length'],'activeZones':_0x5b7bcf['length'],'nearestResistance':_0x143ff4?_0x143ff4[_0x4840c5(0x118)]['getLevel']():null,'nearestSupport':_0x1362e5?_0x1362e5['zone']['getLevel']():null,'stopTicks':this['config']['execution']['stopTicks'],'targetTicks':this[_0x4840c5(0x15a)]['execution']['targetTicks'],'strategy':_0x4840c5(0x12c)};}[_0x2226ad(0x165)](_0x54f7b1){const _0x234394=_0x2226ad;this['recentTrades'][_0x234394(0x182)]({'netPnl':_0x54f7b1,'timestamp':Date['now']()});if(this['recentTrades']['length']>0x64)this[_0x234394(0x16d)]['shift']();_0x54f7b1>0x0?this['stats']['wins']++:this[_0x234394(0x132)]['losses']++,this['stats'][_0x234394(0x10b)]++,this[_0x234394(0x132)]['pnl']+=_0x54f7b1,this['emit']('log',{'type':'debug','message':_0x234394(0x18f)+(_0x54f7b1>0x0?'WIN':'LOSS')+'\x20$'+_0x54f7b1['toFixed'](0x2)});}[_0x2226ad(0x160)](_0x52610f){return this['barHistory']['get'](_0x52610f)||[];}['getStats'](){const _0x1f6177=_0x2226ad;return this[_0x1f6177(0x132)];}['getHealthStatus'](_0x190bc5){const _0x392143=_0x2226ad,_0x478ebe=this['barHistory']['get'](_0x190bc5)||[],_0x1ab606=this['liquidityZones']['get'](_0x190bc5)||[],_0x2da6d1=this['swingPoints'][_0x392143(0x133)](_0x190bc5)||[],_0x50b1f2=this[_0x392143(0x157)]['get'](_0x190bc5),_0x5c298c=_0x478ebe[_0x478ebe[_0x392143(0xf9)]-0x1],_0x455ed5=_0x5c298c?Date['now']()-_0x5c298c['timestamp']:null,_0x53c17b=_0x1ab606[_0x392143(0x13c)](_0x58e577=>_0x58e577['type']===ZoneType[_0x392143(0x12a)])['length'],_0x55e799=_0x1ab606[_0x392143(0x13c)](_0x3dd413=>_0x3dd413[_0x392143(0x18b)]===ZoneType['SUPPORT'])['length'];return{'healthy':_0x478ebe[_0x392143(0xf9)]>=0x5,'barsTotal':_0x478ebe[_0x392143(0xf9)],'barsLast5Min':_0x478ebe[_0x392143(0x13c)](_0x12f638=>Date['now']()-_0x12f638[_0x392143(0x16b)]<0x5*0x3c*0x3e8)[_0x392143(0xf9)],'swingsTotal':_0x2da6d1[_0x392143(0xf9)],'zonesResistance':_0x53c17b,'zonesSupport':_0x55e799,'zonesTotal':_0x1ab606[_0x392143(0xf9)],'currentBarTicks':_0x50b1f2?_0x50b1f2[_0x392143(0x127)]:0x0,'isAggregating':_0x50b1f2&&_0x50b1f2[_0x392143(0x127)]>0x0,'timeSinceLastBarMs':_0x455ed5,'lastSignalTime':this[_0x392143(0x129)],'signalCooldownMs':this['config']['execution']['cooldownMs'],'uptime':Date['now']()-(this[_0x392143(0x102)]||Date['now']())};}[_0x2226ad(0x166)](_0x4684ab){const _0x4e8600=_0x2226ad;this[_0x4e8600(0x153)]['set'](_0x4684ab,[]),this[_0x4e8600(0x174)][_0x4e8600(0x117)](_0x4684ab,[]),this['liquidityZones'][_0x4e8600(0x117)](_0x4684ab,[]),this[_0x4e8600(0x142)][_0x4e8600(0x117)](_0x4684ab,[]),this['currentBar']['delete'](_0x4684ab),this[_0x4e8600(0x140)](_0x4e8600(0xf8),{'type':'info','message':'[HQX-2B]\x20Reset\x20state\x20for\x20'+_0x4684ab});}['preloadBars'](_0x278de4,_0x656511){const _0x3bb1b1=_0x2226ad;if(!_0x656511||_0x656511[_0x3bb1b1(0xf9)]===0x0){this[_0x3bb1b1(0x140)](_0x3bb1b1(0xf8),{'type':_0x3bb1b1(0x17d),'message':'[HQX-2B]\x20No\x20historical\x20bars\x20to\x20preload'});return;}!this['barHistory'][_0x3bb1b1(0x154)](_0x278de4)&&this[_0x3bb1b1(0x10f)](_0x278de4);const _0x15c1bb=[..._0x656511][_0x3bb1b1(0x12f)]((_0x2109a6,_0x48fb03)=>_0x2109a6['timestamp']-_0x48fb03['timestamp']);this['emit'](_0x3bb1b1(0xf8),{'type':'info','message':'[HQX-2B]\x20Preloading\x20'+_0x15c1bb[_0x3bb1b1(0xf9)]+'\x20historical\x20bars...'});let _0x5e2914=0x0;for(const _0x33bb10 of _0x15c1bb){const _0x2ad532=this[_0x3bb1b1(0x17c)](_0x278de4,_0x33bb10);if(_0x2ad532)_0x5e2914++;}const _0x5836e7=this['barHistory']['get'](_0x278de4)||[],_0x1abdc9=this['swingPoints'][_0x3bb1b1(0x133)](_0x278de4)||[],_0x1b0e44=this['liquidityZones'][_0x3bb1b1(0x133)](_0x278de4)||[];this[_0x3bb1b1(0x140)]('log',{'type':_0x3bb1b1(0x168),'message':'[HQX-2B]\x20Preload\x20complete:\x20'+_0x5836e7['length']+_0x3bb1b1(0x18e)+_0x1abdc9['length']+_0x3bb1b1(0x111)+_0x1b0e44[_0x3bb1b1(0xf9)]+'\x20zones'}),_0x5e2914>0x0&&this['emit'](_0x3bb1b1(0xf8),{'type':'debug','message':'[HQX-2B]\x20'+_0x5e2914+_0x3bb1b1(0x131)}),this['lastSignalTime']=0x0;}}class HQX2BStrategy extends EventEmitter{constructor(_0x5b5547={}){const _0x518db6=_0x2226ad;super(),this[_0x518db6(0x15a)]=_0x5b5547,this['strategy']=new HQX2BLiquiditySweep(_0x5b5547),this[_0x518db6(0x159)]['on']('signal',_0x583c7d=>this[_0x518db6(0x140)]('signal',_0x583c7d)),this[_0x518db6(0x159)]['on'](_0x518db6(0xf8),_0x23a729=>this[_0x518db6(0x140)]('log',_0x23a729));}[_0x2226ad(0x194)](_0x37449d){const _0x7d3be3=_0x2226ad;return this[_0x7d3be3(0x159)][_0x7d3be3(0x194)](_0x37449d);}['onTick'](_0x4667e4){const _0x9301b2=_0x2226ad;return this['strategy'][_0x9301b2(0x120)](_0x4667e4);}[_0x2226ad(0xfb)](_0x1a0ebd){const _0x554887=_0x2226ad;return this['strategy'][_0x554887(0xfb)](_0x1a0ebd);}[_0x2226ad(0x17c)](_0x17fd64,_0x460e81){const _0x5c6b7e=_0x2226ad;return this['strategy'][_0x5c6b7e(0x17c)](_0x17fd64,_0x460e81);}['initialize'](_0x590436,_0x5b3ab4,_0x1f2e7e){return this['strategy']['initialize'](_0x590436,_0x5b3ab4,_0x1f2e7e);}[_0x2226ad(0x11b)](_0x42547f,_0x15573a){const _0x418516=_0x2226ad;return this['strategy'][_0x418516(0x11b)](_0x42547f,_0x15573a);}['recordTradeResult'](_0x328a2e){const _0x2bb581=_0x2226ad;return this['strategy'][_0x2bb581(0x165)](_0x328a2e);}['reset'](_0x3d8d34){const _0x481932=_0x2226ad;return this['strategy'][_0x481932(0x166)](_0x3d8d34);}[_0x2226ad(0x108)](){return this['strategy']['getStats']();}[_0x2226ad(0x160)](_0x237b0f){const _0x42ac43=_0x2226ad;return this['strategy'][_0x42ac43(0x160)](_0x237b0f);}['preloadBars'](_0x47d9ef,_0x1682d0){const _0x46e215=_0x2226ad;return this[_0x46e215(0x159)]['preloadBars'](_0x47d9ef,_0x1682d0);}[_0x2226ad(0x186)](_0x34dd8b){const _0xb4bf3=_0x2226ad;return this[_0xb4bf3(0x159)][_0xb4bf3(0x186)](_0x34dd8b);}[_0x2226ad(0x110)](_0x2c0cc1){return null;}}function _0x5493(_0x3f882a,_0x11948f){_0x3f882a=_0x3f882a-0xf8;const _0x2bcb4c=_0x2bcb();let _0x549337=_0x2bcb4c[_0x3f882a];return _0x549337;}module[_0x2226ad(0x155)]={'HQX2BLiquiditySweep':HQX2BLiquiditySweep,'HQX2BStrategy':HQX2BStrategy,'M2':HQX2BStrategy,'S2':HQX2BLiquiditySweep,'OrderSide':OrderSide,'SignalStrength':SignalStrength,'SweepType':SweepType,'ZoneType':ZoneType,'DEFAULT_CONFIG':DEFAULT_CONFIG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _0x38eb(_0x351938,_0x42abe6){_0x351938=_0x351938-0x1bc;const _0x16fdac=_0x16fd();let _0x38eb0b=_0x16fdac[_0x351938];return _0x38eb0b;}const _0x4097f1=_0x38eb;(function(_0x2724c5,_0x28b938){const _0x50eb2b=_0x38eb,_0xd2c3de=_0x2724c5();while(!![]){try{const _0x4e113f=-parseInt(_0x50eb2b(0x1e5))/0x1+-parseInt(_0x50eb2b(0x1bd))/0x2+-parseInt(_0x50eb2b(0x214))/0x3*(-parseInt(_0x50eb2b(0x215))/0x4)+-parseInt(_0x50eb2b(0x226))/0x5*(parseInt(_0x50eb2b(0x1c9))/0x6)+-parseInt(_0x50eb2b(0x1d7))/0x7*(parseInt(_0x50eb2b(0x201))/0x8)+-parseInt(_0x50eb2b(0x1f7))/0x9*(parseInt(_0x50eb2b(0x220))/0xa)+-parseInt(_0x50eb2b(0x1f8))/0xb*(-parseInt(_0x50eb2b(0x1da))/0xc);if(_0x4e113f===_0x28b938)break;else _0xd2c3de['push'](_0xd2c3de['shift']());}catch(_0x3eb96c){_0xd2c3de['push'](_0xd2c3de['shift']());}}}(_0x16fd,0xe4db8));function _0x16fd(){const _0x1dfe83=['round','profitLockPct','breakevenTicks','ofiLookback','abs','HQX_ULTRA_SCALPING_6MODELS','toUpperCase','kalmanMeasurementNoise','atrHistory','_applyKalmanFilter','log','_generateSignal','zscore','pow','11433KGwyRH','40kdKRBg','sell','baseStopTicks','events','stats','%\x20OFI:','LOSS','reset','composite','[HQX-UltraScalping]\x20Initialized\x20for\x20','slice','30GGUwWQ','long','lastSignalTime','buy','shouldExitByZScore','[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)','35YzcCyN','getAnalysisState','strategy','volumeBuffer','786416qFzPXN','processTick','volume','_computeKyleLambda','set','targetMultiplier','_calculateATR',',\x20VPIN=','ofi','tickValue','recordTradeResult','baseTargetTicks','1413780tLJrni','trades','minHoldTimeMs','reduce','filter','short','cooldownMs','exports','side','push','_computeVPIN','zscoreThreshold','length','processBar','8743yqoWga','_computeZScore','high','12SPdneM','emit','max','shift',':\x20tick=','get','recentTrades','vpinWindow','min','initialize','Collecting\x20data...\x20','651672wLKRSl','onTrade','toFixed','debug','vpin','close','vpinToxicThreshold','winStreak','_detectVolatilityRegime','info','low','/50\x20bars','getStats','stopMultiplier','priceBuffer','tickSize','lossStreak','weights','2311461eIXOze','53184340LEfSab','getModelValues','onTick','signals','now','barHistory','\x20Regime:','VERY_STRONG','zscoreExitThreshold','3016RAfWWX','signal','_computeOrderFlowImbalance','kalmanStates','getBarHistory'];_0x16fd=function(){return _0x1dfe83;};return _0x16fd();}const EventEmitter=require(_0x4097f1(0x218)),{v4:uuidv4}=require('uuid'),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};class HQXUltraScalping extends EventEmitter{constructor(_0x233fb5={}){const _0x7341c2=_0x4097f1;super(),this['tickSize']=_0x233fb5[_0x7341c2(0x1f4)]||0.25,this['tickValue']=_0x233fb5[_0x7341c2(0x1c6)]||0x5,this['zscoreEntryThreshold']=1.5,this['zscoreExitThreshold']=0.5,this['vpinWindow']=0x32,this[_0x7341c2(0x1eb)]=0.7,this['kalmanProcessNoise']=0.01,this[_0x7341c2(0x20d)]=0.1,this['volatilityLookback']=0x64,this[_0x7341c2(0x209)]=0x14,this['baseStopTicks']=0x8,this['baseTargetTicks']=0x10,this[_0x7341c2(0x208)]=0x4,this[_0x7341c2(0x207)]=0.5,this['minConfidence']=0.55,this[_0x7341c2(0x1f6)]={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this['barHistory']=new Map(),this['priceBuffer']=new Map(),this[_0x7341c2(0x1bc)]=new Map(),this['kalmanStates']=new Map(),this[_0x7341c2(0x20e)]=new Map(),this['recentTrades']=[],this['winStreak']=0x0,this['lossStreak']=0x0,this[_0x7341c2(0x222)]=0x0,this[_0x7341c2(0x1cf)]=0x7530,this[_0x7341c2(0x1cb)]=0x2710,this[_0x7341c2(0x219)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}['initialize'](_0x2d2cd9,_0x4020b8=0.25,_0x1752de=0x5){const _0x249b99=_0x4097f1;this[_0x249b99(0x1f4)]=_0x4020b8,this[_0x249b99(0x1c6)]=_0x1752de,this['barHistory'][_0x249b99(0x1c1)](_0x2d2cd9,[]),this[_0x249b99(0x1f3)][_0x249b99(0x1c1)](_0x2d2cd9,[]),this['volumeBuffer'][_0x249b99(0x1c1)](_0x2d2cd9,[]),this['atrHistory']['set'](_0x2d2cd9,[]),this['kalmanStates']['set'](_0x2d2cd9,{'estimate':0x0,'errorCovariance':0x1}),this[_0x249b99(0x1db)]('log',{'type':_0x249b99(0x1ee),'message':_0x249b99(0x21e)+_0x2d2cd9+_0x249b99(0x1de)+_0x4020b8+',\x20value='+_0x1752de}),this[_0x249b99(0x1db)]('log',{'type':_0x249b99(0x1ee),'message':_0x249b99(0x225)});}[_0x4097f1(0x1be)](_0x2a2f6d){const _0xf453ec=_0x4097f1,{contractId:_0x38fdf,price:_0x30782e,volume:_0x4c528c,side:_0x32f16e,timestamp:_0x60f2b0}=_0x2a2f6d,_0x2faf05={'timestamp':_0x60f2b0||Date[_0xf453ec(0x1fc)](),'open':_0x30782e,'high':_0x30782e,'low':_0x30782e,'close':_0x30782e,'volume':_0x4c528c||0x1};return this['processBar'](_0x38fdf,_0x2faf05);}[_0x4097f1(0x1fa)](_0x1150f7){return this['processTick'](_0x1150f7);}['onTrade'](_0x2a3c0e){const _0x2289eb=_0x4097f1;return this['processTick']({'contractId':_0x2a3c0e['contractId']||_0x2a3c0e['symbol'],'price':_0x2a3c0e['price'],'volume':_0x2a3c0e['size']||_0x2a3c0e[_0x2289eb(0x1bf)]||0x1,'side':_0x2a3c0e[_0x2289eb(0x1d1)],'timestamp':_0x2a3c0e['timestamp']||Date['now']()});}[_0x4097f1(0x1d6)](_0x50ab47,_0x1eaf78){const _0x1d1e26=_0x4097f1;let _0x4ddfb5=this['barHistory'][_0x1d1e26(0x1df)](_0x50ab47);!_0x4ddfb5&&(this['initialize'](_0x50ab47),_0x4ddfb5=this['barHistory']['get'](_0x50ab47));_0x4ddfb5[_0x1d1e26(0x1d2)](_0x1eaf78);if(_0x4ddfb5['length']>0x1f4)_0x4ddfb5[_0x1d1e26(0x1dd)]();const _0x13a311=this[_0x1d1e26(0x1f3)]['get'](_0x50ab47);_0x13a311[_0x1d1e26(0x1d2)](_0x1eaf78[_0x1d1e26(0x1ea)]);if(_0x13a311['length']>0xc8)_0x13a311['shift']();const _0x44dc2b=this['volumeBuffer']['get'](_0x50ab47),_0x282976=_0x1eaf78['high']-_0x1eaf78['low'];let _0x49e37e=_0x1eaf78[_0x1d1e26(0x1bf)]*0.5,_0x31c32f=_0x1eaf78[_0x1d1e26(0x1bf)]*0.5;if(_0x282976>0x0){const _0x57f264=(_0x1eaf78[_0x1d1e26(0x1ea)]-_0x1eaf78['low'])/_0x282976;_0x49e37e=_0x1eaf78['volume']*_0x57f264,_0x31c32f=_0x1eaf78[_0x1d1e26(0x1bf)]*(0x1-_0x57f264);}_0x44dc2b[_0x1d1e26(0x1d2)]({'buy':_0x49e37e,'sell':_0x31c32f});if(_0x44dc2b[_0x1d1e26(0x1d5)]>0x64)_0x44dc2b[_0x1d1e26(0x1dd)]();if(_0x4ddfb5[_0x1d1e26(0x1d5)]<0x32)return null;const _0x212f77=this['_computeZScore'](_0x13a311),_0xf4dbe9=this[_0x1d1e26(0x1d3)](_0x44dc2b),_0x4ef915=this[_0x1d1e26(0x1c0)](_0x4ddfb5),_0x1b450a=this[_0x1d1e26(0x20f)](_0x50ab47,_0x1eaf78[_0x1d1e26(0x1ea)]),{regime:_0x592a30,params:_0x130bae}=this[_0x1d1e26(0x1ed)](_0x50ab47,_0x4ddfb5),_0x522fdf=this[_0x1d1e26(0x203)](_0x4ddfb5);return this['_generateSignal'](_0x50ab47,_0x1eaf78[_0x1d1e26(0x1ea)],_0x212f77,_0xf4dbe9,_0x4ef915,_0x1b450a,_0x592a30,_0x130bae,_0x522fdf,_0x4ddfb5);}['_computeZScore'](_0x2542b1,_0x3f2bd3=0x32){const _0x209ce0=_0x4097f1;if(_0x2542b1[_0x209ce0(0x1d5)]<_0x3f2bd3)return 0x0;const _0x4ce8ea=_0x2542b1['slice'](-_0x3f2bd3),_0x289c6c=_0x4ce8ea[_0x209ce0(0x1cc)]((_0x253108,_0x37c7e4)=>_0x253108+_0x37c7e4,0x0)/_0x3f2bd3,_0x44cd08=_0x4ce8ea['reduce']((_0x36a560,_0x58d7b1)=>_0x36a560+Math[_0x209ce0(0x213)](_0x58d7b1-_0x289c6c,0x2),0x0)/_0x3f2bd3,_0x1383aa=Math['sqrt'](_0x44cd08);if(_0x1383aa<0.0001)return 0x0;const _0x239c5c=_0x2542b1[_0x2542b1['length']-0x1];return(_0x239c5c-_0x289c6c)/_0x1383aa;}['_computeVPIN'](_0x1349a9){const _0x12ff76=_0x4097f1;if(_0x1349a9[_0x12ff76(0x1d5)]<this[_0x12ff76(0x1e1)])return 0.5;const _0x157fd2=_0x1349a9[_0x12ff76(0x21f)](-this[_0x12ff76(0x1e1)]);let _0x3288ba=0x0,_0x443661=0x0;for(const _0x2eb80d of _0x157fd2){_0x3288ba+=_0x2eb80d['buy'],_0x443661+=_0x2eb80d[_0x12ff76(0x216)];}const _0x5b3975=_0x3288ba+_0x443661;if(_0x5b3975<0x1)return 0.5;return Math[_0x12ff76(0x20a)](_0x3288ba-_0x443661)/_0x5b3975;}['_computeKyleLambda'](_0x382f7d){const _0x36d039=_0x4097f1;if(_0x382f7d['length']<0x14)return 0x0;const _0x4c7792=_0x382f7d[_0x36d039(0x21f)](-0x14),_0x1e6093=[],_0x3c8936=[];for(let _0x3f532f=0x1;_0x3f532f<_0x4c7792[_0x36d039(0x1d5)];_0x3f532f++){_0x1e6093[_0x36d039(0x1d2)](_0x4c7792[_0x3f532f][_0x36d039(0x1ea)]-_0x4c7792[_0x3f532f-0x1][_0x36d039(0x1ea)]),_0x3c8936['push'](_0x4c7792[_0x3f532f]['volume']);}const _0x56d15d=_0x1e6093['reduce']((_0x302cf3,_0x449274)=>_0x302cf3+_0x449274,0x0)/_0x1e6093[_0x36d039(0x1d5)],_0x23d6a4=_0x3c8936[_0x36d039(0x1cc)]((_0x3c821e,_0x1c9c86)=>_0x3c821e+_0x1c9c86,0x0)/_0x3c8936['length'];let _0xd40e0e=0x0,_0x46522a=0x0;for(let _0x4f19d4=0x0;_0x4f19d4<_0x1e6093[_0x36d039(0x1d5)];_0x4f19d4++){_0xd40e0e+=(_0x1e6093[_0x4f19d4]-_0x56d15d)*(_0x3c8936[_0x4f19d4]-_0x23d6a4),_0x46522a+=Math['pow'](_0x3c8936[_0x4f19d4]-_0x23d6a4,0x2);}_0xd40e0e/=_0x1e6093[_0x36d039(0x1d5)],_0x46522a/=_0x1e6093['length'];if(_0x46522a<0.0001)return 0x0;return Math[_0x36d039(0x20a)](_0xd40e0e/_0x46522a);}['_applyKalmanFilter'](_0x9d03a1,_0x1b4a7c){const _0x8be412=_0x4097f1;let _0x2d3f01=this['kalmanStates']['get'](_0x9d03a1);if(!_0x2d3f01)return _0x2d3f01={'estimate':_0x1b4a7c,'errorCovariance':0x1},this[_0x8be412(0x204)]['set'](_0x9d03a1,_0x2d3f01),_0x1b4a7c;const _0x35cd7e=_0x2d3f01['estimate'],_0x47f58b=_0x2d3f01['errorCovariance']+this['kalmanProcessNoise'],_0x2918c9=_0x47f58b/(_0x47f58b+this['kalmanMeasurementNoise']),_0x4f341e=_0x35cd7e+_0x2918c9*(_0x1b4a7c-_0x35cd7e),_0x23e410=(0x1-_0x2918c9)*_0x47f58b;return _0x2d3f01['estimate']=_0x4f341e,_0x2d3f01['errorCovariance']=_0x23e410,_0x4f341e;}[_0x4097f1(0x1ed)](_0x34cdf6,_0xaba7e){const _0x3549ae=_0x4097f1,_0x3f065e=this[_0x3549ae(0x1c3)](_0xaba7e),_0x347499=_0x3f065e/this[_0x3549ae(0x1f4)];let _0xb8be6=this['atrHistory'][_0x3549ae(0x1df)](_0x34cdf6);!_0xb8be6&&(_0xb8be6=[],this[_0x3549ae(0x20e)][_0x3549ae(0x1c1)](_0x34cdf6,_0xb8be6));_0xb8be6[_0x3549ae(0x1d2)](_0x3f065e);if(_0xb8be6[_0x3549ae(0x1d5)]>0x1f4)_0xb8be6[_0x3549ae(0x1dd)]();let _0x43f7aa=0.5;_0xb8be6['length']>=0x14&&(_0x43f7aa=_0xb8be6[_0x3549ae(0x1cd)](_0x22aa40=>_0x22aa40<=_0x3f065e)['length']/_0xb8be6['length']);let _0x46da3a,_0x5f5cbe;if(_0x43f7aa<0.25)_0x46da3a=_0x3549ae(0x1ef),_0x5f5cbe={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x43f7aa<0.75?(_0x46da3a='normal',_0x5f5cbe={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x46da3a='high',_0x5f5cbe={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x46da3a,'params':_0x5f5cbe};}[_0x4097f1(0x1c3)](_0x4a73d5,_0x23d6f0=0xe){const _0x3232fb=_0x4097f1;if(_0x4a73d5[_0x3232fb(0x1d5)]<_0x23d6f0+0x1)return 2.5;const _0x160c1a=[];for(let _0xf3384c=_0x4a73d5['length']-_0x23d6f0;_0xf3384c<_0x4a73d5['length'];_0xf3384c++){const _0x35572e=_0x4a73d5[_0xf3384c],_0x3ce214=_0x4a73d5[_0xf3384c-0x1]['close'],_0x134d8a=Math['max'](_0x35572e[_0x3232fb(0x1d9)]-_0x35572e[_0x3232fb(0x1ef)],Math[_0x3232fb(0x20a)](_0x35572e[_0x3232fb(0x1d9)]-_0x3ce214),Math['abs'](_0x35572e['low']-_0x3ce214));_0x160c1a['push'](_0x134d8a);}return _0x160c1a['reduce']((_0x2848d9,_0x5a3bf1)=>_0x2848d9+_0x5a3bf1,0x0)/_0x160c1a['length'];}['_computeOrderFlowImbalance'](_0x4a4e5a){const _0x573d5c=_0x4097f1;if(_0x4a4e5a['length']<this[_0x573d5c(0x209)])return 0x0;const _0xe90902=_0x4a4e5a['slice'](-this['ofiLookback']);let _0x2664e7=0x0,_0x48fffc=0x0;for(const _0x26531c of _0xe90902){const _0x183aad=_0x26531c['high']-_0x26531c['low'];if(_0x183aad>0x0){const _0x399ac0=(_0x26531c[_0x573d5c(0x1ea)]-_0x26531c[_0x573d5c(0x1ef)])/_0x183aad;_0x2664e7+=_0x399ac0*_0x26531c[_0x573d5c(0x1bf)],_0x48fffc+=(0x1-_0x399ac0)*_0x26531c['volume'];}}const _0x1c721c=_0x2664e7+_0x48fffc;if(_0x1c721c<0x1)return 0x0;return(_0x2664e7-_0x48fffc)/_0x1c721c;}[_0x4097f1(0x211)](_0x4ec529,_0x21928d,_0x9536db,_0x3ea0da,_0x289eb0,_0x4dd09e,_0x571a5d,_0x2008fc,_0x5696ef,_0x42e28c){const _0x1732de=_0x4097f1,_0x2da684=Math['abs'](_0x9536db);if(_0x2da684<_0x2008fc['zscoreThreshold'])return null;if(_0x3ea0da>this['vpinToxicThreshold'])return null;let _0x4c1c5c;if(_0x9536db<-_0x2008fc['zscoreThreshold'])_0x4c1c5c=_0x1732de(0x221);else{if(_0x9536db>_0x2008fc[_0x1732de(0x1d4)])_0x4c1c5c='short';else return null;}const _0x383d9c=_0x4c1c5c==='long'&&_0x5696ef>0.1||_0x4c1c5c===_0x1732de(0x1ce)&&_0x5696ef<-0.1,_0x2b809b=_0x21928d-_0x4dd09e,_0x2acd73=_0x4c1c5c===_0x1732de(0x221)&&_0x2b809b<0x0||_0x4c1c5c===_0x1732de(0x1ce)&&_0x2b809b>0x0,_0x3c4972={'zscore':Math[_0x1732de(0x1e2)](0x1,_0x2da684/0x4),'vpin':0x1-_0x3ea0da,'kyleLambda':_0x289eb0>0.001?0.5:0.8,'kalman':_0x2acd73?0.8:0.4,'volatility':_0x571a5d==='normal'?0.8:_0x571a5d===_0x1732de(0x1ef)?0.7:0.6,'ofi':_0x383d9c?0.9:0.5,'composite':0x0};_0x3c4972[_0x1732de(0x21d)]=_0x3c4972[_0x1732de(0x212)]*this['weights']['zscore']+_0x3c4972[_0x1732de(0x1e9)]*this[_0x1732de(0x1f6)][_0x1732de(0x1e9)]+_0x3c4972['kyleLambda']*this['weights']['kyleLambda']+_0x3c4972['kalman']*this['weights']['kalman']+_0x3c4972['volatility']*this['weights']['volatility']+_0x3c4972['ofi']*this['weights'][_0x1732de(0x1c5)];const _0x37b5f2=Math['min'](0x1,_0x3c4972[_0x1732de(0x21d)]+_0x2008fc['confidenceBonus']);if(_0x37b5f2<this['minConfidence'])return null;if(Date['now']()-this['lastSignalTime']<this['cooldownMs'])return null;const _0x5c366b=Math[_0x1732de(0x206)](this[_0x1732de(0x217)]*_0x2008fc['stopMultiplier']),_0x379577=Math['round'](this['baseTargetTicks']*_0x2008fc['targetMultiplier']),_0x2ed40d=Math[_0x1732de(0x1dc)](0x6,Math['min'](0xc,_0x5c366b)),_0x15fb09=Math['max'](_0x2ed40d*1.5,Math['min'](0x18,_0x379577));let _0x5c8371,_0x14619e,_0x666b9c,_0x2dc41d;_0x4c1c5c==='long'?(_0x5c8371=_0x21928d-_0x2ed40d*this[_0x1732de(0x1f4)],_0x14619e=_0x21928d+_0x15fb09*this['tickSize'],_0x666b9c=_0x21928d+this['breakevenTicks']*this['tickSize'],_0x2dc41d=_0x21928d+_0x15fb09*this[_0x1732de(0x207)]*this['tickSize']):(_0x5c8371=_0x21928d+_0x2ed40d*this[_0x1732de(0x1f4)],_0x14619e=_0x21928d-_0x15fb09*this[_0x1732de(0x1f4)],_0x666b9c=_0x21928d-this[_0x1732de(0x208)]*this[_0x1732de(0x1f4)],_0x2dc41d=_0x21928d-_0x15fb09*this[_0x1732de(0x207)]*this['tickSize']);const _0x9b7715=_0x15fb09/_0x2ed40d,_0x480581=Math['round'](_0x15fb09*0.5),_0x1ea872=Math['round'](_0x2ed40d*0.4);let _0x5d8723=SignalStrength['MODERATE'];if(_0x37b5f2>=0.85)_0x5d8723=SignalStrength[_0x1732de(0x1ff)];else{if(_0x37b5f2>=0.75)_0x5d8723=SignalStrength['STRONG'];else{if(_0x37b5f2<0.6)_0x5d8723=SignalStrength['WEAK'];}}const _0x3fc84c=0.5+(_0x37b5f2-0.5)*0.4,_0xc2dc27=_0x3fc84c*Math['abs'](_0x14619e-_0x21928d)-(0x1-_0x3fc84c)*Math['abs'](_0x21928d-_0x5c8371);this[_0x1732de(0x222)]=Date['now'](),this[_0x1732de(0x219)][_0x1732de(0x1fb)]++;const _0x2ee6d5={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0x4ec529['split']('.')[0x0]||_0x4ec529,'contractId':_0x4ec529,'side':_0x4c1c5c===_0x1732de(0x221)?OrderSide['BID']:OrderSide['ASK'],'direction':_0x4c1c5c,'strategy':_0x1732de(0x20b),'strength':_0x5d8723,'edge':_0xc2dc27,'confidence':_0x37b5f2,'entry':_0x21928d,'entryPrice':_0x21928d,'stopLoss':_0x5c8371,'takeProfit':_0x14619e,'riskReward':_0x9b7715,'stopTicks':_0x2ed40d,'targetTicks':_0x15fb09,'trailTriggerTicks':_0x480581,'trailDistanceTicks':_0x1ea872,'beBreakeven':_0x666b9c,'profitLockLevel':_0x2dc41d,'zScore':_0x9536db,'zScoreExit':this['zscoreExitThreshold'],'vpinValue':_0x3ea0da,'kyleLambda':_0x289eb0,'kalmanEstimate':_0x4dd09e,'volatilityRegime':_0x571a5d,'ofiValue':_0x5696ef,'models':_0x3c4972,'orderFlowConfirmed':_0x383d9c,'kalmanConfirmed':_0x2acd73,'expires':Date[_0x1732de(0x1fc)]()+0xea60};return this[_0x1732de(0x1db)](_0x1732de(0x202),{'side':_0x4c1c5c==='long'?_0x1732de(0x223):'sell','action':'open','reason':'Z='+_0x9536db['toFixed'](0x2)+_0x1732de(0x1c4)+(_0x3ea0da*0x64)[_0x1732de(0x1e7)](0x0)+'%,\x20OFI='+(_0x5696ef*0x64)[_0x1732de(0x1e7)](0x0)+'%,\x20cf='+(_0x37b5f2*0x64)['toFixed'](0x0)+'%',..._0x2ee6d5}),this['emit']('log',{'type':'info','message':'[HQX]\x20SIGNAL:\x20'+_0x4c1c5c[_0x1732de(0x20c)]()+'\x20@\x20'+_0x21928d['toFixed'](0x2)+'\x20|\x20Z:'+_0x9536db[_0x1732de(0x1e7)](0x2)+'\x20VPIN:'+(_0x3ea0da*0x64)[_0x1732de(0x1e7)](0x0)+_0x1732de(0x21a)+(_0x5696ef*0x64)['toFixed'](0x0)+'%\x20Kyle:'+_0x289eb0[_0x1732de(0x1e7)](0x5)+_0x1732de(0x1fe)+_0x571a5d+'\x20|\x20Conf:'+(_0x37b5f2*0x64)[_0x1732de(0x1e7)](0x0)+'%'}),_0x2ee6d5;}[_0x4097f1(0x224)](_0x4a2740){const _0x519404=_0x4097f1,_0x404d02=this['priceBuffer'][_0x519404(0x1df)](_0x4a2740);if(!_0x404d02||_0x404d02['length']<0x32)return![];const _0x1328eb=this[_0x519404(0x1d8)](_0x404d02);return Math['abs'](_0x1328eb)<this[_0x519404(0x200)];}[_0x4097f1(0x1f9)](_0x8ade42){const _0x3961f7=_0x4097f1,_0x23ef9b=this[_0x3961f7(0x1f3)]['get'](_0x8ade42),_0x2df1f0=this[_0x3961f7(0x1bc)][_0x3961f7(0x1df)](_0x8ade42),_0x226995=this[_0x3961f7(0x1fd)][_0x3961f7(0x1df)](_0x8ade42);if(!_0x23ef9b||!_0x2df1f0||!_0x226995||_0x226995[_0x3961f7(0x1d5)]<0x32)return null;const _0x1e9173=this['_computeZScore'](_0x23ef9b),_0x17b8d8=this[_0x3961f7(0x1d3)](_0x2df1f0),_0x3e81ed=this[_0x3961f7(0x1c0)](_0x226995),_0xef9955=this[_0x3961f7(0x203)](_0x226995);return{'zscore':Math['min'](0x1,Math['abs'](_0x1e9173)/0x4),'vpin':0x1-_0x17b8d8,'kyleLambda':_0x3e81ed>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math[_0x3961f7(0x20a)](_0xef9955)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x1e9173,'vpin':_0x17b8d8,'kyleLambda':_0x3e81ed,'ofi':_0xef9955}};}[_0x4097f1(0x227)](_0x540c8b,_0x779f0d){const _0x14d620=_0x4097f1,_0xd41ec=this[_0x14d620(0x1fd)]['get'](_0x540c8b)||[];if(_0xd41ec['length']<0x32)return{'ready':![],'message':_0x14d620(0x1e4)+_0xd41ec[_0x14d620(0x1d5)]+_0x14d620(0x1f0)};const _0x58e10a=this[_0x14d620(0x1f3)]['get'](_0x540c8b)||[],_0x2c3f6a=this['volumeBuffer']['get'](_0x540c8b)||[],_0x251def=this[_0x14d620(0x1d8)](_0x58e10a),_0x3819cb=this['_computeVPIN'](_0x2c3f6a),_0x5ec3e3=this[_0x14d620(0x203)](_0xd41ec),_0x245178=this[_0x14d620(0x1c0)](_0xd41ec),{regime:_0x565309,params:_0x29668a}=this['_detectVolatilityRegime'](_0x540c8b,_0xd41ec);return{'ready':!![],'zScore':_0x251def,'vpin':_0x3819cb,'ofi':_0x5ec3e3,'kyleLambda':_0x245178,'regime':_0x565309,'stopTicks':Math[_0x14d620(0x206)](this[_0x14d620(0x217)]*_0x29668a[_0x14d620(0x1f2)]),'targetTicks':Math[_0x14d620(0x206)](this[_0x14d620(0x1c8)]*_0x29668a[_0x14d620(0x1c2)]),'threshold':_0x29668a[_0x14d620(0x1d4)],'barsProcessed':_0xd41ec[_0x14d620(0x1d5)],'models':'6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)'};}[_0x4097f1(0x1c7)](_0x516f69){const _0x5c6fbc=_0x4097f1;this[_0x5c6fbc(0x1e0)]['push']({'netPnl':_0x516f69,'timestamp':Date['now']()});if(this[_0x5c6fbc(0x1e0)]['length']>0x64)this[_0x5c6fbc(0x1e0)][_0x5c6fbc(0x1dd)]();_0x516f69>0x0?(this['winStreak']++,this['lossStreak']=0x0,this[_0x5c6fbc(0x219)]['wins']++):(this['lossStreak']++,this[_0x5c6fbc(0x1ec)]=0x0,this['stats']['losses']++),this[_0x5c6fbc(0x219)][_0x5c6fbc(0x1ca)]++,this[_0x5c6fbc(0x219)]['pnl']+=_0x516f69,this[_0x5c6fbc(0x1db)](_0x5c6fbc(0x210),{'type':_0x5c6fbc(0x1e8),'message':'[HQX]\x20Trade\x20result:\x20'+(_0x516f69>0x0?'WIN':_0x5c6fbc(0x21b))+'\x20$'+_0x516f69[_0x5c6fbc(0x1e7)](0x2)+',\x20streak:\x20'+(_0x516f69>0x0?this['winStreak']:-this[_0x5c6fbc(0x1f5)])});}['getBarHistory'](_0x54ef8f){const _0x3d4093=_0x4097f1;return this[_0x3d4093(0x1fd)][_0x3d4093(0x1df)](_0x54ef8f)||[];}[_0x4097f1(0x1f1)](){const _0x1672cc=_0x4097f1;return this[_0x1672cc(0x219)];}['reset'](_0x46cbc6){const _0x4f5207=_0x4097f1;this['barHistory'][_0x4f5207(0x1c1)](_0x46cbc6,[]),this[_0x4f5207(0x1f3)][_0x4f5207(0x1c1)](_0x46cbc6,[]),this[_0x4f5207(0x1bc)]['set'](_0x46cbc6,[]),this['atrHistory']['set'](_0x46cbc6,[]),this['kalmanStates'][_0x4f5207(0x1c1)](_0x46cbc6,{'estimate':0x0,'errorCovariance':0x1}),this[_0x4f5207(0x1db)]('log',{'type':_0x4f5207(0x1ee),'message':'[HQX-UltraScalping]\x20Reset\x20state\x20for\x20'+_0x46cbc6});}}class UltraScalpingStrategy extends EventEmitter{constructor(_0x1916a4={}){const _0x459b56=_0x4097f1;super(),this['config']=_0x1916a4,this['strategy']=new HQXUltraScalping(_0x1916a4),this['strategy']['on'](_0x459b56(0x202),_0x17324a=>this[_0x459b56(0x1db)](_0x459b56(0x202),_0x17324a)),this[_0x459b56(0x228)]['on']('log',_0x18437a=>this[_0x459b56(0x1db)](_0x459b56(0x210),_0x18437a));}['processTick'](_0x154bcf){const _0x145791=_0x4097f1;return this[_0x145791(0x228)][_0x145791(0x1be)](_0x154bcf);}[_0x4097f1(0x1fa)](_0x410e82){const _0xef56bb=_0x4097f1;return this['strategy'][_0xef56bb(0x1fa)](_0x410e82);}['onTrade'](_0x2fa94c){const _0x252745=_0x4097f1;return this['strategy'][_0x252745(0x1e6)](_0x2fa94c);}['processBar'](_0x1ded25,_0x1429cc){const _0x49ac9f=_0x4097f1;return this['strategy'][_0x49ac9f(0x1d6)](_0x1ded25,_0x1429cc);}['initialize'](_0x27cdb0,_0x36fd70,_0x330d8d){const _0x144474=_0x4097f1;return this[_0x144474(0x228)][_0x144474(0x1e3)](_0x27cdb0,_0x36fd70,_0x330d8d);}['getAnalysisState'](_0x43dcd5,_0x2c9a76){return this['strategy']['getAnalysisState'](_0x43dcd5,_0x2c9a76);}[_0x4097f1(0x1c7)](_0x5718d3){return this['strategy']['recordTradeResult'](_0x5718d3);}[_0x4097f1(0x21c)](_0x2e2b8f){return this['strategy']['reset'](_0x2e2b8f);}['getStats'](){const _0x2e3386=_0x4097f1;return this[_0x2e3386(0x228)][_0x2e3386(0x1f1)]();}[_0x4097f1(0x205)](_0x1531da){const _0x4bf937=_0x4097f1;return this[_0x4bf937(0x228)][_0x4bf937(0x205)](_0x1531da);}[_0x4097f1(0x1f9)](_0xe00101){const _0x3ec055=_0x4097f1;return this['strategy'][_0x3ec055(0x1f9)](_0xe00101);}['shouldExitByZScore'](_0x206bd0){const _0x5252c6=_0x4097f1;return this['strategy'][_0x5252c6(0x224)](_0x206bd0);}['generateSignal'](_0x3a263f){return null;}}module[_0x4097f1(0x1d0)]={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};
|
|
1
|
+
const _0x41bd06=_0x21ae;function _0x48c5(){const _0x4e7db3=['long','_detectVolatilityRegime','vpinWindow','%,\x20OFI=','now','stats','length','strategy','priceBuffer','\x20VPIN:','ofi','WEAK','29230JdVFhQ',':\x20tick=','_calculateATR','653050yfbkEs','%,\x20cf=','emit','lossStreak','HQX_ULTRA_SCALPING_6MODELS','processBar','\x20Regime:','atrHistory','generateSignal','_computeZScore','pow','%\x20OFI:','low','set','losses','tickValue','getAnalysisState','847654bhGkfI','volatility','830992sveCRR','cooldownMs','filter','uuid','kyleLambda','normal','max','get','ofiLookback','getBarHistory','barHistory','events','min','318vNYpgx','winStreak','_computeOrderFlowImbalance','kalmanProcessNoise','tickSize','buy','kalmanMeasurementNoise','debug','_computeKyleLambda','volatilityLookback','pnl','3TtRwMa','getModelValues','slice','onTick','vpinToxicThreshold','breakevenTicks','3481356HPcOmZ','initialize','signals','profitLockPct','estimate',',\x20streak:\x20','onTrade','volume','ASK','baseStopTicks','close','toUpperCase','round','/50\x20bars','zscoreExitThreshold','sqrt','minHoldTimeMs','abs','push','recentTrades','_generateSignal','_computeVPIN','zscore','602415QhKgfm','log','lastSignalTime','shift','short','targetMultiplier','info','63nQYXIt','BID','reset','%\x20Kyle:','processTick','baseTargetTicks','1233701TQsHgu','minConfidence','sell','weights','kalmanStates','getStats','vpin','volumeBuffer','6\x20(Z-Score,\x20VPIN,\x20Kyle,\x20Kalman,\x20Vol,\x20OFI)','70xddyGO','stopMultiplier','[HQX-UltraScalping]\x206\x20Models:\x20Z-Score(30%),\x20OFI(20%),\x20VPIN(15%),\x20Kalman(15%),\x20Kyle(10%),\x20Vol(10%)','signal','price','recordTradeResult','high','toFixed','reduce','shouldExitByZScore'];_0x48c5=function(){return _0x4e7db3;};return _0x48c5();}(function(_0x480416,_0x3fd8aa){const _0x266074=_0x21ae,_0x2c9339=_0x480416();while(!![]){try{const _0xaa1fe9=parseInt(_0x266074(0x237))/0x1+parseInt(_0x266074(0x226))/0x2+parseInt(_0x266074(0x1da))/0x3*(-parseInt(_0x266074(0x1e0))/0x4)+parseInt(_0x266074(0x223))/0x5*(parseInt(_0x266074(0x246))/0x6)+parseInt(_0x266074(0x204))/0x7+-parseInt(_0x266074(0x239))/0x8*(parseInt(_0x266074(0x1fe))/0x9)+parseInt(_0x266074(0x20d))/0xa*(parseInt(_0x266074(0x1f7))/0xb);if(_0xaa1fe9===_0x3fd8aa)break;else _0x2c9339['push'](_0x2c9339['shift']());}catch(_0x447511){_0x2c9339['push'](_0x2c9339['shift']());}}}(_0x48c5,0x6cece));function _0x21ae(_0x5c39c9,_0x5cd376){_0x5c39c9=_0x5c39c9-0x1da;const _0x48c5f1=_0x48c5();let _0x21ae40=_0x48c5f1[_0x5c39c9];return _0x21ae40;}const EventEmitter=require(_0x41bd06(0x244)),{v4:uuidv4}=require(_0x41bd06(0x23c)),OrderSide={'BID':0x0,'ASK':0x1},SignalStrength={'WEAK':0x1,'MODERATE':0x2,'STRONG':0x3,'VERY_STRONG':0x4};class HQXUltraScalping extends EventEmitter{constructor(_0x6c8c3b={}){const _0x5621ad=_0x41bd06;super(),this[_0x5621ad(0x24a)]=_0x6c8c3b[_0x5621ad(0x24a)]||0.25,this[_0x5621ad(0x235)]=_0x6c8c3b['tickValue']||0x5,this['zscoreEntryThreshold']=1.5,this[_0x5621ad(0x1ee)]=0.5,this[_0x5621ad(0x219)]=0x32,this[_0x5621ad(0x1de)]=0.7,this[_0x5621ad(0x249)]=0.01,this[_0x5621ad(0x24c)]=0.1,this[_0x5621ad(0x24f)]=0x64,this[_0x5621ad(0x241)]=0x14,this['baseStopTicks']=0x8,this[_0x5621ad(0x203)]=0x10,this[_0x5621ad(0x1df)]=0x4,this['profitLockPct']=0.5,this[_0x5621ad(0x205)]=0.55,this[_0x5621ad(0x207)]={'zscore':0.3,'ofi':0.2,'vpin':0.15,'kalman':0.15,'kyleLambda':0.1,'volatility':0.1},this[_0x5621ad(0x243)]=new Map(),this[_0x5621ad(0x21f)]=new Map(),this['volumeBuffer']=new Map(),this['kalmanStates']=new Map(),this['atrHistory']=new Map(),this[_0x5621ad(0x1f3)]=[],this[_0x5621ad(0x247)]=0x0,this[_0x5621ad(0x229)]=0x0,this['lastSignalTime']=0x0,this['cooldownMs']=0x7530,this[_0x5621ad(0x1f0)]=0x2710,this[_0x5621ad(0x21c)]={'signals':0x0,'trades':0x0,'wins':0x0,'losses':0x0,'pnl':0x0};}[_0x41bd06(0x1e1)](_0x5af076,_0xe0de06=0.25,_0x5cac00=0x5){const _0x3556fe=_0x41bd06;this['tickSize']=_0xe0de06,this['tickValue']=_0x5cac00,this[_0x3556fe(0x243)]['set'](_0x5af076,[]),this['priceBuffer']['set'](_0x5af076,[]),this[_0x3556fe(0x20b)][_0x3556fe(0x233)](_0x5af076,[]),this[_0x3556fe(0x22d)]['set'](_0x5af076,[]),this['kalmanStates'][_0x3556fe(0x233)](_0x5af076,{'estimate':0x0,'errorCovariance':0x1}),this[_0x3556fe(0x228)](_0x3556fe(0x1f8),{'type':_0x3556fe(0x1fd),'message':'[HQX-UltraScalping]\x20Initialized\x20for\x20'+_0x5af076+_0x3556fe(0x224)+_0xe0de06+',\x20value='+_0x5cac00}),this[_0x3556fe(0x228)]('log',{'type':'info','message':_0x3556fe(0x20f)});}['processTick'](_0x336dd6){const {contractId:_0x4dca7a,price:_0xa81acf,volume:_0x133943,side:_0x254c22,timestamp:_0x324485}=_0x336dd6,_0x4ec5c6={'timestamp':_0x324485||Date['now'](),'open':_0xa81acf,'high':_0xa81acf,'low':_0xa81acf,'close':_0xa81acf,'volume':_0x133943||0x1};return this['processBar'](_0x4dca7a,_0x4ec5c6);}[_0x41bd06(0x1dd)](_0x5abc9a){return this['processTick'](_0x5abc9a);}[_0x41bd06(0x1e6)](_0x5cee6b){const _0x4c33e8=_0x41bd06;return this[_0x4c33e8(0x202)]({'contractId':_0x5cee6b['contractId']||_0x5cee6b['symbol'],'price':_0x5cee6b[_0x4c33e8(0x211)],'volume':_0x5cee6b['size']||_0x5cee6b[_0x4c33e8(0x1e7)]||0x1,'side':_0x5cee6b['side'],'timestamp':_0x5cee6b['timestamp']||Date['now']()});}['processBar'](_0x38be87,_0x450a59){const _0x1e07d3=_0x41bd06;let _0x36823a=this[_0x1e07d3(0x243)]['get'](_0x38be87);!_0x36823a&&(this['initialize'](_0x38be87),_0x36823a=this['barHistory'][_0x1e07d3(0x240)](_0x38be87));_0x36823a['push'](_0x450a59);if(_0x36823a[_0x1e07d3(0x21d)]>0x1f4)_0x36823a['shift']();const _0x20d723=this[_0x1e07d3(0x21f)][_0x1e07d3(0x240)](_0x38be87);_0x20d723['push'](_0x450a59[_0x1e07d3(0x1ea)]);if(_0x20d723[_0x1e07d3(0x21d)]>0xc8)_0x20d723['shift']();const _0x45e512=this[_0x1e07d3(0x20b)]['get'](_0x38be87),_0xdf1df3=_0x450a59[_0x1e07d3(0x213)]-_0x450a59['low'];let _0x26b127=_0x450a59[_0x1e07d3(0x1e7)]*0.5,_0x1aa31d=_0x450a59['volume']*0.5;if(_0xdf1df3>0x0){const _0x24e867=(_0x450a59['close']-_0x450a59[_0x1e07d3(0x232)])/_0xdf1df3;_0x26b127=_0x450a59[_0x1e07d3(0x1e7)]*_0x24e867,_0x1aa31d=_0x450a59['volume']*(0x1-_0x24e867);}_0x45e512[_0x1e07d3(0x1f2)]({'buy':_0x26b127,'sell':_0x1aa31d});if(_0x45e512['length']>0x64)_0x45e512[_0x1e07d3(0x1fa)]();if(_0x36823a[_0x1e07d3(0x21d)]<0x32)return null;const _0x1190a7=this[_0x1e07d3(0x22f)](_0x20d723),_0x145a48=this[_0x1e07d3(0x1f5)](_0x45e512),_0x51483c=this['_computeKyleLambda'](_0x36823a),_0x4b252d=this['_applyKalmanFilter'](_0x38be87,_0x450a59['close']),{regime:_0x4ad27f,params:_0x4a5cc1}=this['_detectVolatilityRegime'](_0x38be87,_0x36823a),_0x40c0e2=this['_computeOrderFlowImbalance'](_0x36823a);return this['_generateSignal'](_0x38be87,_0x450a59['close'],_0x1190a7,_0x145a48,_0x51483c,_0x4b252d,_0x4ad27f,_0x4a5cc1,_0x40c0e2,_0x36823a);}[_0x41bd06(0x22f)](_0x3fb1ea,_0x4171de=0x32){const _0x1f9557=_0x41bd06;if(_0x3fb1ea[_0x1f9557(0x21d)]<_0x4171de)return 0x0;const _0x3d41d9=_0x3fb1ea['slice'](-_0x4171de),_0x51b52d=_0x3d41d9[_0x1f9557(0x215)]((_0x178b50,_0x257fb1)=>_0x178b50+_0x257fb1,0x0)/_0x4171de,_0x43b8ff=_0x3d41d9[_0x1f9557(0x215)]((_0x32c984,_0x303dea)=>_0x32c984+Math[_0x1f9557(0x230)](_0x303dea-_0x51b52d,0x2),0x0)/_0x4171de,_0x561f07=Math[_0x1f9557(0x1ef)](_0x43b8ff);if(_0x561f07<0.0001)return 0x0;const _0x482fa2=_0x3fb1ea[_0x3fb1ea[_0x1f9557(0x21d)]-0x1];return(_0x482fa2-_0x51b52d)/_0x561f07;}['_computeVPIN'](_0x22e58d){const _0xe73c84=_0x41bd06;if(_0x22e58d['length']<this['vpinWindow'])return 0.5;const _0x1396af=_0x22e58d[_0xe73c84(0x1dc)](-this['vpinWindow']);let _0x191eb8=0x0,_0x4b3a71=0x0;for(const _0x1a2569 of _0x1396af){_0x191eb8+=_0x1a2569[_0xe73c84(0x24b)],_0x4b3a71+=_0x1a2569[_0xe73c84(0x206)];}const _0x51c14f=_0x191eb8+_0x4b3a71;if(_0x51c14f<0x1)return 0.5;return Math['abs'](_0x191eb8-_0x4b3a71)/_0x51c14f;}['_computeKyleLambda'](_0x27d0e2){const _0x562810=_0x41bd06;if(_0x27d0e2[_0x562810(0x21d)]<0x14)return 0x0;const _0x1acd0e=_0x27d0e2['slice'](-0x14),_0x50fa92=[],_0x72da0d=[];for(let _0xf46dcf=0x1;_0xf46dcf<_0x1acd0e[_0x562810(0x21d)];_0xf46dcf++){_0x50fa92['push'](_0x1acd0e[_0xf46dcf]['close']-_0x1acd0e[_0xf46dcf-0x1][_0x562810(0x1ea)]),_0x72da0d['push'](_0x1acd0e[_0xf46dcf]['volume']);}const _0x3874c0=_0x50fa92['reduce']((_0x4cd379,_0x1e05ca)=>_0x4cd379+_0x1e05ca,0x0)/_0x50fa92[_0x562810(0x21d)],_0x37b9f1=_0x72da0d[_0x562810(0x215)]((_0x323930,_0x49ac07)=>_0x323930+_0x49ac07,0x0)/_0x72da0d['length'];let _0x29a830=0x0,_0x57ed47=0x0;for(let _0x51f0f6=0x0;_0x51f0f6<_0x50fa92['length'];_0x51f0f6++){_0x29a830+=(_0x50fa92[_0x51f0f6]-_0x3874c0)*(_0x72da0d[_0x51f0f6]-_0x37b9f1),_0x57ed47+=Math[_0x562810(0x230)](_0x72da0d[_0x51f0f6]-_0x37b9f1,0x2);}_0x29a830/=_0x50fa92['length'],_0x57ed47/=_0x50fa92['length'];if(_0x57ed47<0.0001)return 0x0;return Math[_0x562810(0x1f1)](_0x29a830/_0x57ed47);}['_applyKalmanFilter'](_0x56905a,_0x20d110){const _0x4bd344=_0x41bd06;let _0x25624b=this[_0x4bd344(0x208)][_0x4bd344(0x240)](_0x56905a);if(!_0x25624b)return _0x25624b={'estimate':_0x20d110,'errorCovariance':0x1},this['kalmanStates']['set'](_0x56905a,_0x25624b),_0x20d110;const _0x4fddd0=_0x25624b[_0x4bd344(0x1e4)],_0x4b6418=_0x25624b['errorCovariance']+this['kalmanProcessNoise'],_0x2894ff=_0x4b6418/(_0x4b6418+this[_0x4bd344(0x24c)]),_0x473d4a=_0x4fddd0+_0x2894ff*(_0x20d110-_0x4fddd0),_0x903701=(0x1-_0x2894ff)*_0x4b6418;return _0x25624b['estimate']=_0x473d4a,_0x25624b['errorCovariance']=_0x903701,_0x473d4a;}[_0x41bd06(0x218)](_0x4604d4,_0x36112f){const _0x41c46a=_0x41bd06,_0x3508a8=this[_0x41c46a(0x225)](_0x36112f),_0xe9b967=_0x3508a8/this[_0x41c46a(0x24a)];let _0x19cef1=this['atrHistory']['get'](_0x4604d4);!_0x19cef1&&(_0x19cef1=[],this[_0x41c46a(0x22d)][_0x41c46a(0x233)](_0x4604d4,_0x19cef1));_0x19cef1[_0x41c46a(0x1f2)](_0x3508a8);if(_0x19cef1[_0x41c46a(0x21d)]>0x1f4)_0x19cef1['shift']();let _0x43c6fd=0.5;_0x19cef1['length']>=0x14&&(_0x43c6fd=_0x19cef1[_0x41c46a(0x23b)](_0x3d4d88=>_0x3d4d88<=_0x3508a8)[_0x41c46a(0x21d)]/_0x19cef1[_0x41c46a(0x21d)]);let _0x46352b,_0x5648c9;if(_0x43c6fd<0.25)_0x46352b='low',_0x5648c9={'stopMultiplier':0.8,'targetMultiplier':0.9,'zscoreThreshold':1.2,'confidenceBonus':0.05};else _0x43c6fd<0.75?(_0x46352b=_0x41c46a(0x23e),_0x5648c9={'stopMultiplier':0x1,'targetMultiplier':0x1,'zscoreThreshold':1.5,'confidenceBonus':0x0}):(_0x46352b=_0x41c46a(0x213),_0x5648c9={'stopMultiplier':1.3,'targetMultiplier':1.2,'zscoreThreshold':0x2,'confidenceBonus':-0.05});return{'regime':_0x46352b,'params':_0x5648c9};}[_0x41bd06(0x225)](_0x22abe9,_0x53b3bf=0xe){const _0x56cec0=_0x41bd06;if(_0x22abe9['length']<_0x53b3bf+0x1)return 2.5;const _0x50e946=[];for(let _0x3fa8a6=_0x22abe9[_0x56cec0(0x21d)]-_0x53b3bf;_0x3fa8a6<_0x22abe9['length'];_0x3fa8a6++){const _0x2bfd5e=_0x22abe9[_0x3fa8a6],_0xc65006=_0x22abe9[_0x3fa8a6-0x1][_0x56cec0(0x1ea)],_0x77959b=Math['max'](_0x2bfd5e[_0x56cec0(0x213)]-_0x2bfd5e[_0x56cec0(0x232)],Math['abs'](_0x2bfd5e[_0x56cec0(0x213)]-_0xc65006),Math[_0x56cec0(0x1f1)](_0x2bfd5e[_0x56cec0(0x232)]-_0xc65006));_0x50e946['push'](_0x77959b);}return _0x50e946['reduce']((_0x1623e9,_0x177141)=>_0x1623e9+_0x177141,0x0)/_0x50e946['length'];}['_computeOrderFlowImbalance'](_0x48f64e){const _0x2c6b1e=_0x41bd06;if(_0x48f64e['length']<this['ofiLookback'])return 0x0;const _0x4a8421=_0x48f64e['slice'](-this[_0x2c6b1e(0x241)]);let _0x12f37a=0x0,_0xf0a715=0x0;for(const _0x277a0d of _0x4a8421){const _0x5d1a0b=_0x277a0d[_0x2c6b1e(0x213)]-_0x277a0d[_0x2c6b1e(0x232)];if(_0x5d1a0b>0x0){const _0x2c7f48=(_0x277a0d[_0x2c6b1e(0x1ea)]-_0x277a0d['low'])/_0x5d1a0b;_0x12f37a+=_0x2c7f48*_0x277a0d['volume'],_0xf0a715+=(0x1-_0x2c7f48)*_0x277a0d[_0x2c6b1e(0x1e7)];}}const _0xf6c99f=_0x12f37a+_0xf0a715;if(_0xf6c99f<0x1)return 0x0;return(_0x12f37a-_0xf0a715)/_0xf6c99f;}[_0x41bd06(0x1f4)](_0xb26a83,_0x4d8e8f,_0x4d95bf,_0xbff631,_0x4907b8,_0x53b747,_0x4d6df2,_0x56f5f9,_0x3b4daa,_0x2738d0){const _0x13fc65=_0x41bd06,_0x41ed19=Math['abs'](_0x4d95bf);if(_0x41ed19<_0x56f5f9['zscoreThreshold'])return null;if(_0xbff631>this[_0x13fc65(0x1de)])return null;let _0x3dd068;if(_0x4d95bf<-_0x56f5f9['zscoreThreshold'])_0x3dd068=_0x13fc65(0x217);else{if(_0x4d95bf>_0x56f5f9['zscoreThreshold'])_0x3dd068=_0x13fc65(0x1fb);else return null;}const _0x20c480=_0x3dd068===_0x13fc65(0x217)&&_0x3b4daa>0.1||_0x3dd068===_0x13fc65(0x1fb)&&_0x3b4daa<-0.1,_0x957233=_0x4d8e8f-_0x53b747,_0x556d92=_0x3dd068==='long'&&_0x957233<0x0||_0x3dd068==='short'&&_0x957233>0x0,_0x48d3a9={'zscore':Math[_0x13fc65(0x245)](0x1,_0x41ed19/0x4),'vpin':0x1-_0xbff631,'kyleLambda':_0x4907b8>0.001?0.5:0.8,'kalman':_0x556d92?0.8:0.4,'volatility':_0x4d6df2==='normal'?0.8:_0x4d6df2==='low'?0.7:0.6,'ofi':_0x20c480?0.9:0.5,'composite':0x0};_0x48d3a9['composite']=_0x48d3a9[_0x13fc65(0x1f6)]*this[_0x13fc65(0x207)][_0x13fc65(0x1f6)]+_0x48d3a9[_0x13fc65(0x20a)]*this[_0x13fc65(0x207)][_0x13fc65(0x20a)]+_0x48d3a9['kyleLambda']*this['weights'][_0x13fc65(0x23d)]+_0x48d3a9['kalman']*this['weights']['kalman']+_0x48d3a9[_0x13fc65(0x238)]*this[_0x13fc65(0x207)][_0x13fc65(0x238)]+_0x48d3a9['ofi']*this['weights'][_0x13fc65(0x221)];const _0x331b01=Math[_0x13fc65(0x245)](0x1,_0x48d3a9['composite']+_0x56f5f9['confidenceBonus']);if(_0x331b01<this[_0x13fc65(0x205)])return null;if(Date[_0x13fc65(0x21b)]()-this[_0x13fc65(0x1f9)]<this[_0x13fc65(0x23a)])return null;const _0xe98fab=Math['round'](this[_0x13fc65(0x1e9)]*_0x56f5f9['stopMultiplier']),_0x588bf5=Math[_0x13fc65(0x1ec)](this['baseTargetTicks']*_0x56f5f9[_0x13fc65(0x1fc)]),_0x3e1806=Math[_0x13fc65(0x23f)](0x6,Math['min'](0xc,_0xe98fab)),_0x16c480=Math['max'](_0x3e1806*1.5,Math[_0x13fc65(0x245)](0x18,_0x588bf5));let _0x101298,_0x2ccb3e,_0x467185,_0x494528;_0x3dd068==='long'?(_0x101298=_0x4d8e8f-_0x3e1806*this['tickSize'],_0x2ccb3e=_0x4d8e8f+_0x16c480*this[_0x13fc65(0x24a)],_0x467185=_0x4d8e8f+this[_0x13fc65(0x1df)]*this[_0x13fc65(0x24a)],_0x494528=_0x4d8e8f+_0x16c480*this[_0x13fc65(0x1e3)]*this[_0x13fc65(0x24a)]):(_0x101298=_0x4d8e8f+_0x3e1806*this['tickSize'],_0x2ccb3e=_0x4d8e8f-_0x16c480*this['tickSize'],_0x467185=_0x4d8e8f-this['breakevenTicks']*this[_0x13fc65(0x24a)],_0x494528=_0x4d8e8f-_0x16c480*this[_0x13fc65(0x1e3)]*this['tickSize']);const _0x480741=_0x16c480/_0x3e1806,_0x10c108=Math[_0x13fc65(0x1ec)](_0x16c480*0.5),_0x15bfb4=Math['round'](_0x3e1806*0.4);let _0x459b80=SignalStrength['MODERATE'];if(_0x331b01>=0.85)_0x459b80=SignalStrength['VERY_STRONG'];else{if(_0x331b01>=0.75)_0x459b80=SignalStrength['STRONG'];else{if(_0x331b01<0.6)_0x459b80=SignalStrength[_0x13fc65(0x222)];}}const _0x339366=0.5+(_0x331b01-0.5)*0.4,_0x57a91f=_0x339366*Math['abs'](_0x2ccb3e-_0x4d8e8f)-(0x1-_0x339366)*Math['abs'](_0x4d8e8f-_0x101298);this[_0x13fc65(0x1f9)]=Date['now'](),this[_0x13fc65(0x21c)][_0x13fc65(0x1e2)]++;const _0x332b01={'id':uuidv4(),'timestamp':Date['now'](),'symbol':_0xb26a83['split']('.')[0x0]||_0xb26a83,'contractId':_0xb26a83,'side':_0x3dd068===_0x13fc65(0x217)?OrderSide[_0x13fc65(0x1ff)]:OrderSide[_0x13fc65(0x1e8)],'direction':_0x3dd068,'strategy':_0x13fc65(0x22a),'strength':_0x459b80,'edge':_0x57a91f,'confidence':_0x331b01,'entry':_0x4d8e8f,'entryPrice':_0x4d8e8f,'stopLoss':_0x101298,'takeProfit':_0x2ccb3e,'riskReward':_0x480741,'stopTicks':_0x3e1806,'targetTicks':_0x16c480,'trailTriggerTicks':_0x10c108,'trailDistanceTicks':_0x15bfb4,'beBreakeven':_0x467185,'profitLockLevel':_0x494528,'zScore':_0x4d95bf,'zScoreExit':this[_0x13fc65(0x1ee)],'vpinValue':_0xbff631,'kyleLambda':_0x4907b8,'kalmanEstimate':_0x53b747,'volatilityRegime':_0x4d6df2,'ofiValue':_0x3b4daa,'models':_0x48d3a9,'orderFlowConfirmed':_0x20c480,'kalmanConfirmed':_0x556d92,'expires':Date[_0x13fc65(0x21b)]()+0xea60};return this['emit'](_0x13fc65(0x210),{'side':_0x3dd068==='long'?'buy':_0x13fc65(0x206),'action':'open','reason':'Z='+_0x4d95bf[_0x13fc65(0x214)](0x2)+',\x20VPIN='+(_0xbff631*0x64)[_0x13fc65(0x214)](0x0)+_0x13fc65(0x21a)+(_0x3b4daa*0x64)['toFixed'](0x0)+_0x13fc65(0x227)+(_0x331b01*0x64)[_0x13fc65(0x214)](0x0)+'%',..._0x332b01}),this['emit'](_0x13fc65(0x1f8),{'type':_0x13fc65(0x1fd),'message':'[HQX]\x20SIGNAL:\x20'+_0x3dd068[_0x13fc65(0x1eb)]()+'\x20@\x20'+_0x4d8e8f['toFixed'](0x2)+'\x20|\x20Z:'+_0x4d95bf['toFixed'](0x2)+_0x13fc65(0x220)+(_0xbff631*0x64)[_0x13fc65(0x214)](0x0)+_0x13fc65(0x231)+(_0x3b4daa*0x64)[_0x13fc65(0x214)](0x0)+_0x13fc65(0x201)+_0x4907b8['toFixed'](0x5)+_0x13fc65(0x22c)+_0x4d6df2+'\x20|\x20Conf:'+(_0x331b01*0x64)['toFixed'](0x0)+'%'}),_0x332b01;}['shouldExitByZScore'](_0x2f1ca1){const _0x3ae19e=_0x41bd06,_0x4cdbc6=this[_0x3ae19e(0x21f)][_0x3ae19e(0x240)](_0x2f1ca1);if(!_0x4cdbc6||_0x4cdbc6[_0x3ae19e(0x21d)]<0x32)return![];const _0x5ca7d5=this['_computeZScore'](_0x4cdbc6);return Math[_0x3ae19e(0x1f1)](_0x5ca7d5)<this['zscoreExitThreshold'];}[_0x41bd06(0x1db)](_0x127ec6){const _0x52ea56=_0x41bd06,_0x20b498=this['priceBuffer'][_0x52ea56(0x240)](_0x127ec6),_0x2ecac2=this['volumeBuffer']['get'](_0x127ec6),_0x402fd6=this['barHistory'][_0x52ea56(0x240)](_0x127ec6);if(!_0x20b498||!_0x2ecac2||!_0x402fd6||_0x402fd6[_0x52ea56(0x21d)]<0x32)return null;const _0x437a6a=this[_0x52ea56(0x22f)](_0x20b498),_0x4d7ac3=this[_0x52ea56(0x1f5)](_0x2ecac2),_0x51c0a0=this['_computeKyleLambda'](_0x402fd6),_0x20ca1b=this['_computeOrderFlowImbalance'](_0x402fd6);return{'zscore':Math[_0x52ea56(0x245)](0x1,Math['abs'](_0x437a6a)/0x4),'vpin':0x1-_0x4d7ac3,'kyleLambda':_0x51c0a0>0.001?0.5:0.8,'kalman':0.7,'volatility':0.7,'ofi':Math['abs'](_0x20ca1b)>0.1?0.8:0.5,'composite':0.7,'raw':{'zscore':_0x437a6a,'vpin':_0x4d7ac3,'kyleLambda':_0x51c0a0,'ofi':_0x20ca1b}};}['getAnalysisState'](_0x4386de,_0xfdcc07){const _0x4abd40=_0x41bd06,_0x50cdd5=this['barHistory'][_0x4abd40(0x240)](_0x4386de)||[];if(_0x50cdd5['length']<0x32)return{'ready':![],'message':'Collecting\x20data...\x20'+_0x50cdd5[_0x4abd40(0x21d)]+_0x4abd40(0x1ed)};const _0x4f1aef=this['priceBuffer'][_0x4abd40(0x240)](_0x4386de)||[],_0x3a12a2=this[_0x4abd40(0x20b)][_0x4abd40(0x240)](_0x4386de)||[],_0x349f60=this['_computeZScore'](_0x4f1aef),_0x1e8a40=this[_0x4abd40(0x1f5)](_0x3a12a2),_0x4fd1cd=this[_0x4abd40(0x248)](_0x50cdd5),_0x49bfa3=this[_0x4abd40(0x24e)](_0x50cdd5),{regime:_0x30738f,params:_0x22b4c4}=this[_0x4abd40(0x218)](_0x4386de,_0x50cdd5);return{'ready':!![],'zScore':_0x349f60,'vpin':_0x1e8a40,'ofi':_0x4fd1cd,'kyleLambda':_0x49bfa3,'regime':_0x30738f,'stopTicks':Math[_0x4abd40(0x1ec)](this['baseStopTicks']*_0x22b4c4[_0x4abd40(0x20e)]),'targetTicks':Math['round'](this['baseTargetTicks']*_0x22b4c4['targetMultiplier']),'threshold':_0x22b4c4['zscoreThreshold'],'barsProcessed':_0x50cdd5['length'],'models':_0x4abd40(0x20c)};}[_0x41bd06(0x212)](_0x31b2d8){const _0x592335=_0x41bd06;this[_0x592335(0x1f3)]['push']({'netPnl':_0x31b2d8,'timestamp':Date[_0x592335(0x21b)]()});if(this['recentTrades'][_0x592335(0x21d)]>0x64)this['recentTrades']['shift']();_0x31b2d8>0x0?(this['winStreak']++,this['lossStreak']=0x0,this[_0x592335(0x21c)]['wins']++):(this['lossStreak']++,this['winStreak']=0x0,this['stats'][_0x592335(0x234)]++),this['stats']['trades']++,this[_0x592335(0x21c)][_0x592335(0x250)]+=_0x31b2d8,this[_0x592335(0x228)]('log',{'type':_0x592335(0x24d),'message':'[HQX]\x20Trade\x20result:\x20'+(_0x31b2d8>0x0?'WIN':'LOSS')+'\x20$'+_0x31b2d8['toFixed'](0x2)+_0x592335(0x1e5)+(_0x31b2d8>0x0?this[_0x592335(0x247)]:-this[_0x592335(0x229)])});}['getBarHistory'](_0x5a2626){return this['barHistory']['get'](_0x5a2626)||[];}['getStats'](){return this['stats'];}[_0x41bd06(0x200)](_0x17a0b2){const _0x317f70=_0x41bd06;this[_0x317f70(0x243)]['set'](_0x17a0b2,[]),this['priceBuffer'][_0x317f70(0x233)](_0x17a0b2,[]),this['volumeBuffer']['set'](_0x17a0b2,[]),this['atrHistory']['set'](_0x17a0b2,[]),this[_0x317f70(0x208)][_0x317f70(0x233)](_0x17a0b2,{'estimate':0x0,'errorCovariance':0x1}),this['emit'](_0x317f70(0x1f8),{'type':_0x317f70(0x1fd),'message':'[HQX-UltraScalping]\x20Reset\x20state\x20for\x20'+_0x17a0b2});}}class UltraScalpingStrategy extends EventEmitter{constructor(_0x6f7ee={}){const _0x2ab7b3=_0x41bd06;super(),this['config']=_0x6f7ee,this['strategy']=new HQXUltraScalping(_0x6f7ee),this['strategy']['on'](_0x2ab7b3(0x210),_0x5f3e0a=>this['emit']('signal',_0x5f3e0a)),this['strategy']['on']('log',_0x1342c7=>this[_0x2ab7b3(0x228)]('log',_0x1342c7));}[_0x41bd06(0x202)](_0x18fe95){const _0x274f6e=_0x41bd06;return this[_0x274f6e(0x21e)]['processTick'](_0x18fe95);}['onTick'](_0x16ece7){const _0x28bff4=_0x41bd06;return this[_0x28bff4(0x21e)][_0x28bff4(0x1dd)](_0x16ece7);}['onTrade'](_0x5d26a3){const _0x3af181=_0x41bd06;return this[_0x3af181(0x21e)][_0x3af181(0x1e6)](_0x5d26a3);}['processBar'](_0x16c6f3,_0x11b017){const _0x3660ce=_0x41bd06;return this[_0x3660ce(0x21e)][_0x3660ce(0x22b)](_0x16c6f3,_0x11b017);}[_0x41bd06(0x1e1)](_0x17dddd,_0x36331e,_0x3c8bd7){const _0x693100=_0x41bd06;return this['strategy'][_0x693100(0x1e1)](_0x17dddd,_0x36331e,_0x3c8bd7);}[_0x41bd06(0x236)](_0x40c2c2,_0x4e9d3f){const _0x41628c=_0x41bd06;return this['strategy'][_0x41628c(0x236)](_0x40c2c2,_0x4e9d3f);}['recordTradeResult'](_0x4886c4){const _0x37fcab=_0x41bd06;return this[_0x37fcab(0x21e)][_0x37fcab(0x212)](_0x4886c4);}['reset'](_0x33b827){const _0xfd6755=_0x41bd06;return this['strategy'][_0xfd6755(0x200)](_0x33b827);}[_0x41bd06(0x209)](){const _0x1588d7=_0x41bd06;return this['strategy'][_0x1588d7(0x209)]();}[_0x41bd06(0x242)](_0x15f622){return this['strategy']['getBarHistory'](_0x15f622);}[_0x41bd06(0x1db)](_0x32261c){const _0x192706=_0x41bd06;return this['strategy'][_0x192706(0x1db)](_0x32261c);}[_0x41bd06(0x216)](_0x4edb82){const _0x4cc465=_0x41bd06;return this[_0x4cc465(0x21e)][_0x4cc465(0x216)](_0x4edb82);}[_0x41bd06(0x22e)](_0x3ed470){return null;}}module['exports']={'HQXUltraScalping':HQXUltraScalping,'UltraScalpingStrategy':UltraScalpingStrategy,'M1':UltraScalpingStrategy,'S1':HQXUltraScalping,'OrderSide':OrderSide,'SignalStrength':SignalStrength};
|
package/package.json
CHANGED
package/src/lib/data.js
CHANGED
|
@@ -171,11 +171,12 @@ class MarketDataFeed extends EventEmitter {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
174
|
-
* Get historical
|
|
174
|
+
* Get historical 1-minute bars from HISTORY_PLANT
|
|
175
|
+
* Fetches raw ticks and aggregates them into 1-minute OHLCV bars
|
|
175
176
|
* @param {string} symbol - Symbol (e.g., 'MNQH6')
|
|
176
177
|
* @param {string} exchange - Exchange (default: 'CME')
|
|
177
|
-
* @param {number} barCount - Number of bars to
|
|
178
|
-
* @returns {Promise<Array>} Array of
|
|
178
|
+
* @param {number} barCount - Number of 1-min bars to return (default: 30)
|
|
179
|
+
* @returns {Promise<Array>} Array of 1-min bar objects {timestamp, open, high, low, close, volume}
|
|
179
180
|
*/
|
|
180
181
|
async getHistoricalBars(symbol, exchange = 'CME', barCount = 30) {
|
|
181
182
|
if (!this.credentials) {
|
|
@@ -193,51 +194,55 @@ class MarketDataFeed extends EventEmitter {
|
|
|
193
194
|
await historyConn.connect(historyConfig);
|
|
194
195
|
|
|
195
196
|
return new Promise((resolve, reject) => {
|
|
196
|
-
const
|
|
197
|
+
const ticks = [];
|
|
197
198
|
let isComplete = false;
|
|
198
199
|
|
|
200
|
+
// Request more ticks to cover barCount minutes (estimate ~1500 ticks/min for MNQ)
|
|
201
|
+
const ticksToRequest = Math.min(50000, barCount * 2000);
|
|
202
|
+
|
|
199
203
|
const timeout = setTimeout(() => {
|
|
200
204
|
if (!isComplete) {
|
|
201
205
|
historyConn.disconnect();
|
|
202
|
-
//
|
|
203
|
-
|
|
206
|
+
// Aggregate what we have and return
|
|
207
|
+
const aggregatedBars = this._aggregateTicksTo1MinBars(ticks, barCount);
|
|
208
|
+
resolve(aggregatedBars);
|
|
204
209
|
}
|
|
205
|
-
},
|
|
210
|
+
}, 20000);
|
|
206
211
|
|
|
207
|
-
// Listen for
|
|
212
|
+
// Listen for tick data (template 207)
|
|
208
213
|
historyConn.on('message', (msg) => {
|
|
209
214
|
if (msg.templateId === RES.TICK_BAR_REPLAY) {
|
|
210
215
|
try {
|
|
211
216
|
const data = proto.decode('ResponseTickBarReplay', msg.data);
|
|
212
|
-
const
|
|
217
|
+
const tickObj = data.toJSON ? data.toJSON() : data;
|
|
213
218
|
|
|
214
219
|
// Check for error response
|
|
215
|
-
if (
|
|
220
|
+
if (tickObj.rpCode && tickObj.rpCode[0] !== '0') {
|
|
216
221
|
clearTimeout(timeout);
|
|
217
222
|
isComplete = true;
|
|
218
223
|
historyConn.disconnect();
|
|
219
|
-
reject(new Error(`History request failed: ${
|
|
224
|
+
reject(new Error(`History request failed: ${tickObj.rpCode.join(' - ')}`));
|
|
220
225
|
return;
|
|
221
226
|
}
|
|
222
227
|
|
|
223
|
-
// Add
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
timestamp:
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
low: Number(barObj.lowPrice) || Number(barObj.closePrice),
|
|
230
|
-
close: Number(barObj.closePrice),
|
|
231
|
-
volume: Number(barObj.volume) || 1,
|
|
228
|
+
// Add tick if it has price data
|
|
229
|
+
if (tickObj.closePrice !== undefined) {
|
|
230
|
+
ticks.push({
|
|
231
|
+
timestamp: tickObj.ssboe ? tickObj.ssboe * 1000 : Date.now(),
|
|
232
|
+
price: Number(tickObj.closePrice),
|
|
233
|
+
volume: Number(tickObj.volume) || 1,
|
|
232
234
|
});
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
// Check if this is the final response (rpCode = ['0'])
|
|
236
|
-
if (
|
|
238
|
+
if (tickObj.rpCode && tickObj.rpCode[0] === '0' && tickObj.closePrice === undefined) {
|
|
237
239
|
clearTimeout(timeout);
|
|
238
240
|
isComplete = true;
|
|
239
241
|
historyConn.disconnect();
|
|
240
|
-
|
|
242
|
+
|
|
243
|
+
// Aggregate ticks into 1-minute bars
|
|
244
|
+
const aggregatedBars = this._aggregateTicksTo1MinBars(ticks, barCount);
|
|
245
|
+
resolve(aggregatedBars);
|
|
241
246
|
}
|
|
242
247
|
} catch (e) {
|
|
243
248
|
this.emit('debug', `History decode error: ${e.message}`);
|
|
@@ -247,25 +252,22 @@ class MarketDataFeed extends EventEmitter {
|
|
|
247
252
|
|
|
248
253
|
// Login to HISTORY_PLANT
|
|
249
254
|
historyConn.once('loggedIn', () => {
|
|
250
|
-
// Request tick bar replay - limited count, most recent bars
|
|
251
|
-
// startIndex/finishIndex are required, but userMaxCount + direction=LAST
|
|
252
|
-
// will return only the most recent barCount bars
|
|
253
255
|
const now = Math.floor(Date.now() / 1000);
|
|
254
|
-
const startTime = now - (
|
|
256
|
+
const startTime = now - (barCount * 2 * 60); // Request 2x the time needed
|
|
255
257
|
|
|
256
258
|
historyConn.send('RequestTickBarReplay', {
|
|
257
259
|
templateId: REQ.TICK_BAR_REPLAY, // 206
|
|
258
260
|
userMsg: ['hqx-history'],
|
|
259
261
|
symbol: symbol,
|
|
260
262
|
exchange: exchange,
|
|
261
|
-
barType: 1, // TICK_BAR
|
|
263
|
+
barType: 1, // TICK_BAR (only option for raw ticks)
|
|
262
264
|
barSubType: 1, // REGULAR
|
|
263
265
|
barTypeSpecifier: '1', // 1 tick per bar
|
|
264
|
-
startIndex: startTime, //
|
|
265
|
-
finishIndex: now, //
|
|
266
|
-
userMaxCount:
|
|
267
|
-
direction: 2, // LAST (most recent
|
|
268
|
-
timeOrder: 1, // FORWARDS (
|
|
266
|
+
startIndex: startTime, // Start time
|
|
267
|
+
finishIndex: now, // End time
|
|
268
|
+
userMaxCount: ticksToRequest, // Request enough ticks
|
|
269
|
+
direction: 2, // LAST (most recent first)
|
|
270
|
+
timeOrder: 1, // FORWARDS (chronological order)
|
|
269
271
|
});
|
|
270
272
|
});
|
|
271
273
|
|
|
@@ -283,6 +285,50 @@ class MarketDataFeed extends EventEmitter {
|
|
|
283
285
|
}
|
|
284
286
|
}
|
|
285
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Aggregate raw ticks into 1-minute OHLCV bars
|
|
290
|
+
* @param {Array} ticks - Array of {timestamp, price, volume}
|
|
291
|
+
* @param {number} maxBars - Maximum number of bars to return
|
|
292
|
+
* @returns {Array} Array of 1-min bars {timestamp, open, high, low, close, volume}
|
|
293
|
+
*/
|
|
294
|
+
_aggregateTicksTo1MinBars(ticks, maxBars) {
|
|
295
|
+
if (!ticks || ticks.length === 0) return [];
|
|
296
|
+
|
|
297
|
+
// Sort ticks by timestamp (oldest first)
|
|
298
|
+
const sortedTicks = [...ticks].sort((a, b) => a.timestamp - b.timestamp);
|
|
299
|
+
|
|
300
|
+
// Group ticks by minute
|
|
301
|
+
const barMap = new Map();
|
|
302
|
+
const barIntervalMs = 60000; // 1 minute
|
|
303
|
+
|
|
304
|
+
for (const tick of sortedTicks) {
|
|
305
|
+
const barStartTime = Math.floor(tick.timestamp / barIntervalMs) * barIntervalMs;
|
|
306
|
+
|
|
307
|
+
if (!barMap.has(barStartTime)) {
|
|
308
|
+
barMap.set(barStartTime, {
|
|
309
|
+
timestamp: barStartTime,
|
|
310
|
+
open: tick.price,
|
|
311
|
+
high: tick.price,
|
|
312
|
+
low: tick.price,
|
|
313
|
+
close: tick.price,
|
|
314
|
+
volume: tick.volume,
|
|
315
|
+
});
|
|
316
|
+
} else {
|
|
317
|
+
const bar = barMap.get(barStartTime);
|
|
318
|
+
bar.high = Math.max(bar.high, tick.price);
|
|
319
|
+
bar.low = Math.min(bar.low, tick.price);
|
|
320
|
+
bar.close = tick.price;
|
|
321
|
+
bar.volume += tick.volume;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Convert to array and sort by timestamp
|
|
326
|
+
const bars = Array.from(barMap.values()).sort((a, b) => a.timestamp - b.timestamp);
|
|
327
|
+
|
|
328
|
+
// Return only the last maxBars bars
|
|
329
|
+
return bars.slice(-maxBars);
|
|
330
|
+
}
|
|
331
|
+
|
|
286
332
|
/**
|
|
287
333
|
* Handle incoming messages from TICKER_PLANT
|
|
288
334
|
*/
|
|
@@ -409,22 +409,11 @@ const executeAlgo = async ({ service, account, contract, config, strategy: strat
|
|
|
409
409
|
await marketFeed.connect(rithmicCredentials);
|
|
410
410
|
await marketFeed.subscribe(symbolCode, contract.exchange || 'CME');
|
|
411
411
|
|
|
412
|
-
//
|
|
413
|
-
// Note: HISTORY_PLANT
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const historicalBars = await marketFeed.getHistoricalBars(symbolCode, contract.exchange || 'CME', 30);
|
|
418
|
-
if (historicalBars && historicalBars.length > 0) {
|
|
419
|
-
strategy.preloadBars(contractId, historicalBars);
|
|
420
|
-
ui.addLog('system', `Loaded ${historicalBars.length} bars - ready!`);
|
|
421
|
-
} else {
|
|
422
|
-
ui.addLog('system', 'No historical data - warming up with live bars...');
|
|
423
|
-
}
|
|
424
|
-
} catch (histErr) {
|
|
425
|
-
// HISTORY_PLANT not available (common on paper accounts)
|
|
426
|
-
ui.addLog('system', 'Historical data not available - warming up with live bars...');
|
|
427
|
-
}
|
|
412
|
+
// HQX-2B strategy warmup message
|
|
413
|
+
// Note: HISTORY_PLANT returns limited ticks (10k max = ~1 second of data)
|
|
414
|
+
// which is not enough for 1-min bar aggregation. Strategy warms up with live data.
|
|
415
|
+
if (strategyId === 'hqx-2b') {
|
|
416
|
+
ui.addLog('system', 'HQX-2B warming up - needs ~3 min for first signals...');
|
|
428
417
|
}
|
|
429
418
|
} catch (e) {
|
|
430
419
|
ui.addLog('error', `Failed to connect: ${e.message}`);
|