Skip to content

Commit adc3543

Browse files
committed
Merge branch 'kite3'
2 parents a6dc548 + f19c940 commit adc3543

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+31404
-950
lines changed

.jsdoc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"encoding": "utf8",
2222
"private": true,
2323
"recurse": true,
24+
"sort": false,
2425
"template": "./node_modules/minami"
2526
}
2627
}

CHANGELOG.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
New features
2+
=============
3+
- method: `getProfile`
4+
- method: `getOHLC`
5+
- method: `getLTP`
6+
- method: `getInstrumentsMargins`
7+
- Added MF API calls
8+
- method: `getMFOrders`
9+
- method: `getMFHoldings`
10+
- method: `placeMFOrder`
11+
- method: `cancelMFOrder`
12+
- method: `getMFSIPS`
13+
- method: `placeMFSIP`
14+
- method: `modifyMFSIP`
15+
- method: `cancelMFSIP`
16+
- method: `getMFInstruments`
17+
- method: `exitOrder`
18+
- method: `renewAccessToken`
19+
- method: `invalidateRefreshToken`
20+
- constants for products, order type, transaction type, variety, validity, exchanges and margin segments
21+
22+
API method name changes
23+
=======================
24+
25+
| v2 | v3 |
26+
| ------------------------- | ------------------------- |
27+
| requestAccessToken | generateSession |
28+
| invalidateToken | invalidateAccessToken |
29+
| setSessionHook | setSessionExpiryHook |
30+
| loginUrl | getLoginURL |
31+
| margins | getMargins |
32+
| orderPlace | placeOrder |
33+
| orderModify | modifyOrder |
34+
| orderCancel | cancelOrder |
35+
| orders | getOrders |
36+
| orders(order_id) | getOrderHistory |
37+
| trades | getTrades |
38+
| trades(order_id) | getOrderTrades |
39+
| holdings | getHoldings |
40+
| positions | getPositions |
41+
| productModify | convertPosition |
42+
| instruments | getInstruments |
43+
| historical | getHistoricalData |
44+
| triggerRange | getTriggerRange |
45+
46+
Params and other changes
47+
========================
48+
- `KiteConnect` takes all the params as object including `api_key`
49+
- `convertPosition` method takes all the params as object
50+
- All success response returns only `data` field in response instead with envelope
51+
- All error thrown are in the format of `{"message": "Unknown error", "error_type": "GeneralException", "data": null}`
52+
- [Changes in `generateSession` response structure](https://kite.trade/docs/connect/v3/user/#response-attributes)
53+
- [Changes in `getPositions` response structure](https://kite.trade/docs/connect/v3/portfolio/#response-attributes_1)
54+
- [Changes in `getQuote` response structure](https://kite.trade/docs/connect/v3/market-quotes/#retrieving-full-market-quotes)
55+
- [Changes in `placeOrder` params](https://kite.trade/docs/connect/v3/orders/#bracket-order-bo-parameters)
56+
- Changes in `getHistoricalData` params
57+
- All datetime string fields has been converted to `Date` object.
58+
- `getOrders`, `getOrderHistory`, `getTrades`, `getOrderTrades`, `getMFOrders` responses fields `order_timestamp`, `exchange_timestamp`, `fill_timestamp`
59+
- `getMFSIPS` fields `created`, `last_instalment`
60+
- `generateSession` field `login_time`
61+
- `getQuote` fields `timestamp`, `last_trade_time`
62+
- `getInstruments` field `expiry`
63+
- `getMFInstruments` field `last_price_date`
64+
65+
KiteTicker changes
66+
==================
67+
- `KiteTicker` receives param `access_token` instead of `public_token`
68+
- New params addedd to `KiteTicker` initializer
69+
- `reconnect` - Toggle auto reconnect on/off
70+
- `max_retry` - Max retry count for auto reconnect
71+
- `max_delay` - Max delay between subsequent retries
72+
- Auto reconnect is enabled by default
73+
- Renamed callback `reconnecting` to `reconnect`
74+
- Added new callbacks
75+
- `error` - when socket connection is closed with error. Error is received as a first param
76+
- `close` - when socket connection is closed cleanly
77+
- `order_update` - When order update (postback) is received for the connected user (Data object is received as first argument)
78+
79+

README.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
> **NOTICE (Jan 2018): Upgrade to Kite Connect 3.0**
2-
> This repository is being phased and will be replaced soon by Kite Connect v3. Use the [kite3](https://github.com/zerodhatech/kiteconnectjs/tree/kite3) branch instead. Read the [announcement](https://kite.trade/forum/discussion/2998/upgrade-to-kite-connect-3-0) on the forum.
3-
4-
# The Kite Connect API Javascript client
1+
# The Kite Connect API Javascript client - v3
52
The official Javascript node client for communicating with the [Kite Connect API](https://kite.trade).
63

7-
Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection
4+
Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection.
85

9-
[Rainmatter](http://rainmatter.com) (c) 2016. Licensed under the MIT License.
6+
[Zerodha Technology](http://zerodha.com) (c) 2018. Licensed under the MIT License.
107

118
## Documentation
12-
- [Javascript client documentation](https://kite.trade/docs/kiteconnectjs)
13-
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v1)
9+
- [Javascript client documentation](https://kite.trade/docs/kiteconnectjs/v3)
10+
- [Kite Connect HTTP API documentation](https://kite.trade/docs/connect/v3)
1411

1512
Installation
1613
------------
17-
This module is installed via npm:
14+
Install via npm
1815

19-
npm install --save kiteconnect
16+
npm install kiteconnect@beta
2017

2118
Getting started with API
2219
------------------------
2320
var KiteConnect = require("kiteconnect").KiteConnect;
2421

25-
var kc = new KiteConnect("your_api_key");
22+
var kc = new KiteConnect({
23+
api_key: "your_api_key"
24+
});
2625

27-
kc.requestAccessToken("request_token", "api_secret")
26+
kc.generateSession("request_token", "api_secret")
2827
.then(function(response) {
2928
init();
3029
})
3130
.catch(function(err) {
32-
console.log(err.response);
33-
})
31+
console.log(err);
32+
});
3433

3534
function init() {
3635
// Fetch equity margins.
3736
// You can have other api calls here.
38-
39-
kc.margins("equity")
37+
kc.getMargins()
4038
.then(function(response) {
4139
// You got user's margin details.
4240
}).catch(function(err) {
@@ -46,31 +44,29 @@ Getting started with API
4644

4745
API promises
4846
-------------
49-
All API calls returns a promise which you can use to call methods like `.then(...)`, `.catch(...)`, and `.finally(...)`.
47+
All API calls returns a promise which you can use to call methods like `.then(...)` and `.catch(...)`.
5048

5149
kiteConnectApiCall
5250
.then(function(v) {
5351
// On success
5452
})
5553
.catch(function(e) {
5654
// On rejected
57-
})
58-
.finally(function(e) {
59-
// On finish
6055
});
6156

62-
You can access the full list of [Bluebird Promises API](https://github.com/petkaantonov/bluebird/blob/master/API.md) here.
63-
6457
Getting started WebSocket client
6558
--------------------------------
6659
var KiteTicker = require("kiteconnect").KiteTicker;
67-
var ticker = new KiteTicker(api_key, user_id, public_token);
60+
var ticker = new KiteTicker({
61+
api_key: "api_key",
62+
access_token: "access_token"
63+
});
6864

6965
ticker.connect();
70-
ticker.on("tick", setTick);
66+
ticker.on("ticks", onTicks);
7167
ticker.on("connect", subscribe);
7268

73-
function setTick(ticks) {
69+
function onTicks(ticks) {
7470
console.log("Ticks", ticks);
7571
}
7672

@@ -82,54 +78,58 @@ Getting started WebSocket client
8278

8379
Auto re-connect WebSocket client
8480
-------------------------------
85-
```
86-
Available from version 1.2
87-
```
88-
Optionally you can enable client side auto reconnection to automatically reconnect if the connection is dropped.
81+
Optionally you can enable client side auto re-connection to automatically reconnect if the connection is dropped.
8982
It is very useful at times when client side network is unreliable and patchy.
9083

91-
All you need to do is enable auto reconnection with preferred interval and time. For example
84+
All you need to do is enable auto re-connection with preferred interval and time. For example
9285

9386
// Enable auto reconnect with 5 second interval and retry for maximum of 20 times.
9487
ticker.autoReconnect(true, 20, 5)
9588

96-
// You can also set reconnection times to -1 for inifinite reconnections
89+
// You can also set re-connection times to -1 for infinite re-connections
9790
ticker.autoReconnect(true, -1, 5)
9891

99-
- Event `reconnecting` is called when auto reconnection is triggered and event callback carries two additional params `reconnection interval set` and `current reconnection count`.
92+
- Event `reconnecting` is called when auto re-connection is triggered and event callback carries two additional params `reconnection interval set` and `current re-connection count`.
10093

101-
- Event `noreconnect` is called when number of auto reconnections exceeds the maximum reconnection count set. For example if maximum reconnection count is set as `20` then after 20th reconnection this event will be triggered. Also note that the current process is exited when this event is triggered.
94+
- Event `noreconnect` is called when number of auto re-connections exceeds the maximum re-connection count set. For example if maximum re-connection count is set as `20` then after 20th re-connection this event will be triggered. Also note that the current process is exited when this event is triggered.
10295

103-
- Event `connect` will be triggered again when reconnection succeeds.
96+
- Event `connect` will be triggered again when re-connection succeeds.
10497

10598
Here is an example demonstrating auto reconnection.
10699

107-
var KiteTicker = require("kiteconnect").KiteTicker;
108-
var ticker = new KiteTicker(api_key, user_id, public_token);
100+
var KiteTicker = require("kiteconnect").KiteTicker;
101+
var ticker = new KiteTicker({
102+
api_key: "api_key",
103+
access_token: "access_token"
104+
});
109105

110-
// set autoreconnect with 10 maximum reconnections and 5 second interval
111-
ticker.autoReconnect(true, 10, 5)
112-
ticker.connect();
113-
ticker.on("tick", setTick);
114-
ticker.on("connect", subscribe);
106+
// set autoreconnect with 10 maximum reconnections and 5 second interval
107+
ticker.autoReconnect(true, 10, 5)
108+
ticker.connect();
109+
ticker.on("ticks", onTicks);
110+
ticker.on("connect", subscribe);
115111

116-
ticker.on("noreconnect", function() {
117-
console.log("noreconnect")
118-
});
112+
ticker.on("noreconnect", function() {
113+
console.log("noreconnect");
114+
});
119115

120-
ticker.on("reconnecting", function(reconnect_interval, reconnections) {
121-
console.log("Reconnecting: attempet - ", reconnections, " innterval - ", reconnect_interval);
122-
});
116+
ticker.on("reconnecting", function(reconnect_interval, reconnections) {
117+
console.log("Reconnecting: attempt - ", reconnections, " innterval - ", reconnect_interval);
118+
});
123119

124-
function setTick(ticks) {
125-
console.log("Ticks", ticks);
126-
}
120+
function onTicks(ticks) {
121+
console.log("Ticks", ticks);
122+
}
127123

128-
function subscribe() {
129-
var items = [738561];
130-
ticker.subscribe(items);
131-
ticker.setMode(ticker.modeFull, items);
132-
}
124+
function subscribe() {
125+
var items = [738561];
126+
ticker.subscribe(items);
127+
ticker.setMode(ticker.modeFull, items);
128+
}
129+
130+
## Changelog
131+
132+
[Check CHANGELOG.md](CHANGELOG.md)
133133

134134
A typical web application
135135
-------------------------

0 commit comments

Comments
 (0)