However while trying to modify GTT, i am getting below error. placeGTT Error: { status: 'error', message: 'Trigger already met.', data: null, error_type: 'InputException' }
Here is the code to modify GTT. ` redis.get(tick.instrument_token).then((result) => { let redisData = JSON.parse(result); //console.log(redisData); tick.last_price = 150; //Price harcoded to check logic written below if (tick.last_price > redisData.average_price) {
let percentageIncrease = ((tick.last_price - redisData.average_price) / redisData.average_price) * 100; if (percentageIncrease > 10) {
console.log("Price increased more than than 10% hence updating GTT with increased stopLoss and target");
let stopLossTrigger = tick.last_price * 0.91; let stopLoss = tick.last_price * 0.9; let targetTrigger = tick.last_price * 1.19; let target = tick.last_price * 1.2;