Skip to content

Commit

Permalink
add functionality to analyze single quote
Browse files Browse the repository at this point in the history
  • Loading branch information
madnight committed Jan 14, 2024
1 parent 49f6d7e commit 1b847e6
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,40 @@ <h2>NDX Nasdaq-100</h2>
}

// Call the function to fetch and display the data
getQQQHoldings();

// check if site has a query parameter
const urlParams = new URLSearchParams(window.location.search);
const tickers = urlParams.get('quotes');




if (tickers) {
// Split the tickers into an array, even if there's only one ticker without commas
const tickerArray = tickers.split(',').map(ticker => ticker.trim()); // Trim whitespace from each ticker

// Loop through each ticker and make a request to the finance API
let index = 0;
tickerArray.forEach(ticker => {
const url = "https://finance.beuke.org/quote/" + ticker;
fetch(url)
.then(response => response.json())
.then(data => {
const tableBody = document.getElementById('stockTable').getElementsByTagName('tbody')[0];
const spinner = document.getElementById('loadingSpinner');
console.log(data);
addCells(data, index); // You need to define this function to add data to the table
index = index + 1;
spinner.style.display = 'none';
stockTable.style.display = 'table';
})
.catch(error => {
console.error('Error fetching data for ticker:', ticker, error);
});
});
} else {
getQQQHoldings();
}
</script>

</body>
Expand Down

0 comments on commit 1b847e6

Please sign in to comment.