tradingstrategy-ai / frontend

Web frontend for TradingStrategy.ai
https://tradingstrategy.ai
129 stars 23 forks source link

Strategy performance chart - add benchmark #356

Closed kenkunz closed 1 month ago

kenkunz commented 1 year ago

Depends on #355

Goal

Add a benchmark indicator to the Strategy performance chart. The benchmark should show the buy-and-hold performance for the same trading pair being traded by the strategy.

Details

For v1, we can show some hard-coded tokens (BTC, ETH, MATIC). In the future, each strategy can include info in the metadata API payload to indicate which benchmark tokens to show.

We currently have this "hack" for determining which tokens a strategy trades (displayed in the upper-left corder of strategy tiles) – we could use this to identify which benchmarks to display as well: https://github.com/tradingstrategy-ai/frontend/blob/ceaf396e3ac834b20319c4d7c6201fe4fd1eaccc/src/routes/strategies/StrategyTile.svelte#L36-L44

One thing we'll need to do is to "normalize" the benchmark price data to a profitability % (which is what we show for strategies). For any given timeframe that we display (1w, 1m, 3m, etc.) I would assume we'd want to basline the benchmark price to the same starting value as the strategy (so the two lines start at the same point on the left), then calculate the % profitability change from that baseline forward – so you get a genuine comparison of how the strategy performed relative to the benchmark for that time period.

kenkunz commented 1 year ago

Preferred benchmark:

For this ticket, just do the single-pair buy/hold benchmark.