From 857738c17da4f1eab7bc54bfd04e325a9809b835 Mon Sep 17 00:00:00 2001 From: Ken Kunz Date: Wed, 4 Dec 2024 12:58:53 -0600 Subject: [PATCH 1/5] update strategy config --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index f46890224..83333a82b 100644 --- a/.env +++ b/.env @@ -31,7 +31,7 @@ TS_PUBLIC_TYPESENSE_API_URL=https://typesense2.tradingstrategy.ai TS_PUBLIC_TYPESENSE_API_KEY=npdPPJNELDhdr7v6IS9rQUpFG2VvdyAL TS_PUBLIC_DISCORD_URL=https://discord.gg/5M88m9nM8H TS_PUBLIC_WALLET_CONNECT_PROJECT_ID=9ee7efad98897eb60ba023db6aa72355 -TS_PUBLIC_STRATEGIES='[{"id":"enzyme-polygon-matic-eth-usdc","name":"ETH-MATIC-USDC momentum","url":"https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai","frontpage":true},{"id":"enzyme-arbitrum-eth-btc-rsi","name":"ETH-BTC price surge (Arbitrum)","url":"https://enzyme-arbitrum-eth-btc-rsi.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-polygon-eth-rolling-ratio","name":"ETH/BTC rolling ratio","url":"https://enzyme-polygon-eth-rolling-ratio.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-polygon-eth-btc-rsi","name":"ETH-BTC price surge","url":"https://enzyme-polygon-eth-btc-rsi.tradingstrategy.ai/","frontpage":true,"hiddenPositions":[4]},{"id":"enzyme-ethereum-btc-eth-stoch-rsi","name":"Stochastic ETH/BTC long","url":"https://enzyme-ethereum-btc-eth-stoch-rsi.tradingstrategy.ai","frontpage":true},{"id":"enzyme-polygon-eth-btc-usdc","name":"ETH-BTC-USDC momentum","url":"https://enzyme-polygon-eth-btc-usdc.tradingstrategy.ai","new_version_id":"enzyme-polygon-eth-btc-rsi","frontpage":true},{"id":"enzyme-polygon-matic-usdc","name":"MATIC breakout","url":"https://enzyme-polygon-matic-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-breakout","name":"ETH breakout","url":"https://enzyme-polygon-eth-breakout.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc","name":"ETH Breakout bounce","url":"https://enzyme-polygon-eth-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc-sls","name":"ETH Balance snap","url":"https://enzyme-polygon-eth-usdc-sls.tradingstrategy.ai"},{"id":"polygon-eth-spot-short","name":"ETH mean reversion bounce","url":"https://polygon-eth-spot-short.tradingstrategy.ai"},{"id":"arbitrum-btc-breakout","name":"BTC Barrier Breach","url":"https://arbitrum-btc-breakout.tradingstrategy.ai"}]' +TS_PUBLIC_STRATEGIES='[{"id":"enzyme-polygon-matic-eth-usdc","name":"ETH-MATIC-USDC momentum","url":"https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai","frontpage":true},{"id":"enzyme-arbitrum-eth-btc-rsi","name":"ETH-BTC long swing","url":"https://enzyme-arbitrum-eth-btc-rsi.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-polygon-eth-rolling-ratio","name":"ETH/BTC rolling ratio","url":"https://enzyme-polygon-eth-rolling-ratio.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-ethereum-btc-eth-stoch-rsi","name":"Stochastic ETH-BTC","url":"https://enzyme-ethereum-btc-eth-stoch-rsi.tradingstrategy.ai","frontpage":true},{"id":"enzyme-polygon-matic-usdc","name":"MATIC Level crush","url":"https://enzyme-polygon-matic-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-breakout","name":"ETH breakout","url":"https://enzyme-polygon-eth-breakout.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc","name":"ETH Breakout bounce","url":"https://enzyme-polygon-eth-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc-sls","name":"ETH Balance snap","url":"https://enzyme-polygon-eth-usdc-sls.tradingstrategy.ai"},{"id":"polygon-eth-spot-short","name":"ETH Mean Flip","url":"https://polygon-eth-spot-short.tradingstrategy.ai"},{"id":"arbitrum-btc-breakout","name":"BTC Barrier Breach","url":"https://arbitrum-btc-breakout.tradingstrategy.ai"},{"id":"ethereum-memecoin-swing","name":"ETH Memecoin Social Trend Spotter","url":"https://ethereum-memecoin-swing.tradingstrategy.ai"},{"id":"ethereum-memecoin-vol-basket","name":"Memecoin volatility index","url":"https://ethereum-memecoin-vol-basket.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-btc-rsi","name":"ETH-BTC price surge","url":"https://enzyme-polygon-eth-btc-rsi.tradingstrategy.ai/","frontpage":true,"hiddenPositions":[4],"new_version_id":"enzyme-arbitrum-eth-btc-rsi"},{"id":"enzyme-polygon-eth-btc-usdc","name":"ETH-BTC-USDC momentum","url":"https://enzyme-polygon-eth-btc-usdc.tradingstrategy.ai","new_version_id":"enzyme-polygon-eth-btc-rsi","frontpage":true}]' TS_PUBLIC_GEO_BLOCK='{"strategies:view":["CU","IR","KP","RU","SY"],"strategies:deposit":["CU","IR","KP","RU","SY","US","UK"]}' # Uncomment to test chain maintenance error # TS_PUBLIC_CHAINS_UNDER_MAINTENANCE='{ "binance": "BNB Chain" }' From bf8b7f543690c2ddfd15879ff70781b9578a3da2 Mon Sep 17 00:00:00 2001 From: Ken Kunz Date: Wed, 4 Dec 2024 13:44:09 -0600 Subject: [PATCH 2/5] use camelCase (consistently) in strategy config --- .env | 2 +- src/lib/trade-executor/components/StrategyIcon.svelte | 2 +- src/lib/trade-executor/schemas/configuration.ts | 2 +- src/lib/wallet/MyDeposits.svelte | 2 +- src/routes/strategies/StrategyTile.svelte | 6 +++--- src/routes/strategies/[strategy]/+layout.svelte | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 83333a82b..212ebbcd2 100644 --- a/.env +++ b/.env @@ -31,7 +31,7 @@ TS_PUBLIC_TYPESENSE_API_URL=https://typesense2.tradingstrategy.ai TS_PUBLIC_TYPESENSE_API_KEY=npdPPJNELDhdr7v6IS9rQUpFG2VvdyAL TS_PUBLIC_DISCORD_URL=https://discord.gg/5M88m9nM8H TS_PUBLIC_WALLET_CONNECT_PROJECT_ID=9ee7efad98897eb60ba023db6aa72355 -TS_PUBLIC_STRATEGIES='[{"id":"enzyme-polygon-matic-eth-usdc","name":"ETH-MATIC-USDC momentum","url":"https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai","frontpage":true},{"id":"enzyme-arbitrum-eth-btc-rsi","name":"ETH-BTC long swing","url":"https://enzyme-arbitrum-eth-btc-rsi.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-polygon-eth-rolling-ratio","name":"ETH/BTC rolling ratio","url":"https://enzyme-polygon-eth-rolling-ratio.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-ethereum-btc-eth-stoch-rsi","name":"Stochastic ETH-BTC","url":"https://enzyme-ethereum-btc-eth-stoch-rsi.tradingstrategy.ai","frontpage":true},{"id":"enzyme-polygon-matic-usdc","name":"MATIC Level crush","url":"https://enzyme-polygon-matic-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-breakout","name":"ETH breakout","url":"https://enzyme-polygon-eth-breakout.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc","name":"ETH Breakout bounce","url":"https://enzyme-polygon-eth-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc-sls","name":"ETH Balance snap","url":"https://enzyme-polygon-eth-usdc-sls.tradingstrategy.ai"},{"id":"polygon-eth-spot-short","name":"ETH Mean Flip","url":"https://polygon-eth-spot-short.tradingstrategy.ai"},{"id":"arbitrum-btc-breakout","name":"BTC Barrier Breach","url":"https://arbitrum-btc-breakout.tradingstrategy.ai"},{"id":"ethereum-memecoin-swing","name":"ETH Memecoin Social Trend Spotter","url":"https://ethereum-memecoin-swing.tradingstrategy.ai"},{"id":"ethereum-memecoin-vol-basket","name":"Memecoin volatility index","url":"https://ethereum-memecoin-vol-basket.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-btc-rsi","name":"ETH-BTC price surge","url":"https://enzyme-polygon-eth-btc-rsi.tradingstrategy.ai/","frontpage":true,"hiddenPositions":[4],"new_version_id":"enzyme-arbitrum-eth-btc-rsi"},{"id":"enzyme-polygon-eth-btc-usdc","name":"ETH-BTC-USDC momentum","url":"https://enzyme-polygon-eth-btc-usdc.tradingstrategy.ai","new_version_id":"enzyme-polygon-eth-btc-rsi","frontpage":true}]' +TS_PUBLIC_STRATEGIES='[{"id":"enzyme-polygon-matic-eth-usdc","name":"ETH-MATIC-USDC momentum","url":"https://enzyme-polygon-matic-eth-usdc.tradingstrategy.ai","frontpage":true},{"id":"enzyme-arbitrum-eth-btc-rsi","name":"ETH-BTC long swing","url":"https://enzyme-arbitrum-eth-btc-rsi.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-polygon-eth-rolling-ratio","name":"ETH/BTC rolling ratio","url":"https://enzyme-polygon-eth-rolling-ratio.tradingstrategy.ai/","frontpage":true},{"id":"enzyme-ethereum-btc-eth-stoch-rsi","name":"Stochastic ETH-BTC","url":"https://enzyme-ethereum-btc-eth-stoch-rsi.tradingstrategy.ai","frontpage":true},{"id":"enzyme-polygon-matic-usdc","name":"MATIC Level crush","url":"https://enzyme-polygon-matic-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-breakout","name":"ETH breakout","url":"https://enzyme-polygon-eth-breakout.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc","name":"ETH Breakout bounce","url":"https://enzyme-polygon-eth-usdc.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-usdc-sls","name":"ETH Balance snap","url":"https://enzyme-polygon-eth-usdc-sls.tradingstrategy.ai"},{"id":"polygon-eth-spot-short","name":"ETH Mean Flip","url":"https://polygon-eth-spot-short.tradingstrategy.ai"},{"id":"arbitrum-btc-breakout","name":"BTC Barrier Breach","url":"https://arbitrum-btc-breakout.tradingstrategy.ai"},{"id":"ethereum-memecoin-swing","name":"ETH Memecoin Social Trend Spotter","url":"https://ethereum-memecoin-swing.tradingstrategy.ai"},{"id":"ethereum-memecoin-vol-basket","name":"Memecoin volatility index","url":"https://ethereum-memecoin-vol-basket.tradingstrategy.ai"},{"id":"enzyme-polygon-eth-btc-rsi","name":"ETH-BTC price surge","url":"https://enzyme-polygon-eth-btc-rsi.tradingstrategy.ai/","newVersionId":"enzyme-arbitrum-eth-btc-rsi","hiddenPositions":[4],"frontpage":true},{"id":"enzyme-polygon-eth-btc-usdc","name":"ETH-BTC-USDC momentum","url":"https://enzyme-polygon-eth-btc-usdc.tradingstrategy.ai","newVersionId":"enzyme-polygon-eth-btc-rsi","frontpage":true}]' TS_PUBLIC_GEO_BLOCK='{"strategies:view":["CU","IR","KP","RU","SY"],"strategies:deposit":["CU","IR","KP","RU","SY","US","UK"]}' # Uncomment to test chain maintenance error # TS_PUBLIC_CHAINS_UNDER_MAINTENANCE='{ "binance": "BNB Chain" }' diff --git a/src/lib/trade-executor/components/StrategyIcon.svelte b/src/lib/trade-executor/components/StrategyIcon.svelte index dfc04ceee..9121595cc 100644 --- a/src/lib/trade-executor/components/StrategyIcon.svelte +++ b/src/lib/trade-executor/components/StrategyIcon.svelte @@ -6,7 +6,7 @@ const localIconUrl = `/avatars/${strategy.id}.webp`; const strategyIconUrl = strategy.icon_url?.replace(/^http:/, 'https:'); const dataUrl = strategy.connected ? localIconUrl : strategyIconUrl; - const outdated = Boolean(strategy.new_version_id); + const outdated = Boolean(strategy.newVersionId);
diff --git a/src/lib/trade-executor/schemas/configuration.ts b/src/lib/trade-executor/schemas/configuration.ts index cb8111f55..aa587ecb5 100644 --- a/src/lib/trade-executor/schemas/configuration.ts +++ b/src/lib/trade-executor/schemas/configuration.ts @@ -6,7 +6,7 @@ export const strategyConfigurationSchema = z.object({ id: z.string(), name: z.string(), url: z.string().url(), - new_version_id: z.string().optional(), + newVersionId: z.string().optional(), hiddenPositions: primaryKey.array().default([]), frontpage: z.boolean().default(false), microsite: z.boolean().default(false), diff --git a/src/lib/wallet/MyDeposits.svelte b/src/lib/wallet/MyDeposits.svelte index ed2127343..f84f155e5 100644 --- a/src/lib/wallet/MyDeposits.svelte +++ b/src/lib/wallet/MyDeposits.svelte @@ -39,7 +39,7 @@ contracts.fund_value_calculator ].every(Boolean); - const isOutdated = Boolean(strategy.new_version_id); + const isOutdated = Boolean(strategy.newVersionId); $: connected = $wallet.isConnected; $: wrongNetwork = connected && $wallet.chain?.id !== chain.id; diff --git a/src/routes/strategies/StrategyTile.svelte b/src/routes/strategies/StrategyTile.svelte index e69a9f95e..edb4ac79b 100644 --- a/src/routes/strategies/StrategyTile.svelte +++ b/src/routes/strategies/StrategyTile.svelte @@ -78,7 +78,7 @@ live {/if} - {#if isNew && !strategy.new_version_id} + {#if isNew && !strategy.newVersionId} new {/if} @@ -88,12 +88,12 @@ {/each} {/if} - {#if !simplified && strategy.new_version_id} + {#if !simplified && strategy.newVersionId} Outdated This is an outdated strategy. An updated version is available - here. + here. {/if} diff --git a/src/routes/strategies/[strategy]/+layout.svelte b/src/routes/strategies/[strategy]/+layout.svelte index eeaf69845..b03bd9ab7 100644 --- a/src/routes/strategies/[strategy]/+layout.svelte +++ b/src/routes/strategies/[strategy]/+layout.svelte @@ -20,7 +20,7 @@ $: isPrivate = !strategy.tags.includes('live'); $: isOverviewPage = $page.url.pathname.endsWith(strategy.id); $: hasError = shouldDisplayError(strategy, admin); - $: isOutdated = Boolean(strategy.new_version_id); + $: isOutdated = Boolean(strategy.newVersionId); $: displayWarning = isOverviewPage && (hasError || isOutdated); $: breadcrumbs = { @@ -73,9 +73,9 @@ You are viewing an outdated version of this strategy. An updated version is available - here. To maximize future - returns, participants should consider tranfering deposits to the latest version (though there is no - guarantee of better performance). + here. To maximize future returns, + participants should consider tranfering deposits to the latest version (though there is no guarantee of + better performance). From d301fd9ef083c04eb3309e363669ae5cfbc2fa1b Mon Sep 17 00:00:00 2001 From: Ken Kunz Date: Wed, 4 Dec 2024 17:59:28 -0600 Subject: [PATCH 3/5] extract StrategyPerformanceChart and convert to runes mode --- src/routes/strategies/[strategy]/+page.svelte | 254 +---------------- .../StrategyPerformanceChart.svelte | 261 ++++++++++++++++++ 2 files changed, 263 insertions(+), 252 deletions(-) create mode 100644 src/routes/strategies/[strategy]/StrategyPerformanceChart.svelte diff --git a/src/routes/strategies/[strategy]/+page.svelte b/src/routes/strategies/[strategy]/+page.svelte index ad4b3f829..128ddc1d1 100644 --- a/src/routes/strategies/[strategy]/+page.svelte +++ b/src/routes/strategies/[strategy]/+page.svelte @@ -1,24 +1,8 @@ @@ -168,41 +19,7 @@
- -
- -
- {#if periodPerformance[strategy.id] !== undefined} - - {performanceLabel} - {/if} -
- - (periodPerformance[strategy.id] = getPeriodPerformance(e.detail, spanDays))} - /> - -
- {#each benchmarkTokens as { symbol, color }} - - {/each} -
-
-
- +
@@ -227,72 +44,5 @@ grid-column: 1 / -1; } } - - .chart { - :global([data-css-props]) { - --chart-aspect-ratio: 3.25; - - @media (--viewport-sm-down) { - --chart-aspect-ratio: 2.25; - } - - @media (--viewport-xs) { - --chart-aspect-ratio: 1.75; - } - } - - :global(.stx_xaxis) { - color: transparent; - } - - :global(.stx_xaxis_dark) { - color: var(--c-text-extra-light); - } - } - - .period-performance { - :global([data-css-props]) { - --up-down-font: var(--f-ui-lg-medium); - --up-down-letter-spacing: var(--ls-ui-lg); - - @media (--viewport-md-down) { - --up-down-font: var(--f-ui-md-medium); - --up-down-letter-spacing: var(--ls-ui-md); - } - } - - display: flex; - gap: 1em; - align-items: center; - font: var(--f-ui-sm-medium); - letter-spacing: var(--ls-ui-sm); - color: var(--c-text-extra-light); - } - - .benchmark-tokens { - margin-top: 0.75rem; - margin-bottom: -0.25rem; - display: flex; - gap: 1rem; - justify-content: center; - - label { - display: flex; - gap: 0.25rem; - align-items: center; - font: var(--f-ui-sm-medium); - letter-spacing: var(--ls-ui-sm); - } - - input[type='checkbox'] { - color: inherit; - accent-color: currentColor; - } - - .performance { - font: var(--f-ui-sm-roman); - min-width: 4ch; - } - } } diff --git a/src/routes/strategies/[strategy]/StrategyPerformanceChart.svelte b/src/routes/strategies/[strategy]/StrategyPerformanceChart.svelte new file mode 100644 index 000000000..c02acd438 --- /dev/null +++ b/src/routes/strategies/[strategy]/StrategyPerformanceChart.svelte @@ -0,0 +1,261 @@ + + +
+ +
+ {#if periodPerformance[strategy.id] !== undefined} + + {performanceLabel} + {/if} +
+ + updatePeriodPerformance(e.detail, spanDays)} + /> + +
+ {#each benchmarkTokens as { symbol, color }} + + {/each} +
+
+
+ + From b0dcd95d9139e949d96adf748d145a9ecca23110 Mon Sep 17 00:00:00 2001 From: Ken Kunz Date: Thu, 5 Dec 2024 11:23:03 -0600 Subject: [PATCH 4/5] fix performance chart direction color for edge case - edge case occurs when the first value in the time interval rollup has different +/- sign delta with final value than the actual first tick value - prepend initial quote to prevent start value from being "swallowed" - override initial value to 0 when displaying "Max" timeframe --- src/lib/chart/PerformanceChart.svelte | 43 +++++++++++-------- src/lib/chart/helpers.ts | 10 ++++- .../StrategyPerformanceChart.svelte | 21 +-------- 3 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/lib/chart/PerformanceChart.svelte b/src/lib/chart/PerformanceChart.svelte index 594a7423f..eadff8ff6 100644 --- a/src/lib/chart/PerformanceChart.svelte +++ b/src/lib/chart/PerformanceChart.svelte @@ -16,11 +16,11 @@ Display a peformance line chart for a given (static) dataset. -->