fix pricing of websocket for etf

This commit is contained in:
MuslemRahimi 2024-11-18 18:38:18 +01:00
parent 058925ed53
commit 7eb2a1b4c0
3 changed files with 39 additions and 15 deletions

View File

@ -170,6 +170,7 @@
} else if (type === "Q") {
$wsBidPrice = typeof bp !== "undefined" ? bp : null;
$wsAskPrice = typeof ap !== "undefined" ? ap : null;
$realtimePrice = $wsAskPrice;
}
// Update price increase state

View File

@ -153,8 +153,9 @@
if ($etfTicker && typeof window !== "undefined") {
// add a check to see if running on client-side
if ($realtimePrice !== null && $realtimePrice !== 0) {
$realtimePrice =
$realtimePrice !== 0 ? $realtimePrice : data?.getStockQuote?.price;
$currentPortfolioPrice = $realtimePrice;
} else if ($realtimePrice === null || $realtimePrice === 0) {
$realtimePrice = data?.getStockQuote?.price;
$currentPortfolioPrice = $realtimePrice;
} else if (oneDayPrice?.length !== 0) {
const length = oneDayPrice?.length;
@ -812,7 +813,7 @@
<div
class="text-2xl md:text-3xl font-bold text-white flex flex-row items-center w-full"
>
{displayLegend?.close}
{$realtimePrice ?? displayLegend?.close}
{#if $priceIncrease === true}
<div
@ -932,22 +933,22 @@
<DropdownMenu.Separator />
<DropdownMenu.Group>
<!--
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
1 min
</DropdownMenu.Item>
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
5 min
</DropdownMenu.Item>
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
15 min
</DropdownMenu.Item>
-->
<DropdownMenu.Item
on:click={() => exportData("30min")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
@ -965,7 +966,7 @@
</DropdownMenu.Item>
<DropdownMenu.Item
on:click={() => exportData("1hour")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
@ -982,8 +983,19 @@
</DropdownMenu.Item>
<DropdownMenu.Item
on:click={() => exportData("max")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
? 'hidden'
: ''}"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
><path
fill="#A3A3A3"
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
/></svg
>
1 day
</DropdownMenu.Item>
</DropdownMenu.Group>

View File

@ -940,22 +940,22 @@
<DropdownMenu.Separator />
<DropdownMenu.Group>
<!--
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
1 min
</DropdownMenu.Item>
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
5 min
</DropdownMenu.Item>
<DropdownMenu.Item on:click={exportData} class="cursor-pointer hover:bg-[#27272A]">
<DropdownMenu.Item on:click={exportData} class="cursor-pointer sm:hover:bg-[#27272A]">
<svg class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro' ? 'hidden' : ''}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="#A3A3A3" d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"/></svg>
15 min
</DropdownMenu.Item>
-->
<DropdownMenu.Item
on:click={() => exportData("30min")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
@ -973,7 +973,7 @@
</DropdownMenu.Item>
<DropdownMenu.Item
on:click={() => exportData("1hour")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
@ -990,8 +990,19 @@
</DropdownMenu.Item>
<DropdownMenu.Item
on:click={() => exportData("max")}
class="cursor-pointer hover:bg-[#27272A]"
class="cursor-pointer sm:hover:bg-[#27272A]"
>
<svg
class="w-3.5 h-3.5 mr-1 {data?.user?.tier === 'Pro'
? 'hidden'
: ''}"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
><path
fill="#A3A3A3"
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
/></svg
>
1 day
</DropdownMenu.Item>
</DropdownMenu.Group>