kiteconnect
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -13,3 +13,3 @@ var KiteConnect = require("kiteconnect").KiteConnect; | ||
kc = new KiteConnect(options); | ||
let kc = new KiteConnect(options); | ||
kc.setSessionExpiryHook(sessionHook); | ||
@@ -16,0 +16,0 @@ |
@@ -13,3 +13,3 @@ "use strict"; | ||
* The HTTP calls have been converted to methods and their JSON responses. | ||
* See the **[Kite Connect API documentation](https://kite.trade/docs/connect/v1/)** | ||
* See the **[Kite Connect API documentation](https://kite.trade/docs/connect/v3/)** | ||
* for the complete list of APIs, supported parameters and values, and response formats. | ||
@@ -71,3 +71,3 @@ * | ||
* want to send API requests to a non-default endpoint, this can be ignored. | ||
* @param {string} [params.login_uri="https://kite.trade/connect/login"] Kite connect login url | ||
* @param {string} [params.login_uri="https://kite.zerodha.com/connect/login"] Kite connect login url | ||
* @param {bool} [params.debug=false] If set to true, will console log requests and responses. | ||
@@ -84,3 +84,3 @@ * @param {number} [params.timeout=7000] Time (milliseconds) for which the API client will wait | ||
"root": "https://api.kite.trade", | ||
"login": "https://kite.trade/connect/login", | ||
"login": "https://kite.zerodha.com/connect/login", | ||
"debug": false, | ||
@@ -121,2 +121,3 @@ "timeout": 7000 | ||
"portfolio.holdings": "/portfolio/holdings", | ||
"portfolio.holdings.auction": "/portfolio/holdings/auctions", | ||
"portfolio.positions.convert": "/portfolio/positions", | ||
@@ -288,2 +289,7 @@ | ||
/** | ||
* @memberOf KiteConnect | ||
*/ | ||
self.VARIETY_AUCTION = "auction"; | ||
// Transaction type | ||
@@ -451,3 +457,3 @@ /** | ||
self.getLoginURL = function() { | ||
return self.default_login_uri + "?api_key=" + self.api_key + "&v=3"; | ||
return self.default_login_uri + "?api_key=" + self.api_key + "&v=" + kiteVersion; | ||
}; | ||
@@ -587,3 +593,3 @@ | ||
* @param {string} params.product Product code (NRML, MIS, CNC). | ||
* @param {string} params.order_type Order type (NRML, SL, SL-M, MARKET). | ||
* @param {string} params.order_type Order type (LIMIT, SL, SL-M, MARKET). | ||
* @param {string} [params.validity] Order validity (DAY, IOC). | ||
@@ -599,2 +605,3 @@ * @param {number} [params.price] Order Price | ||
* @param {number} [params.iceberg_quantity] Split quantity for each iceberg leg order | ||
* @param {number} [params.auction_number] A unique identifier for a particular auction | ||
* @param {string} [params.tag] An optional tag to apply to an order to identify it (alphanumeric, max 20 chars) | ||
@@ -761,2 +768,12 @@ */ | ||
/** | ||
* Retrieves list of available instruments for a auction session. | ||
* @method getAuctionInstruments | ||
* @memberOf KiteConnect | ||
* @instance | ||
*/ | ||
self.getAuctionInstruments = function() { | ||
return _get("portfolio.holdings.auction"); | ||
} | ||
/** | ||
* Retrieve positions. | ||
@@ -888,2 +905,3 @@ * @method getPositions | ||
* @param {bool} [continuous=false] is a bool flag to get continuous data for futures and options instruments. Defaults to false. | ||
* @param {bool} [oi=false] is a bool flag to include OI data for futures and options instruments. Defaults to false. | ||
*/ | ||
@@ -890,0 +908,0 @@ self.getHistoricalData = function(instrument_token, interval, from_date, to_date, continuous, oi) { |
@@ -137,2 +137,6 @@ var WebSocket = require("ws"); | ||
* }); | ||
* | ||
* ticker.on("message", function(binary_msg){ | ||
* console.log("Binary message", binary_msg); | ||
* }); | ||
* | ||
@@ -218,5 +222,4 @@ * function onTicks(ticks) { | ||
current_reconnection_count = 0, | ||
last_reconnect_interval = 0; | ||
last_reconnect_interval = 0, | ||
current_ws_url = null, | ||
token_modes = {}, | ||
defaultReconnectMaxDelay = 60, | ||
@@ -306,2 +309,4 @@ defaultReconnectMaxRetries = 50, | ||
if(e.data instanceof ArrayBuffer) { | ||
// Trigger on message event when binary message is received | ||
trigger("message", [e.data]); | ||
if(e.data.byteLength > 2) { | ||
@@ -375,2 +380,3 @@ var d = parseBinary(e.data); | ||
* order_update - When order update (postback) is received for the connected user (Data object is received as first argument). | ||
* message - when binary message is received from the server. | ||
* ~~~~ | ||
@@ -445,4 +451,16 @@ * | ||
/** | ||
* Parse received binary message | ||
* @memberOf KiteTicker | ||
* @method parseBinary | ||
* @instance | ||
* @param {ArrayBufferTypes} binpacks - tick buffer packets | ||
*/ | ||
this.parseBinary = function(binpacks) { | ||
return parseBinary(binpacks); | ||
} | ||
function autoReconnect(t, max_retry, max_delay) { | ||
auto_reconnect = (t == true ? true : false); | ||
auto_reconnect = (t == true); | ||
@@ -684,18 +702,2 @@ // Set default values | ||
} | ||
// de-duplicate an array | ||
function arrayUnique() { | ||
var u = {}, a = []; | ||
for(var i = 0, l = this.length; i < l; ++i){ | ||
if(u.hasOwnProperty(this[i])) { | ||
continue; | ||
} | ||
a.push(this[i]); | ||
u[this[i]] = 1; | ||
} | ||
return a; | ||
} | ||
var self = this; | ||
@@ -702,0 +704,0 @@ }; |
{ | ||
"name": "kiteconnect", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "The official JS client library for the Kite Connect trading APIs", | ||
@@ -5,0 +5,0 @@ "main": "./lib/", |
@@ -173,2 +173,9 @@ # The Kite Connect API Javascript client - v4 | ||
## Generate documentation | ||
``` | ||
$ npm install -g jsdoc | ||
$ jsdoc -r ./lib -d ./docs | ||
``` | ||
## Changelog | ||
@@ -175,0 +182,0 @@ |
@@ -75,2 +75,6 @@ "use strict"; | ||
// getHoldings | ||
.get("/portfolio/holdings/auctions") | ||
.reply(200, parseJson("auctions_list.json")) | ||
// getPositions | ||
@@ -174,3 +178,3 @@ .get("/portfolio/positions") | ||
.post("/margins/orders") | ||
.query({ mode: "compact" }) | ||
.query({ mode: null }) | ||
.reply(200, parseJson("order_margins.json")) | ||
@@ -315,2 +319,16 @@ | ||
// Retrieves list of available instruments for a auction session | ||
describe("getAuctionInstruments", function() { | ||
it("Retrieves list of available instruments for a auction session", (done) => { | ||
kc.getAuctionInstruments() | ||
.then(function(response) { | ||
expect(response).to.be.an("array"); | ||
expect(response).to.have.nested.property("[0].auction_number"); | ||
expect(response).to.have.nested.property("[0].instrument_token"); | ||
expect(response).to.have.nested.property("[0].tradingsymbol"); | ||
return done(); | ||
}).catch(done); | ||
}) | ||
}); | ||
// Retrieve the list of positions | ||
@@ -646,3 +664,3 @@ describe("getPositions", function() { | ||
} | ||
], "compact") | ||
]) | ||
.then(function(response) { | ||
@@ -653,2 +671,6 @@ expect(response).to.have.nested.property("[0].type"); | ||
expect(response).to.have.nested.property("[0].exposure"); | ||
// Order charges | ||
expect(response).to.have.nested.property("[0].charges.total"); | ||
expect(response).to.have.nested.property("[0].charges.transaction_tax"); | ||
expect(response).to.have.nested.property("[0].charges.gst.total"); | ||
return done(); | ||
@@ -655,0 +677,0 @@ }).catch(done); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
496530
44
29205
206
3