diff --git a/src/routes/analysts/analyst-flow/+page.svelte b/src/routes/analysts/analyst-flow/+page.svelte index 9169a4c1..53ca082c 100644 --- a/src/routes/analysts/analyst-flow/+page.svelte +++ b/src/routes/analysts/analyst-flow/+page.svelte @@ -190,7 +190,7 @@ > {item?.analystName} diff --git a/src/routes/options-calculator/+page.svelte b/src/routes/options-calculator/+page.svelte index 61a47cde..64d66273 100644 --- a/src/routes/options-calculator/+page.svelte +++ b/src/routes/options-calculator/+page.svelte @@ -3,7 +3,7 @@ import { Button } from "$lib/components/shadcn/button/index.js"; import SEO from "$lib/components/SEO.svelte"; import { onMount } from "svelte"; - import { buildOptionSymbol } from "$lib/utils"; + import { abbreviateNumber, buildOptionSymbol } from "$lib/utils"; import { setCache, getCache } from "$lib/store"; import { mode } from "mode-watcher"; @@ -23,6 +23,7 @@ let dateList = Object?.keys(optionData); let selectedDate = Object?.keys(optionData)[0]; let strikeList = optionData[selectedDate] || []; + let deltaList = optionData[selectedDate] || []; let selectedStrike = strikeList?.at(0) || []; let optionSymbol; @@ -92,7 +93,6 @@ // Else payoff = (underlying - strike)*100 - premium const payoff = s < strikePrice ? -premium : (s - strikePrice) * 100 - premium; - dataPoints.push([s, payoff]); } @@ -108,7 +108,8 @@ animation: false, }, title: { - text: null, + text: `
`, + useHTML: true, }, xAxis: { // numeric axis from 0 to 600 @@ -123,7 +124,7 @@ style: { color: $mode === "light" ? "#545454" : "white" }, }, plotLines: [ - // Strike Price + // Underlying Price line { value: currentStockPrice, color: "black", @@ -134,14 +135,14 @@ }, zIndex: 5, }, - // Break-Even + // Break-Even line { value: breakEven, color: "#10B981", dashStyle: "Dash", width: 1.2, label: { - text: `Breakeven $${breakEven?.toFixed(2)}`, + text: `Breakeven $${breakEven.toFixed(2)}`, }, zIndex: 5, }, @@ -157,12 +158,9 @@ labels: { style: { color: $mode === "light" ? "#545454" : "white" }, formatter: function () { - return "$" + this.value.toFixed(0); + return abbreviateNumber(this.value.toFixed(2)); }, }, - // If you want symmetrical around zero, set min/max or startOnTick/endOnTick - // startOnTick: false, - // endOnTick: false, }, tooltip: { shared: true, @@ -172,15 +170,32 @@ color: $mode === "light" ? "black" : "white", }, formatter: function () { + const underlyingPrice = this.x; + const profitLoss = this.y; + // Calculate percentage change for underlying price relative to currentStockPrice + const underlyingPctChange = + ((underlyingPrice - currentStockPrice) / currentStockPrice) * 100; + // Calculate profit/loss percentage relative to the total premium paid + const profitLossPctChange = (profitLoss / premium) * 100; + return ` - TSLA Price: $${this.x}