historic-stock

This commit is contained in:
张 元山 2025-05-23 10:51:54 +08:00
parent deb9834cd4
commit 3bdb88ca55
2 changed files with 1232 additions and 90 deletions

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,8 @@ import { NDataTable, NButton, NDropdown, NIcon } from "naive-ui";
import { reactive, onMounted, h } from "vue";
import axios from "axios";
import { ChevronDownOutline } from "@vicons/ionicons5";
import defaultTableData from "../data";
console.log("defaultTableData", defaultTableData);
//
const periodOptions = [
{ label: "Daily", key: "Daily" },
@ -130,106 +131,32 @@ const handleDurationChange = (key) => {
};
onMounted(() => {
getPageData();
getPageDefaultData();
});
const getPageData = async () => {
const getPageDefaultData = async () => {
try {
// state.selectedPeriodstate.selectedDurationAPI
let url =
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
const res = await axios.get(url);
// API
// API
state.tableData = [
{
date: "May 22, 2025",
open: "1.87",
high: "2.03",
low: "1.85",
close: "2.00",
adjClose: "2.00",
change: "-2.44%",
volume: "2,103",
},
{
date: "May 21, 2025",
open: "2.05",
high: "2.05",
low: "2.05",
close: "2.05",
adjClose: "2.05",
change: "-",
volume: "4",
},
{
date: "May 20, 2025",
open: "2.05",
high: "2.05",
low: "1.86",
close: "2.05",
adjClose: "2.05",
change: "-",
volume: "11,042",
},
{
date: "May 19, 2025",
open: "2.04",
high: "2.05",
low: "1.85",
close: "2.05",
adjClose: "2.05",
change: "-",
volume: "6,204",
},
{
date: "May 16, 2025",
open: "2.05",
high: "2.06",
low: "1.85",
close: "2.05",
adjClose: "2.05",
change: "2.50%",
volume: "3,618",
},
{
date: "May 15, 2025",
open: "2.05",
high: "2.05",
low: "1.93",
close: "2.00",
adjClose: "2.00",
change: "-1.48%",
volume: "5,413",
},
{
date: "May 14, 2025",
open: "1.95",
high: "2.05",
low: "1.95",
close: "2.03",
adjClose: "2.03",
change: "4.10%",
volume: "8,886",
},
{
date: "May 13, 2025",
open: "2.26",
high: "2.26",
low: "1.80",
close: "1.95",
adjClose: "1.95",
change: "-18.41%",
volume: "10,750",
},
];
console.log("获取到的数据", state.tableData);
let originalData = res.data.data;
//
let calcApiData = originalData.map((item) => [
new Date(item[0]).toISOString().split("T")[0], // YYYY-MM-DD
item[1],
]);
console.log("接口数据", calcApiData);
state.tableData = defaultTableData;
} catch (error) {
console.error("获取数据失败", error);
}
};
const getPageData = async () => {
let url =
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
const res = await axios.get(url);
};
</script>
<style scoped lang="scss">