@@ -445,11 +477,25 @@
>
{item?.open?.toFixed(2)}
+
+ {item?.adjOpen !== undefined
+ ? item?.adjOpen?.toFixed(2)
+ : "n/a"}
+ |
{item?.high?.toFixed(2)}
|
+
+ {item?.adjHigh !== undefined && item?.adjHigh
+ ? item?.adjHigh?.toFixed(2)
+ : "n/a"}
+ |
@@ -458,13 +504,24 @@
|
- {item?.close?.toFixed(2)}
+ {item?.adjLow !== undefined && item?.adjLow
+ ? item?.adjLow?.toFixed(2)
+ : "n/a"}
|
- {item?.change !== null ? item?.change : "n/a"}
+ {item?.close?.toFixed(2)}
|
+
+
+ {item?.adjClose !== undefined
+ ? item?.adjClose?.toFixed(2)
+ : "n/a"}
+ |
+
-
-
-
-
diff --git a/src/routes/index/[tickerID]/history/+page.server.ts b/src/routes/index/[tickerID]/history/+page.server.ts
index b6f18331..63d36f87 100644
--- a/src/routes/index/[tickerID]/history/+page.server.ts
+++ b/src/routes/index/[tickerID]/history/+page.server.ts
@@ -1,10 +1,10 @@
export const load = async ({ locals, params }) => {
const { apiKey, apiURL } = locals;
const getData = async () => {
- const postData = { ticker: params.tickerID, timePeriod: 'max' };
+ const postData = { ticker: params.tickerID };
- const response = await fetch(apiURL + "/historical-price", {
+ const response = await fetch(apiURL + "/historical-adj-price", {
method: "POST",
headers: {
"Content-Type": "application/json",
diff --git a/src/routes/index/[tickerID]/history/+page.svelte b/src/routes/index/[tickerID]/history/+page.svelte
index 6289ebb2..ae4133c0 100644
--- a/src/routes/index/[tickerID]/history/+page.svelte
+++ b/src/routes/index/[tickerID]/history/+page.svelte
@@ -5,7 +5,6 @@
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
import { Button } from "$lib/components/shadcn/button/index.js";
import { goto } from "$app/navigation";
- import ArrowLogo from "lucide-svelte/icons/move-up-right";
import SEO from "$lib/components/SEO.svelte";
import { onMount } from "svelte";
import { removeCompanyStrings } from "$lib/utils";
@@ -64,33 +63,51 @@
periodStart,
periodKey,
open: entry.open,
+ adjOpen: entry.adjOpen,
high: entry.high,
+ adjHigh: entry.adjHigh,
low: entry.low,
+ adjLow: entry.adjLow,
close: entry.close,
+ adjClose: entry.adjClose,
volume: entry.volume,
};
aggregatedData.push(currentPeriod);
} else {
// Update the current period's values
+ // High values should be the maximum observed so far.
currentPeriod.high = Math.max(currentPeriod.high, entry.high);
+ currentPeriod.adjHigh = Math.max(
+ currentPeriod.adjHigh,
+ entry.adjHigh,
+ );
+ // Low values should be the minimum observed so far.
currentPeriod.low = Math.min(currentPeriod.low, entry.low);
- currentPeriod.close = entry.close; // Update the close to the most recent in the period
+ currentPeriod.adjLow = Math.min(currentPeriod.adjLow, entry.adjLow);
+ // For close values, use the most recent (current) close.
+ currentPeriod.close = entry.close;
+ currentPeriod.adjClose = entry.adjClose;
+ // Sum volumes.
currentPeriod.volume += entry.volume;
}
});
- // Replace Daily data with aggregated data
+ // Replace Daily data with aggregated data including adjusted values
data = aggregatedData.map((period) => ({
time: period.periodStart.toISOString().split("T")[0],
open: period.open,
+ adjOpen: period.adjOpen,
high: period.high,
+ adjHigh: period.adjHigh,
low: period.low,
+ adjLow: period.adjLow,
close: period.close,
+ adjClose: period.adjClose,
volume: period.volume,
}));
}
- // Process the data to add change and changesPercentage
+ // Process the data to add change and changesPercentage (using non-adjusted close values)
const modifiedData = data?.map((entry, index, arr) => {
if (index === 0) {
return { ...entry, change: null, changesPercentage: null };
@@ -102,7 +119,7 @@
previousClose !== 0
? (((currentClose - previousClose) / previousClose) * 100)?.toFixed(2)
: null;
- return { ...entry, change, changesPercentage };
+ return { ...entry, changesPercentage };
});
// Sort the data by "time" from latest to earliest
@@ -130,10 +147,13 @@
$: columns = [
{ key: "time", label: "Date", align: "left" },
{ key: "open", label: "Open", align: "right" },
+ { key: "adjOpen", label: "Adj Open", align: "right" },
{ key: "high", label: "High", align: "right" },
+ { key: "adjHigh", label: "Adj High", align: "right" },
{ key: "low", label: "Low", align: "right" },
+ { key: "adjLow", label: "Adj Low", align: "right" },
{ key: "close", label: "Close", align: "right" },
- { key: "change", label: "Change", align: "right" },
+ { key: "adjClose", label: "Adj Close", align: "right" },
{ key: "changesPercentage", label: "% Change", align: "right" },
{ key: "volume", label: "Volume", align: "right" },
];
@@ -141,10 +161,13 @@
$: sortOrders = {
time: { order: "none", type: "date" },
open: { order: "none", type: "number" },
+ adjOpen: { order: "none", type: "number" },
high: { order: "none", type: "number" },
+ adjHigh: { order: "none", type: "number" },
low: { order: "none", type: "number" },
+ adjLow: { order: "none", type: "number" },
close: { order: "none", type: "number" },
- change: { order: "none", type: "number" },
+ adjClose: { order: "none", type: "number" },
changesPercentage: { order: "none", type: "number" },
volume: { order: "none", type: "number" },
};
@@ -212,19 +235,25 @@
({
time,
open,
+ adjOpen,
high,
+ adjHigh,
low,
+ adjLow,
close,
- change,
+ adjClose,
changesPercentage,
volume,
}) => ({
time,
open,
+ adjOpen,
high,
+ adjHigh,
low,
+ adjLow,
close,
- change,
+ adjClose,
changesPercentage,
volume,
}),
@@ -233,11 +262,13 @@
const csvRows = [];
// Add headers row
- csvRows.push("time,open,high,low,close,change,changesPercentage,volume");
+ csvRows.push(
+ "time,open,adjOpen,high,adjHigh,low,adjLow,close,adjClose,changesPercentage,volume",
+ );
// Add data rows
for (const row of exportList) {
- const csvRow = `${row.time},${row.open},${row.high},${row.low},${row.close},${row.change},${row.changesPercentage},${row.volume}`;
+ const csvRow = `${row.time},${row.open},${row.adjOpen},${row.high},${row.adjHigh},${row.low},${row.adjLow},${row.close},${row.adjClose},${row.changesPercentage},${row.volume}`;
csvRows.push(csvRow);
}
@@ -267,7 +298,7 @@
@@ -279,7 +310,7 @@
|
+
+ {item?.adjOpen !== undefined
+ ? item?.adjOpen?.toFixed(2)
+ : "n/a"}
+ |
{item?.high?.toFixed(2)}
|
+
+ {item?.adjHigh !== undefined && item?.adjHigh
+ ? item?.adjHigh?.toFixed(2)
+ : "n/a"}
+ |
@@ -459,13 +504,24 @@
|
- {item?.close?.toFixed(2)}
+ {item?.adjLow !== undefined && item?.adjLow
+ ? item?.adjLow?.toFixed(2)
+ : "n/a"}
|
- {item?.change !== null ? item?.change : "n/a"}
+ {item?.close?.toFixed(2)}
|
+
+
+ {item?.adjClose !== undefined
+ ? item?.adjClose?.toFixed(2)
+ : "n/a"}
+ |
+
-
-
-
-
diff --git a/src/routes/stocks/[tickerID]/history/+page.svelte b/src/routes/stocks/[tickerID]/history/+page.svelte
index 7c868ea6..38b51301 100644
--- a/src/routes/stocks/[tickerID]/history/+page.svelte
+++ b/src/routes/stocks/[tickerID]/history/+page.svelte
@@ -5,7 +5,6 @@
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
import { Button } from "$lib/components/shadcn/button/index.js";
import { goto } from "$app/navigation";
- import ArrowLogo from "lucide-svelte/icons/move-up-right";
import SEO from "$lib/components/SEO.svelte";
import { onMount } from "svelte";
import { removeCompanyStrings } from "$lib/utils";
@@ -299,7 +298,7 @@
@@ -481,7 +480,9 @@
|
- {item?.adjOpen?.toFixed(2)}
+ {item?.adjOpen !== undefined
+ ? item?.adjOpen?.toFixed(2)
+ : "n/a"}
|
- {item?.adjHigh?.toFixed(2)}
+ {item?.adjHigh !== undefined && item?.adjHigh
+ ? item?.adjHigh?.toFixed(2)
+ : "n/a"}
|
- {item?.adjLow?.toFixed(2)}
+ {item?.adjLow !== undefined && item?.adjLow
+ ? item?.adjLow?.toFixed(2)
+ : "n/a"}
|
- {item?.adjClose?.toFixed(2)}
+ {item?.adjClose !== undefined
+ ? item?.adjClose?.toFixed(2)
+ : "n/a"}
|
|