(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5432],{9246:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/mvrv-z-score",function(){return a(4216)}])},4216:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return MVRVZscore}});var i=a(5893),l=a(9008),n=a.n(l),r=a(7294),o=a(7626),s=a(5912),c=a(1526),d=a(6720),m=a(6488);a(4321),a(813);var h=a(6204),g=a(8688);function MVRVZscore(){let[e,t]=(0,r.useState)(!1),[a,l]=(0,r.useState)(!0),[s,x]=(0,r.useState)("isInfoVisible"),[f,p]=(0,r.useState)(!1),[u,w]=(0,r.useState)([]),[y,v]=(0,r.useState)("BTC"),[b,j]=(0,r.useState)([]),S=(0,g.eI)("https://swmkwzrguapkaodkgcmt.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3bWt3enJndWFwa2FvZGtnY210Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTIxODI1NDMsImV4cCI6MjAyNzc1ODU0M30.At51g7QDyI7Pk-nx_-S5ShAcme7bjhSUqX8YsVvGB9A");(0,r.useEffect)(()=>{let e=window.location.pathname,t="isInfoVisible_".concat(e);x(t);let a=localStorage.getItem(t);null!==a&&l("false"!==a)},[]);let toggleInfo=()=>{let e=!a;localStorage.setItem(s,e.toString()),l(e)};(0,r.useEffect)(()=>{(0,m.ZP)(":not(.sidebar-tooltip)[data-tippy-content]",{placement:"bottom",theme:"customTheme"})},[]);let M=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=new Image;e.src="/assets/images/mainLogoLetters.png",e.onload=()=>{M.current=e,drawChart(u)}},[]);let T=(0,r.useRef)(null),formatAxisLabel=e=>e>=1?e.toFixed(0):e>=.01?e.toFixed(2):e.toFixed(6),formatPrice=e=>e<1e3?e.toFixed(2):e.toFixed(0),fetchBatchedDataInParallel=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2500,a=new Date("2010-10-15"),i=Array.from({length:3},(i,l)=>{let n=l*t,r=n+t-1;return S.from(e).select("date, mvrvz").range(n,r).then(e=>{let{data:t,error:i}=e;return i?(console.error("Error fetching batch ".concat(l,": ").concat(i.message)),[]):t.filter(e=>{let{date:t}=e;return new Date(t)>=a})})});return(await Promise.all(i)).flat()};(0,r.useEffect)(()=>{let fetchData=async()=>{t(!0);try{let[e,t]=await Promise.all([S.from("daily_candles").select("candles").eq("token","BTCUSDT").single(),fetchBatchedDataInParallel("mvrvz",2500)]),{data:a,error:i}=e;if(i)throw Error("Error fetching BTC data: ".concat(i.message));let l=new Date("2010-10-15"),n=a.candles.map(e=>{let{timestamp:t,close:a}=e;return{timestamp:new Date(t).toISOString().split("T")[0],close:parseFloat(a)}}).filter(e=>new Date(e.timestamp)>=l);w(n);let r=t.map(e=>{let{date:t,mvrvz:a}=e;return{date:new Date(t).toISOString().split("T")[0],zScore:parseFloat(a)}});j(r)}catch(e){console.error("Failed to fetch data: ".concat(e.message))}finally{t(!1)}};fetchData()},[]),(0,r.useEffect)(()=>{let handleResize=()=>{drawChart(u)};return window.addEventListener("resize",handleResize),()=>{window.removeEventListener("resize",handleResize)}},[u]),(0,r.useEffect)(()=>{T.current&&u.length>0&&b.length>0&&drawChart(u)},[u,b]);let generateDailyDates=(e,t)=>{let a=[],i=new Date(e),l=new Date(t);for(;i<=l;)a.push(new Date(i).toISOString().split("T")[0]),i.setDate(i.getDate()+1);return a},drawChart=e=>{let t=T.current;if(!t)return;let a=t.getContext("2d");if(!a)return;let i=document.createElement("canvas"),l=i.getContext("2d"),n=t.parentElement,r=n.clientWidth,o=n.clientHeight;t.width=2*r,t.height=2*o,t.style.width="".concat(r,"px"),t.style.height="".concat(o,"px"),a.scale(2,2),i.width=2*r,i.height=2*o,l.scale(2,2);let s=40,c=50;r<=1024?(s=40,c=35):(s=50,c=50);let d=Math.max(...e.map(e=>e.close)),m=Math.min(...e.map(e=>e.close)),h=Math.min(...b.map(e=>e.zScore)),g=Math.max(...b.map(e=>e.zScore));m=Math.max(m,1e-4);let x=Math.max(d,g),f=Math.max(m,1e-4),p=(o-0-10-40)/(Math.log10(x)-Math.log10(f)),w=(o-0-10-40)/(g-h);if(0===e.length)return;let v=u.map(e=>e.timestamp);l.clearRect(0,0,i.width,i.height);let drawAxes=(e,t)=>{let a=(Math.log10(x)-Math.log10(f))/5;e.fillStyle="lightgrey",e.textAlign="right",e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",e.textBaseline="middle";for(let t=0;t<=5;t++){let i=Math.pow(10,Math.log10(f)+t*a),l=o-10-20-(Math.log10(i)-Math.log10(f))*p;e.fillText("".concat(formatAxisLabel(i)),s-10,l),e.strokeStyle="rgba(255, 255, 255, 0.7)",e.lineWidth=.1,e.beginPath(),e.moveTo(s,l),e.lineTo(r-c,l),e.stroke()}let i=(g-h)/5;e.textAlign="left";for(let t=0;t<=5;t++){let a=h+t*i,l=o-10-20-(a-h)*w;e.fillText(a.toFixed(2),r-c+10,l)}e.fillStyle="lightgrey",e.textAlign="center",e.textBaseline="middle",e.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",window.innerWidth;let l=new Date(t[0].timestamp),n=new Date(t[t.length-1].timestamp),d=generateDailyDates(l,n);e.fillText(new Date(l).getFullYear(),s,o-10);for(let t=new Date(l);t<n;t.setFullYear(t.getFullYear()+2)){let a=new Date(t).toISOString().split("T")[0],i=s+d.indexOf(a)*(r-s-c)/(d.length-1);i>s&&i<r-c&&e.fillText(new Date(t).getFullYear(),i,o-10)}};(t=>{t.clearRect(0,0,r,o),t.fillStyle="#171a1e",t.fillRect(0,0,r,o),(()=>{let e=o-10-20-(7-h)*w;t.fillStyle="#dc26264D",t.fillRect(s,0,r-s-c,e-0),t.strokeStyle="red",t.lineWidth=.5,t.beginPath(),t.moveTo(s,0),t.lineTo(r-c,0),t.stroke(),t.beginPath(),t.moveTo(s,e),t.lineTo(r-c,e),t.stroke();let a=o-10-20-(0-h)*w,i=o-10-20-(-.75-h)*w;t.fillStyle="#16a34a4D",t.fillRect(s,a,r-s-c,i-a),t.strokeStyle="green",t.lineWidth=1,t.beginPath(),t.moveTo(s,a),t.lineTo(r-c,a),t.stroke(),t.beginPath(),t.moveTo(s,i),t.lineTo(r-c,i),t.stroke()})();let a=v.map(e=>{let t=u.find(t=>t.timestamp===e),a=b.find(t=>t.date===e);return{date:e,close:t?t.close:null,zScore:a?a.zScore:null}}),drawLine=function(e,t,i,l){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];e.strokeStyle=i,e.lineWidth=l,e.beginPath();let d=!0;a.forEach((a,i)=>{let l=a[t];if(null===l)return;let m=s+i*(r-s-c)/(v.length-1);if(m>=s&&m<=r-c){let t=o-10-20-(n?(l-h)*w:(Math.log10(l)-Math.log10(f))*p);d?(e.moveTo(m,t),d=!1):e.lineTo(m,t)}}),e.stroke()};drawLine(t,"zScore","#cbd5e1",1,!0),drawLine(t,"close","orange",1),drawAxes(t,e)})(l),M.current&&(l.globalAlpha=.5,l.drawImage(M.current,50,10,101.4,30.2),l.globalAlpha=1),a.drawImage(i,0,0,r,o);let j=document.getElementById("cumulative-tooltip"),handleMouseMove=e=>{let l=t.getBoundingClientRect(),n=e.clientX-l.left,d=e.clientY-l.top,m=n<s,p=n>r-c,w=d>o-20;if(m||p||w){j.style.display="none",a.clearRect(0,0,r,o),a.drawImage(i,0,0,r,o);return}if(n<s||n>r-c)return;let v=(n-s)*(u.length-1)/(r-s-c),S=Math.min(Math.max(0,Math.round(v)),u.length-1),M=u[S].timestamp,T=u[S],I=(e=>{let t=b.find(t=>t.date===e);if(!t){let a=b.filter(t=>new Date(t.date)<=new Date(e));t=a.length>0?a[a.length-1]:null}return t})(M);j.style.display="block",j.style.left="".concat(n+10,"px"),j.style.top="".concat(d+10,"px"),n+50+j.offsetWidth>r?j.style.left="".concat(n-j.offsetWidth-60,"px"):j.style.left="".concat(n+30,"px"),d+10+j.offsetHeight>o?j.style.top="".concat(d-j.offsetHeight-10,"px"):j.style.top="".concat(d+10,"px");let k=T&&T.close?"$".concat(formatPrice(T.close)):"N/A",D=I&&void 0!==I.zScore?parseFloat(I.zScore).toFixed(2):"N/A";j.innerHTML="\n        Date: ".concat(new Date(M).toLocaleDateString("en-GB",{timeZone:"UTC"}),'<br>\n        <span style="display: flex; align-items: center;">\n          <img src="https://lcw.nyc3.cdn.digitaloceanspaces.com/production/currencies/64/').concat(y.toLowerCase(),'.png" class="w-2" alt="Bitcoin logo" style="width: 16px; vertical-align: middle; margin-right: 4px;" /> \n          ').concat(y," Price: ").concat(k,'\n        </span>\n        <div style="display: flex; justify-content: flex-start; align-items: center;">\n          <div style="width: 10px; height: 10px; background-color: #ccd5e1; margin-right: 6px; margin-bottom: 3px;"></div>\n          <div>MVRV Z-Score: ').concat(D,"</div>\n        </div>\n      "),a.clearRect(0,0,r,o),a.drawImage(i,0,0,r,o),a.strokeStyle="rgba(255, 255, 255, 0.5)",a.lineWidth=.7,a.setLineDash([5,5]),a.beginPath(),a.moveTo(n,0),a.lineTo(n,o),a.moveTo(0,d),a.lineTo(r,d),a.stroke(),a.setLineDash([]),a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(s-70,d-10,70,20),a.fillStyle="white",a.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",a.textAlign="right";let C=Math.log10(f),N=Math.log10(x),z=Math.pow(10,C+(o-d-20-10)/(o-0-10-40)*(N-C));a.fillText(formatPrice(z),s-3,d+2.5),a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(n-35,o-10-10,70,30),a.fillStyle="white",a.textAlign="center",a.fillText(new Date(M).toLocaleDateString("en-GB",{timeZone:"UTC"}),n,o-10+3);let R=h+(o-d-20-10)/(o-0-10-40)*(g-h);a.fillStyle="rgba(63, 63, 70, 1)",a.fillRect(r-c+10,d-10,70,20),a.fillStyle="white",a.font="10px Oxanium, Helvetica, Verdana, Tahoma, sans-serif",a.textAlign="left",a.fillText(R.toFixed(2),r-c+15,d+2.5)};return t.addEventListener("mousemove",handleMouseMove),t.addEventListener("mouseout",()=>{j.style.display="none",a.clearRect(0,0,r,o),a.drawImage(i,0,0,r,o)}),()=>{t.removeEventListener("mousemove",handleMouseMove)}},drawExtraContent=(e,t,a)=>{let i,l,n,r;let o=window.innerWidth;o>640?(i=28,l=14,n=75,r=35):(i=18,l=12,n=47,r=20),e.font="".concat(l,"px Oxanium"),e.fillStyle="#e4e4e7";let s="Created at TradingDigits.io",c=e.measureText(s).width;e.fillText(s,(t-c)/2,r),e.font="".concat(i,"px Oxanium");let d="".concat(a,", ").concat(new Date().toLocaleDateString()),m=e.measureText(d).width;e.fillText(d,(t-m)/2,n)},downloadChart=(e,t)=>{let a=e.current;a.getContext("2d");let i=document.createElement("canvas"),l=a.width+40,n=a.height+20+40+100;i.width=l,i.height=n;let r=i.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,i.width,i.height),drawExtraContent(r,i.width,t),r.drawImage(a,20,100);let o=document.createElement("a");o.download="".concat(t.replace(/\s+/g,"_").toLowerCase(),".png"),o.href=i.toDataURL("image/png"),o.click()},copyChartToClipboard=async(e,t)=>{let a=e.current;a.getContext("2d");let i=document.createElement("canvas"),l=a.width+40,n=a.height+20+40+100;i.width=l,i.height=n;let r=i.getContext("2d");r.fillStyle="#171a1e",r.fillRect(0,0,i.width,i.height),drawExtraContent(r,i.width,t),r.drawImage(a,20,100),i.toBlob(async e=>{try{let t=new ClipboardItem({"image/png":e});await navigator.clipboard.write([t]),p(!0),setTimeout(()=>p(!1),1e3)}catch(e){console.error("Failed to copy chart: ",e)}})};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(()=>(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(n(),{children:[(0,i.jsx)("title",{children:"Bitcoin MVRV Z-Score: Spot Crypto Market Tops & Bottoms"}),(0,i.jsx)("meta",{name:"description",content:"MVRV Z-Score Index compares Bitcoin market value to its realized value, helping traders identify potential market tops and bottoms"}),(0,i.jsx)("meta",{name:"keywords",content:"mvrv, z, score, bitcoin, btc, index, indicator, chart, crypto, metrics"}),(0,i.jsx)("meta",{property:"og:title",content:"Bitcoin MVRV Z-Score: Spot Crypto Market Tops & Bottoms"}),(0,i.jsx)("meta",{property:"og:description",content:"MVRV Z-Score Index compares Bitcoin market value to its realized value, helping traders identify potential market tops and bottoms"}),(0,i.jsx)("meta",{property:"og:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,i.jsx)("meta",{property:"og:url",content:"https://www.tradingdigits.io/mvrv-z-score"}),(0,i.jsx)("meta",{name:"twitter:title",content:"Bitcoin MVRV Z-Score: Spot Crypto Market Tops & Bottoms"}),(0,i.jsx)("meta",{name:"twitter:description",content:"MVRV Z-Score Index compares Bitcoin market value to its realized value, helping traders identify potential market tops and bottoms"}),(0,i.jsx)("meta",{name:"twitter:image",content:"https://www.tradingdigits.io/assets/images/ogImage.jpg"}),(0,i.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,i.jsx)("meta",{name:"twitter:image:alt",content:"Promotional image with crypto-related illustration on black background, company name, and catchphrase about Trading Digits"}),(0,i.jsx)("meta",{name:"twitter:site",content:"@trading_digits"}),(0,i.jsx)("link",{rel:"canonical",href:"https://www.tradingdigits.io/mvrv-z-score"}),(0,i.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),(0,i.jsx)("link",{href:"https://fonts.googleapis.com/css2?family=Oxanium:wght@300;400;500;600;700&display=swap",rel:"stylesheet"})]})}),{}),(0,i.jsx)("div",{className:"md:mt-[95px] sm:mt-[90px] mt-[80px]",children:(0,i.jsxs)("div",{className:"pb-3 pt-2 sm:pt-1 ".concat(e?"h-screen":"h-full"," 2.5xl:h-full 3xl:h-screen min-[1540px]:pb-[100px]"),children:[(0,i.jsxs)("div",{className:"flex items-center ".concat(a?"lg:justify-start":"lg:justify-center pb-4"," justify-center my-1.75 text-center"),children:[(0,i.jsx)("h1",{className:"pl-2 sm:text-2xl text-xl font-[Oxanium-Regular]",children:"MVRV Z-SCORE INDEX"}),(0,i.jsx)(c.M,{children:!a&&(0,i.jsx)(d.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"ml-3",children:(0,i.jsx)("i",{onClick:toggleInfo,className:"fa-solid fa-circle-info fa-lg text-zinc-200 cursor-pointer hover:text-amber-400 transition duration-300"})})})]}),(0,i.jsx)(c.M,{children:a&&(0,i.jsxs)(d.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"relative px-2 py-2 flex items-center mr-0 mb-8 bg-[#363738] justify-center w-full",children:[(0,i.jsx)("i",{className:"fa-solid fa-circle-info fa-2xl mr-3 text-zinc-200"}),(0,i.jsx)("div",{className:"font-[Oxanium-Regular] sm:text-sm text-xs pr-4",children:(0,i.jsx)("p",{children:'The MVRV Z-Score is a metric used to assess whether Bitcoin is overvalued or undervalued relative to its "fair" or "intrinsic" value, therefore helping traders identify potential market tops and bottoms. It\'s calculated by comparing the asset\'s market value (market cap) to its realized value (the value stored based on prices when each coin last moved). A high Z-score suggests the asset is overvalued, while a low Z-score indicates undervaluation.'})}),(0,i.jsx)("div",{onClick:toggleInfo,className:"absolute top-0 right-0 flex items-start hover:bg-zinc-500 cursor-pointer py-0.5 px-1 transition duration-300",children:(0,i.jsx)("i",{className:"fa-solid fa-xmark"})})]})}),e?(0,i.jsx)("div",{className:"flex w-full items-center justify-center mt-32",children:(0,i.jsx)("img",{src:o.Y.logoLoading,className:"quick-pulse w-48 ",alt:"Loading..."})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{className:"w-full flex items-center justify-between gap-3 text-center sm:text-sm text-xs bg-zinc-800 border-1 border-y border-zinc-700",children:[(0,i.jsxs)("div",{className:"flex gap-3 pl-16 sm:text-presm text-prexs font-[Oxanium-Light]",children:[(0,i.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,i.jsxs)("div",{className:"flex justify-center items-center",children:[(0,i.jsx)("div",{className:"w-2.5 h-2.5 bg-[#f7a500] mr-1.5 mb-0.75"}),(0,i.jsxs)("div",{children:[y," Price"]})]})}),(0,i.jsx)("div",{className:"flex flex-col justify-center items-center",children:(0,i.jsxs)("div",{className:"flex justify-center items-center",children:[(0,i.jsx)("div",{className:"w-2.5 h-2.5 bg-[#ccd5e1] mr-1.5 mb-0.75"}),(0,i.jsx)("div",{children:"MVRV Z-Score"})]})})]}),(0,i.jsxs)("div",{className:"flex pl-[3px] pr-[3px] border-l border-zinc-700",children:[(0,i.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center ".concat(f?"animate-flip":""),onClick:()=>copyChartToClipboard(T,"MVRV Z-Score Index"),children:(0,i.jsx)(h.esY,{className:"text-zinc-300 text-base"})}),(0,i.jsx)("button",{className:"px-2 py-2 hover:rounded-sm bg-zinc-800 hover:bg-zinc-700 transition duration-300 flex items-center justify-center",onClick:()=>downloadChart(T,"MVRV Z-Score Index"),children:(0,i.jsx)(h.aBF,{className:"text-zinc-300 text-base"})})]})]}),(0,i.jsxs)("div",{className:"h-[500px] sm:w-full w-full relative flex flex-col mb-12 bg-[#171a1e] px-5 border-1 border-b border-zinc-700",children:[(0,i.jsx)("div",{className:"w-full flex max-[1080px]:flex-col flex-row justify-between max-[1080px]:items-center max-[1080px]:gap-3"}),(0,i.jsx)("div",{className:"h-full",children:(0,i.jsx)("canvas",{ref:T,className:""})}),(0,i.jsx)("div",{id:"cumulative-tooltip",style:{position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"white",padding:"5px",borderRadius:"5px",pointerEvents:"none",display:"none"}})]})]})]})})]})}MVRVZscore.layout=s.Z}},function(e){e.O(0,[8391,4738,4817,2510,4396,5372,8688,5912,9774,2888,179],function(){return e(e.s=9246)}),_N_E=e.O()}]);