UNPKG

extra-fyers

Version:

A Javascript interface for FYERS API.

1,238 lines (1,232 loc) 106 kB
/// <reference types="ws" /> import { WebSocket } from 'ws'; /** HTTP(s) header keys and values. */ interface HttpHeaders { [key: string]: string; } /** HTTP(s) request options. */ interface HttpRequestOptions { /** Full URL, inluding protocol and query. */ url: string; /** HTTP(s) method (GET). */ method?: string; /** Body of request (JSON). */ body?: object | null; /** Request headers. */ headers?: HttpHeaders; /** What if we don't get a response? */ timeout?: number; } /** Root URL for API requests. */ declare const API_URL: string; /** Root URL for Data API requests. */ declare const DATA_URL: string; /** Root URL for Symbol master files. */ declare const SYMBOLS_URL: string; /** Common response format. */ interface Response { /** ok / error. */ s: string; /** This is the code to identify specific responses. */ code?: number; /** This is the message to identify the specific error responses. */ message?: string; } /** HTTP data of multi-response. */ interface ProxyResponse<Body> { /** HTTP status code. */ statusCode: number; /** The actual place order reponse. */ body: Body; /** HTTP status description. */ statusDescription: string; } /** Attributes required for authorization of all requests. */ interface Authorization$1 { /** This is the app_id which you have received after creating the app. */ app_id: string; /** This value will be used for all the requests. */ access_token: string; } /** Login step 1 request. */ interface LoginStep1Request$1 { /** This is the app_id which you have received after creating the app. */ client_id: string; /** This is where the user will be redirected after successful login. */ redirect_uri: string; /** This value must always be “code”. */ response_type: string; /** The same value will be returned after successful login to the redirect uri. */ state: string; } /** Login step 1 response. */ interface LoginStep1Response$1 extends Response { /** String value which will be used to generate the access_token. */ auth_code: string; /** This value is returned as is from the first request. */ state: string; } /** Login step 2 request. */ interface LoginStep2Request$1 { /** This value must always be “authorization_code”. */ grant_type: string; /** SHA-256 of `api_id:app_secret` in hex. */ appIdHash: string; /** This is the auth_code which is received from the first step. */ code: string; } /** Login step 2 response. */ interface LoginStep2Response$1 extends Response { /** This value will be used for all the subsequent requests. */ access_token: string; } /** Basic details of the client. */ interface Profile$1 { /** The client id of the fyers user. */ fy_id: string; /** Email address of the client. */ email_id: string; /** Name of the client. */ name: string; /** Display name, if any, provided by the client. */ display_name: string; /** URL link to the user’s profile picture, if any. */ image: string; /** PAN of the client. */ PAN: string; /** Last PIN changed date. */ pin_change_date: string; /** Last password changed date. */ pwd_change_date: string; /** Number of days until the current password expires. */ pwd_to_expire: number; } /** Get profile response. */ interface GetProfileResponse extends Response { /** Basic details of the client. */ data: Profile$1; } /** Limit details for particular fund. */ interface FundLimit { /** Unique identity for particular fund. */ id: number; /** Each title represents a heading of the ledger. */ title: string; /** The amount in the capital ledger for the above-mentioned title. */ equityAmount: number; /** The amount in the commodity ledger for the above-mentioned title. */ commodityAmount: number; } /** Get funds response. */ interface GetFundsResponse extends Response { /** Balance available for the user for capital as well as the commodity market. */ fund_limit: FundLimit[]; } /** Details of each equity or mutual fund holding. */ interface Holding$1 { /** An identifier for this holding. */ id: number; /** Fytoken is a unique identifier for every symbol. */ fytoken: string; /** 12-digit International Securities Identification Number. */ isin: string; /** Eg: NSE:RCOM-EQ. */ symbol: string; /** The exchange in which order is placed. */ exchange: number; /** Identify the type of holding. */ holdingType: string; /** The quantity of the symbol which the user has at the beginning of the day. */ quantity: number; /** This reflects the quantity - the quantity sold during the day. */ remainingQuantity: number; /** The original buy price of the holding. */ costPrice: number; /** The Market value of the current holding. */ marketVal: number; /** LTP is the price from which the next sale of the stocks happens. */ ltp: number; /** Profit and loss made. */ pl: number; } /** Overall status of equity and mutual fund holdings in this demat account. */ interface HoldingsOverall$1 { /** Total number of holdings present. */ count_total: number; /** Invested amount for the current holdings. */ total_investment: number; /** The present value of the holdings. */ total_current_value: number; /** Total profit and loss made. */ total_pl: number; /** Percentage value of the total pnl. */ pnl_perc: number; } /** Equity and mutual fund holdings which the user has in this demat account. */ interface GetHoldingsResponse extends Response { /** Details of each holding. */ holdings: Holding$1[]; /** Overall status of holdings in this demat account. */ overall: HoldingsOverall$1; } /** Order placed by the user in the current trading day. */ interface Order$1 { /** The unique order id assigned for each order. */ id: string; /** The order id provided by the exchange. */ exchOrdId: string; /** The symbol for which order is placed. */ symbol: string; /** Fytoken is a unique identifier for every symbol. */ fytoken: string; /** Short name for the symbol Eg: “SBIN-EQ”. */ ex_sym: string; /** Description of symbol for which order is placed. */ description: string; /** The segment this order is placed in. */ segment: number; /** Exchange instrument type. */ instrument: number; /** The exchange in which order is placed. */ exchange: number; /** The type of order. */ type: number; /** The order is buy or sell. */ side: number; /** The product type. */ productType: string; /** Source from where the order was placed. */ source: string; /** The status of the order. */ status: number; /** The order number and status of the order. */ orderNumStatus: number; /** True when placing AMO order. */ offlineOrder: string; /** The original order qty. */ qty: number; /** The remaining qty. */ remainingQuantity: number; /** The filled qty after partial trades. */ filledQty: number; /** The limit price for the order. */ limitPrice: number; /** The stop price for the order. */ stopPrice: number; /** Disclosed quantity. */ discloseQty: number; /** Remaining disclosed quantity. */ dqQtyRem: number; /** Day or IOC. */ orderValidity: string; /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */ orderDateTime: string; /** The parent order id will be provided only for applicable orders. */ parentId?: string; /** Price change from previous trading day. */ ch: number; /** Percent price change from previous trading day. */ chp: number; /** Last price of symbol. */ lp: number; /** The average traded price for the order. */ tradedPrice: number; /** This is used to sort the orders based on the time. */ slNo: number; /** The error messages are shown here. */ message: string; /** PAN of the client. */ pan: string; /** The client id of the fyers user. */ clientId: string; } /** Get order request. */ interface GetOrderRequest { /** The unique order id assigned for each order. */ id: string; } /** Get orders response. */ interface GetOrdersResponse extends Response { /** List of all orders places during the day. */ orderBook: Order$1[]; } /** Current open/closed position for the current trading day. */ interface Position$1 { /** The unique value for each position. */ id: string; /** Fytoken is a unique identifier for every symbol. */ fytoken: string; /** Eg: NSE:SBIN-EQ. */ symbol: string; /** The segment in which the position is taken. */ segment: number; /** The product type of the position. */ productType: string; /** The side shows whether the position is long / short. */ side: number; /** Absolute value of net qty. */ qty: number; /** Incase of commodity positions, this multiplier is required for p&l calculation. */ qtyMulti_com: number; /** Average buy price. */ buyAvg: number; /** Total buy qty. */ buyQty: number; /** Total buy value. */ buyVal: number; /** Average sell price. */ sellAvg: number; /** Total sell qty. */ sellQty: number; /** Total sell value. */ sellVal: number; /** Net average price. */ netAvg: number; /** Net qty. */ netQty: number; /** Average price (netAvg). */ avgPrice: number; /** The total p&l of the position. */ pl: number; /** The realized p&l of the position. */ realized_profit: number; /** The unrealized p&l of the open position. */ unrealized_profit: number; /** Is it a cross currency position? */ crossCurrency: string; /** Incase of cross currency position, the rbi reference rate will be required to calculate the p&l. */ rbiRefRate: number; /** LTP is the price from which the next sale of the stocks happens. */ ltp: number; /** This is used for sorting of positions. */ slNo: number; } /** Overall status of positions for the current trading day. */ interface PositionsOverall$1 { /** Total number of positions present. */ count_total: number; /** Total number of positions opened. */ count_open: number; /** Total profit and losses. */ pl_total: number; /** Profit and losses when the owned product is sold. */ pl_realized: number; /** Profit and loses when the product is owned, but is not sold. */ pl_unrealized: number; } /** Get postions response. */ interface GetPositionsResponse extends Response { /** List of all positions for the current trading day. */ netPositions: Position$1[]; /** Overall status of positions for the current trading day. */ overall: PositionsOverall$1; } /** Trade in the current trading day. */ interface Trade$1 { /** The unique id to sort the trades. */ id: string; /** The order id for which the trade occurred. */ orderNumber: string; /** The order number provided by the exchange. */ exchangeOrderNo: string; /** The trade number generated by the exchange. */ tradeNumber: string; /** Fytoken is a unique identifier for every symbol. */ fyToken: string; /** Eg: NSE:SBIN-EQ. */ symbol: string; /** The segment in which order is placed. */ segment: number; /** The exchange in which order is placed. */ exchange: number; /** The trade is buy or sell. */ transactionType: number; /** The product in which the order was placed. */ productType: string; /** The type of order. */ orderType: number; /** The time when the trade occured in “DD-MM-YYYY hh:mm:ss” format in IST. */ orderDateTime: string; /** The traded price. */ tradePrice: number; /** The total traded qty. */ tradedQty: number; /** The total traded value. */ tradeValue: number; /** Client id. */ clientId: string; /** ? */ row: number; } /** Get trades response. */ interface GetTradesResponse extends Response { /** List of all trades for the current trading day. */ tradeBook: Trade$1[]; } /** Place order request to an exchange via Fyers. */ interface PlaceOrderRequest { /** Eg: NSE:SBIN-EQ. */ symbol: string; /** The quantity should be in multiples of lot size for derivatives. */ qty: number; /** The type of order. */ type: number; /** The order is buy or sell. */ side: number; /** The product in which the order was placed. */ productType: string; /** Provide valid price for Limit and Stoplimit orders. */ limitPrice?: number; /** Provide valid price for Stop and Stoplimit orders. */ stopPrice?: number; /** Allowed only for Equity. */ disclosedQty?: number; /** Day or IOC. */ validity: string; /** True when placing AMO order. */ offlineOrder: string; /** Provide valid price for CO and BO orders. */ stopLoss?: number; /** Provide valid price for BO orders. */ takeProfit?: number; } /** Place/modify/cancel order reponse. */ interface OrderResponse extends Response { /** The order number of the placed/modified/cancelled order. */ id: string; } /** Place order reponse. */ type PlaceOrderResponse = OrderResponse; /** Place orders response. */ interface PlaceOrdersResponse extends Response { /** List of HTTP data for each order. */ data: ProxyResponse<PlaceOrderResponse>[]; } /** Modify order request to Fyers. */ interface ModifyOrderRequest { /** The unique order id assigned for each order. */ id: string; /** The type of order. */ type: number; /** The original order qty. */ qty?: number; /** Disclosed quantity. */ disclosedQty?: number; /** The limit price for the order. */ limitPrice?: number; /** The stop price for the order. */ stopPrice?: number; } /** Modify order response. */ type ModifyOrderResponse = OrderResponse; /** Modify orders response. */ interface ModifyOrdersResponse extends Response { /** List of HTTP data for each order. */ data: ProxyResponse<ModifyOrderResponse>[]; } /** Cancel order request to any exchange via Fyers. */ interface CancelOrderRequest { /** The order number of the placed order. */ id: string; } /** Cancel order response. */ type CancelOrderResponse = OrderResponse; /** Cancel orders response. */ interface CancelOrdersResponse extends Response { /** List of HTTP data for each order. */ data: ProxyResponse<CancelOrderResponse>[]; } /** Exit position request to Fyers. */ interface ExitPositionRequest { /** Mandatory. Eg: NSE:FCONSUMER-EQ-INTRADAY. */ id: string; } /** Exit all positions response. */ interface ExitAllPositionsResponse extends Response { } /** Exit position response. */ interface ExitPositionResponse extends Response { } /** Convert position request to Fyers. */ interface ConvertPositionRequest { /** Mandatory. Eg: 119031547242. */ symbol: string; /** The side shows whether the position is long / short. */ positionSide: number; /** Quantity to be converted. Has to be in multiples of lot size for derivatives. */ convertQty: number; /** Existing productType (CNC positions cannot be converted). */ convertFrom: string; /** The new product type. */ convertTo: string; } /** Convert position response. */ interface ConvertPositionResponse extends Response { /** Unknown. */ positionDetails?: number; } /** Current market status of an exchange's segment. */ interface MarketStatus$1 { /** The exchange in which the position is taken. */ exchange: number; /** The segment in which the position is taken. */ segment: number; /** The type of market: NL, MS, ES, ... */ market_type: string; /** Market status: OPEN, CLOSE. */ status: string; } /** Market status response for all the exchanges and their segments. */ interface GetMarketStatusResponse extends Response { /** List of statuses of various markets. */ marketStatus: MarketStatus$1[]; } /** Market history request for a symbol. */ interface GetMarketHistoryRequest { /** Eg: NSE:RCOM-EQ. */ symbol: string; /** The candle resolution in minutes. */ resolution: string; /** 0 to enter the epoch value. 1 to enter the date format as yyyy-mm-dd. */ date_format: number; /** Indicating the start date of records (epoch, yyyy-mm-dd). */ range_from: string; /** Indicating the end date of records. */ range_to: string; /** Set cont flag 1 for continues data and future options. */ cont_flag: string; } /** Short candle used with market history [time, open, high, low, close, volume]. */ type ShortCandle = [number, number, number, number, number, number]; /** Market history of a particular stock response. */ interface GetMarketHistoryResponse extends Response { /** List of short candles. */ candles: ShortCandle[]; } /** Market quotes request for one or more symbols. */ interface GetMarketQuotesRequest { /** Eg: NSE:RCOM-EQ, ... */ symbols: string; } /** Candle in market quotes (1 minute). */ interface Candle$1 { /** UNIX expoch time. */ t: number; /** Open price (1 minute). */ o: number; /** High price (1 minute). */ h: number; /** Low price (1 minute). */ l: number; /** Close price (1 minute). */ c: number; /** Volume (1 minute). */ v: number; /** Time, formatted. */ tf: string; } /** Quote details of a particular symbol. */ interface MarketQuoteDetails { /** Change value. */ ch: number; /** Percentage of change between the current value and the previous day's market close. */ chp: number; /** Last traded price. */ lp: number; /** Difference between lowest asking and highest bidding price. */ spread: number; /** Asking price for the symbol. */ ask: number; /** Bidding price for the symbol. */ bid: number; /** Price at market opening time. */ open_price: number; /** Highest price for the day. */ high_price: number; /** Lowest price for the day. */ low_price: number; /** Close price of the previous trading day. */ prev_close_price: number; /** Volume traded. */ volume: number; /** Short name for the symbol Eg: “SBIN-EQ”. */ short_name: string; /** Name of the exchange. Eg: “NSE” or “BSE”. */ exchange: string; /** Description of the symbol. */ description: string; /** Original name of the symbol name provided by the use. */ original_name: string; /** Symbol name provided by the user. */ symbol: string; /** Fytoken is a unique identifier for every symbol. */ fyToken: string; /** Today’s time. */ tt: number; /** Current time, open, high, low price and volume with HH:MM timestamp. */ cmd: Candle$1; } /** Market quote for a particular symbol. */ interface MarketQuote$1 { /** Name of symbol. */ n: string; /** Status (ok). */ s: string; /** Market quote details. */ v: MarketQuoteDetails; } /** Market quotes response. */ interface GetMarketQuotesResponse extends Response { /** List of all market quotes. */ d: MarketQuote$1[]; } /** Market depth details request. */ interface GetMarketDepthRequest { /** Eg: NSE:RCOM-EQ. */ symbol: string; /** Set the ohlcv_flag to 1 to get open, high, low, closing and volume quantity. */ ohlcv_flag: number; } /** Open buy/sell orders at a particular price. */ interface MarketOffer$1 { /** Bid/ask price. */ price: number; /** Bid/ask volume. */ volume: number; /** Number of orders. */ ord: number; } /** A measure of the supply and demand for a symbol. */ interface MarketDepth$1 { /** Total buying quantity. */ totalbuyqty: number; /** Total selling quantity. */ totalsellqty: number; /** Bidding price along with volume and total number of orders. */ bids: MarketOffer$1[]; /** Offer price with volume and total number of orders. */ ask: MarketOffer$1[]; /** Price at market opening time. */ o?: number; /** Highest price for the day. */ h?: number; /** Lowest price for the day. */ l?: number; /** Price at the of market closing. */ c?: number; /** Volume traded. */ v?: number; /** Percentage of change between the current value and the previous day's market close. */ chp: number; /** Change value. */ ch: number; /** Last traded quantity. */ ltq: number; /** Last traded time. */ ltt: number; /** Last traded price. */ ltp: number; /** Average traded price. */ atp: number; /** Lower circuit price. */ lower_ckt: number; /** Upper circuit price. */ upper_ckt: number; /** Expiry date. */ expiry: string; /** Open interest. */ oi: number; /** Boolean flag for OI data, true or false. */ oiflag: false; /** Previous day open interest. */ pdoi: number; /** Change in open Interest percentage. */ oipercent: number; } /** Market depth details response. */ interface GetMarketDepthResponse extends Response { /** Dictionary of all market depth details. */ d: { [symbol: string]: MarketDepth$1; }; } /** Symbol category of master file request. */ interface GetSymbolMasterRequest { /** Name of the exchange (NSE, BSE, MCX). */ exchange: string; /** The segment whose symbols are needed (CM, FO, CD, COM). */ segment: string; } /** e-DIS TPIN generation reponse. */ interface GenerateEdisTpinResponse extends Response { /** Unknown, seen to be empty. */ data: string; } /** Details of an e-DIS transaction. */ interface EdisTransaction$1 { /** Transaction id. */ transactionId: string; /** Internal transaction id. */ internalTxnId: string; /** DP transaction id. */ dpTxnId: string; /** ISIN code of stock. */ isin: string; /** Quantity to transact. */ qty: number; /** Quantity already transacted? */ qtyUtlize: number; /** Transaction create date-time/ */ entryDate: string; /** Transaction processing start date? */ startDate: string; /** Transaction processing end date? */ endDate: string; /** No. of days since transaction create date? */ noOfDays: number; /** Source of transaction. */ source: string; /** SUCCESS, FAILURE? */ status: string; /** Unique client code? */ clientId: string; /** Error code (NA). */ errCode: string; /** Error count (0). */ errorCount: string; /** Message. */ reason: string; } /** e-DIS transaction details response. */ interface GetEdisTransactionsResponse extends Response { /** List of e-DIS transactions. */ data: EdisTransaction$1[] | string; } /** e-DIS securities held in a demat account. */ interface EdisHolding$1 { /** 12-digit alphanumeric code of specific symbol. */ isin_code: string; /** Quantity of securities held. */ qty: number; } /** e-DIS holdings submission request. */ interface SubmitEdisHoldingsRequest { /** Records of holdings of the user. */ recordLst: EdisHolding$1[]; } /** e-DIS transactions status inquiry request. */ interface InquireEdisTransactionRequest { /** Transaction id. */ transactionId: string; } /** e-DIS transaction status counts. */ interface EdisTransactionStatus { /** Failure count. */ FAILED_CNT: number; /** Success count. */ SUCEESS_CNT: number; } /** e-DIS transaction status inquiry response. */ interface InquireEdisTransactionResponse extends Response { /** Depository status data. */ data: EdisTransactionStatus; } /** * Get request step 1 for authorization (browser only). * @param options authorization step 1 details \{client_id, redirect_uri, response_type, state\} * @returns HTTP(s) request options for authorization step 1 (manual) */ declare function loginStep1$1(options: LoginStep1Request$1): HttpRequestOptions; /** * Get request step 2 for authorization (browser, server). * @param options authorization step 2 details \{graph_type, appIdHash, code\} * @returns HTTP(s) request options for authorization step 2 (manual) */ declare function loginStep2$1(options: LoginStep2Request$1): HttpRequestOptions; /** * Get basic details of the client. * @param auth authorization \{app_id, access_token\} * @returns details of user's profile \{fy_id, email_id, name, ...\} */ declare function getProfile$1(auth: Authorization$1): Promise<GetProfileResponse>; /** * Get balance available for the user for capital as well as the commodity market. * @param auth authorization \{app_id, access_token\} * @returns details of user's funds \{fund_limit: [\{id, title, equityAmount, commodityAmount\}]\} */ declare function getFunds$1(auth: Authorization$1): Promise<GetFundsResponse>; /** * Get the equity and mutual fund holdings which the user has in this demat account. * @param auth authorization \{app_id, access_token\} * @returns details of user's holdings \{holdings: \{id, ...\}, overall: \{count_total, ...\}\} */ declare function getHoldings$1(auth: Authorization$1): Promise<GetHoldingsResponse>; /** * Get details of an order placed in the current trading day. * @param auth authorization \{app_id, access_token\} * @param options order query \{id\} * @returns details of an order \{orderBook: [\{id, exchOrdId, symbol, ...\}]\} */ declare function getOrder$1(auth: Authorization$1, options: GetOrderRequest): Promise<GetOrdersResponse>; /** * Get details of all the orders placed in the current trading day. * @param auth authorization \{app_id, access_token\} * @returns details of orders \{orderBook: [\{id, exchOrdId, symbol, ...\}]\} */ declare function getOrders$1(auth: Authorization$1): Promise<GetOrdersResponse>; /** * Get details of all the positions in the current trading day. * @param auth authorization \{app_id, access_token\} * @returns details of positions \{netPositions: \{id, ...\}, overall: \{count_total, ...\}\} */ declare function getPositions$1(auth: Authorization$1): Promise<GetPositionsResponse>; /** * Get details of all the trades in the current trading day. * @param auth authorization \{app_id, access_token\} * @returns details of trades \{tradeBook: [\{id, orderNumber, exchangeOrderNo, ...\}]\} */ declare function getTrades$1(auth: Authorization$1): Promise<GetTradesResponse>; /** * Place an order to any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of an order \{symbol, qty, type, side, ...\} * @returns place status \{id\} */ declare function placeOrder$1(auth: Authorization$1, options: PlaceOrderRequest): Promise<PlaceOrderResponse>; /** * Place multiple orders to any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of multiple orders [\{symbol, qty, type, side, ...\}] * @returns place status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\} */ declare function placeOrders$1(auth: Authorization$1, options: PlaceOrderRequest[]): Promise<PlaceOrdersResponse>; /** * Modify an order placed on any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of order \{id, qty, type, side, ...\} * @returns modify status \{id\} */ declare function modifyOrder$1(auth: Authorization$1, options: ModifyOrderRequest): Promise<ModifyOrderResponse>; /** * Modify orders placed on any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of orders [\{id, qty, type, side, ...\}] * @returns modify status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\} */ declare function modifyOrders$1(auth: Authorization$1, options: ModifyOrderRequest[]): Promise<ModifyOrdersResponse>; /** * Cancel an order placed on any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of order \{id\} * @returns cancel status \{id\} */ declare function cancelOrder$1(auth: Authorization$1, options: CancelOrderRequest): Promise<CancelOrderResponse>; /** * Cancel orders placed on any exchange via Fyers. * @param auth authorization \{app_id, access_token\} * @param options details of orders [\{id\}] * @returns cancel status \{data: [\{statusCode, body: \{id\}, statusDescription\}]\} */ declare function cancelOrders$1(auth: Authorization$1, options: CancelOrderRequest[]): Promise<CancelOrdersResponse>; /** * Exit a position on the current trading day. * @param auth authorization \{app_id, access_token\} * @param options details of position \{id\} * @returns exit status \{\} */ declare function exitPosition$1(auth: Authorization$1, options: ExitPositionRequest): Promise<ExitPositionResponse>; /** * Exit all positions on the current trading day. * @param auth authorization \{app_id, access_token\} * @returns exit status \{\} */ declare function exitAllPositions$1(auth: Authorization$1): Promise<ExitAllPositionsResponse>; /** * Convert a position on the current trading day. * @param auth authorization \{app_id, access_token\} * @param options details of position \{symbol, positionSide, convertQty, ...\} * @returns conversion status \{positionDetails\} */ declare function convertPosition$1(auth: Authorization$1, options: ConvertPositionRequest): Promise<ConvertPositionResponse>; /** * Get the current market status of all the exchanges and their segments. * @param auth authorization \{app_id, access_token\} * @returns market status \{marketStatus: [\{exchange, segment, market_type, status\}]\} */ declare function getMarketStatus$1(auth: Authorization$1): Promise<GetMarketStatusResponse>; /** * Get the current market history for a particular symbol. * @param auth authorization \{app_id, access_token\} * @param options market details \{symbol, resolution, date_format, ...\} * @returns market history \{candles: \[\[time, open, high, low, close, volume\]\]\} */ declare function getMarketHistory$1(auth: Authorization$1, options: GetMarketHistoryRequest): Promise<GetMarketHistoryResponse>; /** * Get the current market quotes for a set of symbols. * @param auth authorization \{app_id, access_token\} * @param options market details \{symbols\} * @returns market quotes \{d: [\{n, s, v: \{ch, chp, lp, spread, ...\}\}]\} */ declare function getMarketQuotes$1(auth: Authorization$1, options: GetMarketQuotesRequest): Promise<GetMarketQuotesResponse>; /** * Get the current market depth for a particular symbol. * @param auth authorization \{app_id, access_token\} * @param options market details \{symbol, ohlcv_flag\} * @returns market depth \{d: \{<symbol>: \{totalbuyqty, totalsellqty, bids\}\}\} */ declare function getMarketDepth$1(auth: Authorization$1, options: GetMarketDepthRequest): Promise<GetMarketDepthResponse>; /** * Get all the latest symbols of all the exchanges from the symbol master files. * @param auth authorization (unused) * @param options details of symbol category \{exchange, segment\} * @returns symbol master file */ declare function getSymbolMaster$1(auth: null, options: GetSymbolMasterRequest): Promise<string>; /** * Generate e-DIS TPIN for validating/authorising transaction. * @param auth authorization \{app_id, access_token\} * @returns optional data \{data\} */ declare function generateEdisTpin$1(auth: Authorization$1): Promise<GenerateEdisTpinResponse>; /** * 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. * @param auth authorization \{app_id, access_token\} * @returns list of e-DIS transactions \{data: [\{transactionId, internalTxnId, ...\}]\} */ declare function getEdisTransactions$1(auth: Authorization$1): Promise<GetEdisTransactionsResponse>; /** * 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). * @param auth authorization \{app_id, access_token\} * @param options holding details \{recordLst: [\{isin_code, qty\}]\} * @returns HTTP(s) request options (manual) */ declare function submitEdisHoldingsStep$1(auth: Authorization$1, options: SubmitEdisHoldingsRequest): HttpRequestOptions; /** * Inquire the information/status of the provided transaction Id for the respective holdings you have on your end. * @param auth authorization \{app_id, access_token\} * @param options transaction details \{transactionId\} * @returns edis status \{FAILED_CNT, SUCEESS_CNT\} */ declare function inquireEdisTransaction$1(auth: Authorization$1, options: InquireEdisTransactionRequest): Promise<InquireEdisTransactionResponse>; declare const http_d_API_URL: typeof API_URL; type http_d_CancelOrderRequest = CancelOrderRequest; type http_d_CancelOrderResponse = CancelOrderResponse; type http_d_CancelOrdersResponse = CancelOrdersResponse; type http_d_ConvertPositionRequest = ConvertPositionRequest; type http_d_ConvertPositionResponse = ConvertPositionResponse; declare const http_d_DATA_URL: typeof DATA_URL; type http_d_EdisTransactionStatus = EdisTransactionStatus; type http_d_ExitAllPositionsResponse = ExitAllPositionsResponse; type http_d_ExitPositionRequest = ExitPositionRequest; type http_d_ExitPositionResponse = ExitPositionResponse; type http_d_FundLimit = FundLimit; type http_d_GenerateEdisTpinResponse = GenerateEdisTpinResponse; type http_d_GetEdisTransactionsResponse = GetEdisTransactionsResponse; type http_d_GetFundsResponse = GetFundsResponse; type http_d_GetHoldingsResponse = GetHoldingsResponse; type http_d_GetMarketDepthRequest = GetMarketDepthRequest; type http_d_GetMarketDepthResponse = GetMarketDepthResponse; type http_d_GetMarketHistoryRequest = GetMarketHistoryRequest; type http_d_GetMarketHistoryResponse = GetMarketHistoryResponse; type http_d_GetMarketQuotesRequest = GetMarketQuotesRequest; type http_d_GetMarketQuotesResponse = GetMarketQuotesResponse; type http_d_GetMarketStatusResponse = GetMarketStatusResponse; type http_d_GetOrderRequest = GetOrderRequest; type http_d_GetOrdersResponse = GetOrdersResponse; type http_d_GetPositionsResponse = GetPositionsResponse; type http_d_GetProfileResponse = GetProfileResponse; type http_d_GetSymbolMasterRequest = GetSymbolMasterRequest; type http_d_GetTradesResponse = GetTradesResponse; type http_d_InquireEdisTransactionRequest = InquireEdisTransactionRequest; type http_d_InquireEdisTransactionResponse = InquireEdisTransactionResponse; type http_d_MarketQuoteDetails = MarketQuoteDetails; type http_d_ModifyOrderRequest = ModifyOrderRequest; type http_d_ModifyOrderResponse = ModifyOrderResponse; type http_d_ModifyOrdersResponse = ModifyOrdersResponse; type http_d_OrderResponse = OrderResponse; type http_d_PlaceOrderRequest = PlaceOrderRequest; type http_d_PlaceOrderResponse = PlaceOrderResponse; type http_d_PlaceOrdersResponse = PlaceOrdersResponse; type http_d_ProxyResponse<Body> = ProxyResponse<Body>; type http_d_Response = Response; declare const http_d_SYMBOLS_URL: typeof SYMBOLS_URL; type http_d_ShortCandle = ShortCandle; type http_d_SubmitEdisHoldingsRequest = SubmitEdisHoldingsRequest; declare namespace http_d { export { http_d_API_URL as API_URL, type Authorization$1 as Authorization, type http_d_CancelOrderRequest as CancelOrderRequest, type http_d_CancelOrderResponse as CancelOrderResponse, type http_d_CancelOrdersResponse as CancelOrdersResponse, type Candle$1 as Candle, type http_d_ConvertPositionRequest as ConvertPositionRequest, type http_d_ConvertPositionResponse as ConvertPositionResponse, http_d_DATA_URL as DATA_URL, type EdisHolding$1 as EdisHolding, type EdisTransaction$1 as EdisTransaction, type http_d_EdisTransactionStatus as EdisTransactionStatus, type http_d_ExitAllPositionsResponse as ExitAllPositionsResponse, type http_d_ExitPositionRequest as ExitPositionRequest, type http_d_ExitPositionResponse as ExitPositionResponse, type http_d_FundLimit as FundLimit, type http_d_GenerateEdisTpinResponse as GenerateEdisTpinResponse, type http_d_GetEdisTransactionsResponse as GetEdisTransactionsResponse, type http_d_GetFundsResponse as GetFundsResponse, type http_d_GetHoldingsResponse as GetHoldingsResponse, type http_d_GetMarketDepthRequest as GetMarketDepthRequest, type http_d_GetMarketDepthResponse as GetMarketDepthResponse, type http_d_GetMarketHistoryRequest as GetMarketHistoryRequest, type http_d_GetMarketHistoryResponse as GetMarketHistoryResponse, type http_d_GetMarketQuotesRequest as GetMarketQuotesRequest, type http_d_GetMarketQuotesResponse as GetMarketQuotesResponse, type http_d_GetMarketStatusResponse as GetMarketStatusResponse, type http_d_GetOrderRequest as GetOrderRequest, type http_d_GetOrdersResponse as GetOrdersResponse, type http_d_GetPositionsResponse as GetPositionsResponse, type http_d_GetProfileResponse as GetProfileResponse, type http_d_GetSymbolMasterRequest as GetSymbolMasterRequest, type http_d_GetTradesResponse as GetTradesResponse, type Holding$1 as Holding, type HoldingsOverall$1 as HoldingsOverall, type http_d_InquireEdisTransactionRequest as InquireEdisTransactionRequest, type http_d_InquireEdisTransactionResponse as InquireEdisTransactionResponse, type LoginStep1Request$1 as LoginStep1Request, type LoginStep1Response$1 as LoginStep1Response, type LoginStep2Request$1 as LoginStep2Request, type LoginStep2Response$1 as LoginStep2Response, type MarketDepth$1 as MarketDepth, type MarketOffer$1 as MarketOffer, type MarketQuote$1 as MarketQuote, type http_d_MarketQuoteDetails as MarketQuoteDetails, type MarketStatus$1 as MarketStatus, type http_d_ModifyOrderRequest as ModifyOrderRequest, type http_d_ModifyOrderResponse as ModifyOrderResponse, type http_d_ModifyOrdersResponse as ModifyOrdersResponse, type Order$1 as Order, type http_d_OrderResponse as OrderResponse, type http_d_PlaceOrderRequest as PlaceOrderRequest, type http_d_PlaceOrderResponse as PlaceOrderResponse, type http_d_PlaceOrdersResponse as PlaceOrdersResponse, type Position$1 as Position, type PositionsOverall$1 as PositionsOverall, type Profile$1 as Profile, type http_d_ProxyResponse as ProxyResponse, type http_d_Response as Response, http_d_SYMBOLS_URL as SYMBOLS_URL, type http_d_ShortCandle as ShortCandle, type http_d_SubmitEdisHoldingsRequest as SubmitEdisHoldingsRequest, type Trade$1 as Trade, cancelOrder$1 as cancelOrder, cancelOrders$1 as cancelOrders, convertPosition$1 as convertPosition, exitAllPositions$1 as exitAllPositions, exitPosition$1 as exitPosition, generateEdisTpin$1 as generateEdisTpin, getEdisTransactions$1 as getEdisTransactions, getFunds$1 as getFunds, getHoldings$1 as getHoldings, getMarketDepth$1 as getMarketDepth, getMarketHistory$1 as getMarketHistory, getMarketQuotes$1 as getMarketQuotes, getMarketStatus$1 as getMarketStatus, getOrder$1 as getOrder, getOrders$1 as getOrders, getPositions$1 as getPositions, getProfile$1 as getProfile, getSymbolMaster$1 as getSymbolMaster, getTrades$1 as getTrades, inquireEdisTransaction$1 as inquireEdisTransaction, loginStep1$1 as loginStep1, loginStep2$1 as loginStep2, modifyOrder$1 as modifyOrder, modifyOrders$1 as modifyOrders, placeOrder$1 as placeOrder, placeOrders$1 as placeOrders, submitEdisHoldingsStep$1 as submitEdisHoldingsStep }; } /** Root URL for Market data notifications. */ declare const MARKET_DATA_URL: string; /** Root URL for Order update notifications. */ declare const ORDER_UPDATE_URL: string; /** Common notification format. */ type Notification = Response; /** Update for order placed by the user in the current trading day. */ interface OrderUpdate { /** The unique order id assigned for each order. */ id: string; /** The order id provided by the exchange. */ exchOrdId: string; /** The symbol for which order is placed. */ symbol: string; /** Fytoken is a unique identifier for every symbol. */ fyToken: string; /** The segment this order is placed in. */ segment: string; /** Exchange instrument type. */ instrument: string; /** The type of order. */ type: number; /** The order is buy or sell. */ side: number; /** The product type. */ productType: string; /** The status of the order. */ status: number; /** The order number and status of the order. */ orderNumStatus: string; /** True when placing AMO order. */ offlineOrder: boolean; /** The original order qty. */ qty: number; /** The remaining qty. */ remainingQuantity: number; /** The filled qty after partial trades. */ filledQty: number; /** The limit price for the order. */ limitPrice: number; /** The stop price for the order. */ stopPrice: number; /** Disclosed quantity. */ discloseQty: number; /** Remaining disclosed quantity. */ dqQtyRem: number; /** Day or IOC. */ orderValidity: string; /** The order time as per DD-MMM-YYYY hh:mm:ss in IST. */ orderDateTime: string; /** The parent order id will be provided only for applicable orders. */ parentId?: string; /** The average traded price for the order. */ tradedPrice: number; /** This is used to sort the orders based on the time. */ slNo: number; /** The error messages are shown here. */ message: string; } /** String notification on order update. */ interface OrderUpdateNotification$1 extends Notification { /** Websocket type [1]. */ ws_type?: number; /** Data for the notification. */ d?: OrderUpdate; } /** Header for each binary message. */ interface Header { /** Fytoken is a unique identifier for every symbol. */ token: BigInt; /** Timestamp sent by exchange (UNIX epoch). */ tt: number; /** 7202: OI data (NSE FO/CD, MCX), 7207/7208: NSE, BSE (indices/data), 31038: MCX. */ fyCode: number; /** Market status flag? */ marketStat: number; /** Packet length, including header? */ pktlen: number; /** Has L2 data (market depth)? */ L2: number; } /** Open interest data (fyCode === 7202). */ interface OiData { /** Open interest. */ oi: number; /** Previous day open interest. */ pdoi: number; } /** Common data (fyCode !== 7202). */ interface CommonData { /** Price conversion, divisor for all prices. */ price_conv: number; /** LTP is the price from which the next sale of the stocks happens. */ ltp: number; /** Price at market opening time. */ open_price: number; /** Highest price for the day. */ high_price: number; /** Lowest price for the day. */ low_price: number; /** Close price of the previous trading day. */ prev_close_price: number; /** Open price (1 minute). */ o: number; /** High price (1 minute). */ h: number; /** Low price (1 minute). */ l: number; /** Close price (1 minute). */ c: number; /** Volume (1 minute). */ v: BigInt; /** Open interest. */ oi: BigInt; /** Previous day open interest. */ pdoi: BigInt; } /** Additional data (fyCode === 7208, 31038). */ interface L1Data { /** Last traded quantity. */ LTQ: number; /** Last traded time (UNIX epoch). */ L2_LTT: number; /** Average traded price. */ ATP: number; /** Today's volume. */ volume: number; /** Total buy quantity. */ tot_buy: BigInt; /** Total sell quantity. */ tot_sell: BigInt; /** Highest bid price. */ bid: number; /** Lowest ask price. */ ask: number; } /** Open buy/sell orders at a particular price (L2 === 1). */ interface L2MarketOffer { /** Bid/ask price. */ price: number; /** Bid/ask volume. */ volume: number; /** Number of orders. */ ord: number; } /** Market depth data, 5 rows (L2 === 1). */ interface L2Data { /** Bidding price along with volume and total number of orders. */ bids: L2MarketOffer[]; /** Offer price with volume and total number of orders. */ asks: L2MarketOffer[]; } /** Market data (oi/quote/depth) for symbols subscribed by the user. */ interface MarketData extends Header, CommonData, L1Data, L2Data { } /** Binary notification on Market data. */ interface MarketDataNotification$1 extends Notification { /** Data for the notification. */ d?: MarketData; } /** * Notified function. * @param notification notification */ type OnNotification = (notification: Notification) => void; /** * Order update notified function. * @param notification notification */ type OnOrderUpdateNotification$1 = (notification: OrderUpdateNotification$1) => void; /** * Market data notified function. * @param notification notification */ type OnMarketDataNotification$1 = (notification: MarketDataNotification$1) => void; /** Handler for reciever which has passed (resolved). */ type OnResolve = (response: Response) => void; /** Handler for reciever which has failed (rejected). */ type OnReject = (error: Error) => void; /** Recieve response to a request, which can pass or fail. */ interface Reciever { /** Pass (resolve) handler for reciever. */ resolve: OnResolve; /** Fail (reject) handler for reciever. */ reject: OnReject; } /** * Provides the API for creating and managing a WebSocket connection to * a server, as well as for sending and receiving data on the connection. */ declare class Connection extends WebSocket { /** To recieve response to a request. */ recievers: Reciever[]; } /** * Connect to Order update URL with WebSocket. * @param auth authorization \{app_id, access_token\} * @param fn notified function * @returns WebSocket connection */ declare function connectOrderUpdate$1(auth: Authorization$1, fn: OnOrderUpdateNotification$1): Promise<Connection>; /** * Subscribe to order update. * @param conn websocket connection */ declare function subscribeOrderUpdate$1(conn: Connection): Promise<Response>; /** * Unsubscribe to order update. * @param conn websocket connection */ declare function unsubscribeOrderUpdate$1(conn: Connection): Promise<Response>; /** * Connect to Market data URL with WebSocket. * @param auth authorization \{app_id, access_token\} * @param fn notified function * @returns WebSocket connection */ declare function connectMarketData$1(auth: Authorization$1, fn: OnMarketDataNotification$1): Promise<Connection>; /** * Subscribe to market quote. * @param conn websocket connection * @param symbols list of symbols */ declare function subscribeMarketQuote$1(conn: Connection, symbols: string[]): Promise<Response>; /** * Subscribe to market depth. * @param conn websocket connection * @param symbols list of symbols */ declare function subscribeMarketDepth$1(conn: Connection, symbols: string[]): Promise<Response>; /** * Unsubscribe to market quote. * @param conn websocket connection * @param symbols list of symbols */ declare function unsubscribeMarketQuote$1(conn: Connection, symbols: string[]): Promise<Response>; /** * Unsubscribe to market depth. * @param conn websocket connection * @param symbols list of symbols */ declare function unsubscribeMarketDepth$1(conn: Connection, symbols: string[]): Promise<Response>; type websocket_d_CommonData = CommonData; type websocket_d_Connection = Connection; declare const websocket_d_Connection: typeof Connection; type websocket_d_Header = Header; type websocket_d_L1Data = L1Data; type websocket_d_L2Data = L2Data; type websocket_d_L2MarketOffer = L2MarketOffer; declare const websocket_d_MARKET_DATA_URL: typeof MARKET_DATA_URL; type websocket_d_MarketData = MarketData; type websocket_d_Notification = Notification; declare const websocket_d_ORDER_UPDATE_URL: typeof ORDER_UPDATE_URL; type websocket_d_OiData = OiData; type websocket_d_OnNotification = OnNotification; type websocket_d_OnReject = OnReject; type websocket_d_OnResolve = OnResolve; type websocket_d_OrderUpdate = OrderUpdate; type websocket_d_Reciever = Reciever; type websocket_d_Response = Response; declare namespace websocket_d { export { type Authorization$1 as Authorization, type websocket_d_CommonData as CommonData, websocket_d_Connection as Connection, type websocket_d_Header as Header, type websocket_d_L1Data as L1Data, type websocket_d_L2Data as L2Data, type websocket_d_L2MarketOffer as L2MarketOffer, websocket_d_MARKET_DATA_URL as MARKET_DATA_URL, type websocket_d_MarketData as MarketData, type MarketDataNotification$1 as MarketDataNotification, type websocket_d_Notification as Notification, websocket_d_ORDER_UPDATE_URL as ORDER_UPDATE_URL, type websocket_d_OiData as OiData, type OnMarketDataNotification$1 as OnMarketDataNotification, type websocket_d_OnNotification as OnNotification, type OnOrderUpdateNotification$1 as OnOrderUpdateNotification, type websocket_d_OnReject as OnReject, type websocket_d_OnResolve as OnResolve, type websocket_d_OrderUpdate as OrderUpdate, type OrderUpdateNotification$1 as OrderUpdateNotification, type websocket_d_Reciever as Reciever, type websocket_d_Response as Response, connectMarketData$1 as connectMarketData, connectOrderUpdate$1 as connectOrderUpdate, subscribeMarketDepth$1 as subscribeMarketDepth, subscribeMarketQuote$1 as subscribeMarketQuote, subscribeOrderUpdate$1 as subscribeOrderUpdate, unsubscribeMarketDepth$1 as unsubscribeMarketDepth, unsubscribeMarketQuote$1 as unsubscribeMarketQuote, unsubscribeOrderUpdate$1 as unsubscribeOrderUpdate }; } /** Exchange code. */ type Exchange = "NSE" | "MCX" | "BSE"; /** * Get exchange description. * @param code exchange code (NSE, MCX, BSE) * @returns exchange description */ declare function exchangeDescription(code: Exchange): string; /** * Get exchange code. * @param desc exchange description * @returns exchange code (NSE,