From 22a598c6bbfbad92801ac33ca6ef9cab80ca73e3 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 9 Apr 2025 13:29:06 +0200 Subject: [PATCH] bugfixing --- src/routes/options-calculator/+page.svelte | 1040 ++++++++++---------- 1 file changed, 516 insertions(+), 524 deletions(-) diff --git a/src/routes/options-calculator/+page.svelte b/src/routes/options-calculator/+page.svelte index f75d9052..6122aef2 100644 --- a/src/routes/options-calculator/+page.svelte +++ b/src/routes/options-calculator/+page.svelte @@ -472,8 +472,6 @@ shouldUpdate = true; } catch (error) { console.error("Error loading data:", error); - } finally { - isLoaded = true; } } @@ -741,8 +739,6 @@ config = plotData(); userStrategy = [...userStrategy]; - - isLoaded = true; } } @@ -800,542 +796,402 @@

- {#if isLoaded && config} -
+ - -
-
- -
- -
- {#if inputValue?.length !== 0 && inputValue !== selectedTicker} - - {#each searchBarData as searchItem} - changeTicker(searchItem)} - > -
- {searchItem?.symbol} - {searchItem?.name} -
-
- {:else} - - No results found - - {/each} -
- {/if} -
- - - -
- - - - - - + + +
+
-
- - -
- - - - - - - - - - - - - - - - - - {#each userStrategy as item, index} - - - - - - - - - - + + + {:else} + + No results found + {/each} - -
- Ticker - - Action - - Quantity - - Expiration Date - - Strike - - Type - - Price -
- {selectedTicker} - - changeTicker(searchItem)} + > +
+ {searchItem?.symbol} -
- handleQuantityInput(e, index)} - class="border border-gray-300 dark:border-gray-500 rounded px-2 py-1 w-20 focus:outline-none focus:ring-1 focus:ring-blue-500" - /> - - - - - - - - - {#each userStrategy[index]?.dateList as item} - { - handleExpirationDate(item, index); - }} - class="sm:hover:bg-gray-200 dark:sm:hover:bg-primary cursor-pointer " - > - {formatDate(item)} - - {/each} - - - - - - - - - - - - - {#each userStrategy[index]?.strikeList as item} - { - handleStrikePrice(item, index); - }} - class="sm:hover:bg-gray-200 dark:sm:hover:bg-primary cursor-pointer " - > - {item} - - {/each} - - - - - {searchItem?.name} - - handleOptionPriceInput(e, index)} - class="border border-gray-300 dark:border-gray-500 rounded px-2 py-1 w-24 focus:outline-none focus:ring-1 focus:ring-blue-500" - /> - -
- - - - -
-
-
+ + {/if} + + + +
+ + + + + + + Select Strategy + + + + {#each prebuiltStrategy as strategy} + changeStrategy(strategy)} + class="cursor-pointer sm:hover:bg-gray-300 dark:sm:hover:bg-primary" + > + {strategy.name} + {#if strategy?.sentiment} + {strategy.sentiment} + {/if} + + {/each} + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + {#each userStrategy as item, index} + + + + + + + + + + + {/each} + +
+ Ticker + + Action + + Quantity + + Expiration Date + + Strike + + Type + + Price +
+ {selectedTicker} + + + + handleQuantityInput(e, index)} + class="border border-gray-300 dark:border-gray-500 rounded px-2 py-1 w-20 focus:outline-none focus:ring-1 focus:ring-blue-500" + /> + + + + + + + + + {#each userStrategy[index]?.dateList as item} + { + handleExpirationDate(item, index); + }} + class="sm:hover:bg-gray-200 dark:sm:hover:bg-primary cursor-pointer " + > + {formatDate(item)} + + {/each} + + + + + + + + + + + + + {#each userStrategy[index]?.strikeList as item} + { + handleStrikePrice(item, index); + }} + class="sm:hover:bg-gray-200 dark:sm:hover:bg-primary cursor-pointer " + > + {item} + + {/each} + + + + + + + handleOptionPriceInput(e, index)} + class="border border-gray-300 dark:border-gray-500 rounded px-2 py-1 w-24 focus:outline-none focus:ring-1 focus:ring-blue-500" + /> + +
+ + + + +
+
+
+ + {#if config}
- -
-

- Trade Information -

- - -
- {#each userStrategy as item, index} -
- {"Option-Leg" + " " + (index + 1)} -
-
- {item?.action?.toUpperCase()} +{item?.quantity} - {selectedTicker} - {formatDate(item?.date)} - {item?.strike} - {item?.optionType} @${item?.optionPrice} -
- {/each} -
- - -

- Stock -

-
-
-
- {selectedTicker} Current Price -
-
- ${currentStockPrice} -
-
- -
-
- {selectedTicker} Breakeven Price - -
-
- {typeof breakEvenPrice === "number" - ? "$" + breakEvenPrice?.toFixed(2) - : "n/a"} -
-
-
- - -

- Trade Details -

-
-
-
- Cost of Trade - -
-
- ${totalPremium?.toLocaleString("en-US", { - minimumFractionDigits: 2, - maximumFractionDigits: 2, - })} - -
-
- -
-
- Maximum Profit - -
-
- {metrics?.maxProfit} -
-
- -
-
- Maximum Loss - -
-
- {metrics?.maxLoss} -
-
-
-
{:else} -
+
{/if} + +
+

+ Trade Information +

+ + +
+ {#each userStrategy as item, index} +
+ {"Option-Leg" + " " + (index + 1)} +
+
+ {item?.action?.toUpperCase()} +{item?.quantity} + {selectedTicker} + {formatDate(item?.date)} + {item?.strike} + {item?.optionType} @${item?.optionPrice} +
+ {/each} +
+ + +

+ Stock +

+
+
+
+ {selectedTicker} Current Price +
+
+ ${currentStockPrice} +
+
+ +
+
+ {selectedTicker} Breakeven Price + +
+
+ {typeof breakEvenPrice === "number" + ? "$" + breakEvenPrice?.toFixed(2) + : "n/a"} +
+
+
+ + +

+ Trade Details +

+
+
+
+ Cost of Trade + +
+
+ ${totalPremium?.toLocaleString("en-US", { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} + +
+
+ +
+
+ Maximum Profit + +
+
+ {metrics?.maxProfit} +
+
+ +
+
+ Maximum Loss + +
+
+ {metrics?.maxLoss} +
+
+
+