mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 18:23:50 +00:00
Chart moves to selected trade
This commit is contained in:
parent
12b2e3aad9
commit
0a18721705
|
@ -6,11 +6,13 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, computed, onMounted, watch } from 'vue';
|
import { defineComponent, ref, computed, onMounted, watch } from 'vue';
|
||||||
import { Trade, PairHistory, PlotConfig } from '@/types';
|
import { Trade, PairHistory, PlotConfig, ChartSliderPosition } from '@/types';
|
||||||
import randomColor from '@/shared/randomColor';
|
import randomColor from '@/shared/randomColor';
|
||||||
import heikinashi from '@/shared/heikinashi';
|
import heikinashi from '@/shared/heikinashi';
|
||||||
import { getTradeEntries } from '@/shared/charts/tradeChartData';
|
import { getTradeEntries } from '@/shared/charts/tradeChartData';
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
|
import { addHours, subHours } from 'date-fns';
|
||||||
|
import { utcToZonedTime, zonedTimeToUtc, format } from 'date-fns-tz';
|
||||||
|
|
||||||
import { use } from 'echarts/core';
|
import { use } from 'echarts/core';
|
||||||
import { EChartsOption, SeriesOption, ScatterSeriesOption } from 'echarts';
|
import { EChartsOption, SeriesOption, ScatterSeriesOption } from 'echarts';
|
||||||
|
@ -79,6 +81,7 @@ export default defineComponent({
|
||||||
useUTC: { required: false, default: true, type: Boolean },
|
useUTC: { required: false, default: true, type: Boolean },
|
||||||
plotConfig: { required: true, type: Object as () => PlotConfig },
|
plotConfig: { required: true, type: Object as () => PlotConfig },
|
||||||
theme: { default: 'dark', type: String },
|
theme: { default: 'dark', type: String },
|
||||||
|
sliderPosition: {required: false, type: Object as () => ChartSliderPosition}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const candleChart = ref<typeof ECharts>();
|
const candleChart = ref<typeof ECharts>();
|
||||||
|
@ -634,6 +637,18 @@ export default defineComponent({
|
||||||
updateChart(true);
|
updateChart(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateSliderPosition = () => {
|
||||||
|
let start = format(subHours(props.sliderPosition.startValue,3),'yyyy-MM-dd HH:mm:ss');
|
||||||
|
let end = format(addHours(props.sliderPosition.endValue,3),'yyyy-MM-dd HH:mm:ss');
|
||||||
|
|
||||||
|
candleChart.value.dispatchAction({
|
||||||
|
type: 'dataZoom',
|
||||||
|
dataZoomIndex: 0,
|
||||||
|
startValue: start,
|
||||||
|
endValue: end
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// createSignalData(colDate: number, colOpen: number, colBuy: number, colSell: number): void {
|
// createSignalData(colDate: number, colOpen: number, colBuy: number, colSell: number): void {
|
||||||
// Calculate Buy and sell Series
|
// Calculate Buy and sell Series
|
||||||
// if (!this.signalsCalculated) {
|
// if (!this.signalsCalculated) {
|
||||||
|
@ -673,6 +688,11 @@ export default defineComponent({
|
||||||
() => updateChart(),
|
() => updateChart(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.sliderPosition,
|
||||||
|
() => updateSliderPosition()
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
candleChart,
|
candleChart,
|
||||||
buyData,
|
buyData,
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
:heikin-ashi="settingsStore.useHeikinAshiCandles"
|
:heikin-ashi="settingsStore.useHeikinAshiCandles"
|
||||||
:use-u-t-c="settingsStore.timezone === 'UTC'"
|
:use-u-t-c="settingsStore.timezone === 'UTC'"
|
||||||
:theme="settingsStore.chartTheme"
|
:theme="settingsStore.chartTheme"
|
||||||
|
:sliderPosition="sliderPosition"
|
||||||
>
|
>
|
||||||
</CandleChart>
|
</CandleChart>
|
||||||
<div v-else class="m-auto">
|
<div v-else class="m-auto">
|
||||||
|
@ -91,7 +92,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Trade, PairHistory, EMPTY_PLOTCONFIG, PlotConfig, LoadingStatus } from '@/types';
|
import { Trade, PairHistory, EMPTY_PLOTCONFIG, PlotConfig, LoadingStatus, ChartSliderPosition } from '@/types';
|
||||||
import CandleChart from '@/components/charts/CandleChart.vue';
|
import CandleChart from '@/components/charts/CandleChart.vue';
|
||||||
import PlotConfigurator from '@/components/charts/PlotConfigurator.vue';
|
import PlotConfigurator from '@/components/charts/PlotConfigurator.vue';
|
||||||
import { getCustomPlotConfig, getPlotConfigName } from '@/shared/storage';
|
import { getCustomPlotConfig, getPlotConfigName } from '@/shared/storage';
|
||||||
|
@ -114,6 +115,7 @@ export default defineComponent({
|
||||||
timerange: { required: false, default: '', type: String },
|
timerange: { required: false, default: '', type: String },
|
||||||
/** Only required if historicView is true */
|
/** Only required if historicView is true */
|
||||||
strategy: { required: false, default: '', type: String },
|
strategy: { required: false, default: '', type: String },
|
||||||
|
sliderPosition: {required: false, type: Object as () => ChartSliderPosition}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const root = getCurrentInstance();
|
const root = getCurrentInstance();
|
||||||
|
|
|
@ -6,3 +6,8 @@ export interface CumProfitData {
|
||||||
export interface CumProfitDataPerDate {
|
export interface CumProfitDataPerDate {
|
||||||
[key: number]: CumProfitData;
|
[key: number]: CumProfitData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ChartSliderPosition {
|
||||||
|
startValue: number,
|
||||||
|
endValue: number
|
||||||
|
}
|
||||||
|
|
|
@ -272,10 +272,24 @@
|
||||||
v-if="hasBacktestResult && btFormMode == 'visualize'"
|
v-if="hasBacktestResult && btFormMode == 'visualize'"
|
||||||
class="container-fluid text-center w-100 mt-2"
|
class="container-fluid text-center w-100 mt-2"
|
||||||
>
|
>
|
||||||
<p class="row">
|
<div class="row">
|
||||||
Graph will always show the latest values for the selected strategy. Timerange:
|
<div class="col-md-11 text-left">
|
||||||
{{ timerange }} - {{ strategy }}
|
<p>
|
||||||
</p>
|
Graph will always show the latest values for the selected strategy. Timerange:
|
||||||
|
{{ timerange }} - {{ strategy }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
<b-button
|
||||||
|
v-if="btFormMode === 'visualize'"
|
||||||
|
class="right-bar-toggle"
|
||||||
|
aria-label="Close"
|
||||||
|
size="sm"
|
||||||
|
@click="showRightBar = !showRightBar"
|
||||||
|
>{{ showRightBar ? '>' : '<' }}
|
||||||
|
</b-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row text-center">
|
<div class="row text-center">
|
||||||
<PairSummary
|
<PairSummary
|
||||||
class="col-md-2 overflow-auto"
|
class="col-md-2 overflow-auto"
|
||||||
|
@ -292,20 +306,17 @@
|
||||||
:timerange="timerange"
|
:timerange="timerange"
|
||||||
:strategy="strategy"
|
:strategy="strategy"
|
||||||
:trades="botStore.activeBot.selectedBacktestResult.trades"
|
:trades="botStore.activeBot.selectedBacktestResult.trades"
|
||||||
class="col-md-8 candle-chart-container px-0 w-100 h-100"
|
:class="`${showRightBar ? 'col-md-8' : 'col-md-10'} candle-chart-container px-0 w-100 h-100`"
|
||||||
|
:sliderPosition="sliderPosition"
|
||||||
>
|
>
|
||||||
</CandleChartContainer>
|
</CandleChartContainer>
|
||||||
<TradeListNav
|
<TradeListNav
|
||||||
class="col-md-2 overflow-auto"
|
class="overflow-auto col-md-2"
|
||||||
style="max-height: calc(100vh - 200px)"
|
style="max-height: calc(100vh - 200px)"
|
||||||
|
v-if="showRightBar"
|
||||||
:trades="botStore.activeBot.selectedBacktestResult.trades.filter(t => t.pair === botStore.activeBot.selectedPair)"
|
:trades="botStore.activeBot.selectedBacktestResult.trades.filter(t => t.pair === botStore.activeBot.selectedPair)"
|
||||||
|
@trade-select="navigateChartToTrade"
|
||||||
/>
|
/>
|
||||||
<!--<TradeList
|
|
||||||
class="col-md-2 overflow-auto"
|
|
||||||
:trades="botStore.activeBot.selectedBacktestResult.trades.filter(t => t.pair === botStore.activeBot.selectedPair)"
|
|
||||||
:show-filter="true"
|
|
||||||
:stake-currency="botStore.activeBot.selectedBacktestResult.stake_currency"
|
|
||||||
/> -->
|
|
||||||
</div>
|
</div>
|
||||||
<b-card header="Single trades" class="row mt-2 w-100">
|
<b-card header="Single trades" class="row mt-2 w-100">
|
||||||
<TradeList
|
<TradeList
|
||||||
|
@ -333,7 +344,7 @@ import TradeList from '@/components/ftbot/TradeList.vue';
|
||||||
import TradeListNav from '@/components/ftbot/TradeListNav.vue';
|
import TradeListNav from '@/components/ftbot/TradeListNav.vue';
|
||||||
import BacktestHistoryLoad from '@/components/ftbot/BacktestHistoryLoad.vue';
|
import BacktestHistoryLoad from '@/components/ftbot/BacktestHistoryLoad.vue';
|
||||||
|
|
||||||
import { BacktestPayload } from '@/types';
|
import { BacktestPayload, ChartSliderPosition, Trade } from '@/types';
|
||||||
|
|
||||||
import { formatPercent } from '@/shared/formatters';
|
import { formatPercent } from '@/shared/formatters';
|
||||||
import { defineComponent, computed, ref, onMounted, watch } from 'vue';
|
import { defineComponent, computed, ref, onMounted, watch } from 'vue';
|
||||||
|
@ -376,6 +387,7 @@ export default defineComponent({
|
||||||
const selectedDetailTimeframe = ref('');
|
const selectedDetailTimeframe = ref('');
|
||||||
const timerange = ref('');
|
const timerange = ref('');
|
||||||
const showLeftBar = ref(false);
|
const showLeftBar = ref(false);
|
||||||
|
const showRightBar = ref(true);
|
||||||
const enableProtections = ref(false);
|
const enableProtections = ref(false);
|
||||||
const stakeAmountUnlimited = ref(false);
|
const stakeAmountUnlimited = ref(false);
|
||||||
const maxOpenTrades = ref('');
|
const maxOpenTrades = ref('');
|
||||||
|
@ -383,6 +395,7 @@ export default defineComponent({
|
||||||
const startingCapital = ref('');
|
const startingCapital = ref('');
|
||||||
const btFormMode = ref('run');
|
const btFormMode = ref('run');
|
||||||
const pollInterval = ref<number | null>(null);
|
const pollInterval = ref<number | null>(null);
|
||||||
|
const sliderPosition = ref(<ChartSliderPosition>{});
|
||||||
|
|
||||||
const setBacktestResult = (key: string) => {
|
const setBacktestResult = (key: string) => {
|
||||||
botStore.activeBot.setBacktestResultKey(key);
|
botStore.activeBot.setBacktestResultKey(key);
|
||||||
|
@ -434,6 +447,14 @@ export default defineComponent({
|
||||||
|
|
||||||
botStore.activeBot.startBacktest(btPayload);
|
botStore.activeBot.startBacktest(btPayload);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navigateChartToTrade = (trade : Trade) => {
|
||||||
|
sliderPosition.value = {
|
||||||
|
startValue: trade.open_timestamp,
|
||||||
|
endValue: trade.close_timestamp
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => botStore.activeBot.getState());
|
onMounted(() => botStore.activeBot.getState());
|
||||||
watch(
|
watch(
|
||||||
() => botStore.activeBot.backtestRunning,
|
() => botStore.activeBot.backtestRunning,
|
||||||
|
@ -459,12 +480,15 @@ export default defineComponent({
|
||||||
timerange,
|
timerange,
|
||||||
enableProtections,
|
enableProtections,
|
||||||
showLeftBar,
|
showLeftBar,
|
||||||
|
showRightBar,
|
||||||
stakeAmountUnlimited,
|
stakeAmountUnlimited,
|
||||||
maxOpenTrades,
|
maxOpenTrades,
|
||||||
stakeAmount,
|
stakeAmount,
|
||||||
startingCapital,
|
startingCapital,
|
||||||
btFormMode,
|
btFormMode,
|
||||||
clickBacktest,
|
clickBacktest,
|
||||||
|
navigateChartToTrade,
|
||||||
|
sliderPosition
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user