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.2.21 to 1.2.22

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 E(e){return p(e,"GET","tradebook",null,null)}function S(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:E,placeOrder:S,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")&&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);t(n),!n.hasOwnProperty("d")&&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"]]),Ee=new Map([["MOBILE","FYERS Mobile"],["WEB","FYERS Web"],["ONE","FYERS One"],["ADMIN","Admin"],["API","FYERS API"]]);function Se(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){return{app_id:e.appId,access_token:e.accessToken}}function Xe(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 Ke(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 $e(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,ticker: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:Se(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 je(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 Je(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 We(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 Ze(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 et(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 tt(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 nt(e){return{id:e.id,type:Re(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function rt(e){return{exchange:ue(e.exchange),segment:le(e.segment),type:e.market_type,status:e.status}}function it(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 ot=[1,2,3,5,10,15,20,30,60,120,240,1440];function at(e){var t=1,n=1/0;for(var r of ot){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}function ut(e){return{date:e[0],openPrice:e[1],highPrice:e[2],lowPrice:e[3],closePrice:e[4],volume:e[5]}}function st(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function ct(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 lt(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:st(t.cmd)}}function dt(e){return{price:e.price,volume:e.volume,orders:e.ord}}function pt(e,t){return{price:e.price/t,volume:e.volume,orders:e.ord}}function yt(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 ft(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 mt(e){return{isin_code:e.isin,qty:e.quantity}}function gt(e,t){return.01*Math.round(e*t)}function Tt(e){var t=gt(e,.1);return t+gt(t,18)+gt(e,.00325)+gt(e,.015)+gt(e,1e-4)}class ht extends Error{constructor(e,t){super(t),this.code=e,this.name=this.constructor.name,this.stack=new Error(t).stack}}function vt(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 bt(e,t){return m({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode});var n}function Pt(e){if("ok"!==e.s)throw new ht(e.code,e.message)}function Et(e){if(""===e.id)throw new ht(e.code,e.message)}async function St(e){var t,n=await g(ze(e));return Pt(n),{id:(t=n.data).fy_id,email:t.email_id,name:t.name,pan:t.PAN}}async function Ct(e){var t=await T(ze(e));return Pt(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 Dt(e){var t,n=await h(ze(e));return Pt(n),{details:(t=n).holdings.map(Xe),overall:Ke(t.holdings,t.overall)}}async function Ut(e,t){var n=await v(ze(e),{id:t});return Pt(n),$e(n.orderBook[0])}async function Ot(e){var t,n=await b(ze(e));return Pt(n),{details:(t=n).orderBook.map($e),overall:je(t.orderBook)}}async function It(e){var t,n=await P(ze(e));return Pt(n),{details:(t=n).netPositions.map(Je),overall:We(t.netPositions,t.overall)}}async function wt(e){var t,n=await E(ze(e));return Pt(n),{details:(t=n).tradeBook.map(Ze),overall:et(t.tradeBook)}}async function Mt(e,t){var n=await S(ze(e),tt(t));return Et(n),n.id}function kt(e,t){var n=C(ze(e),t.map(tt));return t.map(((e,t)=>n.then((e=>(Pt(e),Et(e.data[t].body),e.data[t].body.id)))))}async function _t(e,t){var n=await D(ze(e),nt(t));return Pt(n),n.id}function Rt(e,t){var n=U(ze(e),t.map(nt));return t.map(((e,t)=>n.then((e=>{Pt(e),Et(e.data[t].body)}))))}async function At(e,t){Pt(await O(ze(e),{id:t}))}function Lt(e,t){var n=I(ze(e),t.map((e=>({id:e}))));return t.map(((e,t)=>n.then((e=>{Pt(e),Et(e.data[t].body)}))))}async function Nt(e,t){Pt(await w(ze(e),{id:t}))}async function qt(e){Pt(await M(ze(e)))}async function Ft(e,t){var n;Pt(await k(ze(e),(n=t,{symbol:n.symbol,positionSide:me(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"})))}async function Qt(e){var t,n=await _(ze(e));return Pt(n),{details:(t=n).marketStatus.map(rt),overall:it(t.marketStatus)}}async function Bt(e,t){var n,r=await R(ze(e),(n=t,{symbol:n.symbol,resolution:at(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"}));return Pt(r),function(e){return{details:e.candles.map(ut),overall:ct(e.candles)}}(r)}async function xt(e,t){var n=await A(ze(e),{symbols:t.join()});return Pt(n),n.d.map(lt)}async function Gt(e,t){var n=await L(ze(e),{symbol:t,ohlcv_flag:1});return Pt(n),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(dt),sellOffers:n.ask.map(dt),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}}(n)}function Ht(e,t,n){return N(0,{exchange:t,segment:n})}function Yt(e){for(var t=[],n=/[^\n]+/g,r=null;null!=(r=n.exec(e));)t.push(Ve(r[0]));return t}async function Vt(e,t,n){return Yt(await Ht(0,t,n))}async function zt(e){Pt(await q(ze(e)))}async function Xt(e){var t,n,r=await F(ze(e));return Pt(r),{details:(n=0===(t=r).data.length?[]:t.data).map(yt),overall:ft(n)}}function Kt(e,t){return Q(ze(e),{recordLst:t.map(mt)})}async function $t(e,t){var n=await B(ze(e),{transactionId:t});return Pt(n),n.data.FAILED_CNT>0?-n.data.FAILED_CNT:n.data.SUCEESS_CNT}function jt(e,t){return j(ze(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,offlineOrder: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 Jt(e){var t=await J(e);if(t.code<0)throw new ht(t.code,t.message)}async function Wt(e){var t=await W(e);if(t.code<0)throw new ht(t.code,t.message)}function Zt(e,t,n=null){return Z(ze(e),(e=>{e.d&&t(function(e,t){var n=e.d,r=n.token.toString(),i=n.price_conv;return console.log("fyCode:",n.fyCode),{symbol:null!=t&&t.get(r)||null,token:r,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,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:null==n.bids?n.bid/i:n.bids[0].price/i,sellPrice:null==n.asks?n.ask/i:n.asks[0].price/i,buyOffers:null==n.bids?null:n.bids.map((e=>pt(e,i))),sellOffers:null==n.asks?null:n.asks.map((e=>pt(e,i)))}}(e,n))}))}async function en(e,t){var n=await ee(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function tn(e,t){var n=await te(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function nn(e,t){var n=await ne(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function rn(e,t){var n=await re(e,t);if(n.code<0)throw new ht(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 vt(e,t,n)}static loginStep2(e,t){return bt(e,t)}static getSymbolMaster(e,t){return Ht(0,e,t)}getProfile(){return St(this)}getFunds(){return Ct(this)}getHoldings(){return Dt(this)}getOrder(e){return Ut(this,e)}getOrders(){return Ot(this)}getPositions(){return It(this)}getTrades(){return wt(this)}placeOrder(e){return Mt(this,e)}placeOrders(e){return kt(this,e)}modifyOrder(e){return _t(this,e)}modifyOrders(e){return Rt(this,e)}cancelOrder(e){return At(this,e)}cancelOrders(e){return Lt(this,e)}exitPosition(e){return Nt(this,e)}exitAllPositions(){return qt(this)}convertPosition(e){return Ft(this,e)}getMarketStatus(){return Qt(this)}getMarketHistory(e){return Bt(this,e)}getMarketQuotes(e){return xt(this,e)}getMarketDepth(e){return Gt(this,e)}processSymbolMaster(e){var t=Yt(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 Vt(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 zt(this)}getEdisTransactions(){return Xt(this)}submitEdisHoldingsStep(e){return Kt(this,e)}inquireEdisTransaction(e){return $t(this,e)}connectOrderUpdate(e){return null!=this.orderUpdateConnection&&this.orderUpdateConnection.then((e=>e.close())),this.orderUpdateConnection=jt(this,e)}async subscribeOrderUpdate(){return Jt(await this.orderUpdateConnection)}async unsubscribeOrderUpdate(){return Wt(await this.orderUpdateConnection)}async connectMarketData(e){return null!=this.marketDataConnection&&this.marketDataConnection.then((e=>e.close())),this.marketDataConnection=Zt(this,e,this.tokenSymbol)}async subscribeMarketQuote(e){return en(await this.marketDataConnection,e)}async subscribeMarketDepth(e){return tn(await this.marketDataConnection,e)}async unsubscribeMarketQuote(e){return nn(await this.marketDataConnection,e)}async unsubscribeMarketDepth(e){return rn(await this.marketDataConnection,e)}},n.cancelOrder=At,n.cancelOrders=Lt,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.0026)+gt(n,.0018)+gt(n,.002)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.01);return t+n+gt(t+n,18)+gt(e,.0026)+gt(e,.0018)+gt(e,.002)+gt(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+gt(20,18)+gt(n,.05)+gt(n,3e-4)+gt(n,1e-4)):function(e){var t=gt(e,.05);return 20+t+gt(20+t,18)+gt(e,.05)+gt(e,3e-4)+gt(e,1e-4)}(t);var n},n.connectMarketData=Zt,n.connectOrderUpdate=jt,n.convertPosition=Ft,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.00115)+gt(n,5e-4)+gt(n,1e-4)+gt(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+gt(20,18)+gt(n,.04)+gt(n,.009)+gt(n,1e-4)+gt(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?Tt(t):12.5+Tt(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.0019)+gt(n,5e-4)+gt(n,.002)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.01);return t+n+gt(t+n,18)+gt(e,.0019)+gt(e,5e-4)+gt(e,.002)+gt(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.00325)+gt(n,.003)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.025);return t+n+gt(t+n,18)+gt(e,.00325)+gt(e,.003)+gt(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+gt(20,18)+gt(n,.053)+gt(n,.009)+gt(n,.003)+gt(n,1e-4)):function(e){var t=gt(e,.05);return 20+t+gt(20+t,18)+gt(e,.053)+gt(e,.009)+gt(e,.003)+gt(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=Nt,n.generateEdisTpin=zt,n.getEdisTransactions=Xt,n.getFunds=Ct,n.getHoldings=Dt,n.getMarketDepth=Gt,n.getMarketHistory=Bt,n.getMarketQuotes=xt,n.getMarketStatus=Qt,n.getOrder=Ut,n.getOrders=Ot,n.getPositions=It,n.getProfile=St,n.getSymbolMaster=Ht,n.getTrades=wt,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=$t,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=Vt,n.loginStep1=vt,n.loginStep2=bt,n.modifyOrder=_t,n.modifyOrders=Rt,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 Ee.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=Mt,n.placeOrders=kt,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=Yt,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=Kt,n.subscribeMarketDepth=tn,n.subscribeMarketQuote=en,n.subscribeOrderUpdate=Jt,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=function(e){var t=e.indexOf(":");return e.substring(0,t)},n.symbolIsin=function(e,t){return t.get(e).isin},n.symbolLotSize=function(e,t){return t.get(e).lotSize},n.symbolName=function(e){var t=Ye.exec(e);return t[1]||t[2]||t[3]||t[4]},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=rn,n.unsubscribeMarketQuote=nn,n.unsubscribeOrderUpdate=Wt,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 E(e){return p(e,"GET","tradebook",null,null)}function S(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:E,placeOrder:S,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||!0,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")&&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);t(n),!n.hasOwnProperty("d")&&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"]]),Ee=new Map([["MOBILE","FYERS Mobile"],["WEB","FYERS Web"],["ONE","FYERS One"],["ADMIN","Admin"],["API","FYERS API"]]);function Se(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){return{app_id:e.appId,access_token:e.accessToken}}function Xe(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 Ke(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 $e(e){return{id:e.id,symbol:e.symbol,token:e.fytoken,ticker: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:Se(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 je(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 Je(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 We(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 Ze(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 et(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 tt(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 nt(e){return{id:e.id,type:Re(e.type),qty:e.quantity,disclosedQty:e.disclosedQuantity,limitPrice:e.limitPrice,stopPrice:e.stopPrice}}function rt(e){return{exchange:ue(e.exchange),segment:le(e.segment),type:e.market_type,status:e.status}}function it(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 ot=[1,2,3,5,10,15,20,30,60,120,240,1440];function at(e){var t=1,n=1/0;for(var r of ot){var i=Math.abs(e-r);i<n&&(t=r,n=i)}return 1440===t?"D":t.toString()}function ut(e){return{date:e[0],openPrice:e[1],highPrice:e[2],lowPrice:e[3],closePrice:e[4],volume:e[5]}}function st(e){return{date:e.t,openPrice:e.o,highPrice:e.h,lowPrice:e.l,closePrice:e.c,volume:e.v}}function ct(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 lt(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:st(t.cmd)}}function dt(e){return{price:e.price,volume:e.volume,orders:e.ord}}function pt(e,t){return{price:e.price/t,volume:e.volume,orders:e.ord}}function yt(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 ft(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 mt(e){return{isin_code:e.isin,qty:e.quantity}}function gt(e,t){return.01*Math.round(e*t)}function Tt(e){var t=gt(e,.1);return t+gt(t,18)+gt(e,.00325)+gt(e,.015)+gt(e,1e-4)}class ht extends Error{constructor(e,t){super(t),this.code=e,this.name=this.constructor.name,this.stack=new Error(t).stack}}function vt(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 bt(e,t){return m({grant_type:"authorization_code",appIdHash:(n={appHash:e,authorizationCode:t}).appHash,code:n.authorizationCode});var n}function Pt(e){if("ok"!==e.s)throw new ht(e.code,e.message)}function Et(e){if(""===e.id)throw new ht(e.code,e.message)}async function St(e){var t,n=await g(ze(e));return Pt(n),{id:(t=n.data).fy_id,email:t.email_id,name:t.name,pan:t.PAN}}async function Ct(e){var t=await T(ze(e));return Pt(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 Dt(e){var t,n=await h(ze(e));return Pt(n),{details:(t=n).holdings.map(Xe),overall:Ke(t.holdings,t.overall)}}async function Ut(e,t){var n=await v(ze(e),{id:t});return Pt(n),$e(n.orderBook[0])}async function Ot(e){var t,n=await b(ze(e));return Pt(n),{details:(t=n).orderBook.map($e),overall:je(t.orderBook)}}async function It(e){var t,n=await P(ze(e));return Pt(n),{details:(t=n).netPositions.map(Je),overall:We(t.netPositions,t.overall)}}async function wt(e){var t,n=await E(ze(e));return Pt(n),{details:(t=n).tradeBook.map(Ze),overall:et(t.tradeBook)}}async function Mt(e,t){var n=await S(ze(e),tt(t));return Et(n),n.id}function kt(e,t){var n=C(ze(e),t.map(tt));return t.map(((e,t)=>n.then((e=>(Pt(e),Et(e.data[t].body),e.data[t].body.id)))))}async function _t(e,t){var n=await D(ze(e),nt(t));return Pt(n),n.id}function Rt(e,t){var n=U(ze(e),t.map(nt));return t.map(((e,t)=>n.then((e=>{Pt(e),Et(e.data[t].body)}))))}async function At(e,t){Pt(await O(ze(e),{id:t}))}function Lt(e,t){var n=I(ze(e),t.map((e=>({id:e}))));return t.map(((e,t)=>n.then((e=>{Pt(e),Et(e.data[t].body)}))))}async function Nt(e,t){Pt(await w(ze(e),{id:t}))}async function qt(e){Pt(await M(ze(e)))}async function Ft(e,t){var n;Pt(await k(ze(e),(n=t,{symbol:n.symbol,positionSide:me(n.side||"LONG"),convertQty:n.quantity,convertFrom:n.fromProductType||"INTRADAY",convertTo:n.toProductType||"CNC"})))}async function Qt(e){var t,n=await _(ze(e));return Pt(n),{details:(t=n).marketStatus.map(rt),overall:it(t.marketStatus)}}async function Bt(e,t){var n,r=await R(ze(e),(n=t,{symbol:n.symbol,resolution:at(n.resolution),date_format:0,range_from:n.fromDate.toString(),range_to:n.toDate.toString(),cont_flag:n.continuous?"1":"0"}));return Pt(r),function(e){return{details:e.candles.map(ut),overall:ct(e.candles)}}(r)}async function xt(e,t){var n=await A(ze(e),{symbols:t.join()});return Pt(n),n.d.map(lt)}async function Gt(e,t){var n=await L(ze(e),{symbol:t,ohlcv_flag:1});return Pt(n),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(dt),sellOffers:n.ask.map(dt),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}}(n)}function Ht(e,t,n){return N(0,{exchange:t,segment:n})}function Yt(e){for(var t=[],n=/[^\n]+/g,r=null;null!=(r=n.exec(e));)t.push(Ve(r[0]));return t}async function Vt(e,t,n){return Yt(await Ht(0,t,n))}async function zt(e){Pt(await q(ze(e)))}async function Xt(e){var t,n,r=await F(ze(e));return Pt(r),{details:(n=0===(t=r).data.length?[]:t.data).map(yt),overall:ft(n)}}function Kt(e,t){return Q(ze(e),{recordLst:t.map(mt)})}async function $t(e,t){var n=await B(ze(e),{transactionId:t});return Pt(n),n.data.FAILED_CNT>0?-n.data.FAILED_CNT:n.data.SUCEESS_CNT}function jt(e,t){return j(ze(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,offlineOrder: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 Jt(e){var t=await J(e);if(t.code<0)throw new ht(t.code,t.message)}async function Wt(e){var t=await W(e);if(t.code<0)throw new ht(t.code,t.message)}function Zt(e,t,n=null){return Z(ze(e),(e=>{e.d&&t(function(e,t){var n=e.d,r=n.token.toString(),i=n.price_conv;return console.log("fyCode:",n.fyCode),{symbol:null!=t&&t.get(r)||null,token:r,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,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:null==n.bids?n.bid/i:n.bids[0].price/i,sellPrice:null==n.asks?n.ask/i:n.asks[0].price/i,buyOffers:null==n.bids?null:n.bids.map((e=>pt(e,i))),sellOffers:null==n.asks?null:n.asks.map((e=>pt(e,i)))}}(e,n))}))}async function en(e,t){var n=await ee(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function tn(e,t){var n=await te(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function nn(e,t){var n=await ne(e,t);if(n.code<0)throw new ht(n.code,n.message)}async function rn(e,t){var n=await re(e,t);if(n.code<0)throw new ht(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 vt(e,t,n)}static loginStep2(e,t){return bt(e,t)}static getSymbolMaster(e,t){return Ht(0,e,t)}getProfile(){return St(this)}getFunds(){return Ct(this)}getHoldings(){return Dt(this)}getOrder(e){return Ut(this,e)}getOrders(){return Ot(this)}getPositions(){return It(this)}getTrades(){return wt(this)}placeOrder(e){return Mt(this,e)}placeOrders(e){return kt(this,e)}modifyOrder(e){return _t(this,e)}modifyOrders(e){return Rt(this,e)}cancelOrder(e){return At(this,e)}cancelOrders(e){return Lt(this,e)}exitPosition(e){return Nt(this,e)}exitAllPositions(){return qt(this)}convertPosition(e){return Ft(this,e)}getMarketStatus(){return Qt(this)}getMarketHistory(e){return Bt(this,e)}getMarketQuotes(e){return xt(this,e)}getMarketDepth(e){return Gt(this,e)}processSymbolMaster(e){var t=Yt(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 Vt(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 zt(this)}getEdisTransactions(){return Xt(this)}submitEdisHoldingsStep(e){return Kt(this,e)}inquireEdisTransaction(e){return $t(this,e)}connectOrderUpdate(e){return null!=this.orderUpdateConnection&&this.orderUpdateConnection.then((e=>e.close())),this.orderUpdateConnection=jt(this,e)}async subscribeOrderUpdate(){return Jt(await this.orderUpdateConnection)}async unsubscribeOrderUpdate(){return Wt(await this.orderUpdateConnection)}async connectMarketData(e){return null!=this.marketDataConnection&&this.marketDataConnection.then((e=>e.close())),this.marketDataConnection=Zt(this,e,this.tokenSymbol)}async subscribeMarketQuote(e){return en(await this.marketDataConnection,e)}async subscribeMarketDepth(e){return tn(await this.marketDataConnection,e)}async unsubscribeMarketQuote(e){return nn(await this.marketDataConnection,e)}async unsubscribeMarketDepth(e){return rn(await this.marketDataConnection,e)}},n.cancelOrder=At,n.cancelOrders=Lt,n.commodityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.0026)+gt(n,.0018)+gt(n,.002)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.01);return t+n+gt(t+n,18)+gt(e,.0026)+gt(e,.0018)+gt(e,.002)+gt(e,1e-4)}(t);var n,r},n.commodityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+gt(20,18)+gt(n,.05)+gt(n,3e-4)+gt(n,1e-4)):function(e){var t=gt(e,.05);return 20+t+gt(20+t,18)+gt(e,.05)+gt(e,3e-4)+gt(e,1e-4)}(t);var n},n.connectMarketData=Zt,n.connectOrderUpdate=jt,n.convertPosition=Ft,n.currencyFuturesCharges=function(e,t){return n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.00115)+gt(n,5e-4)+gt(n,1e-4)+gt(n,1e-4);var n,r},n.currencyOptionsCharges=function(e,t){return n=t,20+gt(20,18)+gt(n,.04)+gt(n,.009)+gt(n,1e-4)+gt(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?Tt(t):12.5+Tt(t)},n.equityFuturesCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.0019)+gt(n,5e-4)+gt(n,.002)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.01);return t+n+gt(t+n,18)+gt(e,.0019)+gt(e,5e-4)+gt(e,.002)+gt(e,1e-4)}(t);var n,r},n.equityIntradayCharges=function(e,t){return"BUY"===e?(n=t,(r=Math.min(20,gt(n,.03)))+gt(r,18)+gt(n,.00325)+gt(n,.003)+gt(n,1e-4)):function(e){var t=Math.min(20,gt(e,.03)),n=gt(e,.025);return t+n+gt(t+n,18)+gt(e,.00325)+gt(e,.003)+gt(e,1e-4)}(t);var n,r},n.equityOptionsCharges=function(e,t){return"BUY"===e?(n=t,20+gt(20,18)+gt(n,.053)+gt(n,.009)+gt(n,.003)+gt(n,1e-4)):function(e){var t=gt(e,.05);return 20+t+gt(20+t,18)+gt(e,.053)+gt(e,.009)+gt(e,.003)+gt(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=Nt,n.generateEdisTpin=zt,n.getEdisTransactions=Xt,n.getFunds=Ct,n.getHoldings=Dt,n.getMarketDepth=Gt,n.getMarketHistory=Bt,n.getMarketQuotes=xt,n.getMarketStatus=Qt,n.getOrder=Ut,n.getOrders=Ot,n.getPositions=It,n.getProfile=St,n.getSymbolMaster=Ht,n.getTrades=wt,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=$t,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=Vt,n.loginStep1=vt,n.loginStep2=bt,n.modifyOrder=_t,n.modifyOrders=Rt,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 Ee.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=Mt,n.placeOrders=kt,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=Yt,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=Kt,n.subscribeMarketDepth=tn,n.subscribeMarketQuote=en,n.subscribeOrderUpdate=Jt,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=function(e){var t=e.indexOf(":");return e.substring(0,t)},n.symbolIsin=function(e,t){return t.get(e).isin},n.symbolLotSize=function(e,t){return t.get(e).lotSize},n.symbolName=function(e){var t=Ye.exec(e);return t[1]||t[2]||t[3]||t[4]},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=rn,n.unsubscribeMarketQuote=nn,n.unsubscribeOrderUpdate=Wt,n.websocket=ie},{}]},{},[1])(1)}));
{
"name": "extra-fyers.web",
"version": "1.2.21",
"version": "1.2.22",
"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