Socket
Socket
Sign inDemoInstall

extra-fyers.web

Package Overview
Dependencies
Maintainers
1
Versions
155
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 0.0.56 to 0.0.57

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";Object.defineProperty(n,"__esModule",{value:!0});const r=new Map([[-209,"Invalid order id"],[-101,"Invalid order type"],[-305,"For CO orders only market and limit orders are allowed"],[-323,"For BO orders only market and limit orders are allowed"],[-308,"Invalid limit price"],[-309,"Invalid stop price"],[-310,"Invalid order quantity"],[-311,"Invalid stop loss price"],[-313,"Invalid order side of either buy or sell"],[-314,"Invalid product type for the order"],[-315,"Invalid price for stop limit order"],[-316,"Invalid stop loss price for CO/BO orders"],[-323,"Invalid stop loss value"],[-325,"Ivalid target value (take_profit)"],[-326,"Invalid order validity"],[-327,"Invalid order disclosed quantity"],[-328,"Invalid order offline flag"],[-201,"Connection issue while processing your request"],[-202,"Connection timed out"],[-204,"Request wasnt processed"],[-205,"Market wasnt able to accept or process the request"],[-157,"User doesnt exist"],[-159,"Invalid order number"],[-161,"This order has already been cancelled"],[-162,"This order has already traded"],[-163,"Order modfication wasnt done successfully"],[-164,"This order has already been rejected"],[-390,"Invalid stop price"],[-392,"Price is not in multiples of tick size"],[-353,"API limit exceeded"],[-372,"Invalid price"],[-397,"Position quantity is zero"],[-398,"No open positions"],[-399,"No pending orders to be closed/cancelled"],[-329,"Please check if exit positions is complete"],[-373,"No permission"],[-374,"Invalid authorization code (auth_code)"],[-371,"Invalid SHA256 hash of (app_id:secret_key)"],[-17,"Invalid access token used for authentication"],[-352,"Invalid app id"],[-96,"An unexpected error occurred when processing request"],[-351,"Greater than 50 symbols"],[-300,"Invalid symbol"],[-310,"Invalid symbols"],[-301,"Invalid resolution format"],[-302,"Invalid historical timestamp from when you require data"],[-303,"Invalid historical timestamp till when you require data"],[-356,"The range_from value cannot be greater than range_to value"],[-334,"Invalid key date format value"],[-335,"Historical timestamp from when you require data not in epoch format"],[-336,"Historical timestamp till when you require data not in epoch format"],[-337,"Historical timestamp from when you require data not in YYYY-MM-DD format"],[-338,"Historical timestamp till when you require data not in YYYY-MM-DD format"],[-339,"The range cannot be more than 1 year for day resolution"],[-341,"The range cannot be more than 100 days for 1 min resolution"],[-343,"The range cannot be more than 100 days for 2 min resolution"],[-344,"The range cannot be more than 100 days for 3 min resolution"],[-345,"The range cannot be more than 100 days for 5 min resolution"],[-346,"The range cannot be more than 100 days for 10 min resolution"],[-347,"The range cannot be more than 100 days for 15 min resolution"],[-348,"The range cannot be more than 100 days for 20 min resolution"],[-349,"The range cannot be more than 100 days for 30 min resolution"],[-353,"The range cannot be more than 100 days for 60 min resolution"],[-354,"The range cannot be more than 100 days for 120 min resolution"],[-355,"The range cannot be more than 100 days for 240 min resolution"]]);function i(e){return r.get(e)}function o(e){return parseInt(e,10)>50?"19"+e:"20"+e}function a(e){return e.substring(2)}const u=new Map([["JAN","January"],["FEB","February"],["MAR","March"],["APR","April"],["MAY","May"],["JUN","June"],["JUL","July"],["AUG","August"],["SEP","September"],["OCT","October"],["NOV","November"],["DEC","December"]]);function s(e){return u.get(e)}function c(e){return e.substring(0,3).toUpperCase()}const l=new Map([["1","January"],["2","February"],["3","March"],["4","April"],["5","May"],["6","June"],["7","July"],["8","August"],["9","September"],["O","October"],["N","November"],["D","December"]]),d=new Map([["JAN","1"],["FEB","2"],["MAR","3"],["APR","4"],["MAY","5"],["JUN","6"],["JUL","7"],["AUG","8"],["SEP","9"],["OCT","O"],["NOV","N"],["DEC","D"]]);function p(e){return l.get(e)}function y(e){var t=e.substring(0,3).toUpperCase();return d.get(t)}function f(e){return e.replace(/^0+/,"")}function m(e){return e.padStart(2,"0")}var T;!function(e){e[e.NSE=10]="NSE",e[e.MCX=11]="MCX",e[e.BSE=12]="BSE"}(T||(T={}));const g=new Map([[10,"National Stock Exchange (NSE)"],[11,"Multi Commodity Exchange (MCX)"],[12,"Bombay Stock Exchange (BSE)"]]),h=new Map([["N",10],["M",11],["B",12]]);function v(e){return g.get(e)}function C(e){var t=e.charAt(0).toUpperCase();return h.get(t)}var D;!function(e){e[e.Capital=10]="Capital",e[e.Derivative=11]="Derivative",e[e.Currency=12]="Currency",e[e.Commodity=20]="Commodity"}(D||(D={}));const I=new Map([[10,"Capital Market (CM)"],[11,"Equity Derivatives (FO)"],[12,"Currency Derivatives (CD)"],[20,"Commodity Derivatives (COM)"]]),P=new Map([["CM",10],["FO",11],["CD",12],["COM",20]]);function E(e){return I.get(e)}function O(e){var t="CM";return/^com/i.test(e)?t="COM":/^cur/i.test(e)?t="CD":/der|fut|opt/i.test(e)&&(t="FO"),P.get(t)}var R;!function(e){e[e.Long=1]="Long",e[e.Short=-1]="Short",e[e.Closed=0]="Closed"}(R||(R={}));const S=new Map([[1,"Long"],[-1,"Short"],[0,"Closed position"]]),U=new Map([["L",1],["S",-1],["C",0]]);function M(e){return S.get(e)}function b(e){var t=e.charAt(0).toUpperCase();return U.get(t)}var A;!function(e){e[e.Buy=1]="Buy",e[e.Sell=-1]="Sell"}(A||(A={}));const N=new Map([[1,"Buy"],[-1,"Sell"]]),w=new Map([["B",1],["S",-1]]);function F(e){return N.get(e)}function q(e){var t=e.charAt(0).toUpperCase();return w.get(t)}var _;!function(e){e.Mobile="M",e.Web="W",e.FyersOne="R",e.Admin="A",e.API="ITS"}(_||(_={}));const L=new Map([["M","Mobile"],["W","Web"],["R","Fyers One"],["A","Admin"],["ITS","API"]]),k=new Map([["MO","M"],["WE","W"],["ON","R"],["AD","A"],["AP","ITS"]]);function x(e){return L.get(e)}function B(e){var t=e.split(" "),n=t[t.length-1].substring(0,2).toUpperCase();return k.get(n)}var Q;!function(e){e[e.Cancelled=1]="Cancelled",e[e.Traded=2]="Traded",e[e.Unused=3]="Unused",e[e.Transit=4]="Transit",e[e.Rejected=5]="Rejected",e[e.Pending=6]="Pending",e[e.Expired=7]="Expired"}(Q||(Q={}));const X=new Map([[1,"Cancelled"],[2,"Traded / Filled"],[3,"For future use"],[4,"Transit"],[5,"Rejected"],[6,"Pending"],[7,"Expired"]]),H=new Map([["C",1],["F",2],["T",4],["R",5],["P",6],["E",7]]);function z(e){return X.get(e)}function G(e){/traded/i.test(e)&&(e="Filled");var t=e.charAt(0).toUpperCase();return H.get(t)}var V;!function(e){e[e.Limit=1]="Limit",e[e.Market=2]="Market",e[e.SlMarket=3]="SlMarket",e[e.SlLimit=4]="SlLimit"}(V||(V={}));const Y=new Map([[1,"Limit order"],[2,"Market order"],[3,"Stop order (SL-M)"],[4,"Stoplimit order (SL-L)"]]),K=new Map([["L",1],["M",2],["S",3],["R",4]]);function W(e){return Y.get(e)}function J(e){var t=e.charAt(0).toUpperCase();return/s.+l(?!oss)/i.test(e)&&(t="R"),K.get(t)}var j;!function(e){e.Day="DAY",e.IOC="IOC"}(j||(j={}));const $=new Map([["DAY","End of day validity (DAY)"],["IOC","Immediate or Cancel validity (IOC)"]]);function Z(e){return/ioc|imm/i.test(e)?"IOC":"DAY"}var ee;!function(e){e.Call="CE",e.Put="PE"}(ee||(ee={}));const te=new Map([["CE","Call Option (CE)"],["PE","Put Option (PE)"]]);function ne(e){return te.get(e)}function re(e){return/^[ps]/i.test(e)?"PE":"CE"}var ie;!function(e){e.Purchased="T1",e.Delivered="HLD"}(ie||(ie={}));const oe=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"]]);function ae(e){return oe.get(e)}function ue(e){return/not|un/i.test(e)?"T1":"HLD"}var se;!function(e){e.CNC="CNC",e.Intraday="INTRADAY",e.Margin="MARGIN",e.Cover="CO",e.Bracket="BO"}(se||(se={}));const ce=new Map([["CNC","Cash N Carry or Delivery Order, for equity only (CNC)"],["INTRADAY","Intraday Order, applicable for all segments (INTRADAY)"],["MARGIN","Margin Order, applicable only for derivatives (MARGIN)"],["CO","Cover Order (CO)"],["BO","Bracket Order (BO)"]]),le=new Map([["D","CNC"],["I","INTRADAY"],["M","MARGIN"],["M","MARGIN"],["C","CO"],["B","BO"]]);function de(e){return ce.get(e)}function pe(e){/cnc|cash|carry/i.test(e)&&(e="Delivery");var t=e.charAt(0).toUpperCase();return le.get(t)}var ye;!function(e){e[e.EQ=0]="EQ",e[e.PREFSHARES=1]="PREFSHARES",e[e.DEBENTURES=2]="DEBENTURES",e[e.WARRANTS=3]="WARRANTS",e[e.MISC=4]="MISC",e[e.INDEX=10]="INDEX",e[e.FUTIDX=11]="FUTIDX",e[e.FUTIVX=12]="FUTIVX",e[e.FUTSTK=13]="FUTSTK",e[e.OPTIDX=14]="OPTIDX",e[e.OPTSTK=15]="OPTSTK",e[e.FUTCUR=16]="FUTCUR",e[e.FUTIRT=17]="FUTIRT",e[e.FUTIRC=18]="FUTIRC",e[e.OPTCUR=19]="OPTCUR",e[e.UNDCUR=20]="UNDCUR",e[e.UNDIRC=21]="UNDIRC",e[e.UNDIRT=22]="UNDIRT",e[e.UNDIRD=23]="UNDIRD",e[e.INDEX_CD=24]="INDEX_CD",e[e.FUTIRD=25]="FUTIRD",e[e.FUTCOM=30]="FUTCOM",e[e.OPTFUT=31]="OPTFUT",e[e.OPTCOM=32]="OPTCOM"}(ye||(ye={}));const fe=new Map([[0,"Equity Shares (EQ)"],[1,"Preference Shares (PREFSHARES)"],[2,"Collateral-free Debt (DEBENTURES)"],[3,"Warrants on Stock (WARRANTS)"],[4,"Miscellaneous (MISC)"],[10,"Stock Market Index (INDEX)"],[11,"Futures on Index (FUTIDX)"],[12,"Futures on Volatility Index (FUTIVX)"],[13,"Futures on Stock (FUTSTK)"],[14,"Options on Index (OPTIDX)"],[15,"Options on Stock (OPTSTK)"],[16,"Futures on Currency (FUTCUR)"],[17,"Futures on Government of India Treasury Bills (FUTIRT)"],[18,"Futures on Government of India Bonds (FUTIRC)"],[19,"Options on Currency (OPTCUR)"],[20,"Underlying on Currency (UNDCUR)"],[21,"Underlying on Government of Bonds (UNDIRC)"],[22,"Underlying on Government of India Treasury Bills (UNDIRT)"],[23,"Underlying on 10 Year Notional coupon bearing GOI security (UNDIRD)"],[24,"Market-indexed Certificate of deposit (INDEX_CD)"],[25,"Futures on 10 Year Notional coupon bearing GOI security (FUTIRD)"],[30,"Futures on Commodity (FUTCOM)"],[31,"Options on Commodity Futures (OPTFUT)"],[32,"Options on Commodity (OPTCOM)"]]),me=new Map([["EQ",0],["PREFSHARES",1],["DEBENTURES",2],["WARRANTS",3],["MISC",4],["INDEX",10],["FUTIDX",11],["FUTIVX",12],["FUTSTK",13],["OPTIDX",14],["OPTSTK",15],["FUTCUR",16],["FUTIRT",17],["FUTIRC",18],["OPTCUR",19],["UNDCUR",20],["UNDIRC",21],["UNDIRT",22],["UNDIRD",23],["INDEX_CD",24],["FUTIRD",25],["FUTCOM",30],["OPTFUT",31],["OPTCOM",32]]);function Te(e){return fe.get(e)}function ge(e){var t="EQ",n=/fut|future/i.test(e),r=/opt|option/i.test(e),i=/idx|index/i.test(e),o=/und|underlying/i.test(e);return t=/com(\b|$)|commodit/i.test(e)?r?n?"OPTFUT":"OPTCOM":i?"FUTIDX_COM":"FUTCOM":/(^|\b)und|cd(\b|$)|ir[cdt](\b|$)|cur|gov|bond|trea|coup/i.test(e)?/irc(\b|$)|bond/i.test(e)?o?"UNDIRC":"FUTIRC":/ird(\b|$)|coup/i.test(e)?o?"UNDIRD":"FUTIRD":/irt(\b|$)|trea/i.test(e)?o?"UNDIRT":"FUTIRT":i?"INDEX_CD":r?"OPTCUR":"FUTCUR":n||r?/ivx|volatil/i.test(e)?"FUTIVX":i?r?"OPTIDX":"FUTIDX":r?"OPTSTK":"FUTSTK":i?"INDEX":/misc/i.test(e)?"MISC":/warrant/i.test(e)?"WARRANTS":/deb/i.test(e)?"DEBENTURES":/pref/i.test(e)?"PREFSHARES":"EQ",me.get(t)}var he=Object.freeze({__proto__:null,errorDescription:i,year2Description:o,year2:a,month3Description:s,month3:c,month1Description:p,month1:y,day2Description:f,day2:m,get Exchange(){return T},exchangeDescription:v,exchange:C,get Segment(){return D},segmentDescription:E,segment:O,get PositionSide(){return R},positionSideDescription:M,positionSide:b,get OrderSide(){return A},orderSideDescription:F,orderSide:q,get OrderSource(){return _},orderSourceDescription:x,orderSource:B,get OrderStatus(){return Q},orderStatusDescription:z,orderStatus:G,get OrderType(){return V},orderTypeDescription:W,orderType:J,get OrderValidity(){return j},orderValidityDescription:function(e){return $.get(e)},orderValidity:Z,get OptionType(){return ee},optionTypeDescription:ne,optionType:re,get HoldingType(){return ie},holdingTypeDescription:ae,holdingType:ue,get ProductType(){return se},productTypeDescription:de,productType:pe,get InstrumentType(){return ye},instrumentTypeDescription:Te,instrumentType:ge});function ve(e,t){var n=new Error(t);return n.code=e.status,n.response=null,n}function Ce(e,t){return null!=t.headers&&(!!t.headers.hasOwnProperty(e)||!!t.headers.hasOwnProperty(e.toLowerCase()))}function De(e,t){return new Promise(((n,r)=>{var i=t.url,o=t.method||"GET",a=!1,u=!1,s=!1,c=new XMLHttpRequest;c.open(o,i),function(e,t){for(var n in null==t.body||Ce("Content-Type",t)||e.setRequestHeader("Content-Type","application/json; charset=utf-8"),Ce("Accept",t)||e.setRequestHeader("Accept","application/json, text/*"),t.headers)e.setRequestHeader(n,t.headers[n])}(c,t),t.timeout&&(c.timeout=t.timeout),c.responseType=e,c.onerror=function(e){a=!0;var t=e.target;r(ve(t,"Unexpected error occurred"))},c.onabort=function(e){u=!0;var t=e.target;r(ve(t,"Request was aborted"))},c.ontimeout=function(e){s=!0;var t=e.target;r(ve(t,"Request timed out"))},c.onreadystatechange=function(t){if(!(a||u||s)){var o=t.target;if(function(e){return e.readyState===e.DONE}(o))try{var c=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}(o,e);!function(e,t=""){return e.status>=200&&e.status<300||304===e.status||/^file:\/\//i.test(t)}(o,i)?setTimeout((function(){a||u||s||r(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}(o,c))})):n(c)}catch(t){r(t)}}},null==t.body?c.send():t.body instanceof FormData||t.body instanceof URLSearchParams?c.send(t.body):c.send(JSON.stringify(t.body))}))}const Ie="https://api.fyers.in/api/v2/",Pe="https://api.fyers.in/data-rest/v2/",Ee="https://public.fyers.in/sym_details/";var Oe,Re;function Se(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 Ue(e,t,n,r,i){return De("text",Se(e,t,n,r,i))}function Me(e,t,n,r,i){return De("json",Se(e,t,n,r,i))}function be(e,t,n,r,i){return Me(e,t,Ie+n,r,i)}function Ae(e,t,n,r,i){return Me(e,t,Pe+n,r,i)}function Ne(e){return Se(null,"GET",Ie+"generate-authcode",e,null)}function we(e){return Se(null,"POST",Ie+"validate-authcode",null,e)}function Fe(e){return be(e,"GET","profile",null,null)}function qe(e){return be(e,"GET","funds",null,null)}function _e(e){return be(e,"GET","holdings",null,null)}function Le(e,t){return be(e,"GET","orders",t,null)}function ke(e){return be(e,"GET","orders",null,null)}function xe(e){return be(e,"GET","positions",null,null)}function Be(e){return be(e,"GET","tradebook",null,null)}function Qe(e,t){return be(e,"POST","orders",null,t)}function Xe(e,t){return be(e,"POST","orders-multi",null,t)}function He(e,t){return be(e,"PUT","orders",null,t)}function ze(e,t){return be(e,"PUT","orders-multi",null,t)}function Ge(e,t){return be(e,"DELETE","orders",null,t)}function Ve(e,t){return be(e,"DELETE","orders-multi",null,t)}function Ye(e,t){return be(e,"DELETE","positions",null,t)}function Ke(e){return be(e,"DELETE","positions",null,{})}function We(e,t){return be(e,"PUT","positions",null,t)}function Je(e){return be(e,"GET","market-status",null,null)}function je(e,t){return Ae(e,"GET","history/",t,null)}function $e(e,t){return Ae(e,"GET","quotes/",t,null)}function Ze(e,t){return Ae(e,"GET","depth/",t,null)}function et(e,t){var{exchange:n,segment:r}=t;return function(e,t,n,r,i){return Ue(e,t,Ee+n,r,i)}(null,"GET",n+"_"+r+".csv",null,null)}function tt(e){return be(e,"GET","tpin",null,null)}function nt(e){return be(e,"GET","details",null,null)}function rt(e,t){return Se(e,"POST","index",null,t)}function it(e,t){return be(e,"POST","inquiry",null,t)}!function(e){e[e.Start=9]="Start",e[e.Deposits=6]="Deposits",e[e.RealizedReturns=4]="RealizedReturns",e[e.Collaterals=5]="Collaterals",e[e.Adhoc=8]="Adhoc",e[e.Utilized=2]="Utilized",e[e.Receivables=7]="Receivables",e[e.Available=10]="Available",e[e.Clear=3]="Clear",e[e.Total=1]="Total"}(Oe||(Oe={})),function(e){e[e.Time=0]="Time",e[e.Open=1]="Open",e[e.High=2]="High",e[e.Low=3]="Low",e[e.Close=4]="Close",e[e.Volume=5]="Volume"}(Re||(Re={}));var ot=Object.freeze({__proto__:null,API_URL:Ie,DATA_URL:Pe,SYMBOLS_URL:Ee,get FundLimitType(){return Oe},get ShortCandleIndex(){return Re},authorizationStep1:Ne,authorizationStep2:we,getProfile:Fe,getFunds:qe,getHoldings:_e,getOrder:Le,getOrders:ke,getPositions:xe,getTrades:Be,placeOrder:Qe,placeOrders:Xe,modifyOrder:He,modifyOrders:ze,cancelOrder:Ge,cancelOrders:Ve,exitPosition:Ye,exitAllPositions:Ke,convertPosition:We,getMarketStatus:Je,getMarketHistory:je,getMarketQuotes:$e,getMarketDepth:Ze,getSymbolMaster:et,generateEdisTpin:tt,getEdisTransactions:nt,submitEdisHoldingsStep:rt,inquireEdisTransaction:it});const at=new Map([[10,"NSE"],[11,"MCX"],[12,"BSE"]]),ut=new Map([["NSE",10],["MCX",11],["BSE",12]]);function st(e){return at.get(e)}const ct=new Map([[10,"CM"],[11,"FO"],[12,"CD"],[20,"COM"]]),lt=new Map([["CM",10],["FO",11],["CD",12],["COM",20]]);function dt(e){return ct.get(e)}const pt=new Map([[1,"LONG"],[-1,"SHORT"],[0,"CLOSED"]]),yt=new Map([["LONG",1],["SHORT",-1],["CLOSED",0]]);function ft(e){return pt.get(e)}function mt(e){return yt.get(e)}const Tt=new Map([[1,"BUY"],[-1,"SELL"]]),gt=new Map([["BUY",1],["SELL",-1]]);function ht(e){return Tt.get(e)}function vt(e){return gt.get(e)}const Ct=new Map([["M","MOBILE"],["W","WEB"],["R","ONE"],["A","ADMIN"],["ITS","API"]]),Dt=new Map([["MOBILE","M"],["WEB","W"],["ONE","R"],["ADMIN","A"],["API","ITS"]]);function It(e){return Ct.get(e)}const Pt=new Map([[1,"CANCELLED"],[2,"TRADED"],[4,"TRANSIT"],[5,"REJECTED"],[6,"PENDING"],[7,"EXPIRED"]]),Et=new Map([["CANCELLED",1],["TRADED",2],["TRANSIT",4],["REJECTED",5],["PENDING",6],["EXPIRED",7]]);function Ot(e){return Pt.get(e)}const Rt=new Map([[1,"LIMIT"],[2,"MARKET"],[3,"SL-MARKET"],[4,"SL-LIMIT"]]),St=new Map([["LIMIT",1],["MARKET",2],["SL-MARKET",3],["SL-LIMIT",4]]);function Ut(e){return Rt.get(e)}function Mt(e){return St.get(e)}const bt=new Map([["CE","CALL"],["PE","PUT"]]),At=new Map([["CALL","CE"],["PUT","PE"]]);const Nt=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"]]),wt=new Map([["EQ",0],["PREFSHARES",1],["DEBENTURES",2],["WARRANTS",3],["MISC",4],["INDEX",10],["FUTIDX",11],["FUTIVX",12],["FUTSTK",13],["OPTIDX",14],["OPTSTK",15],["FUTCUR",16],["FUTIRT",17],["FUTIRC",18],["OPTCUR",19],["UNDCUR",20],["UNDIRC",21],["UNDIRT",22],["UNDIRD",23],["INDEX_CD",24],["FUTIRD",25],["FUTCOM",30],["OPTFUT",31],["OPTCOM",32]]);function Ft(e){return Nt.get(e)}function qt(e){return{app_id:e.appId,access_token:e.accessToken}}var _t=Oe;function Lt(e){return{isin:e.isin,symbol:e.symbol,exchange:st(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 kt(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 xt(e){return{id:e.id,symbol:e.symbol,ticker:e.ex_sym,description:e.description,segment:dt(e.segment),instrument:Ft(e.instrument),exchange:st(e.exchange),type:Ut(e.type),side:ht(e.side),productType:e.productType,source:It(e.source)||null,status:Ot(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}}var Bt=Q;function Qt(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+=n.status===Bt.Pending||n.status===Bt.Transit?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 Xt(e){return{id:e.id,symbol:e.symbol,segment:dt(e.segment),productType:e.productType,side:ft(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 Ht(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 zt(e){return{id:e.id,orderId:e.orderNumber,symbol:e.symbol,segment:dt(e.segment),exchange:st(e.exchange),side:ht(e.transactionType),productType:e.productType,orderType:Ut(e.orderType),orderDate:e.orderDateTime,price:e.tradePrice,quantity:e.tradedQty,value:e.tradeValue,clientId:e.clientId}}function Gt(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 Vt(e){return{symbol:e.symbol,type:Mt(e.type||"MARKET"),side:vt(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 Yt(e){return{id:e.id,type:Mt(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function Kt(e){return{exchange:st(e.exchange),segment:dt(e.segment),type:e.market_type,status:e.status}}function Wt(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 Jt=[1,2,3,5,10,15,20,30,60,120,240,1440];function jt(e){var t=1,n=1/0;for(var r of Jt){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}var $t=Re;function Zt(e){return{date:e[$t.Time],openPrice:e[$t.Open],highPrice:e[$t.High],lowPrice:e[$t.Low],closePrice:e[$t.Close],volume:e[$t.Volume]}}function en(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function tn(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][$t.Time],t.toDate=e[n][$t.Time],t.openPrice=e[0][$t.Open],t.highPrice=e[0][$t.High],t.lowPrice=e[0][$t.Low],t.closePrice=e[n][$t.Close],e))t.highPrice=Math.max(t.highPrice,r[$t.High]),t.lowPrice=Math.min(t.lowPrice,r[$t.Low]),t.volume+=r[$t.Volume];return t}function nn(e){var t=e.v;return{symbol:e.n,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:en(t.cmd)}}function rn(e){return{price:e.price,volume:e.volume,orders:e.ord}}function on(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 an(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 un(e){return{isin_code:e.isin,qty:e.quantity}}function sn(e,t){return.01*Math.round(e*t)}function cn(e){return sn(e,.1)+sn(e,18)+sn(e,.00325)+sn(e,.015)+sn(e,1e-4)}function ln(e,t,n="default"){var r;return Ne({client_id:(r={appId:e,redirectUrl:t,state:n}).appId,redirect_uri:r.redirectUrl,response_type:"code",state:r.state})}function dn(e,t){var n;return we({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode})}async function pn(e){return t=await Fe(qt(e)),{id:(n=t.data).fy_id,email:n.email_id,name:n.name,pan:n.PAN};var t,n}async function yn(e){return function(e){var t={},n={};for(var r of e.fund_limit)switch(r.id){case _t.Start:t.start=r.equityAmount,n.start=r.commodityAmount;break;case _t.Deposits:t.deposits=r.equityAmount,n.deposits=r.commodityAmount;break;case _t.RealizedReturns:t.realizedReturns=r.equityAmount,n.realizedReturns=r.commodityAmount;break;case _t.Collaterals:t.collaterals=r.equityAmount,n.collaterals=r.commodityAmount;break;case _t.Adhoc:t.adhoc=r.equityAmount,n.adhoc=r.commodityAmount;break;case _t.Utilized:t.utilized=r.equityAmount,n.utilized=r.commodityAmount;break;case _t.Receivables:t.receivables=r.equityAmount,n.receivables=r.commodityAmount;break;case _t.Available:t.available=r.equityAmount,n.available=r.commodityAmount;break;case _t.Clear:t.clear=r.equityAmount,n.clear=r.commodityAmount;break;case _t.Total:t.total=r.equityAmount,n.total=r.commodityAmount}return{equity:t,commodity:n}}(await qe(qt(e)))}async function fn(e){return{details:(t=await _e(qt(e))).holdings.map(Lt),overall:kt(t.holdings,t.overall)};var t}async function mn(e,t){var n={id:t};return xt((await Le(qt(e),n)).orderBook[0])}async function Tn(e){return{details:(t=await ke(qt(e))).orderBook.map(xt),overall:Qt(t.orderBook)};var t}async function gn(e){return{details:(t=await xe(qt(e))).netPositions.map(Xt),overall:Ht(t.netPositions,t.overall)};var t}async function hn(e){return{details:(t=await Be(qt(e))).tradeBook.map(zt),overall:Gt(t.tradeBook)};var t}async function vn(e,t){var n=Vt(t);return(await Qe(qt(e),n)).id}async function Cn(e,t){var n=t.map(Vt);return(await Xe(qt(e),n)).data.map((e=>e.body.id))}async function Dn(e,t){var n=Yt(t);return(await He(qt(e),n)).id}async function In(e,t){var n=t.map(Yt);return(await ze(qt(e),n)).data.map((e=>e.body.id))}async function Pn(e,t){var n={id:t};return(await Ge(qt(e),n)).id}async function En(e,t){var n=t.map((e=>({id:e})));return(await Ve(qt(e),n)).data.map((e=>e.body.id))}async function On(e,t){var n={id:t};return(await Ye(qt(e),n)).s}async function Rn(e){return(await Ke(qt(e))).s}async function Sn(e,t){var n,r={symbol:(n=t).symbol,positionSide:mt(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"};return(await We(qt(e),r)).s}async function Un(e){return{details:(t=await Je(qt(e))).marketStatus.map(Kt),overall:Wt(t.marketStatus)};var t}async function Mn(e,t){var n,r={symbol:(n=t).symbol,resolution:jt(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"};return function(e){return{details:e.candles.map(Zt),overall:tn(e.candles)}}(await je(qt(e),r))}async function bn(e,t){var n={symbols:t.join()};return(await $e(qt(e),n)).d.map(nn)}async function An(e,t){var n={symbol:t,ohlcv_flag:1};return function(e){var t=Object.keys(e.d);if(0===t.length)return null;var n=e.d[t[0]];return{buyQuantity:n.totalbuyqty,sellQuantity:n.totalsellqty,buyOffers:n.bids.map(rn),sellOffers:n.ask.map(rn),openPrice:n.o,highPrice:n.h,lowPrice:n.l,closePrice:n.c,volume:n.v,priceChange:n.ch,priceChangePercent:n.chp,tradedQuantity:n.ltq,tradedPrice:n.ltq,tradedDate:n.ltt,netPrice:n.atp,lowerCircuitPrice:n.lower_ckt,upperCircuitPrice:n.upper_ckt,expiryDate:n.expiry,openInterest:n.oi,openInterestEnabled:n.oiflag,previousOpenInterest:n.pdoi,openInterestChangePercent:n.oipercent}}(await Ze(qt(e),n))}function Nn(e,t,n){return et(0,{exchange:t,segment:n})}async function wn(e){return(await tt(qt(e))).data}async function Fn(e){return t=await nt(qt(e)),{details:(n=0===t.data.length?[]:t.data).map(on),overall:an(n)};var t,n}function qn(e,t){var n={recordLst:t.map(un)};return rt(qt(e),n)}async function _n(e,t){var n={transactionId:t},r=(await it(qt(e),n)).data;return r.FAILED_CNT>0?-r.FAILED_CNT:r.SUCEESS_CNT}n.Fyers=class{constructor(e,t){this.appId=e,this.accessToken=t}static authorizationStep1(e,t,n="default"){return ln(e,t,n)}static authorizationStep2(e,t){return dn(e,t)}getProfile(){return pn(this)}getFunds(){return yn(this)}getHoldings(){return fn(this)}getOrder(e){return mn(this,e)}getOrders(){return Tn(this)}getPositions(){return gn(this)}getTrades(){return hn(this)}placeOrder(e){return vn(this,e)}placeOrders(e){return Cn(this,e)}modifyOrder(e){return Dn(this,e)}modifyOrders(e){return In(this,e)}cancelOrder(e){return Pn(this,e)}cancelOrders(e){return En(this,e)}exitPosition(e){return On(this,e)}exitAllPositions(){return Rn(this)}convertPosition(e){return Sn(this,e)}getMarketStatus(){return Un(this)}getMarketHistory(e){return Mn(this,e)}getMarketQuotes(e){return bn(this,e)}getMarketDepth(e){return An(this,e)}static getSymbolMaster(e,t){return Nn(0,e,t)}generateEdisTpin(){return wn(this)}getEdisTransactions(){return Fn(this)}submitEdisHoldingsStep(e){return qn(this,e)}inquireEdisTransaction(e){return _n(this,e)}},n.appendix=he,n.authorizationStep1=ln,n.authorizationStep2=dn,n.cancelOrder=Pn,n.cancelOrders=En,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,sn(n,.03)))+sn(r,18)+sn(n,.0026)+sn(n,.0018)+sn(n,.002)+sn(n,1e-4)):function(e){var t=Math.min(20,sn(e,.03)),n=sn(e,.01);return t+n+sn(t+n,18)+sn(e,.0026)+sn(e,.0018)+sn(e,.002)+sn(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+sn(20,18)+sn(n,.05)+sn(n,3e-4)+sn(n,1e-4)):function(e){var t=sn(e,.05);return 20+t+sn(20+t,18)+sn(e,.05)+sn(e,3e-4)+sn(e,1e-4)}(t);var n},n.convertPosition=Sn,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,sn(n,.03)))+sn(r,18)+sn(n,.00115)+sn(n,5e-4)+sn(n,1e-4)+sn(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+sn(20,18)+sn(n,.04)+sn(n,.009)+sn(n,1e-4)+sn(n,1e-4);var n},n.day2=m,n.day2Description=f,n.equityDeliveryCharges=function(e,t){return"BUY"===e?cn(t):12.5+cn(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,sn(n,.03)))+sn(r,18)+sn(n,.0019)+sn(n,5e-4)+sn(n,.002)+sn(n,1e-4)):function(e){var t=Math.min(20,sn(e,.03)),n=sn(e,.01);return t+n+sn(t+n,18)+sn(e,.0019)+sn(e,5e-4)+sn(e,.002)+sn(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,sn(n,.03)))+sn(r,18)+sn(n,.00325)+sn(n,.003)+sn(n,1e-4)):function(e){var t=Math.min(20,sn(e,.03)),n=sn(e,.025);return t+n+sn(t+n,18)+sn(e,.00325)+sn(e,.003)+sn(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+sn(20,18)+sn(n,.053)+sn(n,.009)+sn(n,.003)+sn(n,1e-4)):function(e){var t=sn(e,.05);return 20+t+sn(20+t,18)+sn(e,.053)+sn(e,.009)+sn(e,.003)+sn(e,1e-4)}(t);var n},n.errorDescription=i,n.exchange=function(e){return st(C(e))},n.exchangeDescription=function(e){return v((t=e,ut.get(t)));var t},n.exitAllPositions=Rn,n.exitPosition=On,n.generateEdisTpin=wn,n.getEdisTransactions=Fn,n.getFunds=yn,n.getHoldings=fn,n.getMarketDepth=An,n.getMarketHistory=Mn,n.getMarketQuotes=bn,n.getMarketStatus=Un,n.getOrder=mn,n.getOrders=Tn,n.getPositions=gn,n.getProfile=pn,n.getSymbolMaster=Nn,n.getTrades=hn,n.holdingType=function(e){return ue(e)},n.holdingTypeDescription=function(e){return ae(e)},n.http=ot,n.inquireEdisTransaction=_n,n.instrumentType=function(e){return Ft(ge(e))},n.instrumentTypeDescription=function(e){return Te((t=e,wt.get(t)));var t},n.modifyOrder=Dn,n.modifyOrders=In,n.month1=y,n.month1Description=p,n.month3=c,n.month3Description=s,n.optionType=function(e){return t=re(e),bt.get(t);var t},n.optionTypeDescription=function(e){return ne((t=e,At.get(t)));var t},n.orderSide=function(e){return ht(q(e))},n.orderSideDescription=function(e){return F(vt(e))},n.orderSource=function(e){return It(B(e))},n.orderSourceDescription=function(e){return x((t=e,Dt.get(t)));var t},n.orderStatus=function(e){return Ot(G(e))},n.orderStatusDescription=function(e){return z((t=e,Et.get(t)));var t},n.orderType=function(e){return Ut(J(e))},n.orderTypeDescription=function(e){return W(Mt(e))},n.orderValidity=function(e){return Z(e)},n.orderValidityDescription=function(e){return Z(e)},n.placeOrder=vn,n.placeOrders=Cn,n.positionSide=function(e){return ft(b(e))},n.positionSideDescription=function(e){return M(mt(e))},n.productType=function(e){return pe(e)},n.productTypeDescription=function(e){return de(e)},n.segment=function(e){return dt(O(e))},n.segmentDescription=function(e){return E((t=e,lt.get(t)));var t},n.submitEdisHoldingsStep=qn,n.year2=a,n.year2Description=o},{}]},{},[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";Object.defineProperty(n,"__esModule",{value:!0});const r=new Map([[-209,"Invalid order id"],[-101,"Invalid order type"],[-305,"For CO orders only market and limit orders are allowed"],[-323,"For BO orders only market and limit orders are allowed"],[-308,"Invalid limit price"],[-309,"Invalid stop price"],[-310,"Invalid order quantity"],[-311,"Invalid stop loss price"],[-313,"Invalid order side of either buy or sell"],[-314,"Invalid product type for the order"],[-315,"Invalid price for stop limit order"],[-316,"Invalid stop loss price for CO/BO orders"],[-323,"Invalid stop loss value"],[-325,"Ivalid target value (take_profit)"],[-326,"Invalid order validity"],[-327,"Invalid order disclosed quantity"],[-328,"Invalid order offline flag"],[-201,"Connection issue while processing your request"],[-202,"Connection timed out"],[-204,"Request wasnt processed"],[-205,"Market wasnt able to accept or process the request"],[-157,"User doesnt exist"],[-159,"Invalid order number"],[-161,"This order has already been cancelled"],[-162,"This order has already traded"],[-163,"Order modfication wasnt done successfully"],[-164,"This order has already been rejected"],[-390,"Invalid stop price"],[-392,"Price is not in multiples of tick size"],[-353,"API limit exceeded"],[-372,"Invalid price"],[-397,"Position quantity is zero"],[-398,"No open positions"],[-399,"No pending orders to be closed/cancelled"],[-329,"Please check if exit positions is complete"],[-373,"No permission"],[-374,"Invalid authorization code (auth_code)"],[-371,"Invalid SHA256 hash of (app_id:secret_key)"],[-17,"Invalid access token used for authentication"],[-352,"Invalid app id"],[-96,"An unexpected error occurred when processing request"],[-351,"Greater than 50 symbols"],[-300,"Invalid symbol"],[-310,"Invalid symbols"],[-301,"Invalid resolution format"],[-302,"Invalid historical timestamp from when you require data"],[-303,"Invalid historical timestamp till when you require data"],[-356,"The range_from value cannot be greater than range_to value"],[-334,"Invalid key date format value"],[-335,"Historical timestamp from when you require data not in epoch format"],[-336,"Historical timestamp till when you require data not in epoch format"],[-337,"Historical timestamp from when you require data not in YYYY-MM-DD format"],[-338,"Historical timestamp till when you require data not in YYYY-MM-DD format"],[-339,"The range cannot be more than 1 year for day resolution"],[-341,"The range cannot be more than 100 days for 1 min resolution"],[-343,"The range cannot be more than 100 days for 2 min resolution"],[-344,"The range cannot be more than 100 days for 3 min resolution"],[-345,"The range cannot be more than 100 days for 5 min resolution"],[-346,"The range cannot be more than 100 days for 10 min resolution"],[-347,"The range cannot be more than 100 days for 15 min resolution"],[-348,"The range cannot be more than 100 days for 20 min resolution"],[-349,"The range cannot be more than 100 days for 30 min resolution"],[-353,"The range cannot be more than 100 days for 60 min resolution"],[-354,"The range cannot be more than 100 days for 120 min resolution"],[-355,"The range cannot be more than 100 days for 240 min resolution"]]);function i(e){return r.get(e)}function o(e){return parseInt(e,10)>50?"19"+e:"20"+e}function a(e){return e.substring(2)}const u=new Map([["JAN","January"],["FEB","February"],["MAR","March"],["APR","April"],["MAY","May"],["JUN","June"],["JUL","July"],["AUG","August"],["SEP","September"],["OCT","October"],["NOV","November"],["DEC","December"]]);function s(e){return u.get(e)}function c(e){return e.substring(0,3).toUpperCase()}const l=new Map([["1","January"],["2","February"],["3","March"],["4","April"],["5","May"],["6","June"],["7","July"],["8","August"],["9","September"],["O","October"],["N","November"],["D","December"]]),d=new Map([["JAN","1"],["FEB","2"],["MAR","3"],["APR","4"],["MAY","5"],["JUN","6"],["JUL","7"],["AUG","8"],["SEP","9"],["OCT","O"],["NOV","N"],["DEC","D"]]);function p(e){return l.get(e)}function y(e){var t=e.substring(0,3).toUpperCase();return d.get(t)}function f(e){return e.replace(/^0+/,"")}function m(e){return e.padStart(2,"0")}const T=new Map([[10,"National Stock Exchange (NSE)"],[11,"Multi Commodity Exchange (MCX)"],[12,"Bombay Stock Exchange (BSE)"]]),h=new Map([["N",10],["M",11],["B",12]]);function g(e){return T.get(e)}function v(e){var t=e.charAt(0).toUpperCase();return h.get(t)}const C=new Map([[10,"Capital Market (CM)"],[11,"Equity Derivatives (FO)"],[12,"Currency Derivatives (CD)"],[20,"Commodity Derivatives (COM)"]]),D=new Map([["CM",10],["FO",11],["CD",12],["COM",20]]);function I(e){return C.get(e)}function P(e){var t="CM";return/^com/i.test(e)?t="COM":/^cur/i.test(e)?t="CD":/der|fut|opt/i.test(e)&&(t="FO"),D.get(t)}const E=new Map([[1,"Long"],[-1,"Short"],[0,"Closed position"]]),M=new Map([["L",1],["S",-1],["C",0]]);function O(e){return E.get(e)}function b(e){var t=e.charAt(0).toUpperCase();return M.get(t)}const S=new Map([[1,"Buy"],[-1,"Sell"]]),R=new Map([["B",1],["S",-1]]);function U(e){return S.get(e)}function A(e){var t=e.charAt(0).toUpperCase();return R.get(t)}const w=new Map([["M","Mobile"],["W","Web"],["R","Fyers One"],["A","Admin"],["ITS","API"]]),N=new Map([["MO","M"],["WE","W"],["ON","R"],["AD","A"],["AP","ITS"]]);function F(e){return w.get(e)}function q(e){var t=e.split(" "),n=t[t.length-1].substring(0,2).toUpperCase();return N.get(n)}const _=new Map([[1,"Cancelled"],[2,"Traded / Filled"],[3,"For future use"],[4,"Transit"],[5,"Rejected"],[6,"Pending"],[7,"Expired"]]),k=new Map([["C",1],["F",2],["T",4],["R",5],["P",6],["E",7]]);function L(e){return _.get(e)}function x(e){/traded/i.test(e)&&(e="Filled");var t=e.charAt(0).toUpperCase();return k.get(t)}const Q=new Map([[1,"Limit order"],[2,"Market order"],[3,"Stop order (SL-M)"],[4,"Stoplimit order (SL-L)"]]),B=new Map([["L",1],["M",2],["S",3],["R",4]]);function H(e){return Q.get(e)}function z(e){var t=e.charAt(0).toUpperCase();return/s.+l(?!oss)/i.test(e)&&(t="R"),B.get(t)}const G=new Map([["DAY","End of day validity (DAY)"],["IOC","Immediate or Cancel validity (IOC)"]]);function V(e){return/ioc|imm/i.test(e)?"IOC":"DAY"}const X=new Map([["CE","Call Option (CE)"],["PE","Put Option (PE)"]]);function Y(e){return X.get(e)}function J(e){return/^[ps]/i.test(e)?"PE":"CE"}const K=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"]]);function W(e){return K.get(e)}function j(e){return/not|un/i.test(e)?"T1":"HLD"}const $=new Map([["CNC","Cash N Carry or Delivery Order, for equity only (CNC)"],["INTRADAY","Intraday Order, applicable for all segments (INTRADAY)"],["MARGIN","Margin Order, applicable only for derivatives (MARGIN)"],["CO","Cover Order (CO)"],["BO","Bracket Order (BO)"]]),Z=new Map([["D","CNC"],["I","INTRADAY"],["M","MARGIN"],["M","MARGIN"],["C","CO"],["B","BO"]]);function ee(e){return $.get(e)}function te(e){/cnc|cash|carry/i.test(e)&&(e="Delivery");var t=e.charAt(0).toUpperCase();return Z.get(t)}const ne=new Map([[0,"Equity Shares (EQ)"],[1,"Preference Shares (PREFSHARES)"],[2,"Collateral-free Debt (DEBENTURES)"],[3,"Warrants on Stock (WARRANTS)"],[4,"Miscellaneous (MISC)"],[10,"Stock Market Index (INDEX)"],[11,"Futures on Index (FUTIDX)"],[12,"Futures on Volatility Index (FUTIVX)"],[13,"Futures on Stock (FUTSTK)"],[14,"Options on Index (OPTIDX)"],[15,"Options on Stock (OPTSTK)"],[16,"Futures on Currency (FUTCUR)"],[17,"Futures on Government of India Treasury Bills (FUTIRT)"],[18,"Futures on Government of India Bonds (FUTIRC)"],[19,"Options on Currency (OPTCUR)"],[20,"Underlying on Currency (UNDCUR)"],[21,"Underlying on Government of Bonds (UNDIRC)"],[22,"Underlying on Government of India Treasury Bills (UNDIRT)"],[23,"Underlying on 10 Year Notional coupon bearing GOI security (UNDIRD)"],[24,"Market-indexed Certificate of deposit (INDEX_CD)"],[25,"Futures on 10 Year Notional coupon bearing GOI security (FUTIRD)"],[30,"Futures on Commodity (FUTCOM)"],[31,"Options on Commodity Futures (OPTFUT)"],[32,"Options on Commodity (OPTCOM)"]]),re=new Map([["EQ",0],["PREFSHARES",1],["DEBENTURES",2],["WARRANTS",3],["MISC",4],["INDEX",10],["FUTIDX",11],["FUTIVX",12],["FUTSTK",13],["OPTIDX",14],["OPTSTK",15],["FUTCUR",16],["FUTIRT",17],["FUTIRC",18],["OPTCUR",19],["UNDCUR",20],["UNDIRC",21],["UNDIRT",22],["UNDIRD",23],["INDEX_CD",24],["FUTIRD",25],["FUTCOM",30],["OPTFUT",31],["OPTCOM",32]]);function ie(e){return ne.get(e)}function oe(e){var t="EQ",n=/fut|future/i.test(e),r=/opt|option/i.test(e),i=/idx|index/i.test(e),o=/und|underlying/i.test(e);return t=/com(\b|$)|commodit/i.test(e)?r?n?"OPTFUT":"OPTCOM":i?"FUTIDX_COM":"FUTCOM":/(^|\b)und|cd(\b|$)|ir[cdt](\b|$)|cur|gov|bond|trea|coup/i.test(e)?/irc(\b|$)|bond/i.test(e)?o?"UNDIRC":"FUTIRC":/ird(\b|$)|coup/i.test(e)?o?"UNDIRD":"FUTIRD":/irt(\b|$)|trea/i.test(e)?o?"UNDIRT":"FUTIRT":i?"INDEX_CD":r?"OPTCUR":"FUTCUR":n||r?/ivx|volatil/i.test(e)?"FUTIVX":i?r?"OPTIDX":"FUTIDX":r?"OPTSTK":"FUTSTK":i?"INDEX":/misc/i.test(e)?"MISC":/warrant/i.test(e)?"WARRANTS":/deb/i.test(e)?"DEBENTURES":/pref/i.test(e)?"PREFSHARES":"EQ",re.get(t)}var ae=Object.freeze({__proto__:null,errorDescription:i,year2Description:o,year2:a,month3Description:s,month3:c,month1Description:p,month1:y,day2Description:f,day2:m,exchangeDescription:g,exchange:v,segmentDescription:I,segment:P,positionSideDescription:O,positionSide:b,orderSideDescription:U,orderSide:A,orderSourceDescription:F,orderSource:q,orderStatusDescription:L,orderStatus:x,orderTypeDescription:H,orderType:z,orderValidityDescription:function(e){return G.get(e)},orderValidity:V,optionTypeDescription:Y,optionType:J,holdingTypeDescription:W,holdingType:j,productTypeDescription:ee,productType:te,instrumentTypeDescription:ie,instrumentType:oe});function ue(e,t){var n=new Error(t);return n.code=e.status,n.response=null,n}function se(e,t){return null!=t.headers&&(!!t.headers.hasOwnProperty(e)||!!t.headers.hasOwnProperty(e.toLowerCase()))}function ce(e,t){return new Promise(((n,r)=>{var i=t.url,o=t.method||"GET",a=!1,u=!1,s=!1,c=new XMLHttpRequest;c.open(o,i),function(e,t){for(var n in null==t.body||se("Content-Type",t)||e.setRequestHeader("Content-Type","application/json; charset=utf-8"),se("Accept",t)||e.setRequestHeader("Accept","application/json, text/*"),t.headers)e.setRequestHeader(n,t.headers[n])}(c,t),t.timeout&&(c.timeout=t.timeout),c.responseType=e,c.onerror=function(e){a=!0;var t=e.target;r(ue(t,"Unexpected error occurred"))},c.onabort=function(e){u=!0;var t=e.target;r(ue(t,"Request was aborted"))},c.ontimeout=function(e){s=!0;var t=e.target;r(ue(t,"Request timed out"))},c.onreadystatechange=function(t){if(!(a||u||s)){var o=t.target;if(function(e){return e.readyState===e.DONE}(o))try{var c=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}(o,e);!function(e,t=""){return e.status>=200&&e.status<300||304===e.status||/^file:\/\//i.test(t)}(o,i)?setTimeout((function(){a||u||s||r(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}(o,c))})):n(c)}catch(t){r(t)}}},null==t.body?c.send():t.body instanceof FormData||t.body instanceof URLSearchParams?c.send(t.body):c.send(JSON.stringify(t.body))}))}const le="https://api.fyers.in/api/v2/",de="https://api.fyers.in/data-rest/v2/",pe="https://public.fyers.in/sym_details/";var ye,fe;function me(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 Te(e,t,n,r,i){return ce("text",me(e,t,n,r,i))}function he(e,t,n,r,i){return ce("json",me(e,t,n,r,i))}function ge(e,t,n,r,i){return he(e,t,le+n,r,i)}function ve(e,t,n,r,i){return he(e,t,de+n,r,i)}function Ce(e){return me(null,"GET",le+"generate-authcode",e,null)}function De(e){return me(null,"POST",le+"validate-authcode",null,e)}function Ie(e){return ge(e,"GET","profile",null,null)}function Pe(e){return ge(e,"GET","funds",null,null)}function Ee(e){return ge(e,"GET","holdings",null,null)}function Me(e,t){return ge(e,"GET","orders",t,null)}function Oe(e){return ge(e,"GET","orders",null,null)}function be(e){return ge(e,"GET","positions",null,null)}function Se(e){return ge(e,"GET","tradebook",null,null)}function Re(e,t){return ge(e,"POST","orders",null,t)}function Ue(e,t){return ge(e,"POST","orders-multi",null,t)}function Ae(e,t){return ge(e,"PUT","orders",null,t)}function we(e,t){return ge(e,"PUT","orders-multi",null,t)}function Ne(e,t){return ge(e,"DELETE","orders",null,t)}function Fe(e,t){return ge(e,"DELETE","orders-multi",null,t)}function qe(e,t){return ge(e,"DELETE","positions",null,t)}function _e(e){return ge(e,"DELETE","positions",null,{})}function ke(e,t){return ge(e,"PUT","positions",null,t)}function Le(e){return ge(e,"GET","market-status",null,null)}function xe(e,t){return ve(e,"GET","history/",t,null)}function Qe(e,t){return ve(e,"GET","quotes/",t,null)}function Be(e,t){return ve(e,"GET","depth/",t,null)}function He(e,t){var{exchange:n,segment:r}=t;return function(e,t,n,r,i){return Te(e,t,pe+n,r,i)}(null,"GET",n+"_"+r+".csv",null,null)}function ze(e){return ge(e,"GET","tpin",null,null)}function Ge(e){return ge(e,"GET","details",null,null)}function Ve(e,t){return me(e,"POST","index",null,t)}function Xe(e,t){return ge(e,"POST","inquiry",null,t)}!function(e){e[e.Start=9]="Start",e[e.Deposits=6]="Deposits",e[e.RealizedReturns=4]="RealizedReturns",e[e.Collaterals=5]="Collaterals",e[e.Adhoc=8]="Adhoc",e[e.Utilized=2]="Utilized",e[e.Receivables=7]="Receivables",e[e.Available=10]="Available",e[e.Clear=3]="Clear",e[e.Total=1]="Total"}(ye||(ye={})),function(e){e[e.Time=0]="Time",e[e.Open=1]="Open",e[e.High=2]="High",e[e.Low=3]="Low",e[e.Close=4]="Close",e[e.Volume=5]="Volume"}(fe||(fe={}));var Ye=Object.freeze({__proto__:null,API_URL:le,DATA_URL:de,SYMBOLS_URL:pe,get FundLimitType(){return ye},get ShortCandleIndex(){return fe},authorizationStep1:Ce,authorizationStep2:De,getProfile:Ie,getFunds:Pe,getHoldings:Ee,getOrder:Me,getOrders:Oe,getPositions:be,getTrades:Se,placeOrder:Re,placeOrders:Ue,modifyOrder:Ae,modifyOrders:we,cancelOrder:Ne,cancelOrders:Fe,exitPosition:qe,exitAllPositions:_e,convertPosition:ke,getMarketStatus:Le,getMarketHistory:xe,getMarketQuotes:Qe,getMarketDepth:Be,getSymbolMaster:He,generateEdisTpin:ze,getEdisTransactions:Ge,submitEdisHoldingsStep:Ve,inquireEdisTransaction:Xe});const Je=new Map([[10,"NSE"],[11,"MCX"],[12,"BSE"]]),Ke=new Map([["NSE",10],["MCX",11],["BSE",12]]);function We(e){return Je.get(e)}const je=new Map([[10,"CM"],[11,"FO"],[12,"CD"],[20,"COM"]]),$e=new Map([["CM",10],["FO",11],["CD",12],["COM",20]]);function Ze(e){return je.get(e)}const et=new Map([[1,"LONG"],[-1,"SHORT"],[0,"CLOSED"]]),tt=new Map([["LONG",1],["SHORT",-1],["CLOSED",0]]);function nt(e){return et.get(e)}function rt(e){return tt.get(e)}const it=new Map([[1,"BUY"],[-1,"SELL"]]),ot=new Map([["BUY",1],["SELL",-1]]);function at(e){return it.get(e)}function ut(e){return ot.get(e)}const st=new Map([["M","MOBILE"],["W","WEB"],["R","ONE"],["A","ADMIN"],["ITS","API"]]),ct=new Map([["MOBILE","M"],["WEB","W"],["ONE","R"],["ADMIN","A"],["API","ITS"]]);function lt(e){return st.get(e)}const dt=new Map([[1,"CANCELLED"],[2,"TRADED"],[4,"TRANSIT"],[5,"REJECTED"],[6,"PENDING"],[7,"EXPIRED"]]),pt=new Map([["CANCELLED",1],["TRADED",2],["TRANSIT",4],["REJECTED",5],["PENDING",6],["EXPIRED",7]]);function yt(e){return dt.get(e)}const ft=new Map([[1,"LIMIT"],[2,"MARKET"],[3,"SL-MARKET"],[4,"SL-LIMIT"]]),mt=new Map([["LIMIT",1],["MARKET",2],["SL-MARKET",3],["SL-LIMIT",4]]);function Tt(e){return ft.get(e)}function ht(e){return mt.get(e)}const gt=new Map([["CE","CALL"],["PE","PUT"]]),vt=new Map([["CALL","CE"],["PUT","PE"]]);const Ct=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"]]),Dt=new Map([["EQ",0],["PREFSHARES",1],["DEBENTURES",2],["WARRANTS",3],["MISC",4],["INDEX",10],["FUTIDX",11],["FUTIVX",12],["FUTSTK",13],["OPTIDX",14],["OPTSTK",15],["FUTCUR",16],["FUTIRT",17],["FUTIRC",18],["OPTCUR",19],["UNDCUR",20],["UNDIRC",21],["UNDIRT",22],["UNDIRD",23],["INDEX_CD",24],["FUTIRD",25],["FUTCOM",30],["OPTFUT",31],["OPTCOM",32]]);function It(e){return Ct.get(e)}function Pt(e){return{app_id:e.appId,access_token:e.accessToken}}var Et=ye;function Mt(e){return{isin:e.isin,symbol:e.symbol,exchange:We(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 Ot(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 bt(e){return{id:e.id,symbol:e.symbol,ticker:e.ex_sym,description:e.description,segment:Ze(e.segment),instrument:It(e.instrument),exchange:We(e.exchange),type:Tt(e.type),side:at(e.side),productType:e.productType,source:lt(e.source)||null,status:yt(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 St(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 Rt(e){return{id:e.id,symbol:e.symbol,segment:Ze(e.segment),productType:e.productType,side:nt(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 Ut(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 At(e){return{id:e.id,orderId:e.orderNumber,symbol:e.symbol,segment:Ze(e.segment),exchange:We(e.exchange),side:at(e.transactionType),productType:e.productType,orderType:Tt(e.orderType),orderDate:e.orderDateTime,price:e.tradePrice,quantity:e.tradedQty,value:e.tradeValue,clientId:e.clientId}}function wt(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 Nt(e){return{symbol:e.symbol,type:ht(e.type||"MARKET"),side:ut(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 Ft(e){return{id:e.id,type:ht(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function qt(e){return{exchange:We(e.exchange),segment:Ze(e.segment),type:e.market_type,status:e.status}}function _t(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 kt=[1,2,3,5,10,15,20,30,60,120,240,1440];function Lt(e){var t=1,n=1/0;for(var r of kt){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}var xt=fe;function Qt(e){return{date:e[xt.Time],openPrice:e[xt.Open],highPrice:e[xt.High],lowPrice:e[xt.Low],closePrice:e[xt.Close],volume:e[xt.Volume]}}function Bt(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function Ht(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][xt.Time],t.toDate=e[n][xt.Time],t.openPrice=e[0][xt.Open],t.highPrice=e[0][xt.High],t.lowPrice=e[0][xt.Low],t.closePrice=e[n][xt.Close],e))t.highPrice=Math.max(t.highPrice,r[xt.High]),t.lowPrice=Math.min(t.lowPrice,r[xt.Low]),t.volume+=r[xt.Volume];return t}function zt(e){var t=e.v;return{symbol:e.n,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:Bt(t.cmd)}}function Gt(e){return{price:e.price,volume:e.volume,orders:e.ord}}function Vt(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 Xt(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 Yt(e){return{isin_code:e.isin,qty:e.quantity}}function Jt(e,t){return.01*Math.round(e*t)}function Kt(e){return Jt(e,.1)+Jt(e,18)+Jt(e,.00325)+Jt(e,.015)+Jt(e,1e-4)}function Wt(e,t,n="default"){var r;return Ce({client_id:(r={appId:e,redirectUrl:t,state:n}).appId,redirect_uri:r.redirectUrl,response_type:"code",state:r.state})}function jt(e,t){var n;return De({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode})}async function $t(e){return t=await Ie(Pt(e)),{id:(n=t.data).fy_id,email:n.email_id,name:n.name,pan:n.PAN};var t,n}async function Zt(e){return function(e){var t={},n={};for(var r of e.fund_limit)switch(r.id){case Et.Start:t.start=r.equityAmount,n.start=r.commodityAmount;break;case Et.Deposits:t.deposits=r.equityAmount,n.deposits=r.commodityAmount;break;case Et.RealizedReturns:t.realizedReturns=r.equityAmount,n.realizedReturns=r.commodityAmount;break;case Et.Collaterals:t.collaterals=r.equityAmount,n.collaterals=r.commodityAmount;break;case Et.Adhoc:t.adhoc=r.equityAmount,n.adhoc=r.commodityAmount;break;case Et.Utilized:t.utilized=r.equityAmount,n.utilized=r.commodityAmount;break;case Et.Receivables:t.receivables=r.equityAmount,n.receivables=r.commodityAmount;break;case Et.Available:t.available=r.equityAmount,n.available=r.commodityAmount;break;case Et.Clear:t.clear=r.equityAmount,n.clear=r.commodityAmount;break;case Et.Total:t.total=r.equityAmount,n.total=r.commodityAmount}return{equity:t,commodity:n}}(await Pe(Pt(e)))}async function en(e){return{details:(t=await Ee(Pt(e))).holdings.map(Mt),overall:Ot(t.holdings,t.overall)};var t}async function tn(e,t){var n={id:t};return bt((await Me(Pt(e),n)).orderBook[0])}async function nn(e){return{details:(t=await Oe(Pt(e))).orderBook.map(bt),overall:St(t.orderBook)};var t}async function rn(e){return{details:(t=await be(Pt(e))).netPositions.map(Rt),overall:Ut(t.netPositions,t.overall)};var t}async function on(e){return{details:(t=await Se(Pt(e))).tradeBook.map(At),overall:wt(t.tradeBook)};var t}async function an(e,t){var n=Nt(t);return(await Re(Pt(e),n)).id}async function un(e,t){var n=t.map(Nt);return(await Ue(Pt(e),n)).data.map((e=>e.body.id))}async function sn(e,t){var n=Ft(t);return(await Ae(Pt(e),n)).id}async function cn(e,t){var n=t.map(Ft);return(await we(Pt(e),n)).data.map((e=>e.body.id))}async function ln(e,t){var n={id:t};return(await Ne(Pt(e),n)).id}async function dn(e,t){var n=t.map((e=>({id:e})));return(await Fe(Pt(e),n)).data.map((e=>e.body.id))}async function pn(e,t){var n={id:t};return(await qe(Pt(e),n)).s}async function yn(e){return(await _e(Pt(e))).s}async function fn(e,t){var n,r={symbol:(n=t).symbol,positionSide:rt(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"};return(await ke(Pt(e),r)).s}async function mn(e){return{details:(t=await Le(Pt(e))).marketStatus.map(qt),overall:_t(t.marketStatus)};var t}async function Tn(e,t){var n,r={symbol:(n=t).symbol,resolution:Lt(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"};return function(e){return{details:e.candles.map(Qt),overall:Ht(e.candles)}}(await xe(Pt(e),r))}async function hn(e,t){var n={symbols:t.join()};return(await Qe(Pt(e),n)).d.map(zt)}async function gn(e,t){var n={symbol:t,ohlcv_flag:1};return function(e){var t=Object.keys(e.d);if(0===t.length)return null;var n=e.d[t[0]];return{buyQuantity:n.totalbuyqty,sellQuantity:n.totalsellqty,buyOffers:n.bids.map(Gt),sellOffers:n.ask.map(Gt),openPrice:n.o,highPrice:n.h,lowPrice:n.l,closePrice:n.c,volume:n.v,priceChange:n.ch,priceChangePercent:n.chp,tradedQuantity:n.ltq,tradedPrice:n.ltq,tradedDate:n.ltt,netPrice:n.atp,lowerCircuitPrice:n.lower_ckt,upperCircuitPrice:n.upper_ckt,expiryDate:n.expiry,openInterest:n.oi,openInterestEnabled:n.oiflag,previousOpenInterest:n.pdoi,openInterestChangePercent:n.oipercent}}(await Be(Pt(e),n))}function vn(e,t,n){return He(0,{exchange:t,segment:n})}async function Cn(e){return(await ze(Pt(e))).data}async function Dn(e){return t=await Ge(Pt(e)),{details:(n=0===t.data.length?[]:t.data).map(Vt),overall:Xt(n)};var t,n}function In(e,t){var n={recordLst:t.map(Yt)};return Ve(Pt(e),n)}async function Pn(e,t){var n={transactionId:t},r=(await Xe(Pt(e),n)).data;return r.FAILED_CNT>0?-r.FAILED_CNT:r.SUCEESS_CNT}n.Fyers=class{constructor(e,t){this.appId=e,this.accessToken=t}static authorizationStep1(e,t,n="default"){return Wt(e,t,n)}static authorizationStep2(e,t){return jt(e,t)}getProfile(){return $t(this)}getFunds(){return Zt(this)}getHoldings(){return en(this)}getOrder(e){return tn(this,e)}getOrders(){return nn(this)}getPositions(){return rn(this)}getTrades(){return on(this)}placeOrder(e){return an(this,e)}placeOrders(e){return un(this,e)}modifyOrder(e){return sn(this,e)}modifyOrders(e){return cn(this,e)}cancelOrder(e){return ln(this,e)}cancelOrders(e){return dn(this,e)}exitPosition(e){return pn(this,e)}exitAllPositions(){return yn(this)}convertPosition(e){return fn(this,e)}getMarketStatus(){return mn(this)}getMarketHistory(e){return Tn(this,e)}getMarketQuotes(e){return hn(this,e)}getMarketDepth(e){return gn(this,e)}static getSymbolMaster(e,t){return vn(0,e,t)}generateEdisTpin(){return Cn(this)}getEdisTransactions(){return Dn(this)}submitEdisHoldingsStep(e){return In(this,e)}inquireEdisTransaction(e){return Pn(this,e)}},n.appendix=ae,n.authorizationStep1=Wt,n.authorizationStep2=jt,n.cancelOrder=ln,n.cancelOrders=dn,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,Jt(n,.03)))+Jt(r,18)+Jt(n,.0026)+Jt(n,.0018)+Jt(n,.002)+Jt(n,1e-4)):function(e){var t=Math.min(20,Jt(e,.03)),n=Jt(e,.01);return t+n+Jt(t+n,18)+Jt(e,.0026)+Jt(e,.0018)+Jt(e,.002)+Jt(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+Jt(20,18)+Jt(n,.05)+Jt(n,3e-4)+Jt(n,1e-4)):function(e){var t=Jt(e,.05);return 20+t+Jt(20+t,18)+Jt(e,.05)+Jt(e,3e-4)+Jt(e,1e-4)}(t);var n},n.convertPosition=fn,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,Jt(n,.03)))+Jt(r,18)+Jt(n,.00115)+Jt(n,5e-4)+Jt(n,1e-4)+Jt(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+Jt(20,18)+Jt(n,.04)+Jt(n,.009)+Jt(n,1e-4)+Jt(n,1e-4);var n},n.day2=m,n.day2Description=f,n.equityDeliveryCharges=function(e,t){return"BUY"===e?Kt(t):12.5+Kt(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,Jt(n,.03)))+Jt(r,18)+Jt(n,.0019)+Jt(n,5e-4)+Jt(n,.002)+Jt(n,1e-4)):function(e){var t=Math.min(20,Jt(e,.03)),n=Jt(e,.01);return t+n+Jt(t+n,18)+Jt(e,.0019)+Jt(e,5e-4)+Jt(e,.002)+Jt(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,Jt(n,.03)))+Jt(r,18)+Jt(n,.00325)+Jt(n,.003)+Jt(n,1e-4)):function(e){var t=Math.min(20,Jt(e,.03)),n=Jt(e,.025);return t+n+Jt(t+n,18)+Jt(e,.00325)+Jt(e,.003)+Jt(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+Jt(20,18)+Jt(n,.053)+Jt(n,.009)+Jt(n,.003)+Jt(n,1e-4)):function(e){var t=Jt(e,.05);return 20+t+Jt(20+t,18)+Jt(e,.053)+Jt(e,.009)+Jt(e,.003)+Jt(e,1e-4)}(t);var n},n.errorDescription=i,n.exchange=function(e){return We(v(e))},n.exchangeDescription=function(e){return g((t=e,Ke.get(t)));var t},n.exitAllPositions=yn,n.exitPosition=pn,n.generateEdisTpin=Cn,n.getEdisTransactions=Dn,n.getFunds=Zt,n.getHoldings=en,n.getMarketDepth=gn,n.getMarketHistory=Tn,n.getMarketQuotes=hn,n.getMarketStatus=mn,n.getOrder=tn,n.getOrders=nn,n.getPositions=rn,n.getProfile=$t,n.getSymbolMaster=vn,n.getTrades=on,n.holdingType=function(e){return j(e)},n.holdingTypeDescription=function(e){return W(e)},n.http=Ye,n.inquireEdisTransaction=Pn,n.instrumentType=function(e){return It(oe(e))},n.instrumentTypeDescription=function(e){return ie((t=e,Dt.get(t)));var t},n.modifyOrder=sn,n.modifyOrders=cn,n.month1=y,n.month1Description=p,n.month3=c,n.month3Description=s,n.optionType=function(e){return t=J(e),gt.get(t);var t},n.optionTypeDescription=function(e){return Y((t=e,vt.get(t)));var t},n.orderSide=function(e){return at(A(e))},n.orderSideDescription=function(e){return U(ut(e))},n.orderSource=function(e){return lt(q(e))},n.orderSourceDescription=function(e){return F((t=e,ct.get(t)));var t},n.orderStatus=function(e){return yt(x(e))},n.orderStatusDescription=function(e){return L((t=e,pt.get(t)));var t},n.orderType=function(e){return Tt(z(e))},n.orderTypeDescription=function(e){return H(ht(e))},n.orderValidity=function(e){return V(e)},n.orderValidityDescription=function(e){return V(e)},n.placeOrder=an,n.placeOrders=un,n.positionSide=function(e){return nt(b(e))},n.positionSideDescription=function(e){return O(rt(e))},n.productType=function(e){return te(e)},n.productTypeDescription=function(e){return ee(e)},n.segment=function(e){return Ze(P(e))},n.segmentDescription=function(e){return I((t=e,$e.get(t)));var t},n.submitEdisHoldingsStep=In,n.year2=a,n.year2Description=o},{}]},{},[1])(1)}));
{
"name": "extra-fyers.web",
"version": "0.0.56",
"version": "0.0.57",
"description": "A Javascript interface for FYERS API.",

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

Sorry, the diff of this file is too big to display

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