Skip to content

Commit 9d924a2

Browse files
authored
Merge pull request #24 from zerodhatech/feat-gtt
feat: add GTT api calls
2 parents 6a132df + 9203b69 commit 9d924a2

File tree

3 files changed

+1229
-982
lines changed

3 files changed

+1229
-982
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ jspm_packages
3939

4040
# Optional REPL history
4141
.node_repl_history
42+
43+
docs

examples/connect.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ function init() {
5555
modifyOrder("regular");
5656
cancelOrder("regular");
5757

58+
getGTT();
59+
getGTT("some_trigger_id");
60+
placeGTT();
61+
modifyGTT();
62+
deleteGTT("some_trigger_id");
63+
5864
invalidateAccessToken()
5965
}
6066

@@ -342,3 +348,81 @@ function cancelOrder(variety) {
342348
console.log(err);
343349
});
344350
}
351+
352+
function getGTT(trigger_id) {
353+
if (trigger_id) {
354+
kc.getGTTs().then(function (resp) {
355+
console.log(resp)
356+
}).catch(function (error) {
357+
console.log(error)
358+
})
359+
} else {
360+
kc.getGTT(trigger_id).then(function (resp) {
361+
console.log(resp)
362+
}).catch(function (error) {
363+
console.log(error)
364+
})
365+
}
366+
}
367+
368+
function placeGTT() {
369+
kc.placeGTT({
370+
trigger_type: kc.GTT_TYPE_OCO,
371+
tradingsymbol: "SBIN",
372+
exchange: "NSE",
373+
trigger_values: [300, 400],
374+
last_price: 318,
375+
orders: [{
376+
transaction_type: kc.TRANSACTION_TYPE_SELL,
377+
quantity: 1,
378+
product: kc.PRODUCT_CNC,
379+
order_type: kc.ORDER_TYPE_LIMIT,
380+
price: 300
381+
}, {
382+
transaction_type: kc.TRANSACTION_TYPE_SELL,
383+
quantity: 1,
384+
product: kc.PRODUCT_CNC,
385+
order_type: kc.ORDER_TYPE_LIMIT,
386+
price: 400
387+
}]
388+
}).then(function (resp) {
389+
console.log(resp)
390+
}).catch(function (error) {
391+
console.log(error)
392+
})
393+
}
394+
395+
function modifyGTT(trigger_id) {
396+
kc.modifyGTT(trigger_id, {
397+
trigger_type: kc.GTT_TYPE_OCO,
398+
tradingsymbol: "SBIN",
399+
exchange: "NSE",
400+
trigger_values: [301, 401],
401+
last_price: 318,
402+
orders: [{
403+
transaction_type: kc.TRANSACTION_TYPE_SELL,
404+
quantity: 1,
405+
product: kc.PRODUCT_CNC,
406+
order_type: kc.ORDER_TYPE_LIMIT,
407+
price: 300
408+
}, {
409+
transaction_type: kc.TRANSACTION_TYPE_SELL,
410+
quantity: 1,
411+
product: kc.PRODUCT_CNC,
412+
order_type: kc.ORDER_TYPE_LIMIT,
413+
price: 400
414+
}]
415+
}).then(function (resp) {
416+
console.log(resp)
417+
}).catch(function (error) {
418+
console.log(error)
419+
})
420+
}
421+
422+
function deleteGTT(trigger_id) {
423+
kc.deleteGTT(trigger_id).then(function (resp) {
424+
console.log(resp)
425+
}).catch(function (error) {
426+
console.log(error)
427+
})
428+
}

0 commit comments

Comments
 (0)