|
|
@@ -28,14 +28,14 @@
|
|
|
<div class="profit-chart" ref="balanceChartRef"></div>
|
|
|
</template>
|
|
|
</lay-card>
|
|
|
- <lay-card class="custom-card">
|
|
|
+ <!-- <lay-card class="custom-card">
|
|
|
<template v-slot:title>
|
|
|
<span class="card-title">净值图</span>
|
|
|
</template>
|
|
|
<template v-slot:body>
|
|
|
<div class="predictor-chart" ref="predictorChartRef" @mouseleave="startPredictorInterval" @mouseenter="stopPredictorInterval"></div>
|
|
|
</template>
|
|
|
- </lay-card>
|
|
|
+ </lay-card> -->
|
|
|
|
|
|
<lay-card v-if="apiList?.includes('/robot/getRobotLog')" class="custom-card">
|
|
|
<template v-slot:title>
|
|
|
@@ -57,9 +57,8 @@
|
|
|
import { ref, reactive, onMounted, onUnmounted, shallowRef } from "vue";
|
|
|
import { useRoute } from "vue-router";
|
|
|
import * as echarts from "echarts";
|
|
|
-import dayjs from "dayjs";
|
|
|
import LogText from "./components/LogText.vue";
|
|
|
-import { get_robot_detail, get_robot_logs, get_remaining_detail, get_predictor_state } from "@/api";
|
|
|
+import { get_robot_detail, get_robot_logs, get_remaining_detail } from "@/api";
|
|
|
|
|
|
const ROBOT_STATUS: any = reactive({
|
|
|
STOPPED: "已停止",
|
|
|
@@ -74,7 +73,6 @@ const ROBOT_STATUS: any = reactive({
|
|
|
const apiList = ref(window.sessionStorage.getItem("_4L_API_LIST"));
|
|
|
|
|
|
const balanceChartRef = ref();
|
|
|
-const predictorChartRef = ref();
|
|
|
const logtextRef = ref();
|
|
|
|
|
|
const route = useRoute();
|
|
|
@@ -98,11 +96,8 @@ const columns = ref([
|
|
|
let logsList = ref<Array<Logs>>();
|
|
|
let robotDetail = ref<any>({});
|
|
|
let balanceList = ref([]);
|
|
|
-let predictorList = ref<any>([]);
|
|
|
let balanceChart = shallowRef();
|
|
|
-let predictorChart = shallowRef();
|
|
|
let timer = ref();
|
|
|
-let predictorInterval = ref();
|
|
|
|
|
|
// 获取机器人详情
|
|
|
const getRobotDetail = () => {
|
|
|
@@ -117,186 +112,6 @@ const getRobotDetail = () => {
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
-const getPredictorState = () => {
|
|
|
- const params = {};
|
|
|
- pageConfig.loading = true;
|
|
|
- get_predictor_state(params, (data: any) => {
|
|
|
- pageConfig.loading = false;
|
|
|
- console.log(data);
|
|
|
- if (!data) return;
|
|
|
- predictorList.value = data;
|
|
|
- const xData = data.map((item: any) => dayjs(item.update_time * 1).format("MM-DD HH:mm:ss:SSS"));
|
|
|
-
|
|
|
- !predictorChart.value
|
|
|
- ? initPredictorChart(predictorList.value)
|
|
|
- : predictorChart.value.setOption({
|
|
|
- xAxis: [
|
|
|
- {
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 1, // 第1个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 2, // 第2个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 3, // 第3个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 4, // 第4个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 5, // 第5个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- ],
|
|
|
- yAxis: [
|
|
|
- {
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 1, // 第1个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 2, // 第2个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 3, // 第3个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 4, // 第4个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 5, // 第5个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- ],
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: "mid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.mid_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "ask_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.ask_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "bid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.bid_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "optimal_ask_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.optimal_ask_price),
|
|
|
- lineStyle: {
|
|
|
- type: "dashed",
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: "optimal_bid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.optimal_bid_price),
|
|
|
- lineStyle: {
|
|
|
- type: "dashed",
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: "ref_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.ref_price),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "inventory",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 1,
|
|
|
- yAxisIndex: 1,
|
|
|
- data: data.map((item: any) => item.inventory),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "spread",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "delta_plus",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.delta_plus),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "spread_max",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread_max),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "spread_min",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread_min),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "sigma_square",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 3,
|
|
|
- yAxisIndex: 3,
|
|
|
- data: data.map((item: any) => item.sigma_square),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "gamma",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 4,
|
|
|
- yAxisIndex: 4,
|
|
|
- data: data.map((item: any) => item.gamma),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "kappa",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 5,
|
|
|
- yAxisIndex: 5,
|
|
|
- data: data.map((item: any) => item.kappa),
|
|
|
- },
|
|
|
- ],
|
|
|
- });
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
-// 获取账户余额
|
|
|
const getBalanceInfo = (id: number) => {
|
|
|
const params = { id: id };
|
|
|
pageConfig.loading = true;
|
|
|
@@ -418,271 +233,6 @@ const initBalanceChart = (data: any) => {
|
|
|
balanceChart.value.setOption(balanceChartOption);
|
|
|
};
|
|
|
|
|
|
-const initPredictorChart = (data: any) => {
|
|
|
- if (predictorChart.value != null && !predictorChart.value.isDisposed()) echarts.dispose(predictorChart.value);
|
|
|
- predictorChart.value = echarts.init(predictorChartRef.value);
|
|
|
-
|
|
|
- window.removeEventListener("resize", () => predictorChart.value.resize());
|
|
|
- window.addEventListener("resize", () => predictorChart.value.resize());
|
|
|
- const xData = data.map((item: any) => dayjs(item.update_time * 1).format("MM-DD HH:mm:ss:SSS"));
|
|
|
- const option = {
|
|
|
- dataZoom: [
|
|
|
- {
|
|
|
- type: "inside",
|
|
|
- xAxisIndex: [0, 1, 2, 3, 4, 5],
|
|
|
- start: 0,
|
|
|
- end: 100,
|
|
|
- },
|
|
|
- {
|
|
|
- xAxisIndex: [0, 1, 2, 3, 4, 5],
|
|
|
- start: 0,
|
|
|
- end: 100,
|
|
|
- },
|
|
|
- ],
|
|
|
- tooltip: {
|
|
|
- trigger: "axis",
|
|
|
- formatter: (value: any) => {
|
|
|
- return `时间:${value[0].name}<br />${value.map((item: any) => `${item.marker}${item.seriesName}:${item.value}`).join("<br/>")}`;
|
|
|
- },
|
|
|
- },
|
|
|
- toolbox: {
|
|
|
- feature: {
|
|
|
- dataZoom: {},
|
|
|
- brush: {
|
|
|
- type: ["rect", "clear"],
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- legend: [
|
|
|
- {
|
|
|
- data: ["mid_price", "ask_price", "bid_price", "optimal_ask_price", "optimal_bid_price", "ref_price"],
|
|
|
- top: "230px",
|
|
|
- },
|
|
|
- {
|
|
|
- data: ["inventory"],
|
|
|
- top: "380px",
|
|
|
- },
|
|
|
- {
|
|
|
- data: ["spread", "delta_plus", "spread_max", "spread_min"],
|
|
|
- top: "630px",
|
|
|
- },
|
|
|
- {
|
|
|
- data: ["sigma_square"],
|
|
|
- top: "780px",
|
|
|
- },
|
|
|
- {
|
|
|
- data: ["gamma"],
|
|
|
- top: "930px",
|
|
|
- },
|
|
|
- {
|
|
|
- data: ["kappa"],
|
|
|
- top: "1080px",
|
|
|
- },
|
|
|
- ],
|
|
|
-
|
|
|
- grid: [
|
|
|
- {
|
|
|
- top: "50px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "150px", // 主图高度
|
|
|
- },
|
|
|
- {
|
|
|
- top: "300px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "50px",
|
|
|
- },
|
|
|
- {
|
|
|
- top: "450px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "150px",
|
|
|
- },
|
|
|
- {
|
|
|
- top: "700px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "50px",
|
|
|
- },
|
|
|
- {
|
|
|
- top: "850px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "50px",
|
|
|
- },
|
|
|
- {
|
|
|
- top: "1000px",
|
|
|
- left: "60px",
|
|
|
- right: "60px",
|
|
|
- height: "50px",
|
|
|
- },
|
|
|
- ],
|
|
|
- xAxis: [
|
|
|
- {
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 1, // 第1个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 2, // 第2个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 3, // 第3个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 4, // 第4个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 5, // 第5个网格的 x 轴
|
|
|
- type: "category",
|
|
|
- data: xData,
|
|
|
- },
|
|
|
- ],
|
|
|
- yAxis: [
|
|
|
- {
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 1, // 第1个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 2, // 第2个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 3, // 第3个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 4, // 第4个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- {
|
|
|
- gridIndex: 5, // 第5个网格的 y 轴
|
|
|
- type: "value",
|
|
|
- min: "dataMin",
|
|
|
- },
|
|
|
- ],
|
|
|
- series: [
|
|
|
- {
|
|
|
- name: "mid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.mid_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "ask_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.ask_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "bid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.bid_price),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "optimal_ask_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.optimal_ask_price),
|
|
|
- lineStyle: {
|
|
|
- type: "dashed",
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: "optimal_bid_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.optimal_bid_price),
|
|
|
- lineStyle: {
|
|
|
- type: "dashed",
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- name: "ref_price",
|
|
|
- type: "line",
|
|
|
- data: data.map((item: any) => item.ref_price),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "inventory",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 1,
|
|
|
- yAxisIndex: 1,
|
|
|
- data: data.map((item: any) => item.inventory),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "spread",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "delta_plus",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.delta_plus),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "spread_max",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread_max),
|
|
|
- },
|
|
|
- {
|
|
|
- name: "spread_min",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 2,
|
|
|
- yAxisIndex: 2,
|
|
|
- data: data.map((item: any) => item.spread_min),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "sigma_square",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 3,
|
|
|
- yAxisIndex: 3,
|
|
|
- data: data.map((item: any) => item.sigma_square),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "gamma",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 4,
|
|
|
- yAxisIndex: 4,
|
|
|
- data: data.map((item: any) => item.gamma),
|
|
|
- },
|
|
|
-
|
|
|
- {
|
|
|
- name: "kappa",
|
|
|
- type: "line",
|
|
|
- xAxisIndex: 5,
|
|
|
- yAxisIndex: 5,
|
|
|
- data: data.map((item: any) => item.kappa),
|
|
|
- },
|
|
|
- ],
|
|
|
- };
|
|
|
- predictorChart.value.setOption(option);
|
|
|
-};
|
|
|
-
|
|
|
timer.value = setInterval(() => {
|
|
|
getBalanceInfo(robotDetail.value.accId);
|
|
|
getLogsInfo();
|
|
|
@@ -690,32 +240,13 @@ timer.value = setInterval(() => {
|
|
|
|
|
|
getLogsInfo();
|
|
|
|
|
|
-const startPredictorInterval = () => {
|
|
|
- console.log("startPredictorInterval");
|
|
|
- if (!predictorInterval.value) {
|
|
|
- predictorInterval.value = window.setInterval(() => {
|
|
|
- getPredictorState();
|
|
|
- }, 2000);
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
-// 停止定时请求
|
|
|
-const stopPredictorInterval = () => {
|
|
|
- if (predictorInterval.value) {
|
|
|
- clearInterval(predictorInterval.value);
|
|
|
- predictorInterval.value = null; // 释放定时器
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
onMounted(() => {
|
|
|
getRobotDetail();
|
|
|
- startPredictorInterval();
|
|
|
});
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
window.removeEventListener("resize", () => balanceChart.value.resize());
|
|
|
clearInterval(timer.value);
|
|
|
- stopPredictorInterval();
|
|
|
});
|
|
|
</script>
|
|
|
|