diff --git a/package-lock.json b/package-lock.json index e999e3c2b..d91badf57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "@wagmi/core": "^1.4.5", "@walletconnect/modal": "^2.6.2", "@web3modal/ethereum": "^2.7.1", - "assert-ts": "^0.3.4", "bignumber.js": "^9.1.2", "cheerio": "^1.0.0-rc.12", "cookie": "^0.5.0", @@ -4413,11 +4412,6 @@ "util": "^0.12.5" } }, - "node_modules/assert-ts": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/assert-ts/-/assert-ts-0.3.4.tgz", - "integrity": "sha512-CQtNOdOCzzZfE3TF9a1vFTcz4ZfJYM6iHoWYCkpFY3wdk6CkFvevuLwpOFVL/KMJ9vCNIbeidWH5uo/Y8sLVWg==" - }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", diff --git a/package.json b/package.json index 1b4cdf540..840277c8c 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "@wagmi/core": "^1.4.5", "@walletconnect/modal": "^2.6.2", "@web3modal/ethereum": "^2.7.1", - "assert-ts": "^0.3.4", "bignumber.js": "^9.1.2", "cheerio": "^1.0.0-rc.12", "cookie": "^0.5.0", diff --git a/src/lib/trade-executor/components/KeyMetric.svelte b/src/lib/trade-executor/components/KeyMetric.svelte index b3711af76..c405d53e7 100644 --- a/src/lib/trade-executor/components/KeyMetric.svelte +++ b/src/lib/trade-executor/components/KeyMetric.svelte @@ -15,7 +15,7 @@ Display one key metric in a strategy tile. ``` -->
diff --git a/src/routes/strategies/StrategyTile.svelte b/src/routes/strategies/StrategyTile.svelte index c5d82df0f..7f7de1c87 100644 --- a/src/routes/strategies/StrategyTile.svelte +++ b/src/routes/strategies/StrategyTile.svelte @@ -2,22 +2,27 @@ import type { EventHandler } from 'svelte/elements'; import type { ApiChain } from '$lib/helpers/chain.js'; import type { StrategyRuntimeState } from 'trade-executor/strategy/runtime-state'; + import { type RawTick, type Quote, rawTicksToQuotes } from '$lib/chart'; import { goto } from '$app/navigation'; import { Alert, Button, EntitySymbol, Tooltip } from '$lib/components'; import ChartThumbnail from './ChartThumbnail.svelte'; import StrategyDataSummary from './StrategyDataSummary.svelte'; - import { rawTicksToQuotes } from '$lib/chart'; import { getTradeExecutorErrorHtml } from 'trade-executor/strategy/error'; export let strategy: StrategyRuntimeState; export let chain: ApiChain; const href = `/strategies/${strategy.id}`; - const summaryStatistics = strategy.summary_statistics ?? {}; - const chartData = rawTicksToQuotes(summaryStatistics.performance_chart_90_days ?? []); const errorHtml = getTradeExecutorErrorHtml(strategy); - const keyMetrics = summaryStatistics.key_metrics ?? {}; - const isBacktested = Object.values(keyMetrics).some(({ source }) => source === 'backtesting'); + + let chartData: Quote[] = []; + let isBacktested = false; + + if (strategy.connected) { + const stats = strategy.summary_statistics; + chartData = rawTicksToQuotes(stats.performance_chart_90_days as RawTick[]); + isBacktested = Object.values(stats.key_metrics).some(({ source }) => source === 'backtesting'); + } const handleClick: EventHandler = ({ target }) => { // skip explicit goto if user clicked an anchor tag diff --git a/src/routes/strategies/[strategy]/(nav)/+layout.svelte b/src/routes/strategies/[strategy]/(nav)/+layout.svelte index b51237616..ac2deae14 100644 --- a/src/routes/strategies/[strategy]/(nav)/+layout.svelte +++ b/src/routes/strategies/[strategy]/(nav)/+layout.svelte @@ -6,18 +6,18 @@ import { getTradeExecutorErrorHtml } from 'trade-executor/strategy/error'; export let data; - $: ({ chain, summary, state } = data); + $: ({ chain, strategy, state } = data); - $: backtestAvailable = summary.backtest_available; + $: backtestAvailable = strategy.backtest_available; // Get the error message HTML - $: errorHtml = getTradeExecutorErrorHtml(summary); + $: errorHtml = getTradeExecutorErrorHtml(strategy);
- - {summary.name} + + {strategy.name}
- +
@@ -31,9 +31,9 @@
diff --git a/src/routes/strategies/[strategy]/(nav)/+page.svelte b/src/routes/strategies/[strategy]/(nav)/+page.svelte index 343ce944c..9ed8bd439 100644 --- a/src/routes/strategies/[strategy]/(nav)/+page.svelte +++ b/src/routes/strategies/[strategy]/(nav)/+page.svelte @@ -8,13 +8,13 @@ import { formatDaysAgo, formatNumber, formatPercent, formatPrice } from '$lib/helpers/formatters'; import { formatProfitability } from 'trade-executor/helpers/formatters'; import { relativeProfitability } from 'trade-executor/helpers/profit'; - import type { KeyMetricKind } from 'trade-executor/strategy/runtime-state'; + import type { KeyMetricKind } from 'trade-executor/statistics/key-metric'; export let data; - const { chain, strategy, summary } = data; + const { chain, strategy } = data; - const keyMetrics = summary.summary_statistics.key_metrics; - const strategyId = summary.id; + const keyMetrics = strategy.summary_statistics.key_metrics; + const strategyId = strategy.id; let periodPerformance: MaybeNumber; @@ -46,12 +46,12 @@ - {summary.name} | Trading Strategy - + {strategy.name} | Trading Strategy +
- +
@@ -106,7 +106,7 @@
-

{@html summary.long_description}

+

{@html strategy.long_description}

diff --git a/src/routes/strategies/[strategy]/(nav)/StrategyNav.svelte b/src/routes/strategies/[strategy]/(nav)/StrategyNav.svelte index ff860579a..182d914c5 100644 --- a/src/routes/strategies/[strategy]/(nav)/StrategyNav.svelte +++ b/src/routes/strategies/[strategy]/(nav)/StrategyNav.svelte @@ -8,7 +8,7 @@
diff --git a/src/routes/strategies/[strategy]/(nav)/source/+page.svelte b/src/routes/strategies/[strategy]/(nav)/source/+page.svelte index 9b39ae553..2506c0e3d 100644 --- a/src/routes/strategies/[strategy]/(nav)/source/+page.svelte +++ b/src/routes/strategies/[strategy]/(nav)/source/+page.svelte @@ -7,14 +7,14 @@ export let data; - $: ({ summary, code } = data); + $: ({ strategy, code } = data); // Github links disabled as for now they no longer host the canonical source // $: githubUrl = `http://github.com/tradingstrategy-ai/trade-executor/tree/master/strategies/${summary.id}.py`;
- +
- {summary.name} + {strategy.name}