1 | A Javascript interface for FYERS API.<br>
|
2 | 📦 [Node.js](https://www.npmjs.com/package/extra-fyers),
|
3 | 🌐 [Web](https://www.npmjs.com/package/extra-fyers.web),
|
4 | 📜 [Files](https://unpkg.com/extra-fyers/),
|
5 | 📰 [Docs](https://nodef.github.io/extra-fyers/).
|
6 |
|
7 | [FYERS] is one of the cheapest online stock brokers in India, that offers
|
8 | trading in the equity (NSE, BSE), currency (NSE), and commodity segments (MCX).
|
9 | The objective of this package is to provide a cleaner interface to [FYERS API].
|
10 | The `http` namespace provides the same interface as FYERS HTTP API. The
|
11 | `websocket` namespace provides the same interface as FYERS WebSocket API, along
|
12 | with parsing of binary market data. This allows you to recieve *instant*
|
13 | notifications of *order update* and *market data*. The top namespace (global
|
14 | functions, classes) provide a [facade] for the HTTP and the WebSocket APIs and
|
15 | provides additional utility functions, such as calculating charges.
|
16 |
|
17 | Global functions associated with FYERS API, such as `getPositions()`, are
|
18 | stateless and accept `Authorization` as the first parameter. On the other
|
19 | hand, the `Api` class includes stateful functions which do not require
|
20 | the `Authorization` parameter (required while creating object). Note that
|
21 | this authorization can be obtained be performing login with `loginStep1()`
|
22 | and `loginStep2()`.
|
23 |
|
24 | The goals for the future include doing a thorough interface check, and possibly
|
25 | writing a CLI interface. Obtaining details of symbols, including images and more
|
26 | could be done as part of a separate package.
|
27 |
|
28 | This package is available in both *Node.js* and *Web* formats. The web format
|
29 | is exposed as `extra_fyers` standalone variable and can be loaded from
|
30 | [jsDelivr CDN].
|
31 |
|
32 | > Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).
|
33 |
|
34 | [FYERS]: https://fyers.in
|
35 | [FYERS API]: https://myapi.fyers.in/docs/
|
36 | [facade]: https://en.wikipedia.org/wiki/Facade_pattern
|
37 | [jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-fyers.web/index.js
|
38 |
|
39 | <br>
|
40 |
|
41 | ```javascript
|
42 | const fyers = require('extra-fyers');
|
43 |
|
44 | async function main() {
|
45 | var appId = '****'; // app_id recieved after creating app
|
46 | var accessToken = '****'; // access_token recieved after login
|
47 | var api = new fyers.Api(appId, accessToken);
|
48 |
|
49 | // List equity and commodity fund limits.
|
50 | console.log(await api.getFunds());
|
51 |
|
52 | // List holdings.
|
53 | console.log(await api.getHoldings());
|
54 |
|
55 | // Place CNC market order for SBIN (equity) on NSE for 5 shares
|
56 | var id = await api.placeOrder({symbol: 'NSE:SBIN-EQ', quantity: 5});
|
57 |
|
58 | // List postions for today (should list NSE:SBIN-EQ-CNC).
|
59 | console.log(await api.getPositions());
|
60 |
|
61 |
|
62 | // Connect to Market data with WebSocket
|
63 | // and recieve real-time market quotes.
|
64 | await api.connectMarketData(quote => {
|
65 | console.log(quote);
|
66 | });
|
67 | // Choose which symbols you want to subscribe to.
|
68 | await api.subscribeMarketDepth(['NSE:SBIN-EQ']);
|
69 |
|
70 | // Connect to Order update with WebSocket
|
71 | // and recieve real-time order status updates.
|
72 | await api.connectOrderUpdate(order => {
|
73 | console.log(order);
|
74 | });
|
75 | // Subscribe to order status updates.
|
76 | await api.subscribeOrderUpdate();
|
77 | }
|
78 | main();
|
79 | ```
|
80 |
|
81 | <br>
|
82 | <br>
|
83 |
|
84 |
|
85 | ## Index
|
86 |
|
87 | | Property | Description |
|
88 | | ---- | ---- |
|
89 | | [exchangeDescription] | Get exchange description. |
|
90 | | [exchange] | Get exchange code. |
|
91 | | [segmentDescription] | Get segment description. |
|
92 | | [segment] | Get segment code. |
|
93 | | [positionSideDescription] | Get position side description. |
|
94 | | [positionSide] | Get position side code. |
|
95 | | [orderSideDescription] | Get order side description. |
|
96 | | [orderSide] | Get order side code. |
|
97 | | [orderSourceDescription] | Get order source description. |
|
98 | | [orderSource] | Get order source code. |
|
99 | | [orderStatusDescription] | Get order status description. |
|
100 | | [orderStatus] | Get order status code. |
|
101 | | [orderTypeDescription] | Get order type description. |
|
102 | | [orderType] | Get order type code. |
|
103 | | [orderValidityDescription] | Get order validity description. |
|
104 | | [orderValidity] | Get order validity code. |
|
105 | | [optionTypeDescription] | Get option type description. |
|
106 | | [optionType] | Get option type code. |
|
107 | | [derivativeTypeDescription] | Get derivative type description. |
|
108 | | [derivativeType] | Get derivative type code. |
|
109 | | [holdingTypeDescription] | Get holding type description. |
|
110 | | [holdingType] | Get holding type code. |
|
111 | | [productTypeDescription] | Get product type description. |
|
112 | | [productType] | Get product type code. |
|
113 | | [instrumentTypeDescription] | Get instrument type description. |
|
114 | | [instrumentType] | Get instrument type code. |
|
115 | | | |
|
116 | | [symbolName] | Get symbol exchange, underlying, currency-pair, or commodity name. |
|
117 | | [symbolExchange] | Get symbol exchange. |
|
118 | | [symbolSeries] | Get symbol exchange series. |
|
119 | | [symbolOptionType] | Get symbol option type. |
|
120 | | [symbolDerivativeType] | Get symbol derivative type. |
|
121 | | [symbolStrikePrice] | Get symbol strike price. |
|
122 | | [symbolToken] | Get symbol token, a unique identifier. |
|
123 | | [symbolDescription] | Get symbol description. |
|
124 | | [symbolIsin] | Get symbol ISIN. |
|
125 | | [symbolLotSize] | Get symbol minimum lot size. |
|
126 | | | |
|
127 | | [equityDeliveryCharges] | Get equity delivery charges. |
|
128 | | [equityIntradayCharges] | Get equity intraday charges. |
|
129 | | [equityFuturesCharges] | Get equity futures charges. |
|
130 | | [equityOptionsCharges] | Get equity options charges. |
|
131 | | [currencyFuturesCharges] | Get currency futures charges. |
|
132 | | [currencyOptionsCharges] | Get currency options charges. |
|
133 | | [commodityFuturesCharges] | Get commodity futures charges. |
|
134 | | [commodityOptionsCharges] | Get commodity options charges. |
|
135 | | | |
|
136 | | [loginStep1] | Get request step 1 for authorization. |
|
137 | | [loginStep2] | Get request step 2 for authorization. |
|
138 | | | |
|
139 | | [getProfile] | Get basic details of the client. |
|
140 | | [getFunds] | Get balance available for the user for capital as well as the commodity market. |
|
141 | | [getHoldings] | Get the equity and mutual fund holdings which the user has in this demat account. |
|
142 | | | |
|
143 | | [getOrder] | Get details of an order placed in the current trading day. |
|
144 | | [getOrders] | Get details of all the orders placed in the current trading day. |
|
145 | | [getPositions] | Get details of all the positions in the current trading day. |
|
146 | | [getTrades] | Get details of all the trades in the current trading day. |
|
147 | | [placeOrder] | Place an order to any exchange via Fyers. |
|
148 | | [placeOrders] | Place multiple orders to any exchange via Fyers. |
|
149 | | [modifyOrder] | Modifies an order placed on any exchange via Fyers. |
|
150 | | [modifyOrders] | Modifies orders placed on any exchange via Fyers. |
|
151 | | [cancelOrder] | Cancels an order placed on any exchange via Fyers. |
|
152 | | [cancelOrders] | Cancels orders placed on any exchange via Fyers. |
|
153 | | [exitPosition] | Exits a position on the current trading day. |
|
154 | | [exitAllPositions] | Exits all positions on the current trading day. |
|
155 | | [convertPosition] | Converts a position on the current trading day. |
|
156 | | | |
|
157 | | [getMarketStatus] | Get the current market status of all the exchanges and their segments. |
|
158 | | [getMarketHistory] | Get the market history for a particular symbol. |
|
159 | | [getMarketQuotes] | Get the current market quotes for a set of symbols. |
|
160 | | [getMarketDepth] | Get the current market depth for a particular symbol. |
|
161 | | | |
|
162 | | [getSymbolMaster] | Get all the latest symbols of all the exchanges from the symbol master files. |
|
163 | | [processSymbolMaster] | Get details of symbols from the symbol master file text. |
|
164 | | [loadSymbolMaster] | Get details of symbols from the symbol master files. |
|
165 | | | |
|
166 | | [generateEdisTpin] | Generate e-DIS TPIN for validating/authorising transaction. |
|
167 | | [getEdisTransactions] | Get the necessary information regarding the holdings you have on your and also the status of the holdings. |
|
168 | | [submitEdisHoldingsStep] | Redirect to CDSL page for login where you can submit your Holdings information and accordingly you can provide the same to exchange to Sell your holdings (browser only). |
|
169 | | [inquireEdisTransaction] | Inquire the information/status of the provided transaction Id for the respective holdings you have on your end. |
|
170 | | | |
|
171 | | [connectMarketData] | Connect to Market data URL with WebSocket. |
|
172 | | [subscribeMarketQuote] | Subscribe to market quote. |
|
173 | | [subscribeMarketDepth] | Subscribe to market depth. |
|
174 | | [unsubscribeMarketQuote] | Unsubscribe to market quote. |
|
175 | | [unsubscribeMarketDepth] | Unsubscribe to market depth. |
|
176 | | [connectOrderUpdate] | Connect to Order update URL with WebSocket. |
|
177 | | [subscribeOrderUpdate] | Subscribe to order update. |
|
178 | | [unsubscribeOrderUpdate] | Unsubscribe to order update. |
|
179 | | | |
|
180 | | [Api] | Stateful interface for FYERS API. |
|
181 |
|
182 | <br>
|
183 | <br>
|
184 |
|
185 |
|
186 | ## References
|
187 |
|
188 | - [FYERS API Docs](https://myapi.fyers.in/docs/)
|
189 | - [FYERS Community](https://community.fyers.in/)
|
190 | - [FYERS Detailed Charges List](https://fyers.in/charges-list/)
|
191 | - [fyers-api-v2 package](https://www.npmjs.com/package/fyers-api-v2)
|
192 | - [C# wrapper of Fyers API v2 : ArthaChitra](https://github.com/arthachitra/FyersAPI)
|
193 | - [Fyers API golang client : Rishi Anand](https://github.com/rishi-anand/fyers-go-client)
|
194 | - [The Kite Connect API Javascript client - v4](https://kite.trade/docs/kiteconnectjs/v3/index.html)
|
195 | - [Intermarket Trading System (ITS)](https://www.investopedia.com/terms/i/intermarket-trading-system.asp)
|
196 | - [What are stop loss orders and how to use them?](https://support.zerodha.com/category/trading-and-markets/margin-leverage-and-product-and-order-types/articles/what-are-stop-loss-orders-and-how-to-use-them)
|
197 | - [How to use Stoploss-limit(SL) order like a Stoploss-Market(SLM) order?](https://support.zerodha.com/category/trading-and-markets/margin-leverage-and-product-and-order-types/articles/how-to-use-sl-l-order-like-a-sl-m-order)
|
198 | - [What is disclosed quantity feature and how to use it?](https://support.zerodha.com/category/trading-and-markets/kite-web-and-mobile/articles/what-is-disclosed-quantity-feature-and-how-to-use-it)
|
199 | - [What are cover orders and how to use them?](https://support.zerodha.com/category/trading-and-markets/product-and-order-types/order/articles/what-are-cover-orders-and-how-to-use-them)
|
200 | - [What does CNC, MIS and NRML mean?](https://support.zerodha.com/category/trading-and-markets/margin-leverage-and-product-and-order-types/articles/what-does-cnc-mis-and-nrml-mean)
|
201 | - [What is UNDCUR,UNDIRC, UNDIRT, UNDIRT in CDs? And what its use](https://tradingqna.com/t/what-is-undcur-undirc-undirt-undirt-in-cds-and-what-its-use/756)
|
202 | - [Can some one tell me what is FUTIRC?](https://tradingqna.com/t/can-some-one-tell-me-what-is-futirc/34069)
|
203 | - [I want to know in nifty f & o what is futidx, futivx, futstk?](https://tradingqna.com/t/i-want-to-know-in-nifty-f-o-what-is-futidx-futivx-futstk/2367)
|
204 | - [What Is a Rally?](https://www.investopedia.com/terms/r/rally.asp)
|
205 |
|
206 | <br>
|
207 | <br>
|
208 |
|
209 | [](https://www.youtube.com/watch?v=AGCC-_Cuhhw)
|
210 | [](https://nodef.github.io)
|
211 | [](https://zenodo.org/badge/latestdoi/459926913)
|
212 |
|
213 |
|
214 | [exchangeDescription]: https://nodef.github.io/extra-fyers/functions/exchangeDescription.html
|
215 | [exchange]: https://nodef.github.io/extra-fyers/functions/exchange.html
|
216 | [segmentDescription]: https://nodef.github.io/extra-fyers/functions/segmentDescription.html
|
217 | [segment]: https://nodef.github.io/extra-fyers/functions/segment.html
|
218 | [positionSideDescription]: https://nodef.github.io/extra-fyers/functions/positionSideDescription.html
|
219 | [positionSide]: https://nodef.github.io/extra-fyers/functions/positionSide.html
|
220 | [orderSideDescription]: https://nodef.github.io/extra-fyers/functions/orderSideDescription.html
|
221 | [orderSide]: https://nodef.github.io/extra-fyers/functions/orderSide.html
|
222 | [orderSourceDescription]: https://nodef.github.io/extra-fyers/functions/orderSourceDescription.html
|
223 | [orderSource]: https://nodef.github.io/extra-fyers/functions/orderSource.html
|
224 | [orderStatusDescription]: https://nodef.github.io/extra-fyers/functions/orderStatusDescription.html
|
225 | [orderStatus]: https://nodef.github.io/extra-fyers/functions/orderStatus.html
|
226 | [orderTypeDescription]: https://nodef.github.io/extra-fyers/functions/orderTypeDescription.html
|
227 | [orderType]: https://nodef.github.io/extra-fyers/functions/orderType.html
|
228 | [orderValidityDescription]: https://nodef.github.io/extra-fyers/functions/orderValidityDescription.html
|
229 | [orderValidity]: https://nodef.github.io/extra-fyers/functions/orderValidity.html
|
230 | [optionTypeDescription]: https://nodef.github.io/extra-fyers/functions/optionTypeDescription.html
|
231 | [optionType]: https://nodef.github.io/extra-fyers/functions/optionType.html
|
232 | [derivativeTypeDescription]: https://nodef.github.io/extra-fyers/functions/derivativeTypeDescription.html
|
233 | [derivativeType]: https://nodef.github.io/extra-fyers/functions/derivativeType.html
|
234 | [holdingTypeDescription]: https://nodef.github.io/extra-fyers/functions/holdingTypeDescription.html
|
235 | [holdingType]: https://nodef.github.io/extra-fyers/functions/holdingType.html
|
236 | [productTypeDescription]: https://nodef.github.io/extra-fyers/functions/productTypeDescription.html
|
237 | [productType]: https://nodef.github.io/extra-fyers/functions/productType.html
|
238 | [instrumentTypeDescription]: https://nodef.github.io/extra-fyers/functions/instrumentTypeDescription.html
|
239 | [instrumentType]: https://nodef.github.io/extra-fyers/functions/instrumentType.html
|
240 | [symbolName]: https://nodef.github.io/extra-fyers/functions/symbolName.html
|
241 | [symbolExchange]: https://nodef.github.io/extra-fyers/functions/symbolExchange.html
|
242 | [symbolSeries]: https://nodef.github.io/extra-fyers/functions/symbolSeries.html
|
243 | [symbolOptionType]: https://nodef.github.io/extra-fyers/functions/symbolOptionType.html
|
244 | [symbolDerivativeType]: https://nodef.github.io/extra-fyers/functions/symbolDerivativeType.html
|
245 | [symbolStrikePrice]: https://nodef.github.io/extra-fyers/functions/symbolStrikePrice.html
|
246 | [symbolToken]: https://nodef.github.io/extra-fyers/functions/symbolToken.html
|
247 | [symbolDescription]: https://nodef.github.io/extra-fyers/functions/symbolDescription.html
|
248 | [symbolIsin]: https://nodef.github.io/extra-fyers/functions/symbolIsin.html
|
249 | [symbolLotSize]: https://nodef.github.io/extra-fyers/functions/symbolLotSize.html
|
250 | [equityDeliveryCharges]: https://nodef.github.io/extra-fyers/functions/equityDeliveryCharges.html
|
251 | [equityIntradayCharges]: https://nodef.github.io/extra-fyers/functions/equityIntradayCharges.html
|
252 | [equityFuturesCharges]: https://nodef.github.io/extra-fyers/functions/equityFuturesCharges.html
|
253 | [equityOptionsCharges]: https://nodef.github.io/extra-fyers/functions/equityOptionsCharges.html
|
254 | [currencyFuturesCharges]: https://nodef.github.io/extra-fyers/functions/currencyFuturesCharges.html
|
255 | [currencyOptionsCharges]: https://nodef.github.io/extra-fyers/functions/currencyOptionsCharges.html
|
256 | [commodityFuturesCharges]: https://nodef.github.io/extra-fyers/functions/commodityFuturesCharges.html
|
257 | [commodityOptionsCharges]: https://nodef.github.io/extra-fyers/functions/commodityOptionsCharges.html
|
258 | [loginStep1]: https://nodef.github.io/extra-fyers/functions/loginStep1.html
|
259 | [loginStep2]: https://nodef.github.io/extra-fyers/functions/loginStep2.html
|
260 | [getProfile]: https://nodef.github.io/extra-fyers/functions/getProfile.html
|
261 | [getFunds]: https://nodef.github.io/extra-fyers/functions/getFunds.html
|
262 | [getHoldings]: https://nodef.github.io/extra-fyers/functions/getHoldings.html
|
263 | [getOrder]: https://nodef.github.io/extra-fyers/functions/getOrder.html
|
264 | [getOrders]: https://nodef.github.io/extra-fyers/functions/getOrders.html
|
265 | [getPositions]: https://nodef.github.io/extra-fyers/functions/getPositions.html
|
266 | [getTrades]: https://nodef.github.io/extra-fyers/functions/getTrades.html
|
267 | [placeOrder]: https://nodef.github.io/extra-fyers/functions/placeOrder.html
|
268 | [placeOrders]: https://nodef.github.io/extra-fyers/functions/placeOrders.html
|
269 | [modifyOrder]: https://nodef.github.io/extra-fyers/functions/modifyOrder.html
|
270 | [modifyOrders]: https://nodef.github.io/extra-fyers/functions/modifyOrders.html
|
271 | [cancelOrder]: https://nodef.github.io/extra-fyers/functions/cancelOrder.html
|
272 | [cancelOrders]: https://nodef.github.io/extra-fyers/functions/cancelOrders.html
|
273 | [exitPosition]: https://nodef.github.io/extra-fyers/functions/exitPosition.html
|
274 | [exitAllPositions]: https://nodef.github.io/extra-fyers/functions/exitAllPositions.html
|
275 | [convertPosition]: https://nodef.github.io/extra-fyers/functions/convertPosition.html
|
276 | [getMarketStatus]: https://nodef.github.io/extra-fyers/functions/getMarketStatus.html
|
277 | [getMarketHistory]: https://nodef.github.io/extra-fyers/functions/getMarketHistory.html
|
278 | [getMarketQuotes]: https://nodef.github.io/extra-fyers/functions/getMarketQuotes.html
|
279 | [getMarketDepth]: https://nodef.github.io/extra-fyers/functions/getMarketDepth.html
|
280 | [getSymbolMaster]: https://nodef.github.io/extra-fyers/functions/getSymbolMaster.html
|
281 | [processSymbolMaster]: https://nodef.github.io/extra-fyers/functions/processSymbolMaster.html
|
282 | [loadSymbolMaster]: https://nodef.github.io/extra-fyers/functions/loadSymbolMaster.html
|
283 | [generateEdisTpin]: https://nodef.github.io/extra-fyers/functions/generateEdisTpin.html
|
284 | [getEdisTransactions]: https://nodef.github.io/extra-fyers/functions/getEdisTransactions.html
|
285 | [submitEdisHoldingsStep]: https://nodef.github.io/extra-fyers/functions/submitEdisHoldingsStep.html
|
286 | [inquireEdisTransaction]: https://nodef.github.io/extra-fyers/functions/inquireEdisTransaction.html
|
287 | [connectMarketData]: https://nodef.github.io/extra-fyers/functions/connectMarketData.html
|
288 | [subscribeMarketQuote]: https://nodef.github.io/extra-fyers/functions/subscribeMarketQuote.html
|
289 | [subscribeMarketDepth]: https://nodef.github.io/extra-fyers/functions/subscribeMarketDepth.html
|
290 | [unsubscribeMarketQuote]: https://nodef.github.io/extra-fyers/functions/unsubscribeMarketQuote.html
|
291 | [unsubscribeMarketDepth]: https://nodef.github.io/extra-fyers/functions/unsubscribeMarketDepth.html
|
292 | [connectOrderUpdate]: https://nodef.github.io/extra-fyers/functions/connectOrderUpdate.html
|
293 | [subscribeOrderUpdate]: https://nodef.github.io/extra-fyers/functions/subscribeOrderUpdate.html
|
294 | [unsubscribeOrderUpdate]: https://nodef.github.io/extra-fyers/functions/unsubscribeOrderUpdate.html
|
295 | [Api]: https://nodef.github.io/extra-fyers/classes/Api.html
|