Skip to content

Commit 65f78c4

Browse files
api change
change daily adjusted api to weekly adjusted because it was premium
1 parent c6fd27c commit 65f78c4

File tree

3 files changed

+23
-114
lines changed

3 files changed

+23
-114
lines changed

Diff for: package-lock.json

+13-106
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@testing-library/react": "^13.4.0",
88
"@testing-library/user-event": "^13.5.0",
99
"chart.js": "^4.2.1",
10+
"dotenv": "^16.0.3",
1011
"plotly.js": "^2.21.0",
1112
"plotly.js-dist": "^2.21.0",
1213
"react": "^18.2.0",

Diff for: src/components/Analytics.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const Analytics = () => {
4343
const fetchStock = async () => {
4444
const API_KEY = process.env.API_KEY_FOR_ST_DATA_AND_ST_TOCKEN
4545
const Stock_Symbol = inputValue;
46-
// const Stock_Symbol = "POLYPLEX.BSE"
46+
// const Stock_Symbol = "APPH.DEX"
4747
console.log(Stock_Symbol);
48-
const API_Call_Stock = `https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol=${Stock_Symbol}&outputsize=full&apikey=${API_KEY}`;
48+
const API_Call_Stock = `https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY_ADJUSTED&symbol=${Stock_Symbol}&outputsize=full&apikey=${API_KEY}`;
4949
try {
5050
const res_stock = await fetch(API_Call_Stock);
5151
const data_stock = await res_stock.json();
@@ -56,17 +56,18 @@ const Analytics = () => {
5656
const stockChartOpenValues = [];
5757
const stockChartCloseValues = [];
5858

59-
for (let key in data_stock["Time Series (Daily)"]) {
60-
if (key >= "2020-01-01") {
59+
for (let key in data_stock["Weekly Adjusted Time Series"]) {
60+
if (key >= "2019-01-01") {
61+
// console.log("Valid date key:", key);
6162
stockChartXValuesFunction.push(key);
6263
stockChartYValuesFunction.push(
63-
data_stock["Time Series (Daily)"][key]["4. close"]
64+
data_stock["Weekly Adjusted Time Series"][key]["4. close"]
6465
);
6566
stockChartOpenValues.push(
66-
data_stock["Time Series (Daily)"][key]["1. open"]
67+
data_stock["Weekly Adjusted Time Series"][key]["1. open"]
6768
);
6869
stockChartCloseValues.push(
69-
data_stock["Time Series (Daily)"][key]["4. close"]
70+
data_stock["Weekly Adjusted Time Series"][key]["4. close"]
7071
);
7172
}
7273
}
@@ -95,7 +96,7 @@ const Analytics = () => {
9596
if (noHikeDay === false) {
9697
console.log("no data with given hike");
9798
}
98-
// console.log(stockChartYValuesFunction);
99+
console.log(stockChartYValuesFunction);
99100
setStockChartXValues(stockChartXValuesFunction);
100101
setStockChartYValues(stockChartYValuesFunction);
101102
setStockChartColors(stockChartColors);

0 commit comments

Comments
 (0)