mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-22 19:15:15 +00:00
refactor: simplify stoploss printing
This commit is contained in:
parent
667634a35f
commit
17f95c52e7
|
@ -1,6 +1,7 @@
|
||||||
import { Order, PairHistory, Trade, BTOrder } from '@/types';
|
import { Order, PairHistory, Trade, BTOrder } from '@/types';
|
||||||
|
|
||||||
import { ScatterSeriesOption } from 'echarts';
|
import { ScatterSeriesOption } from 'echarts';
|
||||||
|
import { title } from 'process';
|
||||||
|
|
||||||
function buildTooltipCost(order: Order | BTOrder, quoteCurrency: string): string {
|
function buildTooltipCost(order: Order | BTOrder, quoteCurrency: string): string {
|
||||||
return `${order.ft_order_side === 'buy' ? '+' : '-'}${formatPriceCurrency(
|
return `${order.ft_order_side === 'buy' ? '+' : '-'}${formatPriceCurrency(
|
||||||
|
@ -151,7 +152,7 @@ export function generateTradeSeries(
|
||||||
): ScatterSeriesOption {
|
): ScatterSeriesOption {
|
||||||
const { tradeData } = getTradeEntries(dataset, trades);
|
const { tradeData } = getTradeEntries(dataset, trades);
|
||||||
|
|
||||||
const openTrades = trades.filter((t) => t.is_open);
|
const openTrade = trades.find((t) => t.is_open);
|
||||||
|
|
||||||
const tradesSeries: ScatterSeriesOption = {
|
const tradesSeries: ScatterSeriesOption = {
|
||||||
name: nameTrades,
|
name: nameTrades,
|
||||||
|
@ -185,39 +186,41 @@ export function generateTradeSeries(
|
||||||
data: tradeData,
|
data: tradeData,
|
||||||
};
|
};
|
||||||
// Show distance to stoploss
|
// Show distance to stoploss
|
||||||
if (openTrades.length > 0) {
|
if (openTrade) {
|
||||||
// Ensure to import and "use" whatever feature in candleChart! (MarkLine, MarkArea, ...)
|
// Ensure to import and "use" whatever feature in candleChart! (MarkLine, MarkArea, ...)
|
||||||
// Offset to avoid having the line at the very end of the chart
|
// Offset to avoid having the line at the very end of the chart
|
||||||
const offset = dataset.timeframe_ms * 10;
|
const offset = dataset.timeframe_ms * 10;
|
||||||
|
|
||||||
tradesSeries.markLine = {
|
tradesSeries.markLine = {
|
||||||
symbol: 'none',
|
symbol: 'none',
|
||||||
itemStyle: {
|
|
||||||
color: '#ff0000AA',
|
|
||||||
},
|
|
||||||
label: {
|
label: {
|
||||||
show: true,
|
show: true,
|
||||||
position: 'middle',
|
position: 'middle',
|
||||||
},
|
},
|
||||||
lineStyle: {
|
data: [
|
||||||
type: 'solid',
|
[
|
||||||
},
|
|
||||||
data: openTrades.map((t) => {
|
|
||||||
return [
|
|
||||||
{
|
{
|
||||||
name: 'Stoploss',
|
name: 'Stoploss',
|
||||||
yAxis: t.stop_loss_abs,
|
yAxis: openTrade.stop_loss_abs,
|
||||||
|
lineStyle: {
|
||||||
|
color: '#ff0000AA',
|
||||||
|
type: 'solid',
|
||||||
|
},
|
||||||
xAxis:
|
xAxis:
|
||||||
dataset.data_stop_ts - offset > t.open_timestamp
|
dataset.data_stop_ts - offset > openTrade.open_timestamp
|
||||||
? t.open_timestamp
|
? openTrade.open_timestamp
|
||||||
: dataset.data_stop_ts - offset,
|
: dataset.data_stop_ts - offset,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
yAxis: t.stop_loss_abs,
|
lineStyle: {
|
||||||
xAxis: t.close_timestamp ?? dataset.data_stop_ts + dataset.timeframe_ms,
|
color: '#ff0000AA',
|
||||||
|
type: 'solid',
|
||||||
},
|
},
|
||||||
];
|
yAxis: openTrade.stop_loss_abs,
|
||||||
}),
|
xAxis: openTrade.close_timestamp ?? dataset.data_stop_ts + dataset.timeframe_ms,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return tradesSeries;
|
return tradesSeries;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user