-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchunk-ZLPS55V2.js
1 lines (1 loc) · 1.88 KB
/
chunk-ZLPS55V2.js
1
import{d as r,g as O}from"./chunk-DQ47BEOY.js";import{a as W,b}from"./chunk-MRBFV4MS.js";import{$ as I,Y as C,a as B,b as M,fa as N,la as V,q as S,v as Y}from"./chunk-PPE7DTG5.js";var l=function(a){return a.BUY="BUY",a.SELL="SELL",a}(l||{});var te=(()=>{class a{constructor(D,p){this.portfolio$=S(D.stocks$).pipe(I(U=>p.getStocks(U.map(m=>m.vendorCode.etm.primary)).pipe(Y(m=>{let n=m.map(e=>{let i=U.find(o=>o.vendorCode.etm.primary===e.vendorCode.etm.primary),u=i?.transactions.reduce((o,t)=>t.type===l.BUY?o+t.quantity:o-t.quantity,0)||0,L=i?.transactions.reduce((o,t)=>t.type===l.BUY?o+t.quantity*t.price+(t.charges||0):o-t.quantity*t.price-(t.charges||0),0)||0,j=L/u||0,g=e.quote?.nse?(e.quote.nse.price-j)*u:0,h=g/L*100||0;return M(B({},e),{id:i?.id||W(),transactions:i?.transactions||[],quantity:u,averagePrice:j,investment:L,marketValue:e.quote?.nse?e.quote.nse.price*u:0,totalProfitLoss:{direction:g>=0?r.UP:r.DOWN,percentage:h,value:g}})}),c=0,f=0,s=0,A=0,y=0,P=0,d=0,q=0;n.map(e=>{let i=e.quote?.nse&&e.quantity?e.quote.nse.price*e.quantity:0;c+=e.investment||0,f+=i,s+=e.quote?.nse&&e.quantity?e.quote.nse.change.value*e.quantity:0,A+=e.quote?.nse?.close&&e.quantity?e.quote.nse.close*e.quantity:0,e.quote?.nse?.change?.direction===r.UP?y++:P++,e.totalProfitLoss?.direction===r.UP?d++:q++});let w=s/A*100||0,v=f-c,x=v/c*100||0,E=y/n.length*100||0,$=P/n.length*100||0,F=d/n.length*100||0,R=q/n.length*100||0;return{holdings:n,investment:c,marketValue:f,dayProfitLoss:{direction:s>=0?r.UP:r.DOWN,percentage:w,value:s},totalProfitLoss:{direction:v>=0?r.UP:r.DOWN,percentage:x,value:v},dayAdvance:{percentage:E,value:y},dayDecline:{percentage:$,value:P},totalAdvance:{percentage:F,value:d},totalDecline:{percentage:R,value:q}}})))).pipe(C(1))}static{this.\u0275fac=function(p){return new(p||a)(V(b),V(O))}}static{this.\u0275prov=N({token:a,factory:a.\u0275fac,providedIn:"root"})}}return a})();export{l as a,te as b};