Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extra-fyers.web

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-fyers.web - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

2

index.js

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).extra_fyers=e()}}((function(){return function e(t,n,r){function i(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return i(t[a][1][e]||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){"use strict";function r(e,t){var n=new Error(t);return n.code=e.status,n.response=null,n}function i(e,t){return null!=t.headers&&(!!t.headers.hasOwnProperty(e)||!!t.headers.hasOwnProperty(e.toLowerCase()))}function o(e,t){return new Promise(((n,o)=>{var a=t.url,u=t.method||"GET",s=!1,c=!1,l=!1,d=new XMLHttpRequest;d.open(u,a),function(e,t){for(var n in null==t.body||i("Content-Type",t)||e.setRequestHeader("Content-Type","application/json; charset=utf-8"),i("Accept",t)||e.setRequestHeader("Accept","application/json, text/*"),t.headers)e.setRequestHeader(n,t.headers[n])}(d,t),t.timeout&&(d.timeout=t.timeout),d.responseType=e,d.onerror=function(e){s=!0;var t=e.target;o(r(t,"Unexpected error occurred"))},d.onabort=function(e){c=!0;var t=e.target;o(r(t,"Request was aborted"))},d.ontimeout=function(e){l=!0;var t=e.target;o(r(t,"Request timed out"))},d.onreadystatechange=function(t){if(!(s||c||l)){var r=t.target;if(function(e){return e.readyState===e.DONE}(r))try{var i=function(e,t){if("json"===t){if(!e.responseType)try{return JSON.parse(e.responseText)}catch(e){return null}}else if((!t||"text"===t)&&null==e.response)return e.responseText;return e.response}(r,e);!function(e,t=""){return e.status>=200&&e.status<300||304===e.status||/^file:\/\//i.test(t)}(r,a)?setTimeout((function(){s||c||l||o(function(e,t){var n=null;try{n=e.responseText}catch(e){n=t}var r=new Error(n);return r.code=e.status,r.response=t,r}(r,i))})):n(i)}catch(t){o(t)}}},null==t.body?d.send():t.body instanceof FormData||t.body instanceof URLSearchParams?d.send(t.body):d.send(JSON.stringify(t.body))}))}Object.defineProperty(n,"__esModule",{value:!0});const a="https://api.fyers.in/api/v2/",u="https://api.fyers.in/data-rest/v2/",s="https://public.fyers.in/sym_details/";function c(e,t,n,r,i){var o=n+function(e){if(null==e)return"";var t=new URLSearchParams;for(var n in e)t.append(n,e[n]);return"?"+t.toString()}(r),a={};return null!=e&&(a.authorization=e.app_id+":"+e.access_token),{url:o,method:t,headers:a,body:i}}function l(e,t,n,r,i){return o("text",c(e,t,n,r,i))}function d(e,t,n,r,i){return o("json",c(e,t,n,r,i))}function p(e,t,n,r,i){return d(e,t,a+n,r,i)}function y(e,t,n,r,i){return d(e,t,u+n,r,i)}function f(e){return c(null,"GET",a+"generate-authcode",e,null)}function m(e){return c(null,"POST",a+"validate-authcode",null,e)}function g(e){return p(e,"GET","profile",null,null)}function T(e){return p(e,"GET","funds",null,null)}function h(e){return p(e,"GET","holdings",null,null)}function v(e,t){return p(e,"GET","orders",t,null)}function b(e){return p(e,"GET","orders",null,null)}function P(e){return p(e,"GET","positions",null,null)}function S(e){return p(e,"GET","tradebook",null,null)}function E(e,t){return p(e,"POST","orders",null,t)}function C(e,t){return p(e,"POST","orders-multi",null,t)}function D(e,t){return p(e,"PUT","orders",null,t)}function U(e,t){return p(e,"PUT","orders-multi",null,t)}function O(e,t){return p(e,"DELETE","orders",null,t)}function I(e,t){return p(e,"DELETE","orders-multi",null,t)}function w(e,t){return p(e,"DELETE","positions",null,t)}function M(e){return p(e,"DELETE","positions",null,{})}function k(e,t){return p(e,"PUT","positions",null,t)}function _(e){return p(e,"GET","market-status",null,null)}function R(e,t){return y(e,"GET","history/",t,null)}function A(e,t){return y(e,"GET","quotes/",t,null)}function L(e,t){return y(e,"GET","depth/",t,null)}function N(e,t){var{exchange:n,segment:r}=t;return function(e,t,n,r,i){return l(e,t,s+n,r,i)}(null,"GET",n+"_"+r+".csv",null,null)}function q(e){return p(e,"GET","tpin",null,null)}function F(e){return p(e,"GET","details",null,null)}function Q(e,t){return c(e,"POST","index",null,t)}function B(e,t){return p(e,"POST","inquiry",null,t)}var x=Object.freeze({__proto__:null,API_URL:a,DATA_URL:u,SYMBOLS_URL:s,loginStep1:f,loginStep2:m,getProfile:g,getFunds:T,getHoldings:h,getOrder:v,getOrders:b,getPositions:P,getTrades:S,placeOrder:E,placeOrders:C,modifyOrder:D,modifyOrders:U,cancelOrder:O,cancelOrders:I,exitPosition:w,exitAllPositions:M,convertPosition:k,getMarketStatus:_,getMarketHistory:R,getMarketQuotes:A,getMarketDepth:L,getSymbolMaster:N,generateEdisTpin:q,getEdisTransactions:F,submitEdisHoldingsStep:Q,inquireEdisTransaction:B});const G=WebSocket,H="wss://api.fyers.in/socket/v2/dataSock",Y="wss://api.fyers.in/socket/v2/orderSock";function V(e,t){return{price:e.getUint32(t+0),volume:e.getUint32(t+4),ord:e.getUint32(t+8)}}function z(e,t,n){!function(e,t,n){e.token=t.getBigUint64(n+0),e.tt=t.getUint32(n+8),e.fyCode=t.getUint16(n+12),e.marketStat=t.getUint16(n+14),e.pktlen=t.getUint16(n+16),e.L2=t.getUint8(n+18)}(e,t,n+0);var r=7202===e.fyCode||31038===e.fyCode,i=r?88:72;7202===e.fyCode?function(e,t,n){e.oi=BigInt(t.getUint32(n+0)),e.pdoi=BigInt(t.getUint32(n+4))}(e,t,n+24):function(e,t,n,r){e.price_conv=t.getUint32(n+0),e.ltp=t.getUint32(n+4),e.open_price=t.getUint32(n+8),e.high_price=t.getUint32(n+12),e.low_price=t.getUint32(n+16),e.prev_close_price=t.getUint32(n+20),e.o=t.getUint32(n+24),e.h=t.getUint32(n+28),e.l=t.getUint32(n+32),e.c=t.getUint32(n+36),e.v=t.getBigUint64(n+40),r&&(e.oi=t.getBigUint64(n+48),e.pdoi=t.getBigUint64(n+56))}(e,t,n+24,r),7208!==e.fyCode&&31038!==e.fyCode||function(e,t,n,r){e.LTQ=t.getUint32(n+0),e.L2_LTT=t.getUint32(n+4),e.ATP=t.getUint32(n+8),e.volume=t.getUint32(n+12),e.tot_buy=t.getBigUint64(n+16),e.tot_sell=t.getBigUint64(n+24),r&&(e.bid=t.getUint32(n+32),e.ask=t.getUint32(n+36))}(e,t,n+i,1!==e.L2),1===e.L2&&function(e,t,n){for(var r=[],i=[],o=0;o<60;o+=12)r.push(V(t,n+o)),i.push(V(t,n+o+60));e.bids=r,e.asks=i}(e,t,n+i+32)}function X(e,t){var n={token:BigInt(0),tt:0,fyCode:0,marketStat:0,pktlen:0,L2:0,price_conv:0,ltp:0,open_price:0,high_price:0,low_price:0,prev_close_price:0,o:0,h:0,l:0,c:0,v:BigInt(0),oi:BigInt(0),pdoi:BigInt(0),LTQ:0,L2_LTT:0,ATP:0,volume:0,tot_buy:BigInt(0),tot_sell:BigInt(0),bid:0,ask:0,bids:null,asks:null};return z(n,e,t),n}class K extends G{constructor(){super(...arguments),this.recievers=[]}}function $(e){return new Promise(((t,n)=>e.recievers.push({resolve:t,reject:n})))}function j(e,t){return new Promise(((n,r)=>{var{app_id:i,access_token:o}=e,a=new K(`${Y}?${`user-agent=fyers-api&type=orderUpdate&access_token=${i}:${o}`}`),u=setInterval((()=>{a.readyState===G.OPEN&&a.send("ping")}),5e3);a.binaryType="arraybuffer",a.onerror=e=>{for(var t of a.recievers)t.reject(e.error);clearInterval(u),r(e.error)},a.onopen=()=>n(a),a.onmessage=e=>{if("string"==typeof e.data&&"pong"!==e.data){var n=JSON.parse(e.data);t(n),n.hasOwnProperty("d")||0===n.code||a.recievers.length>0&&a.recievers.shift().resolve(n)}}}))}function J(e){return e.send(JSON.stringify({T:"SUB_ORD",SLIST:["orderUpdate"],SUB_T:1})),$(e)}function W(e){return e.send(JSON.stringify({T:"SUB_ORD",SLIST:["orderUpdate"],SUB_T:0})),$(e)}function Z(e,t){return new Promise(((n,r)=>{var{app_id:i,access_token:o}=e,a=new K(`${H}?${`user-agent=fyers-api&type=symbolUpdate&access_token=${i}:${o}`}`),u=setInterval((()=>{a.readyState===G.OPEN&&a.send("ping")}),5e3);a.binaryType="arraybuffer",a.onerror=e=>{for(var t of a.recievers)t.reject(e.error);clearInterval(u),r(e.error)},a.onopen=()=>n(a),a.onmessage=e=>{if("string"==typeof e.data){if("pong"===e.data)return;var n=JSON.parse(e.data);if(t(n),n.hasOwnProperty("d")||0===n.code)return;a.recievers.length>0&&a.recievers.shift().resolve(n)}else{var r=new DataView(e.data);t({s:"ok",d:X(r,0)})}}}))}function ee(e,t){var n={T:"SUB_DATA",TLIST:t,SUB_T:1};return e.send(JSON.stringify(n)),$(e)}function te(e,t){var n={T:"SUB_L2",L2LIST:t,SUB_T:1};return e.send(JSON.stringify(n)),$(e)}function ne(e,t){var n={T:"SUB_DATA",TLIST:t,SUB_T:0};return e.send(JSON.stringify(n)),$(e)}function re(e,t){var n={T:"SUB_L2",L2LIST:t,SUB_T:0};return e.send(JSON.stringify(n)),$(e)}var ie=Object.freeze({__proto__:null,MARKET_DATA_URL:H,ORDER_UPDATE_URL:Y,Connection:K,connectOrderUpdate:j,subscribeOrderUpdate:J,unsubscribeOrderUpdate:W,connectMarketData:Z,subscribeMarketQuote:ee,subscribeMarketDepth:te,unsubscribeMarketQuote:ne,unsubscribeMarketDepth:re});const oe=new Map([[10,"NSE"],[11,"MCX"],[12,"BSE"]]),ae=new Map([["NSE","National Stock Exchange"],["MCX","Multi Commodity Exchange"],["BSE","Bombay Stock Exchange"]]);function ue(e){return oe.get(e)}const se=new Map([[10,"CM"],[11,"FO"],[12,"CD"],[20,"COM"]]),ce=new Map([["CM","Capital Market"],["FO","Equity Derivatives"],["CD","Currency Derivatives"],["COM","Commodity Derivatives"]]);function le(e){return se.get(e)}const de=new Map([[1,"LONG"],[-1,"SHORT"],[0,"CLOSED"]]),pe=new Map([["LONG",1],["SHORT",-1],["CLOSED",0]]),ye=new Map([["LONG","Long position"],["SHORT","Short position"],["CLOSED","Closed position"]]);function fe(e){return de.get(e)}function me(e){return pe.get(e)}const ge=new Map([[1,"BUY"],[-1,"SELL"]]),Te=new Map([["BUY",1],["SELL",-1]]),he=new Map([["BUY","Buy"],["SELL","Sell"]]);function ve(e){return ge.get(e)}function be(e){return Te.get(e)}const Pe=new Map([["M","MOBILE"],["W","WEB"],["R","ONE"],["A","ADMIN"],["ITS","API"]]),Se=new Map([["MOBILE","FYERS Mobile"],["WEB","FYERS Web"],["ONE","FYERS One"],["ADMIN","Admin"],["API","FYERS API"]]);function Ee(e){return Pe.get(e)}const Ce=new Map([[1,"CANCELLED"],[2,"TRADED"],[4,"TRANSIT"],[5,"REJECTED"],[6,"PENDING"],[7,"EXPIRED"]]),De=new Map([["CANCELLED","Cancelled"],["TRADED","Traded / Filled"],["TRANSIT","Transit"],["REJECTED","Rejected"],["PENDING","Pending"],["EXPIRED","Expired"]]),Ue=new Map([["C","CANCELLED"],["F","TRADED"],["T","TRANSIT"],["R","REJECTED"],["P","PENDING"],["E","EXPIRED"]]);function Oe(e){return Ce.get(e)}const Ie=new Map([[1,"LIMIT"],[2,"MARKET"],[3,"SL_MARKET"],[4,"SL_LIMIT"]]),we=new Map([["LIMIT",1],["MARKET",2],["SL_MARKET",3],["SL_LIMIT",4]]),Me=new Map([["LIMIT","Limit order"],["MARKET","Market order"],["SL_MARKET","Stop order (SL-M)"],["SL_LIMIT","Stoplimit order (SL-L)"]]),ke=new Map([["L","LIMIT"],["M","MARKET"],["S","SL_MARKET"],["R","SL_LIMIT"]]);function _e(e){return Ie.get(e)}function Re(e){return we.get(e)}const Ae=new Map([["DAY","End of day validity"],["IOC","Immediate or Cancel validity"]]);const Le=new Map([["CE","Call option"],["PE","Put option"]]);function Ne(e){return/pe|put|sell/i.test(e)?"PE":"CE"}const qe=new Map([["FUT","Future"],["CE","Call option"],["PE","Put option"]]);const Fe=new Map([["T1","The shares are purchased but not yet delivered to the demat account"],["HLD","The shares are purchased and are available in the demat account"]]);const Qe=new Map([["CNC","Cash N Carry or Delivery Order, for equity only"],["INTRADAY","Intraday Order, applicable for all segments"],["MARGIN","Margin Order, applicable only for derivatives"],["CO","Cover Order"],["BO","Bracket Order"]]),Be=new Map([["D","CNC"],["I","INTRADAY"],["M","MARGIN"],["C","CO"],["B","BO"]]);const xe=new Map([[0,"EQ"],[1,"PREFSHARES"],[2,"DEBENTURES"],[3,"WARRANTS"],[4,"MISC"],[10,"INDEX"],[11,"FUTIDX"],[12,"FUTIVX"],[13,"FUTSTK"],[14,"OPTIDX"],[15,"OPTSTK"],[16,"FUTCUR"],[17,"FUTIRT"],[18,"FUTIRC"],[19,"OPTCUR"],[20,"UNDCUR"],[21,"UNDIRC"],[22,"UNDIRT"],[23,"UNDIRD"],[24,"INDEX_CD"],[25,"FUTIRD"],[30,"FUTCOM"],[31,"OPTFUT"],[32,"OPTCOM"]]),Ge=new Map([["EQ","Equity Shares"],["PREFSHARES","Preference Shares"],["DEBENTURES","Collateral-free Debt"],["WARRANTS","Warrants on Stock"],["MISC","Miscellaneous"],["INDEX","Stock Market Index"],["FUTIDX","Futures on Index"],["FUTIVX","Futures on Volatility Index"],["FUTSTK","Futures on Stock"],["OPTIDX","Options on Index"],["OPTSTK","Options on Stock"],["FUTCUR","Futures on Currency"],["FUTIRT","Futures on Government of India Treasury Bills"],["FUTIRC","Futures on Government of India Bonds"],["OPTCUR","Options on Currency"],["UNDCUR","Underlying on Currency"],["UNDIRC","Underlying on Government of Bonds"],["UNDIRT","Underlying on Government of India Treasury Bills"],["UNDIRD","Underlying on 10 Year Notional coupon bearing GOI security"],["INDEX_CD","Market-indexed Certificate of deposit"],["FUTIRD","Futures on 10 Year Notional coupon bearing GOI security"],["FUTCOM","Futures on Commodity"],["OPTFUT","Options on Commodity Futures"],["OPTCOM","Options on Commodity"]]);function He(e){return xe.get(e)}const Ye=/^\w+:(\w+)-\w+|^\w+:(\w+)\d{2}\w{3}FUT|^\w+:(\w+)\d{2}\w{3}\d+[CP]E|^\w+:(\w+)\d{2}\w{1}\d{2}\d+[CP]E/;function Ve(e){var[t,n,,r,,i,,,o]=e.split(",");return{symbol:o,token:t,description:n,lotSize:parseInt(r,10),isin:i||""}}function ze(e){var t=Ye.exec(e);return t[1]||t[2]||t[3]||t[4]}function Xe(e){var t=e.indexOf(":");return e.substring(0,t)}function Ke(e){return{app_id:e.appId,access_token:e.accessToken}}function $e(e){return{isin:e.isin,symbol:e.symbol,token:e.fytoken,exchange:ue(e.exchange),type:e.holdingType,quantity:e.quantity,remainingQuantity:e.remainingQuantity,buyPrice:e.costPrice,buyValue:e.costPrice*e.quantity,currentPrice:e.ltp,currentValue:e.marketVal,returns:e.pl,returnsPercent:e.pl/(e.costPrice*e.quantity)}}function je(e,t){var n=0;for(var r of e)"HLD"===r.holdingType&&n++;return{count:t.count_total,settledCount:n,investedValue:t.total_investment,currentValue:t.total_current_value,returns:t.total_pl,returnsPercent:t.pnl_perc}}function Je(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,name:e.ex_sym,description:e.description,segment:le(e.segment),instrument:He(e.instrument),exchange:ue(e.exchange),type:_e(e.type),side:ve(e.side),productType:e.productType,source:Ee(e.source)||null,status:Oe(e.status),offline:"True"===e.offlineOrder,limitPrice:e.limitPrice,stopPrice:e.stopPrice,quantity:e.qty,remainingQuantity:e.remainingQuantity,tradedQuantity:e.filledQty,disclosedQuantity:e.discloseQty,remainingDisclosedQuantity:e.dqQtyRem,validity:e.orderValidity,date:e.orderDateTime,parentId:e.parentId||null,priceChange:e.ch,priceChangePercent:e.chp,currentPrice:e.lp,tradedPrice:e.tradedPrice,message:e.message,pan:e.pan||null,clientId:e.clientId||null}}function We(e){var t={count:0,openCount:0,closedCount:0,quantity:0,remainingQuantity:0,tradedQuantity:0,disclosedQuantity:0,remainingDisclosedQuantity:0};for(var n of e)t.count++,t.openCount+=6===n.status||4===n.status?1:0,t.quantity+=n.qty,t.remainingQuantity+=n.remainingQuantity,t.tradedQuantity+=n.filledQty,t.disclosedQuantity+=n.discloseQty,t.remainingDisclosedQuantity+=n.dqQtyRem;return t.closedCount=t.count-t.openCount,t}function Ze(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,segment:le(e.segment),productType:e.productType,side:fe(e.side),quantity:e.qty,quantityMultiplier:e.qtyMulti_com,buyPrice:e.buyAvg,buyQuantity:e.buyQty,buyValue:e.buyVal,sellPrice:e.sellAvg,sellQuantity:e.sellQty,sellValue:e.sellVal,netPrice:e.netAvg,netQuantity:e.netQty,returns:e.pl,realizedReturns:e.realized_profit,unrealizedReturns:e.unrealized_profit,crossCurrency:"Y"===e.crossCurrency,rbiRefRate:e.rbiRefRate,currentPrice:e.ltp}}function et(e,t){var n=0,r=0;for(var i of e)n+=i.buyVal,r+=i.sellVal;return{count:t.count_total,openCount:t.count_open,closedCount:t.count_total-t.count_open,buyValue:n,sellValue:r,returns:t.pl_total,realizedReturns:t.pl_realized,unrealizedReturns:t.pl_unrealized}}function tt(e){return{id:e.id,orderId:e.orderNumber,symbol:e.symbol,token:e.fyToken,segment:le(e.segment),exchange:ue(e.exchange),side:ve(e.transactionType),productType:e.productType,orderType:_e(e.orderType),orderDate:e.orderDateTime,price:e.tradePrice,quantity:e.tradedQty,value:e.tradeValue,clientId:e.clientId}}function nt(e){var t={count:0,quantity:0,value:0};for(var n of e)t.count++,t.quantity+=n.tradedQty,t.value+=n.tradeValue;return t}function rt(e){return{symbol:e.symbol,type:Re(e.type||"MARKET"),side:be(e.side||"BUY"),productType:e.productType||"CNC",limitPrice:e.limitPrice||0,stopPrice:e.stopPrice||0,qty:e.quantity,disclosedQty:e.disclosedQuantity||0,validity:e.validity||"DAY",offlineOrder:e.offline?"True":"False",stopLoss:e.stopLoss||0,takeProfit:e.takeProfit||0}}function it(e){return{id:e.id,type:Re(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function ot(e){return{exchange:ue(e.exchange),segment:le(e.segment),type:e.market_type,status:e.status}}function at(e){var t={count:0,openCount:0,closedCount:0};for(var n of e)t.count++,"OPEN"===n.status?t.openCount++:t.closedCount++;return t}const ut=[1,2,3,5,10,15,20,30,60,120,240,1440];function st(e){var t=1,n=1/0;for(var r of ut){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}function ct(e){return{date:e[0],openPrice:e[1],highPrice:e[2],lowPrice:e[3],closePrice:e[4],volume:e[5]}}function lt(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function dt(e){var t={fromDate:0,toDate:0,openPrice:0,highPrice:0,lowPrice:0,closePrice:0,volume:0};if(0===e.length)return t;var n=e.length-1;for(var r of(t.fromDate=e[0][0],t.toDate=e[n][0],t.openPrice=e[0][1],t.highPrice=e[0][2],t.lowPrice=e[0][3],t.closePrice=e[n][4],e))t.highPrice=Math.max(t.highPrice,r[2]),t.lowPrice=Math.min(t.lowPrice,r[3]),t.volume+=r[5];return t}function pt(e){var t=e.v;return{symbol:e.n,token:t.fyToken,name:t.short_name,exchange:t.exchange,description:t.description,priceChange:t.ch,priceChangePercent:t.chp,currentPrice:t.lp,priceSpread:t.spread,sellPrice:t.ask,buyPrice:t.bid,openPrice:t.open_price,highPrice:t.high_price,lowPrice:t.low_price,closePrice:t.prev_close_price,volume:t.volume,date:t.tt,candle:lt(t.cmd)}}function yt(e){return{price:e.price,volume:e.volume,orders:e.ord}}function ft(e,t){return{price:e.price/t,volume:e.volume,orders:e.ord}}function mt(e){return{id:e.transactionId,isin:e.isin,quantity:e.qty,remainingQuantity:e.qty-e.qtyUtlize,entryDate:e.entryDate,startDate:e.startDate,endDate:e.endDate,source:e.source,status:e.status,clientId:e.clientId,errorCode:e.errCode,errorCount:e.errorCount,reason:e.reason}}function gt(e){var t={count:0,quantity:0,remainingQuantity:0};for(var n of e)t.count++,t.quantity+=n.qty,t.remainingQuantity+=n.qty-n.qtyUtlize;return t}function Tt(e){return{isin_code:e.isin,qty:e.quantity}}function ht(e,t){return.01*Math.round(e*t)}function vt(e){var t=ht(e,.1);return t+ht(t,18)+ht(e,.00325)+ht(e,.015)+ht(e,1e-4)}class bt extends Error{constructor(e,t){super(t),this.code=e,this.name=this.constructor.name,this.stack=new Error(t).stack}}function Pt(e,t,n="default"){return f({client_id:(r={appId:e,redirectUrl:t,state:n}).appId,redirect_uri:r.redirectUrl,response_type:"code",state:r.state});var r}function St(e,t){return m({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode});var n}function Et(e){if("ok"!==e.s)throw new bt(e.code,e.message)}function Ct(e){if(""===e.id)throw new bt(e.code,e.message)}async function Dt(e){var t,n=await g(Ke(e));return Et(n),{id:(t=n.data).fy_id,email:t.email_id,name:t.name,pan:t.PAN}}async function Ut(e){var t=await T(Ke(e));return Et(t),function(e){var t={},n={};for(var r of e.fund_limit)switch(r.id){case 9:t.start=r.equityAmount,n.start=r.commodityAmount;break;case 6:t.deposits=r.equityAmount,n.deposits=r.commodityAmount;break;case 4:t.realizedReturns=r.equityAmount,n.realizedReturns=r.commodityAmount;break;case 5:t.collaterals=r.equityAmount,n.collaterals=r.commodityAmount;break;case 8:t.adhoc=r.equityAmount,n.adhoc=r.commodityAmount;break;case 2:t.utilized=r.equityAmount,n.utilized=r.commodityAmount;break;case 7:t.receivables=r.equityAmount,n.receivables=r.commodityAmount;break;case 10:t.available=r.equityAmount,n.available=r.commodityAmount;break;case 3:t.clear=r.equityAmount,n.clear=r.commodityAmount;break;case 1:t.total=r.equityAmount,n.total=r.commodityAmount}return{equity:t,commodity:n}}(t)}async function Ot(e){var t,n=await h(Ke(e));return Et(n),{details:(t=n).holdings.map($e),overall:je(t.holdings,t.overall)}}async function It(e,t){var n=await v(Ke(e),{id:t});return Et(n),Je(n.orderBook[0])}async function wt(e){var t,n=await b(Ke(e));return Et(n),{details:(t=n).orderBook.map(Je),overall:We(t.orderBook)}}async function Mt(e){var t,n=await P(Ke(e));return Et(n),{details:(t=n).netPositions.map(Ze),overall:et(t.netPositions,t.overall)}}async function kt(e){var t,n=await S(Ke(e));return Et(n),{details:(t=n).tradeBook.map(tt),overall:nt(t.tradeBook)}}async function _t(e,t){var n=await E(Ke(e),rt(t));return Ct(n),n.id}function Rt(e,t){var n=C(Ke(e),t.map(rt));return t.map(((e,t)=>n.then((e=>(Et(e),Ct(e.data[t].body),e.data[t].body.id)))))}async function At(e,t){var n=await D(Ke(e),it(t));return Et(n),n.id}function Lt(e,t){var n=U(Ke(e),t.map(it));return t.map(((e,t)=>n.then((e=>{Et(e),Ct(e.data[t].body)}))))}async function Nt(e,t){Et(await O(Ke(e),{id:t}))}function qt(e,t){var n=I(Ke(e),t.map((e=>({id:e}))));return t.map(((e,t)=>n.then((e=>{Et(e),Ct(e.data[t].body)}))))}async function Ft(e,t){Et(await w(Ke(e),{id:t}))}async function Qt(e){Et(await M(Ke(e)))}async function Bt(e,t){var n;Et(await k(Ke(e),(n=t,{symbol:n.symbol,positionSide:me(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"})))}async function xt(e){var t,n=await _(Ke(e));return Et(n),{details:(t=n).marketStatus.map(ot),overall:at(t.marketStatus)}}async function Gt(e,t){var n,r=await R(Ke(e),(n=t,{symbol:n.symbol,resolution:st(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"}));return Et(r),function(e){return{details:e.candles.map(ct),overall:dt(e.candles)}}(r)}async function Ht(e,t){var n=await A(Ke(e),{symbols:t.join()});return Et(n),n.d.map(pt)}async function Yt(e,t){var n=await L(Ke(e),{symbol:t,ohlcv_flag:1});return Et(n),function(e){var t=Object.keys(e.d);if(0===t.length)return null;var n=t[0],r=e.d[n];return{symbol:n,token:null,name:ze(n),exchange:Xe(n),expiryDate:r.expiry,currentPrice:r.ltq,lowerCircuitPrice:r.lower_ckt,upperCircuitPrice:r.upper_ckt,openPrice:r.o,highPrice:r.h,lowPrice:r.l,closePrice:r.c,volume:r.v,priceChange:r.ch,priceChangePercent:r.chp,openInterest:r.oi,previousOpenInterest:r.pdoi,openInterestChangePercent:r.oipercent,tradedQuantity:r.ltq,tradedDate:r.ltt,netPrice:r.atp,buyQuantity:r.totalbuyqty,sellQuantity:r.totalsellqty,buyOffers:r.bids.map(yt),sellOffers:r.ask.map(yt)}}(n)}function Vt(e,t,n){return N(0,{exchange:t,segment:n})}function zt(e){for(var t=[],n=/[^\n]+/g,r=null;null!=(r=n.exec(e));)t.push(Ve(r[0]));return t}async function Xt(e,t,n){return zt(await Vt(0,t,n))}async function Kt(e){Et(await q(Ke(e)))}async function $t(e){var t,n,r=await F(Ke(e));return Et(r),{details:(n=0===(t=r).data.length?[]:t.data).map(mt),overall:gt(n)}}function jt(e,t){return Q(Ke(e),{recordLst:t.map(Tt)})}async function Jt(e,t){var n=await B(Ke(e),{transactionId:t});return Et(n),n.data.FAILED_CNT>0?-n.data.FAILED_CNT:n.data.SUCEESS_CNT}function Wt(e,t){return j(Ke(e),(e=>{e.d&&t(function(e){var t=e.d;return{id:t.id,symbol:t.symbol,token:t.fyToken,type:_e(t.type),side:ve(t.side),productType:t.productType,status:Oe(t.status),validity:t.orderValidity,offline:t.offlineOrder,quantity:t.qty,remainingQuantity:t.remainingQuantity,filledQuantity:t.filledQty,disclosedQuantity:t.discloseQty,remainingDisclosedQuantity:t.dqQtyRem,limitPrice:t.limitPrice,stopPrice:t.stopPrice,date:t.orderDateTime,parentId:t.parentId||null,tradedPrice:t.tradedPrice,message:t.message}}(e))}))}async function Zt(e){var t=await J(e);if(t.code<0)throw new bt(t.code,t.message)}async function en(e){var t=await W(e);if(t.code<0)throw new bt(t.code,t.message)}function tn(e,t,n=null){return Z(Ke(e),(e=>{e.d&&t(function(e,t){var n=e.d,r=n.token.toString(),i=n.price_conv||1,o=null!=t&&t.get(r)||null,a=n.ltp-n.prev_close_price,u=null==n.bids?n.bid:n.bids[0].price,s=null==n.asks?n.ask:n.asks[0].price;return{symbol:o,token:r,name:null!=o?ze(o):null,exchange:null!=o?Xe(o):null,date:n.tt,marketStatus:n.marketStat,currentPrice:n.ltp/i,openPrice:n.open_price/i,highPrice:n.high_price/i,lowPrice:n.low_price/i,closePrice:n.prev_close_price/i,priceChange:a/i,priceChangePercent:a/n.prev_close_price,candle:{date:n.tt,openPrice:n.o/i,highPrice:n.h/i,lowPrice:n.l/i,closePrice:n.c/i,volume:Number(n.v)},openInterest:Number(n.oi),previousOpenInterest:Number(n.pdoi),tradedQuantity:n.LTQ,tradedDate:n.L2_LTT,tradedPrice:n.ATP/i,volume:n.volume,buyQuantity:Number(n.tot_buy),sellQuantity:Number(n.tot_sell),buyPrice:u/i,sellPrice:s/i,priceSpread:(s-u)/i,buyOffers:null==n.bids?null:n.bids.map((e=>ft(e,i))),sellOffers:null==n.asks?null:n.asks.map((e=>ft(e,i)))}}(e,n))}))}async function nn(e,t){var n=await ee(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function rn(e,t){var n=await te(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function on(e,t){var n=await ne(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function an(e,t){var n=await re(e,t);if(n.code<0)throw new bt(n.code,n.message)}n.Api=class{constructor(e,t){this.appId=e,this.accessToken=t,this.symbolDetails=new Map,this.tokenSymbol=new Map,this.orderUpdateConnection=null,this.marketDataConnection=null}static loginStep1(e,t,n="default"){return Pt(e,t,n)}static loginStep2(e,t){return St(e,t)}static getSymbolMaster(e,t){return Vt(0,e,t)}getProfile(){return Dt(this)}getFunds(){return Ut(this)}getHoldings(){return Ot(this)}getOrder(e){return It(this,e)}getOrders(){return wt(this)}getPositions(){return Mt(this)}getTrades(){return kt(this)}placeOrder(e){return _t(this,e)}placeOrders(e){return Rt(this,e)}modifyOrder(e){return At(this,e)}modifyOrders(e){return Lt(this,e)}cancelOrder(e){return Nt(this,e)}cancelOrders(e){return qt(this,e)}exitPosition(e){return Ft(this,e)}exitAllPositions(){return Qt(this)}convertPosition(e){return Bt(this,e)}getMarketStatus(){return xt(this)}getMarketHistory(e){return Gt(this,e)}getMarketQuotes(e){return Ht(this,e)}getMarketDepth(e){return Yt(this,e)}processSymbolMaster(e){var t=zt(e);for(var n of t)this.symbolDetails.set(n.symbol,n),this.tokenSymbol.set(n.token,n.symbol);return t}async loadSymbolMaster(e,t){var n=await Xt(0,e,t);for(var r of n)this.symbolDetails.set(r.symbol,r),this.tokenSymbol.set(r.token,r.symbol);return n}generateEdisTpin(){return Kt(this)}getEdisTransactions(){return $t(this)}submitEdisHoldingsStep(e){return jt(this,e)}inquireEdisTransaction(e){return Jt(this,e)}connectOrderUpdate(e){return null!=this.orderUpdateConnection&&this.orderUpdateConnection.then((e=>e.close())),this.orderUpdateConnection=Wt(this,e)}async subscribeOrderUpdate(){return Zt(await this.orderUpdateConnection)}async unsubscribeOrderUpdate(){return en(await this.orderUpdateConnection)}async connectMarketData(e){return null!=this.marketDataConnection&&this.marketDataConnection.then((e=>e.close())),this.marketDataConnection=tn(this,e,this.tokenSymbol)}async subscribeMarketQuote(e){return nn(await this.marketDataConnection,e)}async subscribeMarketDepth(e){return rn(await this.marketDataConnection,e)}async unsubscribeMarketQuote(e){return on(await this.marketDataConnection,e)}async unsubscribeMarketDepth(e){return an(await this.marketDataConnection,e)}},n.cancelOrder=Nt,n.cancelOrders=qt,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.0026)+ht(n,.0018)+ht(n,.002)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.01);return t+n+ht(t+n,18)+ht(e,.0026)+ht(e,.0018)+ht(e,.002)+ht(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+ht(20,18)+ht(n,.05)+ht(n,3e-4)+ht(n,1e-4)):function(e){var t=ht(e,.05);return 20+t+ht(20+t,18)+ht(e,.05)+ht(e,3e-4)+ht(e,1e-4)}(t);var n},n.connectMarketData=tn,n.connectOrderUpdate=Wt,n.convertPosition=Bt,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.00115)+ht(n,5e-4)+ht(n,1e-4)+ht(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+ht(20,18)+ht(n,.04)+ht(n,.009)+ht(n,1e-4)+ht(n,1e-4);var n},n.derivativeType=function(e){return/fut|lat|buy/.test(e)?"FUT":Ne(e)},n.derivativeTypeDescription=function(e){return qe.get(e)},n.equityDeliveryCharges=function(e,t){return"BUY"===e?vt(t):12.5+vt(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.0019)+ht(n,5e-4)+ht(n,.002)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.01);return t+n+ht(t+n,18)+ht(e,.0019)+ht(e,5e-4)+ht(e,.002)+ht(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.00325)+ht(n,.003)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.025);return t+n+ht(t+n,18)+ht(e,.00325)+ht(e,.003)+ht(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+ht(20,18)+ht(n,.053)+ht(n,.009)+ht(n,.003)+ht(n,1e-4)):function(e){var t=ht(e,.05);return 20+t+ht(20+t,18)+ht(e,.053)+ht(e,.009)+ht(e,.003)+ht(e,1e-4)}(t);var n},n.exchange=function(e){return/bse|native|bombay|mumbai/i.test(e)?"BSE":/\bcom\b|mcx|multi|commodit/i.test(e)?"MCX":"NSE"},n.exchangeDescription=function(e){return ae.get(e)},n.exitAllPositions=Qt,n.exitPosition=Ft,n.generateEdisTpin=Kt,n.getEdisTransactions=$t,n.getFunds=Ut,n.getHoldings=Ot,n.getMarketDepth=Yt,n.getMarketHistory=Gt,n.getMarketQuotes=Ht,n.getMarketStatus=xt,n.getOrder=It,n.getOrders=wt,n.getPositions=Mt,n.getProfile=Dt,n.getSymbolMaster=Vt,n.getTrades=kt,n.holdingType=function(e){return/un|not|pend|t1/i.test(e)?"T1":"HLD"},n.holdingTypeDescription=function(e){return Fe.get(e)},n.http=x,n.inquireEdisTransaction=Jt,n.instrumentType=function(e){var t=/fut|future/i.test(e),n=/opt|option/i.test(e),r=/idx|index/i.test(e),i=/und|underlying/i.test(e);return/com(\b|$)|commodit/i.test(e)?n?t?"OPTFUT":"OPTCOM":r?"FUTIDX":"FUTCOM":/(^|\b)und|cd(\b|$)|ir[cdt](\b|$)|cur|gov|bond|trea|coup/i.test(e)?/irc(\b|$)|bond/i.test(e)?i?"UNDIRC":"FUTIRC":/ird(\b|$)|coup/i.test(e)?i?"UNDIRD":"FUTIRD":/irt(\b|$)|trea/i.test(e)?i?"UNDIRT":"FUTIRT":r?"INDEX_CD":n?"OPTCUR":"FUTCUR":t||n?/ivx|volatil/i.test(e)?"FUTIVX":r?n?"OPTIDX":"FUTIDX":n?"OPTSTK":"FUTSTK":r?"INDEX":/misc/i.test(e)?"MISC":/warrant/i.test(e)?"WARRANTS":/deb/i.test(e)?"DEBENTURES":/pref/i.test(e)?"PREFSHARES":"EQ"},n.instrumentTypeDescription=function(e){return Ge.get(e)},n.loadSymbolMaster=Xt,n.loginStep1=Pt,n.loginStep2=St,n.modifyOrder=At,n.modifyOrders=Lt,n.optionType=Ne,n.optionTypeDescription=function(e){return Le.get(e)},n.orderSide=function(e){return/down|sell|short|crash/i.test(e)?"SELL":"BUY"},n.orderSideDescription=function(e){return he.get(e)},n.orderSource=function(e){return/its|api|sys/i.test(e)?"API":/one|desk/i.test(e)?"ONE":/mob|app/i.test(e)?"MOBILE":/admin/i.test(e)?"ADMIN":"WEB"},n.orderSourceDescription=function(e){return Se.get(e)},n.orderStatus=function(e){var t=e.charAt(0).toUpperCase();return/traded/i.test(e)&&(t="F"),Ue.get(t)},n.orderStatusDescription=function(e){return De.get(e)},n.orderType=function(e){var t=e.charAt(0).toUpperCase();return/s.+l(?!oss)/i.test(e)&&(t="R"),ke.get(t)},n.orderTypeDescription=function(e){return Me.get(e)},n.orderValidity=function(e){return/ioc|cancel|immediate/i.test(e)?"IOC":"DAY"},n.orderValidityDescription=function(e){return Ae.get(e)},n.placeOrder=_t,n.placeOrders=Rt,n.positionSide=function(e){return/up|buy|long|rally/i.test(e)?"LONG":/down|sell|short|crash/i.test(e)?"SHORT":"CLOSED"},n.positionSideDescription=function(e){return ye.get(e)},n.processSymbolMaster=zt,n.productType=function(e){var t=e.charAt(0).toUpperCase();return/cnc|cash|carry|deliver/i.test(e)&&(t="D"),Be.get(t)},n.productTypeDescription=function(e){return Qe.get(e)},n.segment=function(e){return/\bcom\b|mcx|multi|commodit/i.test(e)?"COM":/\bcd\b|currenc/i.test(e)?"CD":/\bfn?o\b|fut|opt|deriv/i.test(e)?"FO":"CM"},n.segmentDescription=function(e){return ce.get(e)},n.submitEdisHoldingsStep=jt,n.subscribeMarketDepth=rn,n.subscribeMarketQuote=nn,n.subscribeOrderUpdate=Zt,n.symbolDerivativeType=function(e){var t=/(?:FUT|CE|PE)$/.exec(e);return null!=t?t[0]:null},n.symbolDescription=function(e,t){return t.get(e).description},n.symbolExchange=Xe,n.symbolIsin=function(e,t){return t.get(e).isin},n.symbolLotSize=function(e,t){return t.get(e).lotSize},n.symbolName=ze,n.symbolOptionType=function(e){var t=e.substring(e.length-2);return"CE"===t||"PE"===t?t:null},n.symbolSeries=function(e){var t=e.lastIndexOf("-");return t>0?e.substring(t):null},n.symbolStrikePrice=function(e){var t=/([\d\.]+)[CP]E$/.exec(e);return null!=t?parseFloat(t[1]):0},n.symbolToken=function(e,t){return t.get(e).token},n.unsubscribeMarketDepth=an,n.unsubscribeMarketQuote=on,n.unsubscribeOrderUpdate=en,n.websocket=ie},{}]},{},[1])(1)}));
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).extra_fyers=e()}}((function(){return function e(t,n,r){function i(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return i(t[a][1][e]||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(e,t,n){"use strict";function r(e,t){var n=new Error(t);return n.code=e.status,n.response=null,n}function i(e,t){return null!=t.headers&&(!!t.headers.hasOwnProperty(e)||!!t.headers.hasOwnProperty(e.toLowerCase()))}function o(e,t){return new Promise(((n,o)=>{var a=t.url,u=t.method||"GET",s=!1,c=!1,l=!1,d=new XMLHttpRequest;d.open(u,a),function(e,t){for(var n in null==t.body||i("Content-Type",t)||e.setRequestHeader("Content-Type","application/json; charset=utf-8"),i("Accept",t)||e.setRequestHeader("Accept","application/json, text/*"),t.headers)e.setRequestHeader(n,t.headers[n])}(d,t),t.timeout&&(d.timeout=t.timeout),d.responseType=e,d.onerror=function(e){s=!0;var t=e.target;o(r(t,"Unexpected error occurred"))},d.onabort=function(e){c=!0;var t=e.target;o(r(t,"Request was aborted"))},d.ontimeout=function(e){l=!0;var t=e.target;o(r(t,"Request timed out"))},d.onreadystatechange=function(t){if(!(s||c||l)){var r=t.target;if(function(e){return e.readyState===e.DONE}(r))try{var i=function(e,t){if("json"===t){if(!e.responseType)try{return JSON.parse(e.responseText)}catch(e){return null}}else if((!t||"text"===t)&&null==e.response)return e.responseText;return e.response}(r,e);!function(e,t=""){return e.status>=200&&e.status<300||304===e.status||/^file:\/\//i.test(t)}(r,a)?setTimeout((function(){s||c||l||o(function(e,t){var n=null;try{n=e.responseText}catch(e){n=t}var r=new Error(n);return r.code=e.status,r.response=t,r}(r,i))})):n(i)}catch(t){o(t)}}},null==t.body?d.send():t.body instanceof FormData||t.body instanceof URLSearchParams?d.send(t.body):d.send(JSON.stringify(t.body))}))}Object.defineProperty(n,"__esModule",{value:!0});const a="https://api.fyers.in/api/v2/",u="https://api.fyers.in/data-rest/v2/",s="https://public.fyers.in/sym_details/";function c(e,t,n,r,i){var o=n+function(e){if(null==e)return"";var t=new URLSearchParams;for(var n in e)t.append(n,e[n]);return"?"+t.toString()}(r),a={};return null!=e&&(a.authorization=e.app_id+":"+e.access_token),{url:o,method:t,headers:a,body:i}}function l(e,t,n,r,i){return o("text",c(e,t,n,r,i))}function d(e,t,n,r,i){return o("json",c(e,t,n,r,i))}function p(e,t,n,r,i){return d(e,t,a+n,r,i)}function y(e,t,n,r,i){return d(e,t,u+n,r,i)}function f(e){return c(null,"GET",a+"generate-authcode",e,null)}function m(e){return c(null,"POST",a+"validate-authcode",null,e)}function g(e){return p(e,"GET","profile",null,null)}function T(e){return p(e,"GET","funds",null,null)}function h(e){return p(e,"GET","holdings",null,null)}function v(e,t){return p(e,"GET","orders",t,null)}function b(e){return p(e,"GET","orders",null,null)}function P(e){return p(e,"GET","positions",null,null)}function S(e){return p(e,"GET","tradebook",null,null)}function E(e,t){return p(e,"POST","orders",null,t)}function C(e,t){return p(e,"POST","orders-multi",null,t)}function D(e,t){return p(e,"PUT","orders",null,t)}function U(e,t){return p(e,"PUT","orders-multi",null,t)}function O(e,t){return p(e,"DELETE","orders",null,t)}function I(e,t){return p(e,"DELETE","orders-multi",null,t)}function w(e,t){return p(e,"DELETE","positions",null,t)}function M(e){return p(e,"DELETE","positions",null,{})}function k(e,t){return p(e,"PUT","positions",null,t)}function _(e){return p(e,"GET","market-status",null,null)}function R(e,t){return y(e,"GET","history/",t,null)}function A(e,t){return y(e,"GET","quotes/",t,null)}function L(e,t){return y(e,"GET","depth/",t,null)}function N(e,t){var{exchange:n,segment:r}=t;return function(e,t,n,r,i){return l(e,t,s+n,r,i)}(null,"GET",n+"_"+r+".csv",null,null)}function q(e){return p(e,"GET","tpin",null,null)}function F(e){return p(e,"GET","details",null,null)}function Q(e,t){return c(e,"POST","index",null,t)}function B(e,t){return p(e,"POST","inquiry",null,t)}var x=Object.freeze({__proto__:null,API_URL:a,DATA_URL:u,SYMBOLS_URL:s,loginStep1:f,loginStep2:m,getProfile:g,getFunds:T,getHoldings:h,getOrder:v,getOrders:b,getPositions:P,getTrades:S,placeOrder:E,placeOrders:C,modifyOrder:D,modifyOrders:U,cancelOrder:O,cancelOrders:I,exitPosition:w,exitAllPositions:M,convertPosition:k,getMarketStatus:_,getMarketHistory:R,getMarketQuotes:A,getMarketDepth:L,getSymbolMaster:N,generateEdisTpin:q,getEdisTransactions:F,submitEdisHoldingsStep:Q,inquireEdisTransaction:B});const G=WebSocket,H="wss://api.fyers.in/socket/v2/dataSock",Y="wss://api.fyers.in/socket/v2/orderSock";function V(e,t){return{price:e.getUint32(t+0),volume:e.getUint32(t+4),ord:e.getUint32(t+8)}}function z(e,t,n){!function(e,t,n){e.token=t.getBigUint64(n+0),e.tt=t.getUint32(n+8),e.fyCode=t.getUint16(n+12),e.marketStat=t.getUint16(n+14),e.pktlen=t.getUint16(n+16),e.L2=t.getUint8(n+18)}(e,t,n+0);var r=7202===e.fyCode||31038===e.fyCode,i=r?88:72;7202===e.fyCode?function(e,t,n){e.oi=BigInt(t.getUint32(n+0)),e.pdoi=BigInt(t.getUint32(n+4))}(e,t,n+24):function(e,t,n,r){e.price_conv=t.getUint32(n+0),e.ltp=t.getUint32(n+4),e.open_price=t.getUint32(n+8),e.high_price=t.getUint32(n+12),e.low_price=t.getUint32(n+16),e.prev_close_price=t.getUint32(n+20),e.o=t.getUint32(n+24),e.h=t.getUint32(n+28),e.l=t.getUint32(n+32),e.c=t.getUint32(n+36),e.v=t.getBigUint64(n+40),r&&(e.oi=t.getBigUint64(n+48),e.pdoi=t.getBigUint64(n+56))}(e,t,n+24,r),7208!==e.fyCode&&31038!==e.fyCode||function(e,t,n,r){e.LTQ=t.getUint32(n+0),e.L2_LTT=t.getUint32(n+4),e.ATP=t.getUint32(n+8),e.volume=t.getUint32(n+12),e.tot_buy=t.getBigUint64(n+16),e.tot_sell=t.getBigUint64(n+24),r&&(e.bid=t.getUint32(n+32),e.ask=t.getUint32(n+36))}(e,t,n+i,1!==e.L2),1===e.L2&&function(e,t,n){for(var r=[],i=[],o=0;o<60;o+=12)r.push(V(t,n+o)),i.push(V(t,n+o+60));e.bids=r,e.asks=i}(e,t,n+i+32)}function X(e,t){var n={token:BigInt(0),tt:0,fyCode:0,marketStat:0,pktlen:0,L2:0,price_conv:0,ltp:0,open_price:0,high_price:0,low_price:0,prev_close_price:0,o:0,h:0,l:0,c:0,v:BigInt(0),oi:BigInt(0),pdoi:BigInt(0),LTQ:0,L2_LTT:0,ATP:0,volume:0,tot_buy:BigInt(0),tot_sell:BigInt(0),bid:0,ask:0,bids:null,asks:null};return z(n,e,t),n}class K extends G{constructor(){super(...arguments),this.recievers=[]}}function $(e){return new Promise(((t,n)=>e.recievers.push({resolve:t,reject:n})))}function j(e,t){return new Promise(((n,r)=>{var{app_id:i,access_token:o}=e,a=new K(`${Y}?${`user-agent=fyers-api&type=orderUpdate&access_token=${i}:${o}`}`),u=setInterval((()=>{a.readyState===G.OPEN&&a.send("ping")}),5e3);a.binaryType="arraybuffer",a.onerror=e=>{for(var t of a.recievers)t.reject(e.error);clearInterval(u),r(e.error)},a.onopen=()=>n(a),a.onmessage=e=>{if("string"==typeof e.data&&"pong"!==e.data){var n=JSON.parse(e.data);t(n),n.hasOwnProperty("d")||0===n.code||a.recievers.length>0&&a.recievers.shift().resolve(n)}}}))}function J(e){return e.send(JSON.stringify({T:"SUB_ORD",SLIST:["orderUpdate"],SUB_T:1})),$(e)}function W(e){return e.send(JSON.stringify({T:"SUB_ORD",SLIST:["orderUpdate"],SUB_T:0})),$(e)}function Z(e,t){return new Promise(((n,r)=>{var{app_id:i,access_token:o}=e,a=new K(`${H}?${`user-agent=fyers-api&type=symbolUpdate&access_token=${i}:${o}`}`),u=setInterval((()=>{a.readyState===G.OPEN&&a.send("ping")}),5e3);a.binaryType="arraybuffer",a.onerror=e=>{for(var t of a.recievers)t.reject(e.error);clearInterval(u),r(e.error)},a.onopen=()=>n(a),a.onmessage=e=>{if("string"==typeof e.data){if("pong"===e.data)return;var n=JSON.parse(e.data);if(t(n),n.hasOwnProperty("d")||0===n.code)return;a.recievers.length>0&&a.recievers.shift().resolve(n)}else{var r=new DataView(e.data);t({s:"ok",d:X(r,0)})}}}))}function ee(e,t){var n={T:"SUB_DATA",TLIST:t,SUB_T:1};return e.send(JSON.stringify(n)),$(e)}function te(e,t){var n={T:"SUB_L2",L2LIST:t,SUB_T:1};return e.send(JSON.stringify(n)),$(e)}function ne(e,t){var n={T:"SUB_DATA",TLIST:t,SUB_T:0};return e.send(JSON.stringify(n)),$(e)}function re(e,t){var n={T:"SUB_L2",L2LIST:t,SUB_T:0};return e.send(JSON.stringify(n)),$(e)}var ie=Object.freeze({__proto__:null,MARKET_DATA_URL:H,ORDER_UPDATE_URL:Y,Connection:K,connectOrderUpdate:j,subscribeOrderUpdate:J,unsubscribeOrderUpdate:W,connectMarketData:Z,subscribeMarketQuote:ee,subscribeMarketDepth:te,unsubscribeMarketQuote:ne,unsubscribeMarketDepth:re});const oe=new Map([[10,"NSE"],[11,"MCX"],[12,"BSE"]]),ae=new Map([["NSE","National Stock Exchange"],["MCX","Multi Commodity Exchange"],["BSE","Bombay Stock Exchange"]]);function ue(e){return oe.get(e)}const se=new Map([[10,"CM"],[11,"FO"],[12,"CD"],[20,"COM"]]),ce=new Map([["CM","Capital Market"],["FO","Equity Derivatives"],["CD","Currency Derivatives"],["COM","Commodity Derivatives"]]);function le(e){return se.get(e)}const de=new Map([[1,"LONG"],[-1,"SHORT"],[0,"CLOSED"]]),pe=new Map([["LONG",1],["SHORT",-1],["CLOSED",0]]),ye=new Map([["LONG","Long position"],["SHORT","Short position"],["CLOSED","Closed position"]]);function fe(e){return de.get(e)}function me(e){return pe.get(e)}const ge=new Map([[1,"BUY"],[-1,"SELL"]]),Te=new Map([["BUY",1],["SELL",-1]]),he=new Map([["BUY","Buy"],["SELL","Sell"]]);function ve(e){return ge.get(e)}function be(e){return Te.get(e)}const Pe=new Map([["M","MOBILE"],["W","WEB"],["R","ONE"],["A","ADMIN"],["ITS","API"]]),Se=new Map([["MOBILE","FYERS Mobile"],["WEB","FYERS Web"],["ONE","FYERS One"],["ADMIN","Admin"],["API","FYERS API"]]);function Ee(e){return Pe.get(e)}const Ce=new Map([[1,"CANCELLED"],[2,"TRADED"],[4,"TRANSIT"],[5,"REJECTED"],[6,"PENDING"],[7,"EXPIRED"]]),De=new Map([["CANCELLED","Cancelled"],["TRADED","Traded / Filled"],["TRANSIT","Transit"],["REJECTED","Rejected"],["PENDING","Pending"],["EXPIRED","Expired"]]),Ue=new Map([["C","CANCELLED"],["F","TRADED"],["T","TRANSIT"],["R","REJECTED"],["P","PENDING"],["E","EXPIRED"]]);function Oe(e){return Ce.get(e)}const Ie=new Map([[1,"LIMIT"],[2,"MARKET"],[3,"SL_MARKET"],[4,"SL_LIMIT"]]),we=new Map([["LIMIT",1],["MARKET",2],["SL_MARKET",3],["SL_LIMIT",4]]),Me=new Map([["LIMIT","Limit order"],["MARKET","Market order"],["SL_MARKET","Stop order (SL-M)"],["SL_LIMIT","Stoplimit order (SL-L)"]]),ke=new Map([["L","LIMIT"],["M","MARKET"],["S","SL_MARKET"],["R","SL_LIMIT"]]);function _e(e){return Ie.get(e)}function Re(e){return we.get(e)}const Ae=new Map([["DAY","End of day validity"],["IOC","Immediate or Cancel validity"]]);const Le=new Map([["CE","Call option"],["PE","Put option"]]);function Ne(e){return/pe|put|sell/i.test(e)?"PE":"CE"}const qe=new Map([["FUT","Future"],["CE","Call option"],["PE","Put option"]]);const Fe=new Map([["T1","The shares are purchased but not yet delivered to the demat account"],["HLD","The shares are purchased and are available in the demat account"]]);const Qe=new Map([["CNC","Cash N Carry or Delivery Order, for equity only"],["INTRADAY","Intraday Order, applicable for all segments"],["MARGIN","Margin Order, applicable only for derivatives"],["CO","Cover Order"],["BO","Bracket Order"]]),Be=new Map([["D","CNC"],["I","INTRADAY"],["M","MARGIN"],["C","CO"],["B","BO"]]);const xe=new Map([[0,"EQ"],[1,"PREFSHARES"],[2,"DEBENTURES"],[3,"WARRANTS"],[4,"MISC"],[10,"INDEX"],[11,"FUTIDX"],[12,"FUTIVX"],[13,"FUTSTK"],[14,"OPTIDX"],[15,"OPTSTK"],[16,"FUTCUR"],[17,"FUTIRT"],[18,"FUTIRC"],[19,"OPTCUR"],[20,"UNDCUR"],[21,"UNDIRC"],[22,"UNDIRT"],[23,"UNDIRD"],[24,"INDEX_CD"],[25,"FUTIRD"],[30,"FUTCOM"],[31,"OPTFUT"],[32,"OPTCOM"]]),Ge=new Map([["EQ","Equity Shares"],["PREFSHARES","Preference Shares"],["DEBENTURES","Collateral-free Debt"],["WARRANTS","Warrants on Stock"],["MISC","Miscellaneous"],["INDEX","Stock Market Index"],["FUTIDX","Futures on Index"],["FUTIVX","Futures on Volatility Index"],["FUTSTK","Futures on Stock"],["OPTIDX","Options on Index"],["OPTSTK","Options on Stock"],["FUTCUR","Futures on Currency"],["FUTIRT","Futures on Government of India Treasury Bills"],["FUTIRC","Futures on Government of India Bonds"],["OPTCUR","Options on Currency"],["UNDCUR","Underlying on Currency"],["UNDIRC","Underlying on Government of Bonds"],["UNDIRT","Underlying on Government of India Treasury Bills"],["UNDIRD","Underlying on 10 Year Notional coupon bearing GOI security"],["INDEX_CD","Market-indexed Certificate of deposit"],["FUTIRD","Futures on 10 Year Notional coupon bearing GOI security"],["FUTCOM","Futures on Commodity"],["OPTFUT","Options on Commodity Futures"],["OPTCOM","Options on Commodity"]]);function He(e){return xe.get(e)}const Ye=/^\w+:(\w+)-\w+|^\w+:(\w+)\d{2}\w{3}FUT|^\w+:(\w+)\d{2}\w{3}\d+[CP]E|^\w+:(\w+)\d{2}\w{1}\d{2}\d+[CP]E/;function Ve(e){var[t,n,,r,,i,,,,o]=e.split(",");return{symbol:o,token:t,description:n,lotSize:parseInt(r,10),isin:i||""}}function ze(e){var t=Ye.exec(e);return t[1]||t[2]||t[3]||t[4]}function Xe(e){var t=e.indexOf(":");return e.substring(0,t)}function Ke(e){return{app_id:e.appId,access_token:e.accessToken}}function $e(e){return{isin:e.isin,symbol:e.symbol,token:e.fytoken,exchange:ue(e.exchange),type:e.holdingType,quantity:e.quantity,remainingQuantity:e.remainingQuantity,buyPrice:e.costPrice,buyValue:e.costPrice*e.quantity,currentPrice:e.ltp,currentValue:e.marketVal,returns:e.pl,returnsPercent:e.pl/(e.costPrice*e.quantity)}}function je(e,t){var n=0;for(var r of e)"HLD"===r.holdingType&&n++;return{count:t.count_total,settledCount:n,investedValue:t.total_investment,currentValue:t.total_current_value,returns:t.total_pl,returnsPercent:t.pnl_perc}}function Je(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,name:e.ex_sym,description:e.description,segment:le(e.segment),instrument:He(e.instrument),exchange:ue(e.exchange),type:_e(e.type),side:ve(e.side),productType:e.productType,source:Ee(e.source)||null,status:Oe(e.status),offline:"True"===e.offlineOrder,limitPrice:e.limitPrice,stopPrice:e.stopPrice,quantity:e.qty,remainingQuantity:e.remainingQuantity,tradedQuantity:e.filledQty,disclosedQuantity:e.discloseQty,remainingDisclosedQuantity:e.dqQtyRem,validity:e.orderValidity,date:e.orderDateTime,parentId:e.parentId||null,priceChange:e.ch,priceChangePercent:e.chp,currentPrice:e.lp,tradedPrice:e.tradedPrice,message:e.message,pan:e.pan||null,clientId:e.clientId||null}}function We(e){var t={count:0,openCount:0,closedCount:0,quantity:0,remainingQuantity:0,tradedQuantity:0,disclosedQuantity:0,remainingDisclosedQuantity:0};for(var n of e)t.count++,t.openCount+=6===n.status||4===n.status?1:0,t.quantity+=n.qty,t.remainingQuantity+=n.remainingQuantity,t.tradedQuantity+=n.filledQty,t.disclosedQuantity+=n.discloseQty,t.remainingDisclosedQuantity+=n.dqQtyRem;return t.closedCount=t.count-t.openCount,t}function Ze(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,segment:le(e.segment),productType:e.productType,side:fe(e.side),quantity:e.qty,quantityMultiplier:e.qtyMulti_com,buyPrice:e.buyAvg,buyQuantity:e.buyQty,buyValue:e.buyVal,sellPrice:e.sellAvg,sellQuantity:e.sellQty,sellValue:e.sellVal,netPrice:e.netAvg,netQuantity:e.netQty,returns:e.pl,realizedReturns:e.realized_profit,unrealizedReturns:e.unrealized_profit,crossCurrency:"Y"===e.crossCurrency,rbiRefRate:e.rbiRefRate,currentPrice:e.ltp}}function et(e,t){var n=0,r=0;for(var i of e)n+=i.buyVal,r+=i.sellVal;return{count:t.count_total,openCount:t.count_open,closedCount:t.count_total-t.count_open,buyValue:n,sellValue:r,returns:t.pl_total,realizedReturns:t.pl_realized,unrealizedReturns:t.pl_unrealized}}function tt(e){return{id:e.id,orderId:e.orderNumber,symbol:e.symbol,token:e.fyToken,segment:le(e.segment),exchange:ue(e.exchange),side:ve(e.transactionType),productType:e.productType,orderType:_e(e.orderType),orderDate:e.orderDateTime,price:e.tradePrice,quantity:e.tradedQty,value:e.tradeValue,clientId:e.clientId}}function nt(e){var t={count:0,quantity:0,value:0};for(var n of e)t.count++,t.quantity+=n.tradedQty,t.value+=n.tradeValue;return t}function rt(e){return{symbol:e.symbol,type:Re(e.type||"MARKET"),side:be(e.side||"BUY"),productType:e.productType||"CNC",limitPrice:e.limitPrice||0,stopPrice:e.stopPrice||0,qty:e.quantity,disclosedQty:e.disclosedQuantity||0,validity:e.validity||"DAY",offlineOrder:e.offline?"True":"False",stopLoss:e.stopLoss||0,takeProfit:e.takeProfit||0}}function it(e){return{id:e.id,type:Re(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function ot(e){return{exchange:ue(e.exchange),segment:le(e.segment),type:e.market_type,status:e.status}}function at(e){var t={count:0,openCount:0,closedCount:0};for(var n of e)t.count++,"OPEN"===n.status?t.openCount++:t.closedCount++;return t}const ut=[1,2,3,5,10,15,20,30,60,120,240,1440];function st(e){var t=1,n=1/0;for(var r of ut){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}function ct(e){return{date:e[0],openPrice:e[1],highPrice:e[2],lowPrice:e[3],closePrice:e[4],volume:e[5]}}function lt(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function dt(e){var t={fromDate:0,toDate:0,openPrice:0,highPrice:0,lowPrice:0,closePrice:0,volume:0};if(0===e.length)return t;var n=e.length-1;for(var r of(t.fromDate=e[0][0],t.toDate=e[n][0],t.openPrice=e[0][1],t.highPrice=e[0][2],t.lowPrice=e[0][3],t.closePrice=e[n][4],e))t.highPrice=Math.max(t.highPrice,r[2]),t.lowPrice=Math.min(t.lowPrice,r[3]),t.volume+=r[5];return t}function pt(e){var t=e.v;return{symbol:e.n,token:t.fyToken,name:t.short_name,exchange:t.exchange,description:t.description,priceChange:t.ch,priceChangePercent:t.chp,currentPrice:t.lp,priceSpread:t.spread,sellPrice:t.ask,buyPrice:t.bid,openPrice:t.open_price,highPrice:t.high_price,lowPrice:t.low_price,closePrice:t.prev_close_price,volume:t.volume,date:t.tt,candle:lt(t.cmd)}}function yt(e){return{price:e.price,volume:e.volume,orders:e.ord}}function ft(e,t){return{price:e.price/t,volume:e.volume,orders:e.ord}}function mt(e){return{id:e.transactionId,isin:e.isin,quantity:e.qty,remainingQuantity:e.qty-e.qtyUtlize,entryDate:e.entryDate,startDate:e.startDate,endDate:e.endDate,source:e.source,status:e.status,clientId:e.clientId,errorCode:e.errCode,errorCount:e.errorCount,reason:e.reason}}function gt(e){var t={count:0,quantity:0,remainingQuantity:0};for(var n of e)t.count++,t.quantity+=n.qty,t.remainingQuantity+=n.qty-n.qtyUtlize;return t}function Tt(e){return{isin_code:e.isin,qty:e.quantity}}function ht(e,t){return.01*Math.round(e*t)}function vt(e){var t=ht(e,.1);return t+ht(t,18)+ht(e,.00325)+ht(e,.015)+ht(e,1e-4)}class bt extends Error{constructor(e,t){super(t),this.code=e,this.name=this.constructor.name,this.stack=new Error(t).stack}}function Pt(e,t,n="default"){return f({client_id:(r={appId:e,redirectUrl:t,state:n}).appId,redirect_uri:r.redirectUrl,response_type:"code",state:r.state});var r}function St(e,t){return m({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode});var n}function Et(e){if("ok"!==e.s)throw new bt(e.code,e.message)}function Ct(e){if(""===e.id)throw new bt(e.code,e.message)}async function Dt(e){var t,n=await g(Ke(e));return Et(n),{id:(t=n.data).fy_id,email:t.email_id,name:t.name,pan:t.PAN}}async function Ut(e){var t=await T(Ke(e));return Et(t),function(e){var t={},n={};for(var r of e.fund_limit)switch(r.id){case 9:t.start=r.equityAmount,n.start=r.commodityAmount;break;case 6:t.deposits=r.equityAmount,n.deposits=r.commodityAmount;break;case 4:t.realizedReturns=r.equityAmount,n.realizedReturns=r.commodityAmount;break;case 5:t.collaterals=r.equityAmount,n.collaterals=r.commodityAmount;break;case 8:t.adhoc=r.equityAmount,n.adhoc=r.commodityAmount;break;case 2:t.utilized=r.equityAmount,n.utilized=r.commodityAmount;break;case 7:t.receivables=r.equityAmount,n.receivables=r.commodityAmount;break;case 10:t.available=r.equityAmount,n.available=r.commodityAmount;break;case 3:t.clear=r.equityAmount,n.clear=r.commodityAmount;break;case 1:t.total=r.equityAmount,n.total=r.commodityAmount}return{equity:t,commodity:n}}(t)}async function Ot(e){var t,n=await h(Ke(e));return Et(n),{details:(t=n).holdings.map($e),overall:je(t.holdings,t.overall)}}async function It(e,t){var n=await v(Ke(e),{id:t});return Et(n),Je(n.orderBook[0])}async function wt(e){var t,n=await b(Ke(e));return Et(n),{details:(t=n).orderBook.map(Je),overall:We(t.orderBook)}}async function Mt(e){var t,n=await P(Ke(e));return Et(n),{details:(t=n).netPositions.map(Ze),overall:et(t.netPositions,t.overall)}}async function kt(e){var t,n=await S(Ke(e));return Et(n),{details:(t=n).tradeBook.map(tt),overall:nt(t.tradeBook)}}async function _t(e,t){var n=await E(Ke(e),rt(t));return Ct(n),n.id}function Rt(e,t){var n=C(Ke(e),t.map(rt));return t.map(((e,t)=>n.then((e=>(Et(e),Ct(e.data[t].body),e.data[t].body.id)))))}async function At(e,t){var n=await D(Ke(e),it(t));return Et(n),n.id}function Lt(e,t){var n=U(Ke(e),t.map(it));return t.map(((e,t)=>n.then((e=>{Et(e),Ct(e.data[t].body)}))))}async function Nt(e,t){Et(await O(Ke(e),{id:t}))}function qt(e,t){var n=I(Ke(e),t.map((e=>({id:e}))));return t.map(((e,t)=>n.then((e=>{Et(e),Ct(e.data[t].body)}))))}async function Ft(e,t){Et(await w(Ke(e),{id:t}))}async function Qt(e){Et(await M(Ke(e)))}async function Bt(e,t){var n;Et(await k(Ke(e),(n=t,{symbol:n.symbol,positionSide:me(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"})))}async function xt(e){var t,n=await _(Ke(e));return Et(n),{details:(t=n).marketStatus.map(ot),overall:at(t.marketStatus)}}async function Gt(e,t){var n,r=await R(Ke(e),(n=t,{symbol:n.symbol,resolution:st(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"}));return Et(r),function(e){return{details:e.candles.map(ct),overall:dt(e.candles)}}(r)}async function Ht(e,t){var n=await A(Ke(e),{symbols:t.join()});return Et(n),n.d.map(pt)}async function Yt(e,t){var n=await L(Ke(e),{symbol:t,ohlcv_flag:1});return Et(n),function(e){var t=Object.keys(e.d);if(0===t.length)return null;var n=t[0],r=e.d[n];return{symbol:n,token:null,name:ze(n),exchange:Xe(n),expiryDate:r.expiry,currentPrice:r.ltq,lowerCircuitPrice:r.lower_ckt,upperCircuitPrice:r.upper_ckt,openPrice:r.o,highPrice:r.h,lowPrice:r.l,closePrice:r.c,volume:r.v,priceChange:r.ch,priceChangePercent:r.chp,openInterest:r.oi,previousOpenInterest:r.pdoi,openInterestChangePercent:r.oipercent,tradedQuantity:r.ltq,tradedDate:r.ltt,netPrice:r.atp,buyQuantity:r.totalbuyqty,sellQuantity:r.totalsellqty,buyOffers:r.bids.map(yt),sellOffers:r.ask.map(yt)}}(n)}function Vt(e,t,n){return N(0,{exchange:t,segment:n})}function zt(e){for(var t=[],n=/[^\n]+/g,r=null;null!=(r=n.exec(e));)t.push(Ve(r[0]));return t}async function Xt(e,t,n){return zt(await Vt(0,t,n))}async function Kt(e){Et(await q(Ke(e)))}async function $t(e){var t,n,r=await F(Ke(e));return Et(r),{details:(n=0===(t=r).data.length?[]:t.data).map(mt),overall:gt(n)}}function jt(e,t){return Q(Ke(e),{recordLst:t.map(Tt)})}async function Jt(e,t){var n=await B(Ke(e),{transactionId:t});return Et(n),n.data.FAILED_CNT>0?-n.data.FAILED_CNT:n.data.SUCEESS_CNT}function Wt(e,t){return j(Ke(e),(e=>{e.d&&t(function(e){var t=e.d;return{id:t.id,symbol:t.symbol,token:t.fyToken,type:_e(t.type),side:ve(t.side),productType:t.productType,status:Oe(t.status),validity:t.orderValidity,offline:t.offlineOrder,quantity:t.qty,remainingQuantity:t.remainingQuantity,filledQuantity:t.filledQty,disclosedQuantity:t.discloseQty,remainingDisclosedQuantity:t.dqQtyRem,limitPrice:t.limitPrice,stopPrice:t.stopPrice,date:t.orderDateTime,parentId:t.parentId||null,tradedPrice:t.tradedPrice,message:t.message}}(e))}))}async function Zt(e){var t=await J(e);if(t.code<0)throw new bt(t.code,t.message)}async function en(e){var t=await W(e);if(t.code<0)throw new bt(t.code,t.message)}function tn(e,t,n=null){return Z(Ke(e),(e=>{e.d&&t(function(e,t){var n=e.d,r=n.token.toString(),i=n.price_conv||1,o=null!=t&&t.get(r)||null,a=n.ltp-n.prev_close_price,u=null==n.bids?n.bid:n.bids[0].price,s=null==n.asks?n.ask:n.asks[0].price;return{symbol:o,token:r,name:null!=o?ze(o):null,exchange:null!=o?Xe(o):null,date:n.tt,marketStatus:n.marketStat,currentPrice:n.ltp/i,openPrice:n.open_price/i,highPrice:n.high_price/i,lowPrice:n.low_price/i,closePrice:n.prev_close_price/i,priceChange:a/i,priceChangePercent:a/n.prev_close_price,candle:{date:n.tt,openPrice:n.o/i,highPrice:n.h/i,lowPrice:n.l/i,closePrice:n.c/i,volume:Number(n.v)},openInterest:Number(n.oi),previousOpenInterest:Number(n.pdoi),tradedQuantity:n.LTQ,tradedDate:n.L2_LTT,tradedPrice:n.ATP/i,volume:n.volume,buyQuantity:Number(n.tot_buy),sellQuantity:Number(n.tot_sell),buyPrice:u/i,sellPrice:s/i,priceSpread:(s-u)/i,buyOffers:null==n.bids?null:n.bids.map((e=>ft(e,i))),sellOffers:null==n.asks?null:n.asks.map((e=>ft(e,i)))}}(e,n))}))}async function nn(e,t){var n=await ee(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function rn(e,t){var n=await te(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function on(e,t){var n=await ne(e,t);if(n.code<0)throw new bt(n.code,n.message)}async function an(e,t){var n=await re(e,t);if(n.code<0)throw new bt(n.code,n.message)}n.Api=class{constructor(e,t){this.appId=e,this.accessToken=t,this.symbolDetails=new Map,this.tokenSymbol=new Map,this.orderUpdateConnection=null,this.marketDataConnection=null}static loginStep1(e,t,n="default"){return Pt(e,t,n)}static loginStep2(e,t){return St(e,t)}static getSymbolMaster(e,t){return Vt(0,e,t)}getProfile(){return Dt(this)}getFunds(){return Ut(this)}getHoldings(){return Ot(this)}getOrder(e){return It(this,e)}getOrders(){return wt(this)}getPositions(){return Mt(this)}getTrades(){return kt(this)}placeOrder(e){return _t(this,e)}placeOrders(e){return Rt(this,e)}modifyOrder(e){return At(this,e)}modifyOrders(e){return Lt(this,e)}cancelOrder(e){return Nt(this,e)}cancelOrders(e){return qt(this,e)}exitPosition(e){return Ft(this,e)}exitAllPositions(){return Qt(this)}convertPosition(e){return Bt(this,e)}getMarketStatus(){return xt(this)}getMarketHistory(e){return Gt(this,e)}getMarketQuotes(e){return Ht(this,e)}getMarketDepth(e){return Yt(this,e)}processSymbolMaster(e){var t=zt(e);for(var n of t)this.symbolDetails.set(n.symbol,n),this.tokenSymbol.set(n.token,n.symbol);return t}async loadSymbolMaster(e,t){var n=await Xt(0,e,t);for(var r of n)this.symbolDetails.set(r.symbol,r),this.tokenSymbol.set(r.token,r.symbol);return n}generateEdisTpin(){return Kt(this)}getEdisTransactions(){return $t(this)}submitEdisHoldingsStep(e){return jt(this,e)}inquireEdisTransaction(e){return Jt(this,e)}connectOrderUpdate(e){return null!=this.orderUpdateConnection&&this.orderUpdateConnection.then((e=>e.close())),this.orderUpdateConnection=Wt(this,e)}async subscribeOrderUpdate(){return Zt(await this.orderUpdateConnection)}async unsubscribeOrderUpdate(){return en(await this.orderUpdateConnection)}async connectMarketData(e){return null!=this.marketDataConnection&&this.marketDataConnection.then((e=>e.close())),this.marketDataConnection=tn(this,e,this.tokenSymbol)}async subscribeMarketQuote(e){return nn(await this.marketDataConnection,e)}async subscribeMarketDepth(e){return rn(await this.marketDataConnection,e)}async unsubscribeMarketQuote(e){return on(await this.marketDataConnection,e)}async unsubscribeMarketDepth(e){return an(await this.marketDataConnection,e)}},n.cancelOrder=Nt,n.cancelOrders=qt,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.0026)+ht(n,.0018)+ht(n,.002)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.01);return t+n+ht(t+n,18)+ht(e,.0026)+ht(e,.0018)+ht(e,.002)+ht(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+ht(20,18)+ht(n,.05)+ht(n,3e-4)+ht(n,1e-4)):function(e){var t=ht(e,.05);return 20+t+ht(20+t,18)+ht(e,.05)+ht(e,3e-4)+ht(e,1e-4)}(t);var n},n.connectMarketData=tn,n.connectOrderUpdate=Wt,n.convertPosition=Bt,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.00115)+ht(n,5e-4)+ht(n,1e-4)+ht(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+ht(20,18)+ht(n,.04)+ht(n,.009)+ht(n,1e-4)+ht(n,1e-4);var n},n.derivativeType=function(e){return/fut|lat|buy/.test(e)?"FUT":Ne(e)},n.derivativeTypeDescription=function(e){return qe.get(e)},n.equityDeliveryCharges=function(e,t){return"BUY"===e?vt(t):12.5+vt(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.0019)+ht(n,5e-4)+ht(n,.002)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.01);return t+n+ht(t+n,18)+ht(e,.0019)+ht(e,5e-4)+ht(e,.002)+ht(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,ht(n,.03)))+ht(r,18)+ht(n,.00325)+ht(n,.003)+ht(n,1e-4)):function(e){var t=Math.min(20,ht(e,.03)),n=ht(e,.025);return t+n+ht(t+n,18)+ht(e,.00325)+ht(e,.003)+ht(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+ht(20,18)+ht(n,.053)+ht(n,.009)+ht(n,.003)+ht(n,1e-4)):function(e){var t=ht(e,.05);return 20+t+ht(20+t,18)+ht(e,.053)+ht(e,.009)+ht(e,.003)+ht(e,1e-4)}(t);var n},n.exchange=function(e){return/bse|native|bombay|mumbai/i.test(e)?"BSE":/\bcom\b|mcx|multi|commodit/i.test(e)?"MCX":"NSE"},n.exchangeDescription=function(e){return ae.get(e)},n.exitAllPositions=Qt,n.exitPosition=Ft,n.generateEdisTpin=Kt,n.getEdisTransactions=$t,n.getFunds=Ut,n.getHoldings=Ot,n.getMarketDepth=Yt,n.getMarketHistory=Gt,n.getMarketQuotes=Ht,n.getMarketStatus=xt,n.getOrder=It,n.getOrders=wt,n.getPositions=Mt,n.getProfile=Dt,n.getSymbolMaster=Vt,n.getTrades=kt,n.holdingType=function(e){return/un|not|pend|t1/i.test(e)?"T1":"HLD"},n.holdingTypeDescription=function(e){return Fe.get(e)},n.http=x,n.inquireEdisTransaction=Jt,n.instrumentType=function(e){var t=/fut|future/i.test(e),n=/opt|option/i.test(e),r=/idx|index/i.test(e),i=/und|underlying/i.test(e);return/com(\b|$)|commodit/i.test(e)?n?t?"OPTFUT":"OPTCOM":r?"FUTIDX":"FUTCOM":/(^|\b)und|cd(\b|$)|ir[cdt](\b|$)|cur|gov|bond|trea|coup/i.test(e)?/irc(\b|$)|bond/i.test(e)?i?"UNDIRC":"FUTIRC":/ird(\b|$)|coup/i.test(e)?i?"UNDIRD":"FUTIRD":/irt(\b|$)|trea/i.test(e)?i?"UNDIRT":"FUTIRT":r?"INDEX_CD":n?"OPTCUR":"FUTCUR":t||n?/ivx|volatil/i.test(e)?"FUTIVX":r?n?"OPTIDX":"FUTIDX":n?"OPTSTK":"FUTSTK":r?"INDEX":/misc/i.test(e)?"MISC":/warrant/i.test(e)?"WARRANTS":/deb/i.test(e)?"DEBENTURES":/pref/i.test(e)?"PREFSHARES":"EQ"},n.instrumentTypeDescription=function(e){return Ge.get(e)},n.loadSymbolMaster=Xt,n.loginStep1=Pt,n.loginStep2=St,n.modifyOrder=At,n.modifyOrders=Lt,n.optionType=Ne,n.optionTypeDescription=function(e){return Le.get(e)},n.orderSide=function(e){return/down|sell|short|crash/i.test(e)?"SELL":"BUY"},n.orderSideDescription=function(e){return he.get(e)},n.orderSource=function(e){return/its|api|sys/i.test(e)?"API":/one|desk/i.test(e)?"ONE":/mob|app/i.test(e)?"MOBILE":/admin/i.test(e)?"ADMIN":"WEB"},n.orderSourceDescription=function(e){return Se.get(e)},n.orderStatus=function(e){var t=e.charAt(0).toUpperCase();return/traded/i.test(e)&&(t="F"),Ue.get(t)},n.orderStatusDescription=function(e){return De.get(e)},n.orderType=function(e){var t=e.charAt(0).toUpperCase();return/s.+l(?!oss)/i.test(e)&&(t="R"),ke.get(t)},n.orderTypeDescription=function(e){return Me.get(e)},n.orderValidity=function(e){return/ioc|cancel|immediate/i.test(e)?"IOC":"DAY"},n.orderValidityDescription=function(e){return Ae.get(e)},n.placeOrder=_t,n.placeOrders=Rt,n.positionSide=function(e){return/up|buy|long|rally/i.test(e)?"LONG":/down|sell|short|crash/i.test(e)?"SHORT":"CLOSED"},n.positionSideDescription=function(e){return ye.get(e)},n.processSymbolMaster=zt,n.productType=function(e){var t=e.charAt(0).toUpperCase();return/cnc|cash|carry|deliver/i.test(e)&&(t="D"),Be.get(t)},n.productTypeDescription=function(e){return Qe.get(e)},n.segment=function(e){return/\bcom\b|mcx|multi|commodit/i.test(e)?"COM":/\bcd\b|currenc/i.test(e)?"CD":/\bfn?o\b|fut|opt|deriv/i.test(e)?"FO":"CM"},n.segmentDescription=function(e){return ce.get(e)},n.submitEdisHoldingsStep=jt,n.subscribeMarketDepth=rn,n.subscribeMarketQuote=nn,n.subscribeOrderUpdate=Zt,n.symbolDerivativeType=function(e){var t=/(?:FUT|CE|PE)$/.exec(e);return null!=t?t[0]:null},n.symbolDescription=function(e,t){return t.get(e).description},n.symbolExchange=Xe,n.symbolIsin=function(e,t){return t.get(e).isin},n.symbolLotSize=function(e,t){return t.get(e).lotSize},n.symbolName=ze,n.symbolOptionType=function(e){var t=e.substring(e.length-2);return"CE"===t||"PE"===t?t:null},n.symbolSeries=function(e){var t=e.lastIndexOf("-");return t>0?e.substring(t):null},n.symbolStrikePrice=function(e){var t=/([\d\.]+)[CP]E$/.exec(e);return null!=t?parseFloat(t[1]):0},n.symbolToken=function(e,t){return t.get(e).token},n.unsubscribeMarketDepth=an,n.unsubscribeMarketQuote=on,n.unsubscribeOrderUpdate=en,n.websocket=ie},{}]},{},[1])(1)}));
{
"name": "extra-fyers.web",
"version": "1.3.2",
"version": "1.3.3",
"description": "A Javascript interface for FYERS API.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc