Show current stoploss line

This commit is contained in:
Matthias 2023-06-20 21:11:39 +02:00
parent 46ca166863
commit c1e447e163
2 changed files with 38 additions and 1 deletions

View File

@ -37,6 +37,9 @@ import {
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
// MarkAreaComponent,
MarkLineComponent,
// MarkPointComponent,
} from 'echarts/components';
import { use } from 'echarts/core';
import { CanvasRenderer } from 'echarts/renderers';
@ -54,6 +57,9 @@ use([
TooltipComponent,
VisualMapComponent,
VisualMapPiecewiseComponent,
// MarkAreaComponent,
MarkLineComponent,
// MarkPointComponent,
CandlestickChart,
BarChart,

View File

@ -127,6 +127,8 @@ export function generateTradeSeries(
): ScatterSeriesOption {
const { tradeData } = getTradeEntries(dataset, trades);
const openTrades = trades.filter((t) => t.is_open);
const tradesSeries: ScatterSeriesOption = {
name: nameTrades,
type: 'scatter',
@ -158,6 +160,35 @@ export function generateTradeSeries(
symbolSize: 13,
data: tradeData,
};
// Show distance to stoploss
if (openTrades.length > 0) {
// Ensure to import and "use" whatever feature in candleChart! (MarkLine, MarkArea, ...)
tradesSeries.markLine = {
symbol: 'none',
itemStyle: {
color: '#ff000055',
},
label: {
show: true,
position: 'middle',
},
lineStyle: {
type: 'solid',
},
data: openTrades.map((t) => {
return [
{
name: 'Stoploss',
yAxis: t.stop_loss_abs,
xAxis: t.open_timestamp,
},
{
yAxis: t.stop_loss_abs,
xAxis: t.close_timestamp ?? dataset.data_stop_ts,
},
];
}),
};
}
return tradesSeries;
}