mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 21:15:15 +00:00
Final components to script setup
This commit is contained in:
parent
85820c8684
commit
ff1b217ca9
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<v-chart v-if="trades" :option="chartOptions" autoresize :theme="settingsStore.chartTheme" />
|
<e-charts v-if="trades" :option="chartOptions" autoresize :theme="settingsStore.chartTheme" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
import { EChartsOption } from 'echarts';
|
import { EChartsOption } from 'echarts';
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import {
|
||||||
} from 'echarts/components';
|
} from 'echarts/components';
|
||||||
|
|
||||||
import { ClosedTrade, CumProfitData, CumProfitDataPerDate } from '@/types';
|
import { ClosedTrade, CumProfitData, CumProfitDataPerDate } from '@/types';
|
||||||
import { defineComponent, computed, ComputedRef } from 'vue';
|
import { computed, ComputedRef } from 'vue';
|
||||||
import { useSettingsStore } from '@/stores/settings';
|
import { useSettingsStore } from '@/stores/settings';
|
||||||
import { dataZoomPartial } from '@/shared/charts/chartZoom';
|
import { dataZoomPartial } from '@/shared/charts/chartZoom';
|
||||||
|
|
||||||
|
@ -38,22 +38,16 @@ use([
|
||||||
// Define Column labels here to avoid typos
|
// Define Column labels here to avoid typos
|
||||||
const CHART_PROFIT = 'Profit';
|
const CHART_PROFIT = 'Profit';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'CumProfitChart',
|
|
||||||
components: {
|
|
||||||
'v-chart': ECharts,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
trades: { required: true, type: Array as () => ClosedTrade[] },
|
trades: { required: true, type: Array as () => ClosedTrade[] },
|
||||||
showTitle: { default: true, type: Boolean },
|
showTitle: { default: true, type: Boolean },
|
||||||
profitColumn: { default: 'profit_abs', type: String },
|
profitColumn: { default: 'profit_abs', type: String },
|
||||||
},
|
});
|
||||||
setup(props) {
|
const settingsStore = useSettingsStore();
|
||||||
const settingsStore = useSettingsStore();
|
// const botList = ref<string[]>([]);
|
||||||
// const botList = ref<string[]>([]);
|
// const cumulativeData = ref<{ date: number; profit: any }[]>([]);
|
||||||
// const cumulativeData = ref<{ date: number; profit: any }[]>([]);
|
|
||||||
|
|
||||||
const cumulativeData: ComputedRef<{ date: number; profit: number }[]> = computed(() => {
|
const cumulativeData: ComputedRef<{ date: number; profit: number }[]> = computed(() => {
|
||||||
const res: CumProfitData[] = [];
|
const res: CumProfitData[] = [];
|
||||||
const resD: CumProfitDataPerDate = {};
|
const resD: CumProfitDataPerDate = {};
|
||||||
const closedTrades = props.trades
|
const closedTrades = props.trades
|
||||||
|
@ -91,9 +85,9 @@ export default defineComponent({
|
||||||
// });
|
// });
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const chartOptions = computed((): EChartsOption => {
|
const chartOptions = computed((): EChartsOption => {
|
||||||
const chartOptionsLoc: EChartsOption = {
|
const chartOptionsLoc: EChartsOption = {
|
||||||
title: {
|
title: {
|
||||||
text: 'Cumulative Profit',
|
text: 'Cumulative Profit',
|
||||||
|
@ -185,10 +179,6 @@ export default defineComponent({
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
return chartOptionsLoc;
|
return chartOptionsLoc;
|
||||||
});
|
|
||||||
|
|
||||||
return { settingsStore, cumulativeData, chartOptions };
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<v-chart
|
<e-charts
|
||||||
v-if="dailyStats.data"
|
v-if="dailyStats.data"
|
||||||
:option="dailyChartOptions"
|
:option="dailyChartOptions"
|
||||||
:theme="settingsStore.chartTheme"
|
:theme="settingsStore.chartTheme"
|
||||||
|
@ -7,8 +7,8 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent, computed, ComputedRef } from 'vue';
|
import { computed, ComputedRef } from 'vue';
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
// import { EChartsOption } from 'echarts';
|
// import { EChartsOption } from 'echarts';
|
||||||
|
|
||||||
|
@ -44,11 +44,7 @@ use([
|
||||||
const CHART_ABS_PROFIT = 'Absolute profit';
|
const CHART_ABS_PROFIT = 'Absolute profit';
|
||||||
const CHART_TRADE_COUNT = 'Trade Count';
|
const CHART_TRADE_COUNT = 'Trade Count';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
components: {
|
|
||||||
'v-chart': ECharts,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
dailyStats: {
|
dailyStats: {
|
||||||
type: Object as () => DailyReturnValue,
|
type: Object as () => DailyReturnValue,
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -57,23 +53,22 @@ export default defineComponent({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
|
|
||||||
setup(props) {
|
const settingsStore = useSettingsStore();
|
||||||
const settingsStore = useSettingsStore();
|
const absoluteMin = computed(() =>
|
||||||
const absoluteMin = computed(() =>
|
|
||||||
props.dailyStats.data.reduce(
|
props.dailyStats.data.reduce(
|
||||||
(min, p) => (p.abs_profit < min ? p.abs_profit : min),
|
(min, p) => (p.abs_profit < min ? p.abs_profit : min),
|
||||||
props.dailyStats.data[0]?.abs_profit,
|
props.dailyStats.data[0]?.abs_profit,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const absoluteMax = computed(() =>
|
const absoluteMax = computed(() =>
|
||||||
props.dailyStats.data.reduce(
|
props.dailyStats.data.reduce(
|
||||||
(max, p) => (p.abs_profit > max ? p.abs_profit : max),
|
(max, p) => (p.abs_profit > max ? p.abs_profit : max),
|
||||||
props.dailyStats.data[0]?.abs_profit,
|
props.dailyStats.data[0]?.abs_profit,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
const dailyChartOptions: ComputedRef<EChartsOption> = computed(() => {
|
const dailyChartOptions: ComputedRef<EChartsOption> = computed(() => {
|
||||||
return {
|
return {
|
||||||
title: {
|
title: {
|
||||||
text: 'Daily profit',
|
text: 'Daily profit',
|
||||||
|
@ -156,13 +151,6 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
dailyChartOptions,
|
|
||||||
settingsStore,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<v-chart
|
<e-charts
|
||||||
v-if="trades.length > 0"
|
v-if="trades.length > 0"
|
||||||
:option="hourlyChartOptions"
|
:option="hourlyChartOptions"
|
||||||
autoresize
|
autoresize
|
||||||
|
@ -7,10 +7,10 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
import { useSettingsStore } from '@/stores/settings';
|
import { useSettingsStore } from '@/stores/settings';
|
||||||
import { defineComponent, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import { Trade } from '@/types';
|
import { Trade } from '@/types';
|
||||||
import { timestampHour } from '@/shared/formatters';
|
import { timestampHour } from '@/shared/formatters';
|
||||||
|
@ -45,19 +45,13 @@ use([
|
||||||
const CHART_PROFIT = 'Profit %';
|
const CHART_PROFIT = 'Profit %';
|
||||||
const CHART_TRADE_COUNT = 'Trade Count';
|
const CHART_TRADE_COUNT = 'Trade Count';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'HourlyChart',
|
|
||||||
components: {
|
|
||||||
'v-chart': ECharts,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
trades: { required: true, type: Array as () => Trade[] },
|
trades: { required: true, type: Array as () => Trade[] },
|
||||||
showTitle: { default: true, type: Boolean },
|
showTitle: { default: true, type: Boolean },
|
||||||
},
|
});
|
||||||
setup(props) {
|
const settingsStore = useSettingsStore();
|
||||||
const settingsStore = useSettingsStore();
|
|
||||||
|
|
||||||
const hourlyData = computed(() => {
|
const hourlyData = computed(() => {
|
||||||
const res = new Array(24);
|
const res = new Array(24);
|
||||||
for (let i = 0; i < 24; i += 1) {
|
for (let i = 0; i < 24; i += 1) {
|
||||||
res[i] = { hour: i, hourDesc: `${i}h`, profit: 0.0, count: 0.0 };
|
res[i] = { hour: i, hourDesc: `${i}h`, profit: 0.0, count: 0.0 };
|
||||||
|
@ -73,8 +67,8 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
const hourlyChartOptions = computed((): EChartsOption => {
|
const hourlyChartOptions = computed((): EChartsOption => {
|
||||||
return {
|
return {
|
||||||
title: {
|
title: {
|
||||||
text: 'Hourly Profit',
|
text: 'Hourly Profit',
|
||||||
|
@ -157,9 +151,6 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
});
|
|
||||||
return { settingsStore, hourlyChartOptions };
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="d-flex flex-column h-100 position-relative">
|
<div class="d-flex flex-column h-100 position-relative">
|
||||||
<div class="flex-grow-1 order-2">
|
<div class="flex-grow-1 order-2">
|
||||||
<v-chart v-if="trades" :option="chartOptions" autoresize :theme="settingsStore.chartTheme" />
|
<e-charts v-if="trades" :option="chartOptions" autoresize :theme="settingsStore.chartTheme" />
|
||||||
</div>
|
</div>
|
||||||
<b-form-group
|
<b-form-group
|
||||||
class="w-25 order-1"
|
class="w-25 order-1"
|
||||||
|
@ -22,8 +22,8 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineComponent, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import ECharts from 'vue-echarts';
|
import ECharts from 'vue-echarts';
|
||||||
import { EChartsOption } from 'echarts';
|
import { EChartsOption } from 'echarts';
|
||||||
|
|
||||||
|
@ -57,28 +57,22 @@ use([
|
||||||
// Define Column labels here to avoid typos
|
// Define Column labels here to avoid typos
|
||||||
const CHART_PROFIT = 'Trade count';
|
const CHART_PROFIT = 'Trade count';
|
||||||
|
|
||||||
export default defineComponent({
|
const props = defineProps({
|
||||||
name: 'ProfitDistributionChart',
|
|
||||||
components: {
|
|
||||||
'v-chart': ECharts,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
trades: { required: true, type: Array as () => ClosedTrade[] },
|
trades: { required: true, type: Array as () => ClosedTrade[] },
|
||||||
showTitle: { default: true, type: Boolean },
|
showTitle: { default: true, type: Boolean },
|
||||||
},
|
});
|
||||||
setup(props) {
|
const settingsStore = useSettingsStore();
|
||||||
const settingsStore = useSettingsStore();
|
// registerTransform(ecStat.transform.histogram);
|
||||||
// registerTransform(ecStat.transform.histogram);
|
// console.log(profits);
|
||||||
// console.log(profits);
|
// const data = [[]];
|
||||||
// const data = [[]];
|
const binOptions = [10, 15, 20, 25, 50];
|
||||||
const binOptions = [10, 15, 20, 25, 50];
|
const data = computed(() => {
|
||||||
const data = computed(() => {
|
|
||||||
const profits = props.trades.map((trade) => trade.profit_ratio);
|
const profits = props.trades.map((trade) => trade.profit_ratio);
|
||||||
|
|
||||||
return binData(profits, settingsStore.profitDistributionBins);
|
return binData(profits, settingsStore.profitDistributionBins);
|
||||||
});
|
});
|
||||||
|
|
||||||
const chartOptions = computed((): EChartsOption => {
|
const chartOptions = computed((): EChartsOption => {
|
||||||
const chartOptionsLoc: EChartsOption = {
|
const chartOptionsLoc: EChartsOption = {
|
||||||
title: {
|
title: {
|
||||||
text: 'Profit distribution',
|
text: 'Profit distribution',
|
||||||
|
@ -139,10 +133,6 @@ export default defineComponent({
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
return chartOptionsLoc;
|
return chartOptionsLoc;
|
||||||
});
|
|
||||||
// console.log(chartOptions);
|
|
||||||
return { settingsStore, chartOptions, binOptions };
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -21,43 +21,30 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
import { timestampms } from '@/shared/formatters';
|
import { timestampms } from '@/shared/formatters';
|
||||||
import { Lock } from '@/types';
|
import { Lock } from '@/types';
|
||||||
|
|
||||||
import { showAlert } from '@/stores/alerts';
|
import { showAlert } from '@/stores/alerts';
|
||||||
import { useBotStore } from '@/stores/ftbotwrapper';
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
||||||
import { defineComponent } from 'vue';
|
import { TableField } from 'bootstrap-vue-next';
|
||||||
|
const botStore = useBotStore();
|
||||||
|
|
||||||
export default defineComponent({
|
const tableFields: TableField[] = [
|
||||||
name: 'PairLockList',
|
|
||||||
setup() {
|
|
||||||
const botStore = useBotStore();
|
|
||||||
|
|
||||||
const tableFields = [
|
|
||||||
{ key: 'pair', label: 'Pair' },
|
{ key: 'pair', label: 'Pair' },
|
||||||
{ key: 'lock_end_timestamp', label: 'Until', formatter: 'timestampms' },
|
{ key: 'lock_end_timestamp', label: 'Until', formatter: (value) => timestampms(value as number) },
|
||||||
{ key: 'reason', label: 'Reason' },
|
{ key: 'reason', label: 'Reason' },
|
||||||
{ key: 'actions' },
|
{ key: 'actions' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const removePairLock = (item: Lock) => {
|
const removePairLock = (item: Lock) => {
|
||||||
console.log(item);
|
console.log(item);
|
||||||
if (item.id !== undefined) {
|
if (item.id !== undefined) {
|
||||||
botStore.activeBot.deleteLock(item.id);
|
botStore.activeBot.deleteLock(item.id);
|
||||||
} else {
|
} else {
|
||||||
showAlert('This Freqtrade version does not support deleting locks.');
|
showAlert('This Freqtrade version does not support deleting locks.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
timestampms,
|
|
||||||
botStore,
|
|
||||||
tableFields,
|
|
||||||
removePairLock,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user