/* ► CryptoCoders Digitex Bracket Order Script ◄ */ /* Description: This script automatically places a stop loss and take-profit conditional order for you when you place an order on the Digitex ladder. Update your settings below and copy the whole script into the developer tools console (F12 on Chrome/Brave) */ const FUTURES = 1; // DO NOT EDIT THIS LINE const SPOT = 2; // DO NOT EDIT THIS LINE const STOP_ONLY = 3; // DO NOT EDIT THIS LINE const BOTH = 4; // DO NOT EDIT THIS LINE const MARKET = 5; // DO NOT EDIT THIS LINE const LIMIT = 6; // DO NOT EDIT THIS LINE /* ----------------------------------------- SETTINGS ----------------------------------------- */ var SETTINGS = { api_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', tick_size: 1, tp_distance: 3, sl_distance: 2, debug: true, trigger: SPOT, // Futures price will be supported in the future Symbol: 'BTCUSD1-PERP', // DO NOT EDIT THIS - It's auto updated! bracket_type: BOTH, // or STOP_ONLY; BOTH (default) places a stop loss AND take profit order for you orderType: MARKET, quickOrders: [ //DO NOT MODIFY THIS { S: 3, t: 5, o: 5 }, { S: 5, t: 7, o: 5 }, { S: 5, t: 10, o: 6 } ], enabled: true, // toogle true/false to disable the plugin useNotifs: true, useSounds: true }; /* --------------------------------------- End SETTINGS --------------------------------------- */ /* DO NOT MODIFY BELOW THIS LINE */ var settingsBtn,listener,contracts,currentPresetBtn,curQty,positions=[],orders=[],spotPx=null,exchangePx=null;const knob='<img class="cursor-pointer knob" src="https://lambot.app/css/Drag-icon.png" alt="Move Order" style="position:relative; left: -10px;">';function parseMsg(t){if(1==t.id&&("ok"==t.status?styledConsole("Successfully Authorized","success"):styledConsole("Authorization: Unsuccessful -"+t.msg,"error")),SETTINGS.enabled)if("tradingStatus"==t.ch)styledConsole("Trading Status:"+t.data.available,"success");else if("orderFilled"==t.ch){if(0==t.data.positionContracts)return console.log("Position Disolved",positions),ws.send(JSON.stringify({id:6,method:"cancelCondOrder",params:{symbol:SETTINGS.Symbol,allForTrader:!0}})),void(positions=[]);if(contracts<0&&"BUY"==t.data.orderSide||contracts>0&&"SELL"==t.data.orderSide)return;if(console.log(`${t.data.origQty-t.data.qty} ${t.data.orderSide} contracts sold.`),positions.filter(e=>e.id==t.data.origClOrdId).length)positions=positions.filter(e=>(e.id==t.data.origClOrdId&&(e.contracts=e.contracts+(t.data.origQty-t.data.qty)),!0));else{const i=orders.filter(e=>e.id==t.data.origClOrdId)[0];var e=new Position(i);positions.push(e),e.sendConditionals()}}else if("orderStatus"==t.ch){if("ACCEPTED"==t.data.orderStatus){if(contracts<0&&"BUY"==t.data.orderSide||contracts>0&&"BUY"==t.data.orderSide)return;if("MARKET"==t.data.orderType){var i=new Position({id:t.data.origClOrdId,entry:Math.ceil(t.data.markPx),contracts:t.data.qty,TPOrdType:SETTINGS.orderType,side:t.data.orderSide.toLowerCase(),TP:"SELL"==t.data.orderSide?Math.ceil(t.data.markPx)-SETTINGS.tick_size*SETTINGS.tp_distance:Math.ceil(t.data.markPx)+SETTINGS.tick_size*SETTINGS.tp_distance,SL:"SELL"==t.data.orderSide?Math.ceil(t.data.markPx)+SETTINGS.tick_size*SETTINGS.sl_distance:Math.ceil(t.data.markPx)-SETTINGS.tick_size*SETTINGS.sl_distance});positions.push(i),i.sendConditionals()}else{var s=new Order({id:t.data.origClOrdId,entry:t.data.px,contracts:t.data.qty,TPOrdType:SETTINGS.orderType,side:t.data.orderSide.toLowerCase(),TP:"SELL"==t.data.orderSide?t.data.px-SETTINGS.tick_size*SETTINGS.tp_distance:t.data.px+SETTINGS.tick_size*SETTINGS.tp_distance,SL:"SELL"==t.data.orderSide?t.data.px+SETTINGS.tick_size*SETTINGS.sl_distance:t.data.px-SETTINGS.tick_size*SETTINGS.sl_distance});orders.push(s)}}}else"condOrderStatus"==t.ch?"TRIGGERED"==t.data.status&&t.data.symbol==SETTINGS.Symbol&&t.data.conditionalOrders.forEach(t=>{const e=t.oldActionId;console.log("SL"==e.substring(0,2)?"Stop Loss Hit":"Take Profit Hit");var i=positions.filter(t=>t.conditionalOrders[0].substring(0,16)==e||t.conditionalOrders[1].substring(0,16)==e);i[0].cancelConditionals(),"SL"==e.substring(0,2)?(playAlarm(),notify("Stop Loss Activated","Entry: "+i[0].entry+"\nExit: "+t.pxValue+"\nSide: "+i[0].side)):"TP"==e.substring(0,2)&&(playChaching(),notify("Take Profit Activated","Entry: "+i[0].entry+"\nExit: "+t.pxValue+"\nSide: "+i[0].side))}):"orderCancelled"==t.ch?t.data.orders.forEach(t=>{orders=orders.filter(e=>e.id!=t.origClOrdId)}):"error"==t.ch&&console.error(t)}class OrderType{constructor(t){this.id=t.id||uuid(),this._contracts=t.contracts,this.side=t.side,this.entry=t.entry,this._TP=t.TP||null,this._SL=t.SL||null,this.TPOrdType=t.TPOrdType||MARKET,this.active=!0,this.created=new Date,0!=this.entry&&console.log(`New ${this.constructor.name}:\nEntry: $${this.entry}\nQty: ${this.contracts}`)}get contracts(){return this._contracts}get TP(){return this._TP}get SL(){return this._SL}set contracts(t){this._contracts=1*t}set TP(t){"long"==this.side&&!t<exchangePx||"short"==this.side&&!t>exchangePx?console.error(`An attempt change the order Take Profit with ID:${this.id} to $${t}. This would result in an immidiate position liquidation.`):(this._TP=t,this.save())}set SL(t){"long"==this.side&&!t<exchangePx||"short"==this.side&&!t>exchangePx?console.error(`An attempt change the order Take Profit with ID:${this.id} to $${t}. This would result in an immidiate position liquidation.`):this._TP=t}get pxType(){return"SPOT_PRICE"}get TPCondition(){return"buy"==this.side?"GREATER_EQUAL":"LESS_EQUAL"}get SLCondition(){return"buy"==this.side?"LESS_EQUAL":"GREATER_EQUAL"}get conditionalSide(){return"buy"==this.side?"SELL":"BUY"}get level(){return 1*this.entry}get ladderRow(){return $("table.ladder-grid__table tbody").find(`td:contains(${this.level})`)}get TPladderRow(){return this.TP?$($("table.ladder-grid__table tbody").find(`td:contains(${this.TP})`)[0]).parent():null}get SLladderRow(){return this.SL?$($("table.ladder-grid__table tbody").find(`td:contains(${this.SL})`)[0]).parent():null}set TP(t){"long"==this.side&&!t<exchangePx||"short"==this.side&&!t>exchangePx?console.error(`An attempt change the order Take Profit with ID:${this.id} to $${t}. This would result in an immidiate position liquidation.`):(this._TP=t,this.save())}}class Order extends OrderType{constructor(t){super(t),this._isConditional=t.isConditional||!1}set isConditional(t){"boolean"==typeof t?this._isConditional=t:console.error("TypeError: Attempt to change order to a conditional failed. Order.isConditional = boolean Must be a boolean.")}get isConditional(){return this._isConditional}save(t=!0){}existsInDB(){return DB.getTable("Orders").filter(t=>t.id==this.id).length}removeFromDB(){}serialize(){return JSON.stringify({id:this.id,entry:this.entry,contracts:this.contracts,side:this.side,isConditional:this.isConditional,TP:this.TP,SL:this.SL})}}class Position extends OrderType{constructor(t){super(t),this.conditionalOrders=[],this.stopIsTrailing=!1}get stopHit(){return!this.active}get contracts(){return 1*this._contracts}set contracts(t){if(this._contracts=1*t,0==this.contracts)return console.log("Position with ID: "+this.id+" - Disolved"),void this.cancelConditionals();this.conditionalOrders.length&&this.plotOnLadder()}sendConditionals(t=!0){const e={id:5,method:"placeCondOrder",params:{symbol:SETTINGS.Symbol,actionId:"TP_"+uuid(),pxType:this.pxType,condition:this.TPCondition,pxValue:this.TP,clOrdId:this.id,ordType:this.TPOrdType==MARKET?"MARKET":"LIMIT",timeInForce:"GTC",side:this.conditionalSide,px:this.TPOrdType==LIMIT?this.TP-2*SETTING.tick_size:this.TP,qty:this.contracts,mayIncrPosition:!1}},i={id:4,method:"placeCondOrder",params:{symbol:SETTINGS.Symbol,actionId:"SL_"+uuid(),pxType:this.pxType,condition:this.SLCondition,pxValue:this.SL,clOrdId:this.id,ordType:"MARKET",timeInForce:"GTC",side:this.conditionalSide,px:this.SL,qty:this.contracts,mayIncrPosition:!1}};SETTINGS.bracket_type==BOTH?(this.conditionalOrders.push(e.params.actionId),this.conditionalOrders.push(i.params.actionId),ws.send(JSON.stringify(i)),ws.send(JSON.stringify(e))):(this.conditionalOrders.push(i.params.actionId),ws.send(JSON.stringify(i)))}cancelConditionals(t=!1){this.conditionalOrders.forEach(e=>{ws.send(JSON.stringify({id:6,method:"cancelCondOrder",params:{symbol:SETTINGS.Symbol,actionId:e,allForTrader:!!t}}))}),this.removePlot()}plotOnLadder(){let t=this.TP>this.entry?1:5;this.SLladderRow.find("td.ladder-grid__price").css("color","rgb(228,88,93)"),this.TPladderRow.find("td.ladder-grid__price").css("color","rgb(37,208,131)"),this.SLladderRow.find(`:nth-child(${t})`).css({backgroundImage:'url("https://lambot.app/css/SL.png")',backgroundRepeat:"no-repeat"}).addClass("icon"),SETTINGS.bracket_type==BOTH&&this.TPladderRow.find(`:nth-child(${t})`).css({backgroundImage:'url("https://lambot.app/css/MB.png")',backgroundRepeat:"no-repeat"}).addClass("icon")}removePlot(){this.SLladderRow.find("td.ladder-grid__price").css("color","rgb(220,220,220)"),this.TPladderRow.find("td.ladder-grid__price").css("color","rgb(220,220,220)")}}class db{constructor(t=null){try{localStorage.test="t",localStorage.setItem("test","t"),localStorage.removeItem("test"),this.enabled=1}catch(t){console.warn("Cannot use storage for some unknown reason. This could be caused by settings within your browser."),this.enabled=0}this.pre=t||t}set prefix(t){this.enabled&&(this.pre=t)}get prefix(){return this.pre+"_"}setSettings(){this.enabled&&localStorage.setItem(this.prefix+"Settings",JSON.stringify(SETTINGS))}getSettings(){if(this.enabled)return JSON.parse(localStorage.getItem(this.prefix+"Settings"))}InsertTable(t,e){var i=this.getTable(t);i.push({id:i.length,value:e}),localStorage.setItem(this.prefix+t,JSON.stringify(i))}generateID(t){return this.getTable(t).length}truncate(){console.log("Truncating Database: "+this.pre),Object.keys(localStorage).filter(t=>t.includes(this.prefix)).forEach(t=>{localStorage.removeItem(t)})}update(t,e,i){var s=this.getTable(t).forEach(t=>{t.id==e&&(t.value=i)});return localStorage.setItem(this.prefix+t,JSON.stringify(s)),s}removeItem(t,e){if(this.enabled)return localStorage.removeItem(this.prefix+t+"_"+e),1}CreateTable(t){if(this.enabled)return!localStorage.getItem(this.prefix+t)&&(localStorage.setItem(this.prefix+t,JSON.stringify([])),!0)}GetByID(t,e){return this.getTable(t).filter(t=>t.id==e)[0]}getTable(t){if(this.enabled){var e=localStorage.getItem(this.prefix+t)||null;return e?JSON.parse(e):(this.CreateTable(t),[])}}dropTable(t){if(this.enabled){console.groupCollapsed("Dropping Table:",t);let i=Object.keys(localStorage).filter(e=>e.includes(this.prefix+t));var e=0;return i.forEach((t,i)=>{console.warn("Deleting: ",t),localStorage.removeItem(t),e=i}),console.groupEnd(),e}return-1}}const DB=new db("BracketMod");function styledConsole(t,e){var i={main:["background: linear-gradient(#D33106, #571402)","border: 1px solid #3E0E02","color: white","width: 100%","display: block","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","line-height: 40px","text-align: center","font-weight: bold","border-radius: 5px"].join(";"),success:["background: rgb(20, 31, 26)","color: rgb(37, 208, 131)"].join(";"),error:["background: rgb(33, 23, 23)","color: rgb(228, 88, 93)"].join(";"),warning:["color: #dede7d"].join(";")};console.log("%c "+t,i[e])}function uuid(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}function setup(){console.clear();var t=["background: linear-gradient(#D33106, #571402)","border: 1px solid #3E0E02","color: white","width: 100%","display: block","text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3)","box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 5px 3px -5px rgba(0, 0, 0, 0.5), 0 -13px 5px -10px rgba(255, 255, 255, 0.4) inset","line-height: 40px","text-align: center","font-weight: bold","border-radius: 5px"].join(";");console.log("%c CryptoCoders Digitex Bracket Mod ",t),console.log("Installed v. 0.9"),styledConsole("Please wait, Running setup...","warning"),ws=new WebSocket("wss://ws.mapi.digitexfutures.com"),ws.onopen=function(){styledConsole("Authorizing to your Digitex account...","warning"),ws.send(JSON.stringify({id:1,method:"auth",params:{type:"token",value:SETTINGS.api_key}}))},ws.onmessage=function(t){var e=t.data;"ping"==e?ws.send("pong"):parseMsg(JSON.parse(e))},ws.onclose=function(){setTimeout(()=>{ws=new WebSocket("wss://ws.mapi.digitexfutures.com")},5e3),console.warn("Warning! Websocket Closed! Attepmting to reconnect to Digitex...")},setTimeout(()=>{styledConsole("Complete! Start trading with confidence!","success"),$("body").prepend('<audio id="alarm"><source src="https://lambot.app/css/alarm.wav" type="audio/wav">Your browser does not support the audio element.</audio>'),$("body").prepend('<audio id="chaching"><source src="https://lambot.app/css/chaching.wav" type="audio/wav">Your browser does not support the audio element.</audio>'),$($(".ladder-grid__controls-table")[1]).after('<p style="text-align: center;margin:auto; border" 2px solid #131313">Bracket Quick Select</p>'+`<button class="quickSelect" id="q0" style="width: 60px;height: 30px; background-color: rgb(26,26,26); color: rgb(149,149,149); border: 1px solid #131313;">${SETTINGS.quickOrders[0].S}/${SETTINGS.quickOrders[0].t}${SETTINGS.quickOrders[0].o==LIMIT?"L":""}</button>`+`<button class="quickSelect" id="q1" style="width: 61px;height: 30px; background-color: rgb(26,26,26); color: rgb(149,149,149); border: 1px solid #131313;">${SETTINGS.quickOrders[1].S}/${SETTINGS.quickOrders[1].t}${SETTINGS.quickOrders[1].o==LIMIT?"L":""}</button>`+`<button class="quickSelect" id="q2" style="width: 61px;height: 30px; background-color: rgb(26,26,26); color: rgb(149,149,149); border: 1px solid #131313;">${SETTINGS.quickOrders[2].S}/${SETTINGS.quickOrders[2].t}${SETTINGS.quickOrders[2].o==LIMIT?"L":""}</button>`+'<button id="q0h" style="width: 60px;height: 15px; font-size: 9px; background-color: rgb(26,26,26); color: rgb(149,149,149);">1</button><button id="q1h" style="width: 60px;height: 15px; font-size: 9px; background-color: rgb(26,26,26); color: rgb(149,149,149);">1</button><button id="q2h" style="width: 60px;height: 15px; font-size: 9px; background-color: rgb(26,26,26); color: rgb(149,149,149);">1</button>'),settingsBtn=$(".ladder-grid__controls-setting"),$(".quickSelect").each(function(){let t=$(this).html().replace("L","").split("/"),e=t[0],i=t[1];SETTINGS.enabled&&SETTINGS.sl_distance==e&&SETTINGS.tp_distance==i&&$(this).css({backgroundColor:"rgba(56,177,220, 0.1)",color:"rgb(56,177,220)"}).addClass("BM-Active"),$("#"+$(this).attr("id")+"h").text((.1*localStorage.quantity*e/(1*$($(".text-with-dgtx")[0]).html().replace(",",""))*100).toFixed(3)+"%")}),$(".quickSelect").on("click",function(){$(this).hasClass("BM-Active")?(SETTINGS.enabled=!1,DB.setSettings(),$(this).css({backgroundColor:"rgb(26,26,26)",color:"rgb(149,149,149)"}).removeClass("BM-Active")):(SETTINGS.enabled=!0,SETTINGS.orderType=$(this).html().includes("L")?LIMIT:MARKET,SETTINGS.sl_distance=1*$(this).html().split("/")[0],SETTINGS.tp_distance=1*$(this).html().split("/")[1].replace("L",""),DB.setSettings(),$(".BM-Active").css({backgroundColor:"rgb(26,26,26)",color:"rgb(149,149,149)"}).removeClass("BM-Active"),$(this).css({backgroundColor:"rgba(56,177,220, 0.1)",color:"rgb(56,177,220)"}).addClass("BM-Active"))}),setInterval(()=>{try{exchangePx=1*$("td.active.ladder-grid__price").html()}catch(t){console.warn(t.message)}contracts=1*$(".position").html().replaceAll("\x3c!----\x3e","").trim();var t=window.location.href;curQty!=localStorage.quantity&&$(".quickSelect").each(function(){let t=$(this).html().replace("L","").split("/")[0];$("#"+$(this).attr("id")+"h").text((.1*localStorage.quantity*t/(1*$($(".text-with-dgtx")[0]).html().replace(",",""))*100).toFixed(3)+"%")}),curQty=localStorage.quantity,t.includes("BTCUSD1")?(SETTINGS.tick_size=1,SETTINGS.Symbol="BTCUSD1-PERP"):t.includes("BTCUSD")&&(SETTINGS.tick_size=5,SETTINGS.Symbol="BTCUSD-PERP")},50),$("table.ladder-grid__table tbody").find("td:not(.cursor-default):not(.text-upnl)").on("mouseover",function(t){const e=$(this).is(":nth-child(2)")?$(this).next().html():$(this).prev().html(),i=$(this).is(":nth-child(2)")?$(this).next():$(this).prev();if($(this).is(":nth-child(2)")&&e<=exchangePx)if(i.prop("style","color: #afaf54;"),SETTINGS.bracket_type==BOTH){const t=$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)+SETTINGS.tp_distance*SETTINGS.tick_size})`),i=$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)-SETTINGS.sl_distance*SETTINGS.tick_size})`);t.addClass("temp").css({color:"rgb(37, 208, 131)",background:"linear-gradient(to bottom, rgba(255,0,0,1) 1%, rgba(255,255,255,0) 100%);"}),i.addClass("temp").prop("style","color: rgb(228, 88, 93);")}else{$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)-SETTINGS.sl_distance*SETTINGS.tick_size})`).addClass("temp").prop("style","color: rgb(228, 88, 93);")}else if($(this).is(":nth-child(4)")&&e>=exchangePx)if(i.prop("style","color: #afaf54;"),SETTINGS.bracket_type==BOTH){const t=$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)-SETTINGS.tp_distance*SETTINGS.tick_size})`),i=$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)+SETTINGS.sl_distance*SETTINGS.tick_size})`);t.addClass("temp").prop("style","color: rgb(37, 208, 131);"),i.addClass("temp").prop("style","color: rgb(228, 88, 93);")}else{$("table.ladder-grid__table tbody").find(`td:contains(${parseInt(e)+SETTINGS.sl_distance*SETTINGS.tick_size})`).addClass("temp").prop("style","color: rgb(228, 88, 93);")}}).on("mouseout",function(){($(this).is(":nth-child(2)")?$(this).next():$(this).prev()).prop("style",""),$(".temp").prop("style","")}),settingsBtn.on("click",function(){setTimeout(()=>{SETTINGS.trigger,SPOT;var t=SETTINGS.bracket_type===BOTH?["selected",""]:["","selected"];$(".modal-body").append("<h4>Bracket Order Settings</h4>");const e=$(".modal-body").append('<div class="row col-12"></div>');e.append(`<div class="form-group"><label class="form-label" for="orderType">Bracket Type</label><select class="form-control" id="orderType"><option value="3" ${t[1]}>Just Stop Loss</options><option value="4"${t[0]}>Place Both Brackets (TP & SL)</options></select></div>`),e.append(` <div class="row col-12">\n <div class="col-6">Sounds <input type="checkbox" id="sounds" ${1==SETTINGS.useSounds?"checked":""}/></div>\n <div class="col-6">Notifications <input type="checkbox" id="notifs" ${1==SETTINGS.useNotifs?"checked":""}/></div>\n </div>`),e.append(`\n <h5>Bracket Presets</h5>\n <div class="row col-12">\n <div class="col-5" style="text-align: center;">Stop Loss</div>\n <div class="col-5"style="text-align: center;">Take Profit</div>\n <div class="col-2"style="text-align: right;">Limit TP</div>\n </div>\n <div class="row col-12">\n <div class="col-5"><input class="form-control" type="number" data-preset="0S" placeholder="Stop Loss" value="${SETTINGS.quickOrders[0].S}"/></div>\n <div class="col-5"><input class="form-control" type="number" data-preset="0t" placeholder="Take Profit" value="${SETTINGS.quickOrders[0].t}"/></div>\n <div class="col-2"><input type="checkbox" data-preset="0o" ${SETTINGS.quickOrders[0].o==LIMIT?"checked":""}/></div>\n </div>`),e.append(`\n <div class="row col-12">\n <div class="col-5"><input class="form-control" type="number" data-preset="1S" placeholder="Stop Loss" value="${SETTINGS.quickOrders[1].S}"/></div>\n <div class="col-5"><input class="form-control" type="number" data-preset="1t" placeholder="Take Profit" value="${SETTINGS.quickOrders[1].t}"/></div>\n <div class="col-2"><input type="checkbox" data-preset="1o" ${SETTINGS.quickOrders[1].o==LIMIT?"checked":""}/></div>\n </div>`),e.append(`\n <div class="row col-12">\n <div class="col-5"><input class="form-control" type="number" data-preset="2S" placeholder="Stop Loss" value="${SETTINGS.quickOrders[2].S}"/></div>\n <div class="col-5"><input class="form-control" type="number" data-preset="2t" placeholder="Take Profit" value="${SETTINGS.quickOrders[2].t}"/></div>\n <div class="col-2"><input type="checkbox" data-preset="2o" ${SETTINGS.quickOrders[2].o==LIMIT?"checked":""}/></div>\n </div>`),$("#sounds").on("change",function(){$(this).prop("checked")?SETTINGS.useSounds=!0:SETTINGS.useSounds=!1}),$("#notifs").on("change",function(){$(this).prop("checked")?SETTINGS.useNotifs=!0:SETTINGS.useNotifs=!1}),$("input[data-preset]").on("change",function(){let t=1*$(this).data("preset")[0],e=$(this).data("preset")[1];"o"==e?$(this).prop("checked")?SETTINGS.quickOrders[t].o=LIMIT:SETTINGS.quickOrders[t].o=MARKET:SETTINGS.quickOrders[t][e]=1*$(this).val(),DB.setSettings(),$(`#q${t}`).html(`${SETTINGS.quickOrders[t].S}/${SETTINGS.quickOrders[t].t}${SETTINGS.quickOrders[t].o==LIMIT?"L":""}`).css({backgroundColor:"rgb(26,26,26)",color:"rgb(149,149,149)"}).removeClass("BM-Active")}),$("#StopDist").on("change",function(){SETTINGS.sl_distance=1*$(this).val(),DB.setSettings()}),$("#TPDist").on("change",function(){SETTINGS.tp_distance=1*$(this).val(),DB.setSettings()}),$("#orderTrigger").on("change",function(){"Spot"==$(this).val()?SETTINGS.trigger=SPOT:SETTINGS.trigger=FUTURES,DB.setSettings()}),$("#orderType").on("change",function(){$(this).val()==BOTH?SETTINGS.bracket_type=BOTH:SETTINGS.bracket_type=STOP_ONLY,DB.setSettings()})},100)}),$(".text_myorders").trigger("click"),$(".navbar-nav").append('<li class="nav-item"><a href="https://lambot.app" class="nav-link">Lambot?</a></li>'),DB.CreateTable("Orders"),DB.CreateTable("Positions"),DB.getSettings()?SETTINGS=DB.getSettings():DB.setSettings()},5e3)}function playChaching(){SETTINGS.useSounds&&$("#chaching")[0].play()}function playAlarm(){if(SETTINGS.useSounds){var t=$("#alarm")[0];t.play(),setTimeout(()=>{t.pause()},2e3)}}DB.getSettings()&&(SETTINGS=DB.getSettings()),setup(),setInterval(()=>{$(".icon").css({backgroundImage:"none"}),positions.forEach(t=>{t.removePlot(),t.plotOnLadder()})},1e3);var notifs=!1;function notify(t,e){if(notifs&&SETTINGS.useNotifs)return new Notification(t,{body:e})}"Notification"in window?"granted"===Notification.permission?notifs=!0:"denied"!==Notification.permission&&Notification.requestPermission().then(function(t){"granted"===t&&(notifs=!0)}):notifs=!1,$(document).on("keydown",function(t){t.altKey&&40==t.which?(console.log("Market Short Order for "+localStorage.quantity),ws.send(JSON.stringify({id:3,method:"placeOrder",params:{symbol:SETTINGS.Symbol,clOrdId:uuid(),ordType:"MARKET",timeInForce:"IOC",side:"SELL",px:0,qty:1*localStorage.quantity}}))):t.altKey&&38==t.which&&(console.log("Market Long Order for "+localStorage.quantity),ws.send(JSON.stringify({id:3,method:"placeOrder",params:{symbol:SETTINGS.Symbol,clOrdId:uuid(),ordType:"MARKET",timeInForce:"IOC",side:"BUY",px:0,qty:1*localStorage.quantity}})))});