UNPKG

106 kBTypeScriptView Raw
1/// <reference types="ws" />
2import { WebSocket } from 'ws';
3
4/** HTTP(s) header keys and values. */
5interface HttpHeaders {
6 [key: string]: string;
7}
8/** HTTP(s) request options. */
9interface HttpRequestOptions {
10 /** Full URL, inluding protocol and query. */
11 url: string;
12 /** HTTP(s) method (GET). */
13 method?: string;
14 /** Body of request (JSON). */
15 body?: object | null;
16 /** Request headers. */
17 headers?: HttpHeaders;
18 /** What if we don't get a response? */
19 timeout?: number;
20}
21
22/** Root URL for API requests. */
23declare const API_URL: string;
24/** Root URL for Data API requests. */
25declare const DATA_URL: string;
26/** Root URL for Symbol master files. */
27declare const SYMBOLS_URL: string;
28/** Common response format. */
29interface Response {
30 /** ok / error. */
31 s: string;
32 /** This is the code to identify specific responses. */
33 code?: number;
34 /** This is the message to identify the specific error responses. */
35 message?: string;
36}
37/** HTTP data of multi-response. */
38interface ProxyResponse<Body> {
39 /** HTTP status code. */
40 statusCode: number;
41 /** The actual place order reponse. */
42 body: Body;
43 /** HTTP status description. */
44 statusDescription: string;
45}
46/** Attributes required for authorization of all requests. */
47interface Authorization$1 {
48 /** This is the app_id which you have received after creating the app. */
49 app_id: string;
50 /** This value will be used for all the requests. */
51 access_token: string;
52}
53/** Login step 1 request. */
54interface LoginStep1Request$1 {
55 /** This is the app_id which you have received after creating the app. */
56 client_id: string;
57 /** This is where the user will be redirected after successful login. */
58 redirect_uri: string;
59 /** This value must always be “code”. */
60 response_type: string;
61 /** The same value will be returned after successful login to the redirect uri. */
62 state: string;
63}
64/** Login step 1 response. */
65interface LoginStep1Response$1 extends Response {
66 /** String value which will be used to generate the access_token. */
67 auth_code: string;
68 /** This value is returned as is from the first request. */
69 state: string;
70}
71/** Login step 2 request. */
72interface LoginStep2Request$1 {
73 /** This value must always be “authorization_code”. */
74 grant_type: string;
75 /** SHA-256 of `api_id:app_secret` in hex. */
76 appIdHash: string;
77 /** This is the auth_code which is received from the first step. */
78 code: string;
79}
80/** Login step 2 response. */
81interface LoginStep2Response$1 extends Response {
82 /** This value will be used for all the subsequent requests. */
83 access_token: string;
84}
85/** Basic details of the client. */
86interface Profile$1 {
87 /** The client id of the fyers user. */
88 fy_id: string;
89 /** Email address of the client. */
90 email_id: string;
91 /** Name of the client. */
92 name: string;
93 /** Display name, if any, provided by the client. */
94 display_name: string;
95 /** URL link to the user’s profile picture, if any. */
96 image: string;
97 /** PAN of the client. */
98 PAN: string;
99 /** Last PIN changed date. */
100 pin_change_date: string;
101 /** Last password changed date. */
102 pwd_change_date: string;
103 /** Number of days until the current password expires. */
104 pwd_to_expire: number;
105}
106/** Get profile response. */
107interface GetProfileResponse extends Response {
108 /** Basic details of the client. */
109 data: Profile$1;
110}
111/** Limit details for particular fund. */
112interface FundLimit {
113 /** Unique identity for particular fund. */
114 id: number;
115 /** Each title represents a heading of the ledger. */
116 title: string;
117 /** The amount in the capital ledger for the above-mentioned title. */
118 equityAmount: number;
119 /** The amount in the commodity ledger for the above-mentioned title. */
120 commodityAmount: number;
121}
122/** Get funds response. */
123interface GetFundsResponse extends Response {
124 /** Balance available for the user for capital as well as the commodity market. */
125 fund_limit: FundLimit[];
126}
127/** Details of each equity or mutual fund holding. */
128interface Holding$1 {
129 /** An identifier for this holding. */
130 id: number;
131 /** Fytoken is a unique identifier for every symbol. */
132 fytoken: string;
133 /** 12-digit International Securities Identification Number. */
134 isin: string;
135 /** Eg: NSE:RCOM-EQ. */
136 symbol: string;
137 /** The exchange in which order is placed. */
138 exchange: number;
139 /** Identify the type of holding. */
140 holdingType: string;
141 /** The quantity of the symbol which the user has at the beginning of the day. */
142 quantity: number;
143 /** This reflects the quantity - the quantity sold during the day. */
144 remainingQuantity: number;
145 /** The original buy price of the holding. */
146 costPrice: number;
147 /** The Market value of the current holding. */
148 marketVal: number;
149 /** LTP is the price from which the next sale of the stocks happens. */
150 ltp: number;
151 /** Profit and loss made. */
152 pl: number;
153}
154/** Overall status of equity and mutual fund holdings in this demat account. */
155interface HoldingsOverall$1 {
156 /** Total number of holdings present. */
157 count_total: number;
158 /** Invested amount for the current holdings. */
159 total_investment: number;
160 /** The present value of the holdings. */
161 total_current_value: number;
162 /** Total profit and loss made. */
163 total_pl: number;
164 /** Percentage value of the total pnl. */
165 pnl_perc: number;
166}
167/** Equity and mutual fund holdings which the user has in this demat account. */
168interface GetHoldingsResponse extends Response {
169 /** Details of each holding. */
170 holdings: Holding$1[];
171 /** Overall status of holdings in this demat account. */
172 overall: HoldingsOverall$1;
173}
174/** Order placed by the user in the current trading day. */
175interface Order$1 {
176 /** The unique order id assigned for each order. */
177 id: string;
178 /** The order id provided by the exchange. */
179 exchOrdId: string;
180 /** The symbol for which order is placed. */
181 symbol: string;
182 /** Fytoken is a unique identifier for every symbol. */
183 fytoken: string;
184 /** Short name for the symbol Eg: “SBIN-EQ”. */
185 ex_sym: string;
186 /** Description of symbol for which order is placed. */
187 description: string;
188 /** The segment this order is placed in. */
189 segment: number;
190 /** Exchange instrument type. */
191 instrument: number;
192 /** The exchange in which order is placed. */
193 exchange: number;
194 /** The type of order. */
195 type: number;
196 /** The order is buy or sell. */
197 side: number;
198 /** The product type. */
199 productType: string;
200 /** Source from where the order was placed. */
201 source: string;
202 /** The status of the order. */
203 status: number;
204 /** The order number and status of the order. */
205 orderNumStatus: number;
206 /** True when placing AMO order. */
207 offlineOrder: string;
208 /** The original order qty. */
209 qty: number;
210 /** The remaining qty. */
211 remainingQuantity: number;
212 /** The filled qty after partial trades. */
213 filledQty: number;
214 /** The limit price for the order. */
215 limitPrice: number;
216 /** The stop price for the order. */
217 stopPrice: number;
218 /** Disclosed quantity. */
219 discloseQty: number;
220 /** Remaining disclosed quantity. */
221 dqQtyRem: number;
222 /** Day or IOC. */
223 orderValidity: string;
224 /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */
225 orderDateTime: string;
226 /** The parent order id will be provided only for applicable orders. */
227 parentId?: string;
228 /** Price change from previous trading day. */
229 ch: number;
230 /** Percent price change from previous trading day. */
231 chp: number;
232 /** Last price of symbol. */
233 lp: number;
234 /** The average traded price for the order. */
235 tradedPrice: number;
236 /** This is used to sort the orders based on the time. */
237 slNo: number;
238 /** The error messages are shown here. */
239 message: string;
240 /** PAN of the client. */
241 pan: string;
242 /** The client id of the fyers user. */
243 clientId: string;
244}
245/** Get order request. */
246interface GetOrderRequest {
247 /** The unique order id assigned for each order. */
248 id: string;
249}
250/** Get orders response. */
251interface GetOrdersResponse extends Response {
252 /** List of all orders places during the day. */
253 orderBook: Order$1[];
254}
255/** Current open/closed position for the current trading day. */
256interface Position$1 {
257 /** The unique value for each position. */
258 id: string;
259 /** Fytoken is a unique identifier for every symbol. */
260 fytoken: string;
261 /** Eg: NSE:SBIN-EQ. */
262 symbol: string;
263 /** The segment in which the position is taken. */
264 segment: number;
265 /** The product type of the position. */
266 productType: string;
267 /** The side shows whether the position is long / short. */
268 side: number;
269 /** Absolute value of net qty. */
270 qty: number;
271 /** Incase of commodity positions, this multiplier is required for p&l calculation. */
272 qtyMulti_com: number;
273 /** Average buy price. */
274 buyAvg: number;
275 /** Total buy qty. */
276 buyQty: number;
277 /** Total buy value. */
278 buyVal: number;
279 /** Average sell price. */
280 sellAvg: number;
281 /** Total sell qty. */
282 sellQty: number;
283 /** Total sell value. */
284 sellVal: number;
285 /** Net average price. */
286 netAvg: number;
287 /** Net qty. */
288 netQty: number;
289 /** Average price (netAvg). */
290 avgPrice: number;
291 /** The total p&l of the position. */
292 pl: number;
293 /** The realized p&l of the position. */
294 realized_profit: number;
295 /** The unrealized p&l of the open position. */
296 unrealized_profit: number;
297 /** Is it a cross currency position? */
298 crossCurrency: string;
299 /** Incase of cross currency position, the rbi reference rate will be required to calculate the p&l. */
300 rbiRefRate: number;
301 /** LTP is the price from which the next sale of the stocks happens. */
302 ltp: number;
303 /** This is used for sorting of positions. */
304 slNo: number;
305}
306/** Overall status of positions for the current trading day. */
307interface PositionsOverall$1 {
308 /** Total number of positions present. */
309 count_total: number;
310 /** Total number of positions opened. */
311 count_open: number;
312 /** Total profit and losses. */
313 pl_total: number;
314 /** Profit and losses when the owned product is sold. */
315 pl_realized: number;
316 /** Profit and loses when the product is owned, but is not sold. */
317 pl_unrealized: number;
318}
319/** Get postions response. */
320interface GetPositionsResponse extends Response {
321 /** List of all positions for the current trading day. */
322 netPositions: Position$1[];
323 /** Overall status of positions for the current trading day. */
324 overall: PositionsOverall$1;
325}
326/** Trade in the current trading day. */
327interface Trade$1 {
328 /** The unique id to sort the trades. */
329 id: string;
330 /** The order id for which the trade occurred. */
331 orderNumber: string;
332 /** The order number provided by the exchange. */
333 exchangeOrderNo: string;
334 /** The trade number generated by the exchange. */
335 tradeNumber: string;
336 /** Fytoken is a unique identifier for every symbol. */
337 fyToken: string;
338 /** Eg: NSE:SBIN-EQ. */
339 symbol: string;
340 /** The segment in which order is placed. */
341 segment: number;
342 /** The exchange in which order is placed. */
343 exchange: number;
344 /** The trade is buy or sell. */
345 transactionType: number;
346 /** The product in which the order was placed. */
347 productType: string;
348 /** The type of order. */
349 orderType: number;
350 /** The time when the trade occured in “DD-MM-YYYY hh:mm:ss” format in IST. */
351 orderDateTime: string;
352 /** The traded price. */
353 tradePrice: number;
354 /** The total traded qty. */
355 tradedQty: number;
356 /** The total traded value. */
357 tradeValue: number;
358 /** Client id. */
359 clientId: string;
360 /** ? */
361 row: number;
362}
363/** Get trades response. */
364interface GetTradesResponse extends Response {
365 /** List of all trades for the current trading day. */
366 tradeBook: Trade$1[];
367}
368/** Place order request to an exchange via Fyers. */
369interface PlaceOrderRequest {
370 /** Eg: NSE:SBIN-EQ. */
371 symbol: string;
372 /** The quantity should be in multiples of lot size for derivatives. */
373 qty: number;
374 /** The type of order. */
375 type: number;
376 /** The order is buy or sell. */
377 side: number;
378 /** The product in which the order was placed. */
379 productType: string;
380 /** Provide valid price for Limit and Stoplimit orders. */
381 limitPrice?: number;
382 /** Provide valid price for Stop and Stoplimit orders. */
383 stopPrice?: number;
384 /** Allowed only for Equity. */
385 disclosedQty?: number;
386 /** Day or IOC. */
387 validity: string;
388 /** True when placing AMO order. */
389 offlineOrder: string;
390 /** Provide valid price for CO and BO orders. */
391 stopLoss?: number;
392 /** Provide valid price for BO orders. */
393 takeProfit?: number;
394}
395/** Place/modify/cancel order reponse. */
396interface OrderResponse extends Response {
397 /** The order number of the placed/modified/cancelled order. */
398 id: string;
399}
400/** Place order reponse. */
401declare type PlaceOrderResponse = OrderResponse;
402/** Place orders response. */
403interface PlaceOrdersResponse extends Response {
404 /** List of HTTP data for each order. */
405 data: ProxyResponse<PlaceOrderResponse>[];
406}
407/** Modify order request to Fyers. */
408interface ModifyOrderRequest {
409 /** The unique order id assigned for each order. */
410 id: string;
411 /** The type of order. */
412 type: number;
413 /** The original order qty. */
414 qty?: number;
415 /** Disclosed quantity. */
416 disclosedQty?: number;
417 /** The limit price for the order. */
418 limitPrice?: number;
419 /** The stop price for the order. */
420 stopPrice?: number;
421}
422/** Modify order response. */
423declare type ModifyOrderResponse = OrderResponse;
424/** Modify orders response. */
425interface ModifyOrdersResponse extends Response {
426 /** List of HTTP data for each order. */
427 data: ProxyResponse<ModifyOrderResponse>[];
428}
429/** Cancel order request to any exchange via Fyers. */
430interface CancelOrderRequest {
431 /** The order number of the placed order. */
432 id: string;
433}
434/** Cancel order response. */
435declare type CancelOrderResponse = OrderResponse;
436/** Cancel orders response. */
437interface CancelOrdersResponse extends Response {
438 /** List of HTTP data for each order. */
439 data: ProxyResponse<CancelOrderResponse>[];
440}
441/** Exit position request to Fyers. */
442interface ExitPositionRequest {
443 /** Mandatory. Eg: NSE:FCONSUMER-EQ-INTRADAY. */
444 id: string;
445}
446/** Exit all positions response. */
447interface ExitAllPositionsResponse extends Response {
448}
449/** Exit position response. */
450interface ExitPositionResponse extends Response {
451}
452/** Convert position request to Fyers. */
453interface ConvertPositionRequest {
454 /** Mandatory. Eg: 119031547242. */
455 symbol: string;
456 /** The side shows whether the position is long / short. */
457 positionSide: number;
458 /** Quantity to be converted. Has to be in multiples of lot size for derivatives. */
459 convertQty: number;
460 /** Existing productType (CNC positions cannot be converted). */
461 convertFrom: string;
462 /** The new product type. */
463 convertTo: string;
464}
465/** Convert position response. */
466interface ConvertPositionResponse extends Response {
467 /** Unknown. */
468 positionDetails?: number;
469}
470/** Current market status of an exchange's segment. */
471interface MarketStatus$1 {
472 /** The exchange in which the position is taken. */
473 exchange: number;
474 /** The segment in which the position is taken. */
475 segment: number;
476 /** The type of market: NL, MS, ES, ... */
477 market_type: string;
478 /** Market status: OPEN, CLOSE. */
479 status: string;
480}
481/** Market status response for all the exchanges and their segments. */
482interface GetMarketStatusResponse extends Response {
483 /** List of statuses of various markets. */
484 marketStatus: MarketStatus$1[];
485}
486/** Market history request for a symbol. */
487interface GetMarketHistoryRequest {
488 /** Eg: NSE:RCOM-EQ. */
489 symbol: string;
490 /** The candle resolution in minutes. */
491 resolution: string;
492 /** 0 to enter the epoch value. 1 to enter the date format as yyyy-mm-dd. */
493 date_format: number;
494 /** Indicating the start date of records (epoch, yyyy-mm-dd). */
495 range_from: string;
496 /** Indicating the end date of records. */
497 range_to: string;
498 /** Set cont flag 1 for continues data and future options. */
499 cont_flag: string;
500}
501/** Short candle used with market history [time, open, high, low, close, volume]. */
502declare type ShortCandle = [number, number, number, number, number, number];
503/** Market history of a particular stock response. */
504interface GetMarketHistoryResponse extends Response {
505 /** List of short candles. */
506 candles: ShortCandle[];
507}
508/** Market quotes request for one or more symbols. */
509interface GetMarketQuotesRequest {
510 /** Eg: NSE:RCOM-EQ, ... */
511 symbols: string;
512}
513/** Candle in market quotes (1 minute). */
514interface Candle$1 {
515 /** UNIX expoch time. */
516 t: number;
517 /** Open price (1 minute). */
518 o: number;
519 /** High price (1 minute). */
520 h: number;
521 /** Low price (1 minute). */
522 l: number;
523 /** Close price (1 minute). */
524 c: number;
525 /** Volume (1 minute). */
526 v: number;
527 /** Time, formatted. */
528 tf: string;
529}
530/** Quote details of a particular symbol. */
531interface MarketQuoteDetails {
532 /** Change value. */
533 ch: number;
534 /** Percentage of change between the current value and the previous day's market close. */
535 chp: number;
536 /** Last traded price. */
537 lp: number;
538 /** Difference between lowest asking and highest bidding price. */
539 spread: number;
540 /** Asking price for the symbol. */
541 ask: number;
542 /** Bidding price for the symbol. */
543 bid: number;
544 /** Price at market opening time. */
545 open_price: number;
546 /** Highest price for the day. */
547 high_price: number;
548 /** Lowest price for the day. */
549 low_price: number;
550 /** Close price of the previous trading day. */
551 prev_close_price: number;
552 /** Volume traded. */
553 volume: number;
554 /** Short name for the symbol Eg: “SBIN-EQ”. */
555 short_name: string;
556 /** Name of the exchange. Eg: “NSE” or “BSE”. */
557 exchange: string;
558 /** Description of the symbol. */
559 description: string;
560 /** Original name of the symbol name provided by the use. */
561 original_name: string;
562 /** Symbol name provided by the user. */
563 symbol: string;
564 /** Fytoken is a unique identifier for every symbol. */
565 fyToken: string;
566 /** Today’s time. */
567 tt: number;
568 /** Current time, open, high, low price and volume with HH:MM timestamp. */
569 cmd: Candle$1;
570}
571/** Market quote for a particular symbol. */
572interface MarketQuote$1 {
573 /** Name of symbol. */
574 n: string;
575 /** Status (ok). */
576 s: string;
577 /** Market quote details. */
578 v: MarketQuoteDetails;
579}
580/** Market quotes response. */
581interface GetMarketQuotesResponse extends Response {
582 /** List of all market quotes. */
583 d: MarketQuote$1[];
584}
585/** Market depth details request. */
586interface GetMarketDepthRequest {
587 /** Eg: NSE:RCOM-EQ. */
588 symbol: string;
589 /** Set the ohlcv_flag to 1 to get open, high, low, closing and volume quantity. */
590 ohlcv_flag: number;
591}
592/** Open buy/sell orders at a particular price. */
593interface MarketOffer$1 {
594 /** Bid/ask price. */
595 price: number;
596 /** Bid/ask volume. */
597 volume: number;
598 /** Number of orders. */
599 ord: number;
600}
601/** A measure of the supply and demand for a symbol. */
602interface MarketDepth$1 {
603 /** Total buying quantity. */
604 totalbuyqty: number;
605 /** Total selling quantity. */
606 totalsellqty: number;
607 /** Bidding price along with volume and total number of orders. */
608 bids: MarketOffer$1[];
609 /** Offer price with volume and total number of orders. */
610 ask: MarketOffer$1[];
611 /** Price at market opening time. */
612 o?: number;
613 /** Highest price for the day. */
614 h?: number;
615 /** Lowest price for the day. */
616 l?: number;
617 /** Price at the of market closing. */
618 c?: number;
619 /** Volume traded. */
620 v?: number;
621 /** Percentage of change between the current value and the previous day's market close. */
622 chp: number;
623 /** Change value. */
624 ch: number;
625 /** Last traded quantity. */
626 ltq: number;
627 /** Last traded time. */
628 ltt: number;
629 /** Last traded price. */
630 ltp: number;
631 /** Average traded price. */
632 atp: number;
633 /** Lower circuit price. */
634 lower_ckt: number;
635 /** Upper circuit price. */
636 upper_ckt: number;
637 /** Expiry date. */
638 expiry: string;
639 /** Open interest. */
640 oi: number;
641 /** Boolean flag for OI data, true or false. */
642 oiflag: false;
643 /** Previous day open interest. */
644 pdoi: number;
645 /** Change in open Interest percentage. */
646 oipercent: number;
647}
648/** Market depth details response. */
649interface GetMarketDepthResponse extends Response {
650 /** Dictionary of all market depth details. */
651 d: {
652 [symbol: string]: MarketDepth$1;
653 };
654}
655/** Symbol category of master file request. */
656interface GetSymbolMasterRequest {
657 /** Name of the exchange (NSE, BSE, MCX). */
658 exchange: string;
659 /** The segment whose symbols are needed (CM, FO, CD, COM). */
660 segment: string;
661}
662/** e-DIS TPIN generation reponse. */
663interface GenerateEdisTpinResponse extends Response {
664 /** Unknown, seen to be empty. */
665 data: string;
666}
667/** Details of an e-DIS transaction. */
668interface EdisTransaction$1 {
669 /** Transaction id. */
670 transactionId: string;
671 /** Internal transaction id. */
672 internalTxnId: string;
673 /** DP transaction id. */
674 dpTxnId: string;
675 /** ISIN code of stock. */
676 isin: string;
677 /** Quantity to transact. */
678 qty: number;
679 /** Quantity already transacted? */
680 qtyUtlize: number;
681 /** Transaction create date-time/ */
682 entryDate: string;
683 /** Transaction processing start date? */
684 startDate: string;
685 /** Transaction processing end date? */
686 endDate: string;
687 /** No. of days since transaction create date? */
688 noOfDays: number;
689 /** Source of transaction. */
690 source: string;
691 /** SUCCESS, FAILURE? */
692 status: string;
693 /** Unique client code? */
694 clientId: string;
695 /** Error code (NA). */
696 errCode: string;
697 /** Error count (0). */
698 errorCount: string;
699 /** Message. */
700 reason: string;
701}
702/** e-DIS transaction details response. */
703interface GetEdisTransactionsResponse extends Response {
704 /** List of e-DIS transactions. */
705 data: EdisTransaction$1[] | string;
706}
707/** e-DIS securities held in a demat account. */
708interface EdisHolding$1 {
709 /** 12-digit alphanumeric code of specific symbol. */
710 isin_code: string;
711 /** Quantity of securities held. */
712 qty: number;
713}
714/** e-DIS holdings submission request. */
715interface SubmitEdisHoldingsRequest {
716 /** Records of holdings of the user. */
717 recordLst: EdisHolding$1[];
718}
719/** e-DIS transactions status inquiry request. */
720interface InquireEdisTransactionRequest {
721 /** Transaction id. */
722 transactionId: string;
723}
724/** e-DIS transaction status counts. */
725interface EdisTransactionStatus {
726 /** Failure count. */
727 FAILED_CNT: number;
728 /** Success count. */
729 SUCEESS_CNT: number;
730}
731/** e-DIS transaction status inquiry response. */
732interface InquireEdisTransactionResponse extends Response {
733 /** Depository status data. */
734 data: EdisTransactionStatus;
735}
736/**
737 * Get request step 1 for authorization (browser only).
738 * @param options authorization step 1 details \{client_id, redirect_uri, response_type, state\}
739 * @returns HTTP(s) request options for authorization step 1 (manual)
740 */
741declare function loginStep1$1(options: LoginStep1Request$1): HttpRequestOptions;
742/**
743 * Get request step 2 for authorization (browser, server).
744 * @param options authorization step 2 details \{graph_type, appIdHash, code\}
745 * @returns HTTP(s) request options for authorization step 2 (manual)
746 */
747declare function loginStep2$1(options: LoginStep2Request$1): HttpRequestOptions;
748/**
749 * Get basic details of the client.
750 * @param auth authorization \{app_id, access_token\}
751 * @returns details of user's profile \{fy_id, email_id, name, ...\}
752 */
753declare function getProfile$1(auth: Authorization$1): Promise<GetProfileResponse>;
754/**
755 * Get balance available for the user for capital as well as the commodity market.
756 * @param auth authorization \{app_id, access_token\}
757 * @returns details of user's funds \{fund_limit: [\{id, title, equityAmount, commodityAmount\}]\}
758 */
759declare function getFunds$1(auth: Authorization$1): Promise<GetFundsResponse>;
760/**
761 * Get the equity and mutual fund holdings which the user has in this demat account.
762 * @param auth authorization \{app_id, access_token\}
763 * @returns details of user's holdings \{holdings: \{id, ...\}, overall: \{count_total, ...\}\}
764 */
765declare function getHoldings$1(auth: Authorization$1): Promise<GetHoldingsResponse>;
766/**
767 * Get details of an order placed in the current trading day.
768 * @param auth authorization \{app_id, access_token\}
769 * @param options order query \{id\}
770 * @returns details of an order \{orderBook: [\{id, exchOrdId, symbol, ...\}]\}
771 */
772declare function getOrder$1(auth: Authorization$1, options: GetOrderRequest): Promise<GetOrdersResponse>;
773/**
774 * Get details of all the orders placed in the current trading day.
775 * @param auth authorization \{app_id, access_token\}
776 * @returns details of orders \{orderBook: [\{id, exchOrdId, symbol, ...\}]\}
777 */
778declare function getOrders$1(auth: Authorization$1): Promise<GetOrdersResponse>;
779/**
780 * Get details of all the positions in the current trading day.
781 * @param auth authorization \{app_id, access_token\}
782 * @returns details of positions \{netPositions: \{id, ...\}, overall: \{count_total, ...\}\}
783 */
784declare function getPositions$1(auth: Authorization$1): Promise<GetPositionsResponse>;
785/**
786 * Get details of all the trades in the current trading day.
787 * @param auth authorization \{app_id, access_token\}
788 * @returns details of trades \{tradeBook: [\{id, orderNumber, exchangeOrderNo, ...\}]\}
789 */
790declare function getTrades$1(auth: Authorization$1): Promise<GetTradesResponse>;
791/**
792 * Place an order to any exchange via Fyers.
793 * @param auth authorization \{app_id, access_token\}
794 * @param options details of an order \{symbol, qty, type, side, ...\}
795 * @returns place status \{id\}
796 */
797declare function placeOrder$1(auth: Authorization$1, options: PlaceOrderRequest): Promise<PlaceOrderResponse>;
798/**
799 * Place multiple orders to any exchange via Fyers.
800 * @param auth authorization \{app_id, access_token\}
801 * @param options details of multiple orders [\{symbol, qty, type, side, ...\}]
802 * @returns place status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\}
803 */
804declare function placeOrders$1(auth: Authorization$1, options: PlaceOrderRequest[]): Promise<PlaceOrdersResponse>;
805/**
806 * Modify an order placed on any exchange via Fyers.
807 * @param auth authorization \{app_id, access_token\}
808 * @param options details of order \{id, qty, type, side, ...\}
809 * @returns modify status \{id\}
810 */
811declare function modifyOrder$1(auth: Authorization$1, options: ModifyOrderRequest): Promise<ModifyOrderResponse>;
812/**
813 * Modify orders placed on any exchange via Fyers.
814 * @param auth authorization \{app_id, access_token\}
815 * @param options details of orders [\{id, qty, type, side, ...\}]
816 * @returns modify status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\}
817 */
818declare function modifyOrders$1(auth: Authorization$1, options: ModifyOrderRequest[]): Promise<ModifyOrdersResponse>;
819/**
820 * Cancel an order placed on any exchange via Fyers.
821 * @param auth authorization \{app_id, access_token\}
822 * @param options details of order \{id\}
823 * @returns cancel status \{id\}
824 */
825declare function cancelOrder$1(auth: Authorization$1, options: CancelOrderRequest): Promise<CancelOrderResponse>;
826/**
827 * Cancel orders placed on any exchange via Fyers.
828 * @param auth authorization \{app_id, access_token\}
829 * @param options details of orders [\{id\}]
830 * @returns cancel status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\}
831 */
832declare function cancelOrders$1(auth: Authorization$1, options: CancelOrderRequest[]): Promise<CancelOrdersResponse>;
833/**
834 * Exit a position on the current trading day.
835 * @param auth authorization \{app_id, access_token\}
836 * @param options details of position \{id\}
837 * @returns exit status \{\}
838 */
839declare function exitPosition$1(auth: Authorization$1, options: ExitPositionRequest): Promise<ExitPositionResponse>;
840/**
841 * Exit all positions on the current trading day.
842 * @param auth authorization \{app_id, access_token\}
843 * @returns exit status \{\}
844 */
845declare function exitAllPositions$1(auth: Authorization$1): Promise<ExitAllPositionsResponse>;
846/**
847 * Convert a position on the current trading day.
848 * @param auth authorization \{app_id, access_token\}
849 * @param options details of position \{symbol, positionSide, convertQty, ...\}
850 * @returns conversion status \{positionDetails\}
851 */
852declare function convertPosition$1(auth: Authorization$1, options: ConvertPositionRequest): Promise<ConvertPositionResponse>;
853/**
854 * Get the current market status of all the exchanges and their segments.
855 * @param auth authorization \{app_id, access_token\}
856 * @returns market status \{marketStatus: [\{exchange, segment, market_type, status\}]\}
857 */
858declare function getMarketStatus$1(auth: Authorization$1): Promise<GetMarketStatusResponse>;
859/**
860 * Get the current market history for a particular symbol.
861 * @param auth authorization \{app_id, access_token\}
862 * @param options market details \{symbol, resolution, date_format, ...\}
863 * @returns market history \{candles: \[\[time, open, high, low, close, volume\]\]\}
864 */
865declare function getMarketHistory$1(auth: Authorization$1, options: GetMarketHistoryRequest): Promise<GetMarketHistoryResponse>;
866/**
867 * Get the current market quotes for a set of symbols.
868 * @param auth authorization \{app_id, access_token\}
869 * @param options market details \{symbols\}
870 * @returns market quotes \{d: [\{n, s, v: \{ch, chp, lp, spread, ...\}\}]\}
871 */
872declare function getMarketQuotes$1(auth: Authorization$1, options: GetMarketQuotesRequest): Promise<GetMarketQuotesResponse>;
873/**
874 * Get the current market depth for a particular symbol.
875 * @param auth authorization \{app_id, access_token\}
876 * @param options market details \{symbol, ohlcv_flag\}
877 * @returns market depth \{d: \{<symbol>: \{totalbuyqty, totalsellqty, bids\}\}\}
878 */
879declare function getMarketDepth$1(auth: Authorization$1, options: GetMarketDepthRequest): Promise<GetMarketDepthResponse>;
880/**
881 * Get all the latest symbols of all the exchanges from the symbol master files.
882 * @param auth authorization (unused)
883 * @param options details of symbol category \{exchange, segment\}
884 * @returns symbol master file
885 */
886declare function getSymbolMaster$1(auth: null, options: GetSymbolMasterRequest): Promise<string>;
887/**
888 * Generate e-DIS TPIN for validating/authorising transaction.
889 * @param auth authorization \{app_id, access_token\}
890 * @returns optional data \{data\}
891 */
892declare function generateEdisTpin$1(auth: Authorization$1): Promise<GenerateEdisTpinResponse>;
893/**
894 * Get the necessary information regarding the holdings you have on your and also the Status of the holdings. If the “sell” for the particular holdings is a success or not.
895 * @param auth authorization \{app_id, access_token\}
896 * @returns list of e-DIS transactions \{data: [\{transactionId, internalTxnId, ...\}]\}
897 */
898declare function getEdisTransactions$1(auth: Authorization$1): Promise<GetEdisTransactionsResponse>;
899/**
900 * 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).
901 * @param auth authorization \{app_id, access_token\}
902 * @param options holding details \{recordLst: [\{isin_code, qty\}]\}
903 * @returns HTTP(s) request options (manual)
904 */
905declare function submitEdisHoldingsStep$1(auth: Authorization$1, options: SubmitEdisHoldingsRequest): HttpRequestOptions;
906/**
907 * Inquire the information/status of the provided transaction Id for the respective holdings you have on your end.
908 * @param auth authorization \{app_id, access_token\}
909 * @param options transaction details \{transactionId\}
910 * @returns edis status \{FAILED_CNT, SUCEESS_CNT\}
911 */
912declare function inquireEdisTransaction$1(auth: Authorization$1, options: InquireEdisTransactionRequest): Promise<InquireEdisTransactionResponse>;
913
914declare const http_d_API_URL: typeof API_URL;
915declare const http_d_DATA_URL: typeof DATA_URL;
916declare const http_d_SYMBOLS_URL: typeof SYMBOLS_URL;
917type http_d_Response = Response;
918type http_d_ProxyResponse<Body> = ProxyResponse<Body>;
919type http_d_GetProfileResponse = GetProfileResponse;
920type http_d_FundLimit = FundLimit;
921type http_d_GetFundsResponse = GetFundsResponse;
922type http_d_GetHoldingsResponse = GetHoldingsResponse;
923type http_d_GetOrderRequest = GetOrderRequest;
924type http_d_GetOrdersResponse = GetOrdersResponse;
925type http_d_GetPositionsResponse = GetPositionsResponse;
926type http_d_GetTradesResponse = GetTradesResponse;
927type http_d_PlaceOrderRequest = PlaceOrderRequest;
928type http_d_OrderResponse = OrderResponse;
929type http_d_PlaceOrderResponse = PlaceOrderResponse;
930type http_d_PlaceOrdersResponse = PlaceOrdersResponse;
931type http_d_ModifyOrderRequest = ModifyOrderRequest;
932type http_d_ModifyOrderResponse = ModifyOrderResponse;
933type http_d_ModifyOrdersResponse = ModifyOrdersResponse;
934type http_d_CancelOrderRequest = CancelOrderRequest;
935type http_d_CancelOrderResponse = CancelOrderResponse;
936type http_d_CancelOrdersResponse = CancelOrdersResponse;
937type http_d_ExitPositionRequest = ExitPositionRequest;
938type http_d_ExitAllPositionsResponse = ExitAllPositionsResponse;
939type http_d_ExitPositionResponse = ExitPositionResponse;
940type http_d_ConvertPositionRequest = ConvertPositionRequest;
941type http_d_ConvertPositionResponse = ConvertPositionResponse;
942type http_d_GetMarketStatusResponse = GetMarketStatusResponse;
943type http_d_GetMarketHistoryRequest = GetMarketHistoryRequest;
944type http_d_ShortCandle = ShortCandle;
945type http_d_GetMarketHistoryResponse = GetMarketHistoryResponse;
946type http_d_GetMarketQuotesRequest = GetMarketQuotesRequest;
947type http_d_MarketQuoteDetails = MarketQuoteDetails;
948type http_d_GetMarketQuotesResponse = GetMarketQuotesResponse;
949type http_d_GetMarketDepthRequest = GetMarketDepthRequest;
950type http_d_GetMarketDepthResponse = GetMarketDepthResponse;
951type http_d_GetSymbolMasterRequest = GetSymbolMasterRequest;
952type http_d_GenerateEdisTpinResponse = GenerateEdisTpinResponse;
953type http_d_GetEdisTransactionsResponse = GetEdisTransactionsResponse;
954type http_d_SubmitEdisHoldingsRequest = SubmitEdisHoldingsRequest;
955type http_d_InquireEdisTransactionRequest = InquireEdisTransactionRequest;
956type http_d_EdisTransactionStatus = EdisTransactionStatus;
957type http_d_InquireEdisTransactionResponse = InquireEdisTransactionResponse;
958declare namespace http_d {
959 export {
960 http_d_API_URL as API_URL,
961 http_d_DATA_URL as DATA_URL,
962 http_d_SYMBOLS_URL as SYMBOLS_URL,
963 http_d_Response as Response,
964 http_d_ProxyResponse as ProxyResponse,
965 Authorization$1 as Authorization,
966 LoginStep1Request$1 as LoginStep1Request,
967 LoginStep1Response$1 as LoginStep1Response,
968 LoginStep2Request$1 as LoginStep2Request,
969 LoginStep2Response$1 as LoginStep2Response,
970 Profile$1 as Profile,
971 http_d_GetProfileResponse as GetProfileResponse,
972 http_d_FundLimit as FundLimit,
973 http_d_GetFundsResponse as GetFundsResponse,
974 Holding$1 as Holding,
975 HoldingsOverall$1 as HoldingsOverall,
976 http_d_GetHoldingsResponse as GetHoldingsResponse,
977 Order$1 as Order,
978 http_d_GetOrderRequest as GetOrderRequest,
979 http_d_GetOrdersResponse as GetOrdersResponse,
980 Position$1 as Position,
981 PositionsOverall$1 as PositionsOverall,
982 http_d_GetPositionsResponse as GetPositionsResponse,
983 Trade$1 as Trade,
984 http_d_GetTradesResponse as GetTradesResponse,
985 http_d_PlaceOrderRequest as PlaceOrderRequest,
986 http_d_OrderResponse as OrderResponse,
987 http_d_PlaceOrderResponse as PlaceOrderResponse,
988 http_d_PlaceOrdersResponse as PlaceOrdersResponse,
989 http_d_ModifyOrderRequest as ModifyOrderRequest,
990 http_d_ModifyOrderResponse as ModifyOrderResponse,
991 http_d_ModifyOrdersResponse as ModifyOrdersResponse,
992 http_d_CancelOrderRequest as CancelOrderRequest,
993 http_d_CancelOrderResponse as CancelOrderResponse,
994 http_d_CancelOrdersResponse as CancelOrdersResponse,
995 http_d_ExitPositionRequest as ExitPositionRequest,
996 http_d_ExitAllPositionsResponse as ExitAllPositionsResponse,
997 http_d_ExitPositionResponse as ExitPositionResponse,
998 http_d_ConvertPositionRequest as ConvertPositionRequest,
999 http_d_ConvertPositionResponse as ConvertPositionResponse,
1000 MarketStatus$1 as MarketStatus,
1001 http_d_GetMarketStatusResponse as GetMarketStatusResponse,
1002 http_d_GetMarketHistoryRequest as GetMarketHistoryRequest,
1003 http_d_ShortCandle as ShortCandle,
1004 http_d_GetMarketHistoryResponse as GetMarketHistoryResponse,
1005 http_d_GetMarketQuotesRequest as GetMarketQuotesRequest,
1006 Candle$1 as Candle,
1007 http_d_MarketQuoteDetails as MarketQuoteDetails,
1008 MarketQuote$1 as MarketQuote,
1009 http_d_GetMarketQuotesResponse as GetMarketQuotesResponse,
1010 http_d_GetMarketDepthRequest as GetMarketDepthRequest,
1011 MarketOffer$1 as MarketOffer,
1012 MarketDepth$1 as MarketDepth,
1013 http_d_GetMarketDepthResponse as GetMarketDepthResponse,
1014 http_d_GetSymbolMasterRequest as GetSymbolMasterRequest,
1015 http_d_GenerateEdisTpinResponse as GenerateEdisTpinResponse,
1016 EdisTransaction$1 as EdisTransaction,
1017 http_d_GetEdisTransactionsResponse as GetEdisTransactionsResponse,
1018 EdisHolding$1 as EdisHolding,
1019 http_d_SubmitEdisHoldingsRequest as SubmitEdisHoldingsRequest,
1020 http_d_InquireEdisTransactionRequest as InquireEdisTransactionRequest,
1021 http_d_EdisTransactionStatus as EdisTransactionStatus,
1022 http_d_InquireEdisTransactionResponse as InquireEdisTransactionResponse,
1023 loginStep1$1 as loginStep1,
1024 loginStep2$1 as loginStep2,
1025 getProfile$1 as getProfile,
1026 getFunds$1 as getFunds,
1027 getHoldings$1 as getHoldings,
1028 getOrder$1 as getOrder,
1029 getOrders$1 as getOrders,
1030 getPositions$1 as getPositions,
1031 getTrades$1 as getTrades,
1032 placeOrder$1 as placeOrder,
1033 placeOrders$1 as placeOrders,
1034 modifyOrder$1 as modifyOrder,
1035 modifyOrders$1 as modifyOrders,
1036 cancelOrder$1 as cancelOrder,
1037 cancelOrders$1 as cancelOrders,
1038 exitPosition$1 as exitPosition,
1039 exitAllPositions$1 as exitAllPositions,
1040 convertPosition$1 as convertPosition,
1041 getMarketStatus$1 as getMarketStatus,
1042 getMarketHistory$1 as getMarketHistory,
1043 getMarketQuotes$1 as getMarketQuotes,
1044 getMarketDepth$1 as getMarketDepth,
1045 getSymbolMaster$1 as getSymbolMaster,
1046 generateEdisTpin$1 as generateEdisTpin,
1047 getEdisTransactions$1 as getEdisTransactions,
1048 submitEdisHoldingsStep$1 as submitEdisHoldingsStep,
1049 inquireEdisTransaction$1 as inquireEdisTransaction,
1050 };
1051}
1052
1053/** Root URL for Market data notifications. */
1054declare const MARKET_DATA_URL: string;
1055/** Root URL for Order update notifications. */
1056declare const ORDER_UPDATE_URL: string;
1057/** Common notification format. */
1058declare type Notification = Response;
1059/** Update for order placed by the user in the current trading day. */
1060interface OrderUpdate {
1061 /** The unique order id assigned for each order. */
1062 id: string;
1063 /** The order id provided by the exchange. */
1064 exchOrdId: string;
1065 /** The symbol for which order is placed. */
1066 symbol: string;
1067 /** Fytoken is a unique identifier for every symbol. */
1068 fyToken: string;
1069 /** The segment this order is placed in. */
1070 segment: string;
1071 /** Exchange instrument type. */
1072 instrument: string;
1073 /** The type of order. */
1074 type: number;
1075 /** The order is buy or sell. */
1076 side: number;
1077 /** The product type. */
1078 productType: string;
1079 /** The status of the order. */
1080 status: number;
1081 /** The order number and status of the order. */
1082 orderNumStatus: string;
1083 /** True when placing AMO order. */
1084 offlineOrder: boolean;
1085 /** The original order qty. */
1086 qty: number;
1087 /** The remaining qty. */
1088 remainingQuantity: number;
1089 /** The filled qty after partial trades. */
1090 filledQty: number;
1091 /** The limit price for the order. */
1092 limitPrice: number;
1093 /** The stop price for the order. */
1094 stopPrice: number;
1095 /** Disclosed quantity. */
1096 discloseQty: number;
1097 /** Remaining disclosed quantity. */
1098 dqQtyRem: number;
1099 /** Day or IOC. */
1100 orderValidity: string;
1101 /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */
1102 orderDateTime: string;
1103 /** The parent order id will be provided only for applicable orders. */
1104 parentId?: string;
1105 /** The average traded price for the order. */
1106 tradedPrice: number;
1107 /** This is used to sort the orders based on the time. */
1108 slNo: number;
1109 /** The error messages are shown here. */
1110 message: string;
1111}
1112/** String notification on order update. */
1113interface OrderUpdateNotification$1 extends Notification {
1114 /** Websocket type [1]. */
1115 ws_type?: number;
1116 /** Data for the notification. */
1117 d?: OrderUpdate;
1118}
1119/** Header for each binary message. */
1120interface Header {
1121 /** Fytoken is a unique identifier for every symbol. */
1122 token: BigInt;
1123 /** Timestamp sent by exchange (UNIX epoch). */
1124 tt: number;
1125 /** 7202: OI data (NSE FO/CD, MCX), 7207/7208: NSE, BSE (indices/data), 31038: MCX. */
1126 fyCode: number;
1127 /** Market status flag? */
1128 marketStat: number;
1129 /** Packet length, including header? */
1130 pktlen: number;
1131 /** Has L2 data (market depth)? */
1132 L2: number;
1133}
1134/** Open interest data (fyCode === 7202). */
1135interface OiData {
1136 /** Open interest. */
1137 oi: number;
1138 /** Previous day open interest. */
1139 pdoi: number;
1140}
1141/** Common data (fyCode !== 7202). */
1142interface CommonData {
1143 /** Price conversion, divisor for all prices. */
1144 price_conv: number;
1145 /** LTP is the price from which the next sale of the stocks happens. */
1146 ltp: number;
1147 /** Price at market opening time. */
1148 open_price: number;
1149 /** Highest price for the day. */
1150 high_price: number;
1151 /** Lowest price for the day. */
1152 low_price: number;
1153 /** Close price of the previous trading day. */
1154 prev_close_price: number;
1155 /** Open price (1 minute). */
1156 o: number;
1157 /** High price (1 minute). */
1158 h: number;
1159 /** Low price (1 minute). */
1160 l: number;
1161 /** Close price (1 minute). */
1162 c: number;
1163 /** Volume (1 minute). */
1164 v: BigInt;
1165 /** Open interest. */
1166 oi: BigInt;
1167 /** Previous day open interest. */
1168 pdoi: BigInt;
1169}
1170/** Additional data (fyCode === 7208, 31038). */
1171interface L1Data {
1172 /** Last traded quantity. */
1173 LTQ: number;
1174 /** Last traded time (UNIX epoch). */
1175 L2_LTT: number;
1176 /** Average traded price. */
1177 ATP: number;
1178 /** Today's volume. */
1179 volume: number;
1180 /** Total buy quantity. */
1181 tot_buy: BigInt;
1182 /** Total sell quantity. */
1183 tot_sell: BigInt;
1184 /** Highest bid price. */
1185 bid: number;
1186 /** Lowest ask price. */
1187 ask: number;
1188}
1189/** Open buy/sell orders at a particular price (L2 === 1). */
1190interface L2MarketOffer {
1191 /** Bid/ask price. */
1192 price: number;
1193 /** Bid/ask volume. */
1194 volume: number;
1195 /** Number of orders. */
1196 ord: number;
1197}
1198/** Market depth data, 5 rows (L2 === 1). */
1199interface L2Data {
1200 /** Bidding price along with volume and total number of orders. */
1201 bids: L2MarketOffer[];
1202 /** Offer price with volume and total number of orders. */
1203 asks: L2MarketOffer[];
1204}
1205/** Market data (oi/quote/depth) for symbols subscribed by the user. */
1206interface MarketData extends Header, CommonData, L1Data, L2Data {
1207}
1208/** Binary notification on Market data. */
1209interface MarketDataNotification$1 extends Notification {
1210 /** Data for the notification. */
1211 d?: MarketData;
1212}
1213/**
1214 * Notified function.
1215 * @param notification notification
1216 */
1217declare type OnNotification = (notification: Notification) => void;
1218/**
1219 * Order update notified function.
1220 * @param notification notification
1221 */
1222declare type OnOrderUpdateNotification$1 = (notification: OrderUpdateNotification$1) => void;
1223/**
1224 * Market data notified function.
1225 * @param notification notification
1226 */
1227declare type OnMarketDataNotification$1 = (notification: MarketDataNotification$1) => void;
1228/** Handler for reciever which has passed (resolved). */
1229declare type OnResolve = (response: Response) => void;
1230/** Handler for reciever which has failed (rejected). */
1231declare type OnReject = (error: Error) => void;
1232/** Recieve response to a request, which can pass or fail. */
1233interface Reciever {
1234 /** Pass (resolve) handler for reciever. */
1235 resolve: OnResolve;
1236 /** Fail (reject) handler for reciever. */
1237 reject: OnReject;
1238}
1239/**
1240 * Provides the API for creating and managing a WebSocket connection to
1241 * a server, as well as for sending and receiving data on the connection.
1242 */
1243declare class Connection extends WebSocket {
1244 /** To recieve response to a request. */
1245 recievers: Reciever[];
1246}
1247/**
1248 * Connect to Order update URL with WebSocket.
1249 * @param auth authorization \{app_id, access_token\}
1250 * @param fn notified function
1251 * @returns WebSocket connection
1252 */
1253declare function connectOrderUpdate$1(auth: Authorization$1, fn: OnOrderUpdateNotification$1): Promise<Connection>;
1254/**
1255 * Subscribe to order update.
1256 * @param conn websocket connection
1257 */
1258declare function subscribeOrderUpdate$1(conn: Connection): Promise<Response>;
1259/**
1260 * Unsubscribe to order update.
1261 * @param conn websocket connection
1262 */
1263declare function unsubscribeOrderUpdate$1(conn: Connection): Promise<Response>;
1264/**
1265 * Connect to Market data URL with WebSocket.
1266 * @param auth authorization \{app_id, access_token\}
1267 * @param fn notified function
1268 * @returns WebSocket connection
1269 */
1270declare function connectMarketData$1(auth: Authorization$1, fn: OnMarketDataNotification$1): Promise<Connection>;
1271/**
1272 * Subscribe to market quote.
1273 * @param conn websocket connection
1274 * @param symbols list of symbols
1275 */
1276declare function subscribeMarketQuote$1(conn: Connection, symbols: string[]): Promise<Response>;
1277/**
1278 * Subscribe to market depth.
1279 * @param conn websocket connection
1280 * @param symbols list of symbols
1281 */
1282declare function subscribeMarketDepth$1(conn: Connection, symbols: string[]): Promise<Response>;
1283/**
1284 * Unsubscribe to market quote.
1285 * @param conn websocket connection
1286 * @param symbols list of symbols
1287 */
1288declare function unsubscribeMarketQuote$1(conn: Connection, symbols: string[]): Promise<Response>;
1289/**
1290 * Unsubscribe to market depth.
1291 * @param conn websocket connection
1292 * @param symbols list of symbols
1293 */
1294declare function unsubscribeMarketDepth$1(conn: Connection, symbols: string[]): Promise<Response>;
1295
1296declare const websocket_d_MARKET_DATA_URL: typeof MARKET_DATA_URL;
1297declare const websocket_d_ORDER_UPDATE_URL: typeof ORDER_UPDATE_URL;
1298type websocket_d_Notification = Notification;
1299type websocket_d_OrderUpdate = OrderUpdate;
1300type websocket_d_Header = Header;
1301type websocket_d_OiData = OiData;
1302type websocket_d_CommonData = CommonData;
1303type websocket_d_L1Data = L1Data;
1304type websocket_d_L2MarketOffer = L2MarketOffer;
1305type websocket_d_L2Data = L2Data;
1306type websocket_d_MarketData = MarketData;
1307type websocket_d_OnNotification = OnNotification;
1308type websocket_d_OnResolve = OnResolve;
1309type websocket_d_OnReject = OnReject;
1310type websocket_d_Reciever = Reciever;
1311type websocket_d_Connection = Connection;
1312declare const websocket_d_Connection: typeof Connection;
1313type websocket_d_Response = Response;
1314declare namespace websocket_d {
1315 export {
1316 websocket_d_MARKET_DATA_URL as MARKET_DATA_URL,
1317 websocket_d_ORDER_UPDATE_URL as ORDER_UPDATE_URL,
1318 websocket_d_Notification as Notification,
1319 websocket_d_OrderUpdate as OrderUpdate,
1320 OrderUpdateNotification$1 as OrderUpdateNotification,
1321 websocket_d_Header as Header,
1322 websocket_d_OiData as OiData,
1323 websocket_d_CommonData as CommonData,
1324 websocket_d_L1Data as L1Data,
1325 websocket_d_L2MarketOffer as L2MarketOffer,
1326 websocket_d_L2Data as L2Data,
1327 websocket_d_MarketData as MarketData,
1328 MarketDataNotification$1 as MarketDataNotification,
1329 websocket_d_OnNotification as OnNotification,
1330 OnOrderUpdateNotification$1 as OnOrderUpdateNotification,
1331 OnMarketDataNotification$1 as OnMarketDataNotification,
1332 websocket_d_OnResolve as OnResolve,
1333 websocket_d_OnReject as OnReject,
1334 websocket_d_Reciever as Reciever,
1335 websocket_d_Connection as Connection,
1336 connectOrderUpdate$1 as connectOrderUpdate,
1337 subscribeOrderUpdate$1 as subscribeOrderUpdate,
1338 unsubscribeOrderUpdate$1 as unsubscribeOrderUpdate,
1339 connectMarketData$1 as connectMarketData,
1340 subscribeMarketQuote$1 as subscribeMarketQuote,
1341 subscribeMarketDepth$1 as subscribeMarketDepth,
1342 unsubscribeMarketQuote$1 as unsubscribeMarketQuote,
1343 unsubscribeMarketDepth$1 as unsubscribeMarketDepth,
1344 websocket_d_Response as Response,
1345 Authorization$1 as Authorization,
1346 };
1347}
1348
1349/** Exchange code. */
1350declare type Exchange = "NSE" | "MCX" | "BSE";
1351/**
1352 * Get exchange description.
1353 * @param code exchange code (NSE, MCX, BSE)
1354 * @returns exchange description
1355 */
1356declare function exchangeDescription(code: Exchange): string;
1357/**
1358 * Get exchange code.
1359 * @param desc exchange description
1360 * @returns exchange code (NSE, MCX, BSE)
1361 */
1362declare function exchange(desc: string): Exchange;
1363/** Segment code. */
1364declare type Segment = "CM" | "FO" | "CD" | "COM";
1365/**
1366 * Get segment description.
1367 * @param code segment code (CM, FO, CD, COM)
1368 * @returns segment description
1369 */
1370declare function segmentDescription(code: Segment): string;
1371/**
1372 * Get segment code.
1373 * @param desc segment description
1374 * @returns segment code (CM, FO, CD, COM)
1375 */
1376declare function segment(desc: string): Segment;
1377/** Position side code. */
1378declare type PositionSide = "LONG" | "SHORT" | "CLOSED";
1379/**
1380 * Get position side description.
1381 * @param code position side code (LONG, SHORT, CLOSED)
1382 * @returns position side description
1383 */
1384declare function positionSideDescription(code: PositionSide): string;
1385/**
1386 * Get position side code.
1387 * @param desc position side description
1388 * @returns position side code (LONG, SHORT, CLOSED)
1389 */
1390declare function positionSide(desc: string): PositionSide;
1391/** Order side code. */
1392declare type OrderSide = "BUY" | "SELL";
1393/**
1394 * Get order side description.
1395 * @param code order side code (BUY, SELL)
1396 * @returns order side description
1397 */
1398declare function orderSideDescription(code: OrderSide): string;
1399/**
1400 * Get order side code.
1401 * @param desc order side description
1402 * @returns order side code (BUY, SELL)
1403 */
1404declare function orderSide(desc: string): OrderSide;
1405/** Order source code. */
1406declare type OrderSource = "MOBILE" | "WEB" | "ONE" | "ADMIN" | "API";
1407/**
1408 * Get order source description.
1409 * @param code order source code (MOBILE, WEB, ONE, ADMIN, API)
1410 * @returns order source description
1411 */
1412declare function orderSourceDescription(code: OrderSource): string;
1413/**
1414 * Get order source code.
1415 * @param desc order source description
1416 * @returns order source code (MOBILE, WEB, ONE, ADMIN, API)
1417 */
1418declare function orderSource(desc: string): OrderSource;
1419/** Order status code. */
1420declare type OrderStatus = "CANCELLED" | "TRADED" | "TRANSIT" | "REJECTED" | "PENDING" | "EXPIRED";
1421/**
1422 * Get order status description.
1423 * @param code order status code (CANCELLED, TRADED, ...)
1424 * @returns order status description
1425 */
1426declare function orderStatusDescription(code: OrderStatus): string;
1427/**
1428 * Get order status code.
1429 * @param desc order status description
1430 * @returns order status code (CANCELLED, TRADED, ...)
1431 */
1432declare function orderStatus(desc: string): OrderStatus;
1433/** Order type code. */
1434declare type OrderType = "LIMIT" | "MARKET" | "SL_MARKET" | "SL_LIMIT";
1435/**
1436 * Get order type description.
1437 * @param code order type code (LIMIT, MARKET, SL_MARKET, SL_LIMIT)
1438 * @returns order type description
1439 */
1440declare function orderTypeDescription(code: OrderType): string;
1441/**
1442 * Get order type code.
1443 * @param desc order type description
1444 * @returns order type code (LIMIT, MARKET, SL_MARKET, SL_LIMIT)
1445 */
1446declare function orderType(desc: string): OrderType;
1447/** Order validity code. */
1448declare type OrderValidity = "DAY" | "IOC";
1449/**
1450 * Get order validity description.
1451 * @param code order validity code (DAY, IOC)
1452 * @returns order validity description
1453 */
1454declare function orderValidityDescription(code: OrderValidity): string;
1455/**
1456 * Get order validity code.
1457 * @param desc order validity description
1458 * @returns order validity code (DAY, IOC)
1459 */
1460declare function orderValidity(desc: string): OrderValidity;
1461/** Option type code. */
1462declare type OptionType = "CE" | "PE";
1463/**
1464 * Get option type description.
1465 * @param code option type code (CE, PE)
1466 * @returns option type description
1467 */
1468declare function optionTypeDescription(code: OptionType): string;
1469/**
1470 * Get option type code.
1471 * @param desc option type description
1472 * @returns option type code (CE, PE)
1473 */
1474declare function optionType(desc: string): OptionType;
1475/** Derivative type code. */
1476declare type DerivativeType = "FUT" | "CE" | "PE";
1477/**
1478 * Get derivative type description.
1479 * @param code derivative type code (FUT, CE, PE)
1480 * @returns derivative type description
1481 */
1482declare function derivativeTypeDescription(code: DerivativeType): string;
1483/**
1484 * Get derivative type code.
1485 * @param desc derivative type description
1486 * @returns derivative type code (CE, PE)
1487 */
1488declare function derivativeType(desc: string): DerivativeType;
1489/** Holding type code. */
1490declare type HoldingType = "T1" | "HLD";
1491/**
1492 * Get holding type description.
1493 * @param code holding type code (T1, HLD)
1494 * @returns holding type description
1495 */
1496declare function holdingTypeDescription(code: HoldingType): string;
1497/**
1498 * Get holding type code.
1499 * @param desc holding type description
1500 * @returns holding type code (T1, HLD)
1501 */
1502declare function holdingType(desc: string): HoldingType;
1503/** Product type code. */
1504declare type ProductType = "CNC" | "INTRADAY" | "MARGIN" | "CO" | "BO";
1505/**
1506 * Get product type description.
1507 * @param code product type code (CNC, INTRADAY, MARGIN, CO, BO)
1508 * @returns product type description
1509 */
1510declare function productTypeDescription(code: ProductType): string;
1511/**
1512 * Get product type code.
1513 * @param desc product type description
1514 * @returns product type code (CNC, INTRADAY, MARGIN, CO, BO)
1515 */
1516declare function productType(desc: string): ProductType;
1517/** Instrument type code. */
1518declare type InstrumentType = "EQ" | "PREFSHARES" | "DEBENTURES" | "WARRANTS" | "MISC" | "INDEX" | // CM segment
1519"FUTIDX" | "FUTIVX" | "FUTSTK" | "OPTIDX" | "OPTSTK" | // FO segment
1520"FUTCUR" | "FUTIRT" | "FUTIRC" | "OPTCUR" | "UNDCUR" | "UNDIRC" | "UNDIRT" | "UNDIRD" | "INDEX_CD" | "FUTIRD" | // CD segment
1521"FUTCOM" | "OPTFUT" | "OPTCOM";
1522/**
1523 * Get instrument type description.
1524 * @param code instrument type code
1525 * @returns instrument type description
1526 */
1527declare function instrumentTypeDescription(code: InstrumentType): string;
1528/**
1529 * Get instrument type code.
1530 * @param desc instrument type description
1531 * @returns instrument type code
1532 */
1533declare function instrumentType(desc: string): InstrumentType;
1534/** Essential details of a symbol, as given in Symbol master CSV file. */
1535interface SymbolDetails {
1536 /** Eg: NSE:RCOM-EQ. */
1537 symbol: string;
1538 /** A unique identifier for every symbol. */
1539 token: string;
1540 /** Description of the symbol. */
1541 description: string;
1542 /** Minimum lot size for the symbol. */
1543 lotSize: number;
1544 /** ISIN code of stock. */
1545 isin: string;
1546}
1547/**
1548 * Get symbol exchange, underlying, currency-pair, or commodity name.
1549 * @param code symbol code
1550 * @returns symbol name
1551 */
1552declare function symbolName(code: string): string;
1553/**
1554 * Get symbol exchange.
1555 * @param code symbol code
1556 * @returns symbol exchange
1557 */
1558declare function symbolExchange(code: string): Exchange;
1559/**
1560 * Get symbol exchange series.
1561 * @param code symbol code
1562 * @returns symbol exchange series (EQ, BE, MF, ME, ...)
1563 */
1564declare function symbolSeries(code: string): string | null;
1565/**
1566 * Get symbol option type.
1567 * @param code symbol code
1568 * @returns symbol option type
1569 */
1570declare function symbolOptionType(code: string): OptionType | null;
1571/**
1572 * Get symbol derivative type.
1573 * @param code symbol code
1574 * @returns symbol derivative type
1575 */
1576declare function symbolDerivativeType(code: string): DerivativeType | null;
1577/**
1578 * Get symbol strike price.
1579 * @param code symbol code
1580 * @returns symbol strike price
1581 */
1582declare function symbolStrikePrice(code: string): number;
1583/**
1584 * Get symbol token, a unique identifier.
1585 * @param code symbol code
1586 * @param map symbol details map
1587 * @returns symbol token
1588 */
1589declare function symbolToken(code: string, map: Map<string, SymbolDetails>): string;
1590/**
1591 * Get symbol description.
1592 * @param code symbol code
1593 * @param map symbol details map
1594 * @returns symbol description
1595 */
1596declare function symbolDescription(code: string, map: Map<string, SymbolDetails>): string;
1597/**
1598 * Get symbol ISIN.
1599 * @param code symbol code
1600 * @param map symbol details map
1601 * @returns symbol ISIN
1602 */
1603declare function symbolIsin(code: string, map: Map<string, SymbolDetails>): string;
1604/**
1605 * Get symbol minimum lot size.
1606 * @param code symbol code
1607 * @param map symbol details map
1608 * @returns symbol minimum lot size
1609 */
1610declare function symbolLotSize(code: string, map: Map<string, SymbolDetails>): number;
1611/** Attributes required for authorization of all requests. */
1612interface Authorization {
1613 /** This is the app_id which you have received after creating the app. */
1614 appId: string;
1615 /** This value will be used for all the requests. */
1616 accessToken: string;
1617}
1618/** Login step 1 request. */
1619interface LoginStep1Request {
1620 /** This is the app_id which you have received after creating the app. */
1621 appId: string;
1622 /** This is where the user will be redirected after successful login. */
1623 redirectUrl: string;
1624 /** The same value will be returned after successful login to the redirect uri. */
1625 state: string;
1626}
1627/** Login step 1 response. */
1628interface LoginStep1Response {
1629 /** String value which will be used to generate the access_token. */
1630 authorizationCode: string;
1631 /** This value is returned as is from the first request. */
1632 state: string;
1633}
1634/** Login step 2 request. */
1635interface LoginStep2Request {
1636 /** SHA-256 of `api_id:app_secret` in hex. */
1637 appHash: string;
1638 /** This is the auth_code which is received from the first step. */
1639 authorizationCode: string;
1640}
1641/** Login step 2 response. */
1642interface LoginStep2Response {
1643 /** This value will be used for all the subsequent requests. */
1644 accessToken: string;
1645}
1646/** Basic details of the client. */
1647interface Profile {
1648 /** The client id of the fyers user. */
1649 id: string;
1650 /** Email address of the client. */
1651 email: string;
1652 /** Name of the client. */
1653 name: string;
1654 /** PAN of the client. */
1655 pan: string;
1656}
1657/** Limits for equity/commodity fund. */
1658interface Fund {
1659 /** Limit at start of the day. */
1660 start: number;
1661 /** Fund Transfer. */
1662 deposits: number;
1663 /** Realized Profit and Loss. */
1664 realizedReturns: number;
1665 /** Collaterals. */
1666 collaterals: number;
1667 /** Adhoc Limit. */
1668 adhoc: number;
1669 /** Utilized Amount. */
1670 utilized: number;
1671 /** Receivables. */
1672 receivables: number;
1673 /** Available Balance. */
1674 available: number;
1675 /** Clear Balance. */
1676 clear: number;
1677 /** Total Balance. */
1678 total: number;
1679}
1680/** Balance available for the user for capital as well as the commodity market. */
1681interface Funds {
1682 /** Fund limits for capital market. */
1683 equity: Fund;
1684 /** Fund limits for commodity market. */
1685 commodity: Fund;
1686}
1687/** Details of each holding. */
1688interface Holding {
1689 /** 12-digit International Securities Identification Number. */
1690 isin: string;
1691 /** Eg: NSE:RCOM-EQ. */
1692 symbol: string;
1693 /** A unique identifier for every symbol. */
1694 token: string;
1695 /** The exchange in which order is placed. */
1696 exchange: Exchange;
1697 /** Identify the type of holding. */
1698 type: HoldingType;
1699 /** The quantity of the symbol which the user has at the beginning of the day. */
1700 quantity: number;
1701 /** This reflects the quantity - the quantity sold during the day. */
1702 remainingQuantity: number;
1703 /** The original buy price of the holding. */
1704 buyPrice: number;
1705 /** The original buy value of the holding. */
1706 buyValue: number;
1707 /** LTP is the price from which the next sale of the stocks happens. */
1708 currentPrice: number;
1709 /** The Market value of the current holding. */
1710 currentValue: number;
1711 /** Profit and loss made. */
1712 returns: number;
1713 /** Profit and loss percent made. */
1714 returnsPercent: number;
1715}
1716/** Overall status of holdings in this demat account. */
1717interface HoldingsOverall {
1718 /** Total number of holdings present. */
1719 count: number;
1720 /** Total number of settled holdings (HLD). */
1721 settledCount: number;
1722 /** Invested amount for the current holdings. */
1723 investedValue: number;
1724 /** The present value of the holdings. */
1725 currentValue: number;
1726 /** Total profit and loss made. */
1727 returns: number;
1728 /** Percentage value of the total pnl. */
1729 returnsPercent: number;
1730}
1731/** Equity and mutual fund holdings which the user has in this demat account. */
1732interface Holdings {
1733 /** Details of each holding. */
1734 details: Holding[];
1735 /** Overall status of holdings in this demat account. */
1736 overall: HoldingsOverall;
1737}
1738/** Order placed by the user in the current trading day. */
1739interface Order {
1740 /** The order id assigned for each order. */
1741 id: string;
1742 /** The symbol for which order is placed. */
1743 symbol: string;
1744 /** A unique identifier for every symbol. */
1745 token: string;
1746 /** The name of symbol for which order is placed. */
1747 name: string;
1748 /** The exchange in which order is placed. */
1749 exchange: Exchange;
1750 /** Short name for the symbol Eg: “SBIN-EQ”. */
1751 description?: string;
1752 /** The segment this order is placed in. */
1753 segment: Segment;
1754 /** Exchange instrument type. */
1755 instrument: InstrumentType;
1756 /** The type of order. */
1757 type: OrderType;
1758 /** The order is buy or sell. */
1759 side: OrderSide;
1760 /** The product type. */
1761 productType: ProductType;
1762 /** Source from where the order was placed. */
1763 source: OrderSource;
1764 /** The status of the order. */
1765 status: OrderStatus;
1766 /** True when placing AMO order. */
1767 offline: boolean;
1768 /** The limit price for the order. */
1769 limitPrice: number;
1770 /** The stop price for the order. */
1771 stopPrice: number;
1772 /** The original order qty. */
1773 quantity: number;
1774 /** The remaining qty. */
1775 remainingQuantity: number;
1776 /** The filled qty after partial trades. */
1777 tradedQuantity: number;
1778 /** Disclosed quantity. */
1779 disclosedQuantity: number;
1780 /** Remaining disclosed quantity. */
1781 remainingDisclosedQuantity: number;
1782 /** Day or IOC. */
1783 validity: OrderValidity;
1784 /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */
1785 date: string;
1786 /** The parent order id will be provided only for applicable orders. */
1787 parentId?: string;
1788 /** Price change from previous trading day. */
1789 priceChange: number;
1790 /** Percent price change from previous trading day. */
1791 priceChangePercent: number;
1792 /** Last price of symbol. */
1793 currentPrice: number;
1794 /** The average traded price for the order. */
1795 tradedPrice: number;
1796 /** The error messages are shown here. */
1797 message: string;
1798 /** PAN of the client. */
1799 pan: string;
1800 /** The client id of the fyers user. */
1801 clientId: string;
1802}
1803/** Overall status of orders for the current trading day. */
1804interface OrdersOverall {
1805 /** Total number of orders present. */
1806 count: number;
1807 /** Total number of open orders. */
1808 openCount: number;
1809 /** Total number of closed orders. */
1810 closedCount: number;
1811 /** The original order qty. */
1812 quantity: number;
1813 /** The remaining qty. */
1814 remainingQuantity: number;
1815 /** The filled qty after partial trades. */
1816 tradedQuantity: number;
1817 /** Disclosed quantity. */
1818 disclosedQuantity: number;
1819 /** Remaining disclosed quantity. */
1820 remainingDisclosedQuantity: number;
1821}
1822/** All the orders placed by the user in the current trading day. */
1823interface Orders {
1824 /** List of all orders places during the day. */
1825 details: Order[];
1826 /** Overall status of orders. */
1827 overall: OrdersOverall;
1828}
1829/** Current open and closed position for the current trading day. */
1830interface Position {
1831 /** The unique value for each position. */
1832 id: string;
1833 /** Eg: NSE:SBIN-EQ. */
1834 symbol: string;
1835 /** A unique identifier for every symbol. */
1836 token: string;
1837 /** The segment in which the position is taken. */
1838 segment: Segment;
1839 /** The product type of the position. */
1840 productType: ProductType;
1841 /** The side shows whether the position is long / short. */
1842 side: PositionSide;
1843 /** Absolute value of net qty. */
1844 quantity: number;
1845 /** Incase of commodity positions, this multiplier is required for p&l calculation. */
1846 quantityMultiplier: number;
1847 /** Average buy price. */
1848 buyPrice: number;
1849 /** Total buy qty. */
1850 buyQuantity: number;
1851 /** Total buy value. */
1852 buyValue: number;
1853 /** Average sell price. */
1854 sellPrice: number;
1855 /** Total sell qty. */
1856 sellQuantity: number;
1857 /** Total sell value. */
1858 sellValue: number;
1859 /** Net average price. */
1860 netPrice: number;
1861 /** Net qty. */
1862 netQuantity: number;
1863 /** The total p&l of the position. */
1864 returns: number;
1865 /** The realized p&l of the position. */
1866 realizedReturns: number;
1867 /** The unrealized p&l of the open position. */
1868 unrealizedReturns: number;
1869 /** Is it a cross currency position? */
1870 crossCurrency: boolean;
1871 /** Incase of cross currency position, the rbi reference rate will be required to calculate the p&l. */
1872 rbiRefRate: number;
1873 /** LTP is the price from which the next sale of the stocks happens. */
1874 currentPrice: number;
1875}
1876/** Overall status of positions for the current trading day. */
1877interface PositionsOverall {
1878 /** Total number of positions present. */
1879 count: number;
1880 /** Total number of positions opened. */
1881 openCount: number;
1882 /** Total number of positions closed. */
1883 closedCount: number;
1884 /** Total buy value. */
1885 buyValue: number;
1886 /** Total sell value. */
1887 sellValue: number;
1888 /** Total profit and losses. */
1889 returns: number;
1890 /** Profit and losses when the owned product is sold. */
1891 realizedReturns: number;
1892 /** Profit and loses when the product is owned, but is not sold. */
1893 unrealizedReturns: number;
1894}
1895/** Current open and closed positions for the current trading day. */
1896interface Positions {
1897 /** List of all positions for the current trading day. */
1898 details: Position[];
1899 /** Overall status of positions for the current trading day. */
1900 overall: PositionsOverall;
1901}
1902/** Trade for the current day across all platforms and exchanges in the current trading day. */
1903interface Trade {
1904 /** The unique id to sort the trades. */
1905 id: string;
1906 /** The order id for which the trade occurred. */
1907 orderId: string;
1908 /** Eg: NSE:SBIN-EQ. */
1909 symbol: string;
1910 /** A unique identifier for every symbol. */
1911 token: string;
1912 /** The segment in which order is placed. */
1913 segment: Segment;
1914 /** The exchange in which order is placed. */
1915 exchange: Exchange;
1916 /** The trade is buy or sell. */
1917 side: OrderSide;
1918 /** The product in which the order was placed. */
1919 productType: ProductType;
1920 /** The type of order. */
1921 orderType: OrderType;
1922 /** The time when the trade occured in “DD-MM-YYYY hh:mm:ss” format in IST. */
1923 orderDate: string;
1924 /** The traded price. */
1925 price: number;
1926 /** The total traded qty. */
1927 quantity: number;
1928 /** The total traded value. */
1929 value: number;
1930 /** Client id. */
1931 clientId: string;
1932}
1933/** Overall trades for the current trading day. */
1934interface TradesOverall {
1935 /** Total number of trades. */
1936 count: number;
1937 /** The total traded qty. */
1938 quantity: number;
1939 /** The total traded value. */
1940 value: number;
1941}
1942/** All the trades for the current day across all platforms and exchanges in the current trading day. */
1943interface Trades {
1944 /** List of all trades for the current trading day. */
1945 details: Trade[];
1946 /** Overall trades for the current trading day. */
1947 overall: TradesOverall;
1948}
1949/** Defines an order to any exchange via Fyers. */
1950interface PlaceOrder {
1951 /** Eg: NSE:SBIN-EQ. */
1952 symbol: string;
1953 /** The type of order. */
1954 type?: OrderType;
1955 /** The order is buy or sell. */
1956 side?: OrderSide;
1957 /** The product in which the order was placed. */
1958 productType?: ProductType;
1959 /** Provide valid price for Limit and Stoplimit orders. */
1960 limitPrice?: number;
1961 /** Provide valid price for Stop and Stoplimit orders. */
1962 stopPrice?: number;
1963 /** The quantity should be in multiples of lot size for derivatives. */
1964 quantity: number;
1965 /** Allowed only for Equity. */
1966 disclosedQuantity?: number;
1967 /** Day or IOC. */
1968 validity?: OrderValidity;
1969 /** True when placing AMO order. */
1970 offline?: boolean;
1971 /** Provide valid price for CO and BO orders. */
1972 stopLoss?: number;
1973 /** Provide valid price for BO orders. */
1974 takeProfit?: number;
1975}
1976/** Defines an order modification request to Fyers. */
1977interface ModifyOrder {
1978 /** The order id assigned for each order. */
1979 id: string;
1980 /** The type of order. */
1981 type: OrderType;
1982 /** The original order qty. */
1983 quantity?: number;
1984 /** Disclosed quantity. */
1985 disclosedQuantity?: number;
1986 /** The limit price for the order. */
1987 limitPrice?: number;
1988 /** The stop price for the order. */
1989 stopPrice?: number;
1990}
1991/** Defines a convert position request to Fyers. */
1992interface ConvertPosition {
1993 /** Mandatory. Eg: 119031547242. */
1994 symbol: string;
1995 /** The side shows whether the position is long / short. */
1996 side?: PositionSide;
1997 /** Quantity to be converted. Has to be in multiples of lot size for derivatives. */
1998 quantity: number;
1999 /** Existing productType (CNC positions cannot be converted). */
2000 fromProductType?: ProductType;
2001 /** The new product type. */
2002 toProductType?: ProductType;
2003}
2004/** Current market status of an exchange's segment. */
2005interface MarketStatus {
2006 /** The exchange in which the position is taken. */
2007 exchange: Exchange;
2008 /** The segment in which the position is taken. */
2009 segment: Segment;
2010 /** TODO: The type of market: NL, MS, ES, ... */
2011 type: string;
2012 /** TODO: Market status: OPEN, CLOSE. */
2013 status: string;
2014}
2015/** Overall status of market segments. */
2016interface MarketsStatusOverall {
2017 /** Total number of market segments. */
2018 count: number;
2019 /** Total number of open market segments. */
2020 openCount: number;
2021 /** Total number of closed market segments. */
2022 closedCount: number;
2023}
2024/** Market status of all the exchanges and their segments. */
2025interface MarketsStatus {
2026 /** List of statuses of various market segments. */
2027 details: MarketStatus[];
2028 /** Overall status of market segments. */
2029 overall: MarketsStatusOverall;
2030}
2031/** Request for getting market history of a symbol. */
2032interface GetMarketHistory {
2033 /** Eg: NSE:RCOM-EQ. */
2034 symbol: string;
2035 /** The candle resolution in minutes. */
2036 resolution: number;
2037 /** Indicating the start date of records (epoch, yyyy-mm-dd). */
2038 fromDate: number;
2039 /** Indicating the end date of records. */
2040 toDate: number;
2041 /** Set cont flag 1 for continues data and future options. */
2042 continuous: boolean;
2043}
2044/** Candle in market history, quotes. */
2045interface Candle {
2046 /** UNIX epoch time. */
2047 date: number;
2048 /** Open price. */
2049 openPrice: number;
2050 /** High price. */
2051 highPrice: number;
2052 /** Low price. */
2053 lowPrice: number;
2054 /** Previous Close price. */
2055 closePrice: number;
2056 /** Volume. */
2057 volume: number;
2058}
2059/** Overall market history details. */
2060interface MarketHistoryOverall {
2061 /** Start UNIX epoch time. */
2062 fromDate: number;
2063 /** Stop UNIX epoch time. */
2064 toDate: number;
2065 /** Open price. */
2066 openPrice: number;
2067 /** High price. */
2068 highPrice: number;
2069 /** Low price. */
2070 lowPrice: number;
2071 /** Close price. */
2072 closePrice: number;
2073 /** Volume. */
2074 volume: number;
2075}
2076/** Market history of a particular stock. */
2077interface MarketHistory {
2078 /** List of candes. */
2079 details: Candle[];
2080 /** Overall status of market history. */
2081 overall: MarketHistoryOverall;
2082}
2083/** Market quote details for a particular symbol. */
2084interface MarketQuote {
2085 /** Symbol name provided by the user. */
2086 symbol: string;
2087 /** A unique identifier for every symbol. */
2088 token: string;
2089 /** Short name for the symbol Eg: “SBIN-EQ”. */
2090 name: string;
2091 /** Name of the exchange. Eg: “NSE” or “BSE”. */
2092 exchange: Exchange;
2093 /** Description of the symbol. */
2094 description?: string;
2095 /** Today’s time. */
2096 date: number;
2097 /** Last traded price. */
2098 currentPrice: number;
2099 /** Price at market opening time. */
2100 openPrice: number;
2101 /** Highest price for the day. */
2102 highPrice: number;
2103 /** Lowest price for the day. */
2104 lowPrice: number;
2105 /** Close price of the previous trading day. */
2106 closePrice: number;
2107 /** Volume traded. */
2108 volume: number;
2109 /** Change value. */
2110 priceChange: number;
2111 /** Percentage of change between the current value and the previous day's market close. */
2112 priceChangePercent: number;
2113 /** Current time, open, high, low price and volume with HH:MM timestamp. */
2114 candle: Candle;
2115 /** Asking price for the symbol. */
2116 sellPrice: number;
2117 /** Bidding price for the symbol. */
2118 buyPrice: number;
2119 /** Difference between lowest asking and highest bidding price. */
2120 priceSpread: number;
2121}
2122/** Open buy/sell orders at a particular price. */
2123interface MarketOffer {
2124 /** Bid/ask price. */
2125 price: number;
2126 /** Bid/ask volume. */
2127 volume: number;
2128 /** Orders? */
2129 orders: number;
2130}
2131/** A measure of the supply and demand for a symbol. */
2132interface MarketDepth {
2133 /** Symbol name provided by the user. */
2134 symbol: string;
2135 /** A unique identifier for every symbol. */
2136 token: string | null;
2137 /** Short name for the symbol Eg: “SBIN-EQ”. */
2138 name: string;
2139 /** Name of the exchange. Eg: “NSE” or “BSE”. */
2140 exchange: Exchange;
2141 /** Expiry date. */
2142 expiryDate: string;
2143 /** Last traded price. */
2144 currentPrice: number;
2145 /** Lower circuit price. */
2146 lowerCircuitPrice: number;
2147 /** Upper circuit price. */
2148 upperCircuitPrice: number;
2149 /** Price at market opening time. */
2150 openPrice?: number;
2151 /** Highest price for the day. */
2152 highPrice?: number;
2153 /** Lowest price for the day. */
2154 lowPrice?: number;
2155 /** Price at the of market closing. */
2156 closePrice?: number;
2157 /** Volume traded. */
2158 volume?: number;
2159 /** Change value. */
2160 priceChange: number;
2161 /** Percentage of change between the current value and the previous day's market close. */
2162 priceChangePercent: number;
2163 /** Open interest. */
2164 openInterest: number;
2165 /** Previous day open interest. */
2166 previousOpenInterest: number;
2167 /** Change in open Interest percentage. */
2168 openInterestChangePercent: number;
2169 /** Last traded time. */
2170 tradedDate: number;
2171 /** Last traded quantity. */
2172 tradedQuantity: number;
2173 /** Average traded price. */
2174 netPrice: number;
2175 /** Total buying quantity. */
2176 buyQuantity: number;
2177 /** Total selling quantity. */
2178 sellQuantity: number;
2179 /** Bidding price along with volume and total number of orders. */
2180 buyOffers: MarketOffer[];
2181 /** Offer price with volume and total number of orders. */
2182 sellOffers: MarketOffer[];
2183}
2184/** Details of an e-DIS transaction. */
2185interface EdisTransaction {
2186 /** Transaction id. */
2187 id: string;
2188 /** ISIN code of stock. */
2189 isin: string;
2190 /** Quantity to transact. */
2191 quantity: number;
2192 /** Quantity already transacted? */
2193 remainingQuantity: number;
2194 /** Transaction create date-time/ */
2195 entryDate: string;
2196 /** Transaction processing start date? */
2197 startDate: string;
2198 /** Transaction processing end date? */
2199 endDate: string;
2200 /** Source of transaction. */
2201 source: string;
2202 /** SUCCESS, FAILURE? */
2203 status: string;
2204 /** Unique client code? */
2205 clientId: string;
2206 /** Error code (NA). */
2207 errorCode: string;
2208 /** Error count (0). */
2209 errorCount: string;
2210 /** Message. */
2211 reason: string;
2212}
2213/** Overall status of e-DIS transaction in this demat account. */
2214interface EdisTransactionsOverall {
2215 /** Total number of transactions. */
2216 count: number;
2217 /** Quantity to transact. */
2218 quantity: number;
2219 /** Quantity already transacted? */
2220 remainingQuantity: number;
2221}
2222/** Details of all e-DIS transactions. */
2223interface EdisTransactions {
2224 /** List of e-DIS transactions. */
2225 details: EdisTransaction[];
2226 /** Overall status of transactions. */
2227 overall: EdisTransactionsOverall;
2228}
2229/** e-DIS securities held in a demat account. */
2230interface EdisHolding {
2231 /** 12-digit alphanumeric code of specific symbol. */
2232 isin: string;
2233 /** Quantity of securities held. */
2234 quantity: number;
2235}
2236/** Order update notification from WebSocket. */
2237interface OrderUpdateNotification {
2238 /** The unique order id assigned for each order. */
2239 id: string;
2240 /** The symbol for which order is placed. */
2241 symbol: string;
2242 /** A unique identifier for every symbol. */
2243 token: string;
2244 /** The type of order. */
2245 type: OrderType;
2246 /** The order is buy or sell. */
2247 side: OrderSide;
2248 /** The product type. */
2249 productType: ProductType;
2250 /** The status of the order. */
2251 status: OrderStatus;
2252 /** Day or IOC. */
2253 validity: OrderValidity;
2254 /** True when placing AMO order. */
2255 offline: boolean;
2256 /** The original order qty. */
2257 quantity: number;
2258 /** The remaining qty. */
2259 remainingQuantity: number;
2260 /** The filled qty after partial trades. */
2261 filledQuantity: number;
2262 /** Disclosed quantity. */
2263 disclosedQuantity: number;
2264 /** Remaining disclosed quantity. */
2265 remainingDisclosedQuantity: number;
2266 /** The limit price for the order. */
2267 limitPrice: number;
2268 /** The stop price for the order. */
2269 stopPrice: number;
2270 /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */
2271 date: string;
2272 /** The parent order id will be provided only for applicable orders. */
2273 parentId?: string;
2274 /** The average traded price for the order. */
2275 tradedPrice: number;
2276 /** The error messages are shown here. */
2277 message: string;
2278}
2279/** Market quote notification from WebSocket. */
2280interface MarketQuoteNotification {
2281 /** The symbol for which order is placed. */
2282 symbol?: string;
2283 /** A unique identifier for every symbol. */
2284 token: string;
2285 /** Short name for the symbol Eg: “SBIN-EQ”. */
2286 name: string | null;
2287 /** Name of the exchange. Eg: “NSE” or “BSE”. */
2288 exchange: Exchange | null;
2289 /** Timestamp sent by exchange (UNIX epoch). */
2290 date: number;
2291 /** Market status flag? */
2292 marketStatus: number;
2293 /** LTP is the price from which the next sale of the stocks happens. */
2294 currentPrice: number;
2295 /** Price at market opening time. */
2296 openPrice: number;
2297 /** Highest price for the day. */
2298 highPrice: number;
2299 /** Lowest price for the day. */
2300 lowPrice: number;
2301 /** Close price of the previous trading day. */
2302 closePrice: number;
2303 /** Change value. */
2304 priceChange: number;
2305 /** Percentage of change between the current value and the previous day's market close. */
2306 priceChangePercent: number;
2307 /** 1 minute candle. */
2308 candle: Candle;
2309 /** Open interest. */
2310 openInterest: number;
2311 /** Previous day open interest. */
2312 previousOpenInterest: number;
2313 /** Last traded quantity. */
2314 tradedQuantity: number;
2315 /** Last traded time (UNIX epoch). */
2316 tradedDate: number;
2317 /** Average traded price. */
2318 tradedPrice: number;
2319 /** Today's volume. */
2320 volume: number;
2321 /** Total buy quantity. */
2322 buyQuantity: number;
2323 /** Total sell quantity. */
2324 sellQuantity: number;
2325 /** Highest bid price. */
2326 buyPrice: number;
2327 /** Lowest ask price. */
2328 sellPrice: number;
2329 /** Difference between lowest asking and highest bidding price. */
2330 priceSpread: number;
2331}
2332/** Market depth notification from WebSocket. */
2333interface MarketDepthNotification extends MarketQuoteNotification {
2334 /** Bidding price along with volume and total number of orders. */
2335 buyOffers: MarketOffer[];
2336 /** Offer price with volume and total number of orders. */
2337 sellOffers: MarketOffer[];
2338}
2339/** Market depth notification from WebSocket. */
2340interface MarketDataNotification extends MarketDepthNotification {
2341}
2342/**
2343 * Market data notified function.
2344 * @param notification notification
2345 */
2346declare type OnMarketDataNotification = (notification: MarketDataNotification) => void;
2347/**
2348 * Order update notified function.
2349 * @param notification notification
2350 */
2351declare type OnOrderUpdateNotification = (notification: OrderUpdateNotification) => void;
2352/**
2353 * Get equity delivery charges.
2354 * @param side order side (BUY, SELL)
2355 * @param value traded value
2356 * @returns total charges including brokerage and taxes
2357 */
2358declare function equityDeliveryCharges(side: OrderSide, value: number): number;
2359/**
2360 * Get equity intraday charges.
2361 * @param side order side (BUY, SELL)
2362 * @param value traded value
2363 * @returns total charges including brokerage and taxes
2364 */
2365declare function equityIntradayCharges(side: OrderSide, value: number): number;
2366/**
2367 * Get equity futures charges.
2368 * @param side order side (BUY, SELL)
2369 * @param value traded value
2370 * @returns total charges including brokerage and taxes
2371 */
2372declare function equityFuturesCharges(side: OrderSide, value: number): number;
2373/**
2374 * Get equity options charges.
2375 * @param side order side (BUY, SELL)
2376 * @param value traded value
2377 * @returns total charges including brokerage and taxes
2378 */
2379declare function equityOptionsCharges(side: OrderSide, value: number): number;
2380/**
2381 * Get currency futures charges.
2382 * @param side order side (BUY, SELL)
2383 * @param value traded value
2384 * @returns total charges including brokerage and taxes
2385 */
2386declare function currencyFuturesCharges(side: OrderSide, value: number): number;
2387/**
2388 * Get currency options charges.
2389 * @param side order side (BUY, SELL)
2390 * @param value traded value
2391 * @returns total charges including brokerage and taxes
2392 */
2393declare function currencyOptionsCharges(side: OrderSide, value: number): number;
2394/**
2395 * Get commodity futures charges.
2396 * @param side order side (BUY, SELL)
2397 * @param value traded value
2398 * @returns total charges including brokerage and taxes
2399 */
2400declare function commodityFuturesCharges(side: OrderSide, value: number): number;
2401/**
2402 * Get commodity options charges.
2403 * @param side order side (BUY, SELL)
2404 * @param value traded value
2405 * @returns total charges including brokerage and taxes
2406 */
2407declare function commodityOptionsCharges(side: OrderSide, value: number): number;
2408/**
2409 * Get request step 1 for authorization.
2410 * @param appId app_id which you have received after creating the app
2411 * @param redirectUrl where the user will be redirected after login
2412 * @param state same value will be returned after login to the redirect url
2413 * @returns request step 1 for authorization
2414 */
2415declare function loginStep1(appId: string, redirectUrl: string, state?: string): HttpRequestOptions;
2416/**
2417 * Get request step 2 for authorization.
2418 * @param appHash SHA-256 of `api_id:app_secret` in hex
2419 * @param authorizationCode auth_code which is received from the first step
2420 * @returns request step 2 for authorization
2421 */
2422declare function loginStep2(appHash: string, authorizationCode: string): HttpRequestOptions;
2423/**
2424 * Get basic details of the client.
2425 * @param auth authorization \{appId, accessToken\}
2426 * @returns details of user's profile \{id, email, name, ...\}
2427 */
2428declare function getProfile(auth: Authorization): Promise<Profile>;
2429/**
2430 * Get balance available for the user for capital as well as the commodity market.
2431 * @param auth authorization \{appId, accessToken\}
2432 * @returns details of user's funds \{equity: \{start, ...\}, commodity: \{start, ...\}\}
2433 */
2434declare function getFunds(auth: Authorization): Promise<Funds>;
2435/**
2436 * Get the equity and mutual fund holdings which the user has in this demat account.
2437 * @param auth authorization \{appId, accessToken\}
2438 * @returns details of user's holdings \{details: [\{isin, ...\}], overall: \{count, ...\}\}
2439 */
2440declare function getHoldings(auth: Authorization): Promise<Holdings>;
2441/**
2442 * Get details of an order placed in the current trading day.
2443 * @param auth authorization \{appId, accessToken\}
2444 * @param id order id
2445 * @returns details of an order \{id, symbol, ticker, ...\}
2446 */
2447declare function getOrder(auth: Authorization, id: string): Promise<Order>;
2448/**
2449 * Get details of all the orders placed in the current trading day.
2450 * @param auth authorization \{appId, accessToken\}
2451 * @returns details of orders \{details: [\{id, ...\}], overall: \{count, ...\}\}
2452 */
2453declare function getOrders(auth: Authorization): Promise<Orders>;
2454/**
2455 * Get details of all the positions in the current trading day.
2456 * @param auth authorization \{appId, accessToken\}
2457 * @returns details of positions \{details: [\{id, ...\}], overall: \{count, ...\}\}
2458 */
2459declare function getPositions(auth: Authorization): Promise<Positions>;
2460/**
2461 * Get details of all the trades in the current trading day.
2462 * @param auth authorization \{appId, accessToken\}
2463 * @returns details of trades \{details: [\{id, ...\}], overall: \{count, ...\}\}
2464 */
2465declare function getTrades(auth: Authorization): Promise<Trades>;
2466/**
2467 * Place an order to any exchange via Fyers.
2468 * @param auth authorization \{appId, accessToken\}
2469 * @param order details of an order \{symbol, type, side, ...\}
2470 * @returns order id
2471 */
2472declare function placeOrder(auth: Authorization, order: PlaceOrder): Promise<string>;
2473/**
2474 * Place multiple orders to any exchange via Fyers.
2475 * @param auth authorization \{appId, accessToken\}
2476 * @param orders details of multiple orders [\{symbol, type, side, ...\}]
2477 * @returns unique order ids
2478 */
2479declare function placeOrders(auth: Authorization, orders: PlaceOrder[]): Promise<string>[];
2480/**
2481 * Modifies an order placed on any exchange via Fyers.
2482 * @param auth authorization \{appId, accessToken\}
2483 * @param order details of order \{id, type, quantity, ...\}
2484 * @returns order id
2485 */
2486declare function modifyOrder(auth: Authorization, order: ModifyOrder): Promise<string>;
2487/**
2488 * Modifies orders placed on any exchange via Fyers.
2489 * @param auth authorization \{appId, accessToken\}
2490 * @param orders details of orders [\{id, type, quantity, ...\}]
2491 * @returns unique order ids
2492 */
2493declare function modifyOrders(auth: Authorization, orders: ModifyOrder[]): Promise<void>[];
2494/**
2495 * Cancels an order placed on any exchange via Fyers.
2496 * @param auth authorization \{appId, accessToken\}
2497 * @param id order id
2498 * @returns order id
2499 */
2500declare function cancelOrder(auth: Authorization, id: string): Promise<void>;
2501/**
2502 * Cancels orders placed on any exchange via Fyers.
2503 * @param auth authorization \{appId, accessToken\}
2504 * @param ids unique order ids
2505 * @returns unique order ids
2506 */
2507declare function cancelOrders(auth: Authorization, ids: string[]): Promise<void>[];
2508/**
2509 * Exits a position on the current trading day.
2510 * @param auth authorization \{appId, accessToken\}
2511 * @param id position id
2512 */
2513declare function exitPosition(auth: Authorization, id: string): Promise<void>;
2514/**
2515 * Exits all positions on the current trading day.
2516 * @param auth authorization \{appId, accessToken\}
2517 */
2518declare function exitAllPositions(auth: Authorization): Promise<void>;
2519/**
2520 * Converts a position on the current trading day.
2521 * @param auth authorization \{appId, accessToken\}
2522 * @param conversion details of conversion \{symbol, side, quantity, ...\}
2523 */
2524declare function convertPosition(auth: Authorization, conversion: ConvertPosition): Promise<void>;
2525/**
2526 * Get the current market status of all the exchanges and their segments.
2527 * @param auth authorization \{appId, accessToken\}
2528 * @returns markets status \{details: [\{exchange, ...\}], overall: \{count, ...\}\}
2529 */
2530declare function getMarketStatus(auth: Authorization): Promise<MarketsStatus>;
2531/**
2532 * Get the market history for a particular symbol.
2533 * @param auth authorization \{appId, accessToken\}
2534 * @param market market details \{symbol, resolution, fromDate, ...\}
2535 * @returns market history \{details: [\{date, ...\}], overall: \{dateFrom, ...\}\}
2536 */
2537declare function getMarketHistory(auth: Authorization, market: GetMarketHistory): Promise<MarketHistory>;
2538/**
2539 * Get the current market quotes for a set of symbols.
2540 * @param auth authorization \{appId, accessToken\}
2541 * @param symbols list of symbols
2542 * @returns market quotes [\{symbol, name, exchange, ...\}]
2543 */
2544declare function getMarketQuotes(auth: Authorization, symbols: string[]): Promise<MarketQuote[]>;
2545/**
2546 * Get the current market depth for a particular symbol.
2547 * @param auth authorization \{appId, accessToken\}
2548 * @param symbol symbol name
2549 * @returns market depth \{buyQuantity, sellQuantity, buyOffers, ...\}
2550 */
2551declare function getMarketDepth(auth: Authorization, symbol: string): Promise<MarketDepth>;
2552/**
2553 * Get all the latest symbols of all the exchanges from the symbol master files.
2554 * @param auth authorization (unused)
2555 * @param exchange exchange name
2556 * @param segment segment name
2557 * @returns symbol master file as text
2558 */
2559declare function getSymbolMaster(auth: null, exchange: string, segment: string): Promise<string>;
2560/**
2561 * Get details of symbols from the symbol master file text.
2562 * @param csv symbol master file text
2563 * @returns list of symbol details [\{symbol, description, lotSize, ...\}]
2564 */
2565declare function processSymbolMaster(csv: string): SymbolDetails[];
2566/**
2567 * Get details of symbols from the symbol master files.
2568 * @param auth authorization (unused)
2569 * @param exchange exchange name
2570 * @param segment segment name
2571 * @returns list of symbol details [\{symbol, description, lotSize, ...\}]
2572 */
2573declare function loadSymbolMaster(auth: null, exchange: string, segment: string): Promise<SymbolDetails[]>;
2574/**
2575 * Generate e-DIS TPIN for validating/authorising transaction.
2576 * @param auth authorization \{appId, accessToken\}
2577 */
2578declare function generateEdisTpin(auth: Authorization): Promise<void>;
2579/**
2580 * Get the necessary information regarding the holdings you have on your and also the status of the holdings. If the “sell” for the particular holdings is a success or not.
2581 * @param auth authorization \{appId, accessToken\}
2582 * @returns list of e-DIS transactions \{details: [\{id, isin, ...\}], overall: \{count, quantity, ...\}\}
2583 */
2584declare function getEdisTransactions(auth: Authorization): Promise<EdisTransactions>;
2585/**
2586 * 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).
2587 * @param auth authorization \{appId, accessToken\}
2588 * @param holdings holding details [\{isin, quantity\}]
2589 * @returns HTTP(s) request options (manual)
2590 */
2591declare function submitEdisHoldingsStep(auth: Authorization, holdings: EdisHolding[]): HttpRequestOptions;
2592/**
2593 * Inquire the information/status of the provided transaction Id for the respective holdings you have on your end.
2594 * @param auth authorization \{appId, accessToken\}
2595 * @param id transaction id
2596 * @returns edis status
2597 */
2598declare function inquireEdisTransaction(auth: Authorization, id: string): Promise<number>;
2599/**
2600 * Connect to Order update URL with WebSocket.
2601 * @param auth authorization \{appId, accessToken\}
2602 * @param fn notified function
2603 * @returns WebSocket connection
2604 */
2605declare function connectOrderUpdate(auth: Authorization, fn: OnOrderUpdateNotification): Promise<Connection>;
2606/**
2607 * Subscribe to order update.
2608 * @param conn websocket connection
2609 */
2610declare function subscribeOrderUpdate(conn: Connection): Promise<void>;
2611/**
2612 * Unsubscribe to order update.
2613 * @param conn websocket connection
2614 */
2615declare function unsubscribeOrderUpdate(conn: Connection): Promise<void>;
2616/**
2617 * Connect to Market data URL with WebSocket.
2618 * @param auth authorization \{appId, accessToken\}
2619 * @param fn notified function
2620 * @returns WebSocket connection
2621 */
2622declare function connectMarketData(auth: Authorization, fn: OnMarketDataNotification, map?: Map<string, string>): Promise<Connection>;
2623/**
2624 * Subscribe to market quote.
2625 * @param conn websocket connection
2626 * @param symbols list of symbols
2627 */
2628declare function subscribeMarketQuote(conn: Connection, symbols: string[]): Promise<void>;
2629/**
2630 * Subscribe to market depth.
2631 * @param conn websocket connection
2632 * @param symbols list of symbols
2633 */
2634declare function subscribeMarketDepth(conn: Connection, symbols: string[]): Promise<void>;
2635/**
2636 * Unsubscribe to market quote.
2637 * @param conn websocket connection
2638 * @param symbols list of symbols
2639 */
2640declare function unsubscribeMarketQuote(conn: Connection, symbols: string[]): Promise<void>;
2641/**
2642 * Unsubscribe to market depth.
2643 * @param conn websocket connection
2644 * @param symbols list of symbols
2645 */
2646declare function unsubscribeMarketDepth(conn: Connection, symbols: string[]): Promise<void>;
2647/** Stateful interface for FYERS API. */
2648declare class Api implements Authorization {
2649 appId: string;
2650 accessToken: string;
2651 /** Symbol to symbol details map. */
2652 symbolDetails: Map<string, SymbolDetails>;
2653 /** Token to symbol map. */
2654 tokenSymbol: Map<string, string>;
2655 /** Order update notification connection. */
2656 orderUpdateConnection: Promise<Connection>;
2657 /** Market data notification connection. */
2658 marketDataConnection: Promise<Connection>;
2659 /**
2660 * Create a container that stores authorization, symbol maps, and connections (WebSocket).
2661 * @param appId unique app_id received after creating app
2662 * @param accessToken access token for the current trading day recieved after authorization
2663 */
2664 constructor(appId: string, accessToken: string);
2665 /**
2666 * Get request step 1 for authorization.
2667 * @param appId app_id which you have received after creating the app
2668 * @param redirectUrl where the user will be redirected after login
2669 * @param state same value will be returned after login to the redirect url
2670 * @returns request step 1 for authorization
2671 */
2672 static loginStep1(appId: string, redirectUrl: string, state?: string): HttpRequestOptions;
2673 /**
2674 * Get request step 2 for authorization.
2675 * @param appHash SHA-256 of `api_id:app_secret` in hex
2676 * @param authorizationCode auth_code which is received from the first step
2677 * @returns request step 2 for authorization
2678 */
2679 static loginStep2(appHash: string, authorizationCode: string): HttpRequestOptions;
2680 /**
2681 * Get all the latest symbols of all the exchanges from the symbol master files.
2682 * @param exchange exchange name
2683 * @param segment segment name
2684 * @returns symbol master file as text
2685 */
2686 static getSymbolMaster(exchange: string, segment: string): Promise<string>;
2687 /**
2688 * Get basic details of the client.
2689 * @returns details of user's profile \{id, email, name, ...\}
2690 */
2691 getProfile(): Promise<Profile>;
2692 /**
2693 * Get balance available for the user for capital as well as the commodity market.
2694 * @returns details of user's funds \{equity: \{start, ...\}, commodity: \{start, ...\}\}
2695 */
2696 getFunds(): Promise<Funds>;
2697 /**
2698 * Get the equity and mutual fund holdings which the user has in this demat account.
2699 * @returns details of user's holdings \{details: [\{isin, ...\}], overall: \{count, ...\}\}
2700 */
2701 getHoldings(): Promise<Holdings>;
2702 /**
2703 * Get details of an order placed in the current trading day.
2704 * @param id order id
2705 * @returns details of an order \{id, symbol, ticker, ...\}
2706 */
2707 getOrder(id: string): Promise<Order>;
2708 /**
2709 * Get details of all the orders placed in the current trading day.
2710 * @returns details of orders \{details: [\{id, ...\}], overall: \{count, ...\}\}
2711 */
2712 getOrders(): Promise<Orders>;
2713 /**
2714 * Get details of all the positions in the current trading day.
2715 * @returns details of positions \{details: [\{id, ...\}], overall: \{count, ...\}\}
2716 */
2717 getPositions(): Promise<Positions>;
2718 /**
2719 * Get details of all the trades in the current trading day.
2720 * @returns details of trades \{details: [\{id, ...\}], overall: \{count, ...\}\}
2721 */
2722 getTrades(): Promise<Trades>;
2723 /**
2724 * Place an order to any exchange via Fyers.
2725 * @param order details of an order \{symbol, type, side, ...\}
2726 * @returns order id
2727 */
2728 placeOrder(order: PlaceOrder): Promise<string>;
2729 /**
2730 * Place multiple orders to any exchange via Fyers.
2731 * @param orders details of multiple orders [\{symbol, type, side, ...\}]
2732 * @returns unique order ids
2733 */
2734 placeOrders(orders: PlaceOrder[]): Promise<string>[];
2735 /**
2736 * Modifies an order placed on any exchange via Fyers.
2737 * @param order details of order \{id, type, quantity, ...\}
2738 * @returns order id
2739 */
2740 modifyOrder(order: ModifyOrder): Promise<string>;
2741 /**
2742 * Modifies orders placed on any exchange via Fyers.
2743 * @param orders details of orders [\{id, type, quantity, ...\}]
2744 * @returns unique order ids
2745 */
2746 modifyOrders(orders: ModifyOrder[]): Promise<void>[];
2747 /**
2748 * Cancels an order placed on any exchange via Fyers.
2749 * @param id order id
2750 * @returns order id
2751 */
2752 cancelOrder(id: string): Promise<void>;
2753 /**
2754 * Cancels orders placed on any exchange via Fyers.
2755 * @param ids unique order ids
2756 * @returns unique order ids
2757 */
2758 cancelOrders(ids: string[]): Promise<void>[];
2759 /**
2760 * Exits a position on the current trading day.
2761 * @param id position id
2762 * @returns position status
2763 */
2764 exitPosition(id: string): Promise<void>;
2765 /**
2766 * Exits all positions on the current trading day.
2767 * @returns positions status
2768 */
2769 exitAllPositions(): Promise<void>;
2770 /**
2771 * Converts a position on the current trading day.
2772 * @param conversion details of conversion \{symbol, side, quantity, ...\}
2773 * @returns conversion status
2774 */
2775 convertPosition(conversion: ConvertPosition): Promise<void>;
2776 /**
2777 * Get the current market status of all the exchanges and their segments.
2778 * @returns markets status \{details: [\{exchange, ...\}], overall: \{count, ...\}\}
2779 */
2780 getMarketStatus(): Promise<MarketsStatus>;
2781 /**
2782 * Get the market history for a particular symbol.
2783 * @param market market details \{symbol, resolution, fromDate, ...\}
2784 * @returns market history \{details: [\{date, ...\}], overall: \{dateFrom, ...\}\}
2785 */
2786 getMarketHistory(market: GetMarketHistory): Promise<MarketHistory>;
2787 /**
2788 * Get the current market quotes for a set of symbols.
2789 * @param symbols list of symbols
2790 * @returns market quotes [\{symbol, name, exchange, ...\}]
2791 */
2792 getMarketQuotes(symbols: string[]): Promise<MarketQuote[]>;
2793 /**
2794 * Get the current market depth for a particular symbol.
2795 * @param symbol symbol name
2796 * @returns market depth \{buyQuantity, sellQuantity, buyOffers, ...\}
2797 */
2798 getMarketDepth(symbol: string): Promise<MarketDepth>;
2799 /**
2800 * Get details of symbols from the symbol master file text.
2801 * @param csv symbol master file text
2802 * @returns list of symbol details [\{symbol, description, lotSize, ...\}]
2803 */
2804 processSymbolMaster(csv: string): SymbolDetails[];
2805 /**
2806 * Get details of symbols from the symbol master files.
2807 * @param exchange exchange name
2808 * @param segment segment name
2809 * @returns list of symbol details [\{symbol, description, lotSize, ...\}]
2810 */
2811 loadSymbolMaster(exchange: string, segment: string): Promise<SymbolDetails[]>;
2812 /**
2813 * Generate e-DIS TPIN for validating/authorising transaction.
2814 * @returns optional data
2815 */
2816 generateEdisTpin(): Promise<void>;
2817 /**
2818 * Get the necessary information regarding the holdings you have on your and also the status of the holdings. If the “sell” for the particular holdings is a success or not.
2819 * @returns list of e-DIS transactions \{details: [\{id, isin, ...\}], overall: \{count, quantity, ...\}\}
2820 */
2821 getEdisTransactions(): Promise<EdisTransactions>;
2822 /**
2823 * 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).
2824 * @param holdings holding details [\{isin, quantity\}]
2825 * @returns HTTP(s) request options (manual)
2826 */
2827 submitEdisHoldingsStep(holdings: EdisHolding[]): HttpRequestOptions;
2828 /**
2829 * Inquire the information/status of the provided transaction Id for the respective holdings you have on your end.
2830 * @param id transaction id
2831 * @returns edis status
2832 */
2833 inquireEdisTransaction(id: string): Promise<number>;
2834 /**
2835 * Connect to Order update URL with WebSocket.
2836 * @param fn notified function
2837 * @returns WebSocket connection
2838 */
2839 connectOrderUpdate(fn: OnOrderUpdateNotification): Promise<Connection>;
2840 /**
2841 * Subscribe to order update.
2842 */
2843 subscribeOrderUpdate(): Promise<void>;
2844 /**
2845 * Unsubscribe to order update.
2846 */
2847 unsubscribeOrderUpdate(): Promise<void>;
2848 /**
2849 * Connect to Market data URL with WebSocket.
2850 * @param fn notified function
2851 * @returns WebSocket connection
2852 */
2853 connectMarketData(fn: OnMarketDataNotification): Promise<Connection>;
2854 /**
2855 * Subscribe to market quote.
2856 * @param symbols list of symbols
2857 */
2858 subscribeMarketQuote(symbols: string[]): Promise<void>;
2859 /**
2860 * Subscribe to market depth.
2861 * @param symbols list of symbols
2862 */
2863 subscribeMarketDepth(symbols: string[]): Promise<void>;
2864 /**
2865 * Unsubscribe to market quote.
2866 * @param symbols list of symbols
2867 */
2868 unsubscribeMarketQuote(symbols: string[]): Promise<void>;
2869 /**
2870 * Unsubscribe to market depth.
2871 * @param symbols list of symbols
2872 */
2873 unsubscribeMarketDepth(symbols: string[]): Promise<void>;
2874}
2875
2876export { Api, Authorization, Candle, ConvertPosition, DerivativeType, EdisHolding, EdisTransaction, EdisTransactions, EdisTransactionsOverall, Exchange, Fund, Funds, GetMarketHistory, Holding, HoldingType, Holdings, HoldingsOverall, HttpHeaders, HttpRequestOptions, InstrumentType, LoginStep1Request, LoginStep1Response, LoginStep2Request, LoginStep2Response, MarketDataNotification, MarketDepth, MarketDepthNotification, MarketHistory, MarketHistoryOverall, MarketOffer, MarketQuote, MarketQuoteNotification, MarketStatus, MarketsStatus, MarketsStatusOverall, ModifyOrder, OnMarketDataNotification, OnOrderUpdateNotification, OptionType, Order, OrderSide, OrderSource, OrderStatus, OrderType, OrderUpdateNotification, OrderValidity, Orders, OrdersOverall, PlaceOrder, Position, PositionSide, Positions, PositionsOverall, ProductType, Profile, Segment, SymbolDetails, Trade, Trades, TradesOverall, cancelOrder, cancelOrders, commodityFuturesCharges, commodityOptionsCharges, connectMarketData, connectOrderUpdate, convertPosition, currencyFuturesCharges, currencyOptionsCharges, derivativeType, derivativeTypeDescription, equityDeliveryCharges, equityFuturesCharges, equityIntradayCharges, equityOptionsCharges, exchange, exchangeDescription, exitAllPositions, exitPosition, generateEdisTpin, getEdisTransactions, getFunds, getHoldings, getMarketDepth, getMarketHistory, getMarketQuotes, getMarketStatus, getOrder, getOrders, getPositions, getProfile, getSymbolMaster, getTrades, holdingType, holdingTypeDescription, http_d as http, inquireEdisTransaction, instrumentType, instrumentTypeDescription, loadSymbolMaster, loginStep1, loginStep2, modifyOrder, modifyOrders, optionType, optionTypeDescription, orderSide, orderSideDescription, orderSource, orderSourceDescription, orderStatus, orderStatusDescription, orderType, orderTypeDescription, orderValidity, orderValidityDescription, placeOrder, placeOrders, positionSide, positionSideDescription, processSymbolMaster, productType, productTypeDescription, segment, segmentDescription, submitEdisHoldingsStep, subscribeMarketDepth, subscribeMarketQuote, subscribeOrderUpdate, symbolDerivativeType, symbolDescription, symbolExchange, symbolIsin, symbolLotSize, symbolName, symbolOptionType, symbolSeries, symbolStrikePrice, symbolToken, unsubscribeMarketDepth, unsubscribeMarketQuote, unsubscribeOrderUpdate, websocket_d as websocket };