diff --git a/src/components/charts/CandleChart.vue b/src/components/charts/CandleChart.vue index f0d6913f..22a775d3 100644 --- a/src/components/charts/CandleChart.vue +++ b/src/components/charts/CandleChart.vue @@ -503,6 +503,7 @@ export default defineComponent({ tooltip: { show: true, trigger: 'axis', + renderMode: 'richText', backgroundColor: 'rgba(80,80,80,0.7)', borderWidth: 0, textStyle: { diff --git a/src/shared/charts/tradeChartData.ts b/src/shared/charts/tradeChartData.ts index 3e27cf29..9bb6793f 100644 --- a/src/shared/charts/tradeChartData.ts +++ b/src/shared/charts/tradeChartData.ts @@ -2,6 +2,12 @@ import { formatPercent } from '@/shared/formatters'; import { roundTimeframe } from '@/shared/timemath'; import { PairHistory, Trade } from '@/types'; +function buildToolTip(trade: Trade, side: string): string { + return `${trade.is_short ? 'Short' : 'Long'} ${side} ${formatPercent( + trade.profit_ratio, + )} \nEnter-tag: ${trade.enter_tag ?? ''} \nExit-Tag: ${trade.exit_reason ?? ''}`; +} + /** Return trade entries for charting */ export function getTradeEntries(dataset: PairHistory, filteredTrades: Trade[]) { const tradeData: (number | string)[][] = []; @@ -20,37 +26,35 @@ export function getTradeEntries(dataset: PairHistory, filteredTrades: Trade[]) { trade.open_timestamp >= dataset.data_start_ts && trade.open_timestamp <= dataset.data_stop_ts ) { + // Trade entry tradeData.push([ roundTimeframe(dataset.timeframe_ms ?? 0, trade.open_timestamp), trade.open_rate, - 'triangle', // TODO: use better symbol + 'circle', // TODO: use better symbol trade.is_short ? 180 : 0, - trade.profit_abs ?? 0 > 0 ? 'green' : 'red', + (trade.profit_abs ?? 0) > 0 ? '#31e04b' : '#ed1511', // trade.is_short ? '#ffaf0d' : '#ff0df3', '', // trade.profit_abs, - `${trade.is_short ? 'Short' : 'Long'} entry ${formatPercent(trade.profit_ratio)} ${ - trade.enter_tag ?? '' - }`, + buildToolTip(trade, 'entry'), ]); } if ( trade.close_timestamp !== undefined && - trade.close_timestamp < dataset.data_stop_ts && + trade.close_timestamp <= dataset.data_stop_ts && trade.close_timestamp > dataset.data_start_ts ) { if (trade.close_date !== undefined && trade.close_rate !== undefined) { + // Trade exit tradeData.push([ roundTimeframe(dataset.timeframe_ms ?? 0, trade.close_timestamp), trade.close_rate, 'rect', trade.is_short ? 180 : 0, // trade.is_short ? '#ffaf0d' : '#00ff26', - trade.profit_abs ?? 0 > 0 ? 'green' : 'red', + (trade.profit_abs ?? 0) > 0 ? '#31e04b' : '#ed1511', formatPercent(trade.profit_ratio, 2), - `${trade.is_short ? 'Short' : 'Long'} exit ${formatPercent(trade.profit_ratio)}% ${ - trade.enter_tag ?? '' - }`, + buildToolTip(trade, 'exit'), ]); } }