mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-22 19:15:15 +00:00
Improve Trade vis formatting
This commit is contained in:
parent
0947f73441
commit
f8918db078
|
@ -503,6 +503,7 @@ export default defineComponent({
|
|||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'axis',
|
||||
renderMode: 'richText',
|
||||
backgroundColor: 'rgba(80,80,80,0.7)',
|
||||
borderWidth: 0,
|
||||
textStyle: {
|
||||
|
|
|
@ -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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user