protect endpoints
This commit is contained in:
parent
c441ce6fd3
commit
2827d4dde3
@ -31,13 +31,12 @@
|
||||
if (cachedData) {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
const postData = { ticker: ticker };
|
||||
const postData = { ticker: ticker, path: 'analyst-insight' };
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + "/analyst-insight", {
|
||||
const response = await fetch("/api/ticker-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -184,12 +184,12 @@ function findLowestAndHighestFee(data, lastDateStr) {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'borrowed-share'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/borrowed-share', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -169,17 +169,17 @@ const getClinicalTrial = async (ticker) => {
|
||||
displayList = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'clinical-trial'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/clinical-trial', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
rawData = await response.json();
|
||||
rawData = await response?.json();
|
||||
displayList = rawData;
|
||||
// Cache the data for this specific tickerID with a specific name 'getClinicalTrial'
|
||||
setCache(ticker, rawData, 'getClinicalTrial');
|
||||
|
||||
@ -106,12 +106,12 @@ const getCorporateLobbing = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'corporate-lobbying'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/corporate-lobbying', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -33,15 +33,15 @@
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
try {
|
||||
const response = await fetch(data?.apiURL+'/correlation-ticker', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify({ ticker })
|
||||
body: JSON.stringify({ ticker:ticker, path: 'correlation-ticker' })
|
||||
});
|
||||
rawData = (await response.json()) || [];
|
||||
rawData = (await response?.json()) || [];
|
||||
+
|
||||
setCache(ticker, rawData, 'getCorrelation');
|
||||
} catch (error) {
|
||||
|
||||
@ -190,13 +190,12 @@ async function getFairPrice(ticker) {
|
||||
fairPrice = cachedData;
|
||||
} else {
|
||||
try {
|
||||
const response = await fetch(data?.apiURL+'/fair-price', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify({ ticker })
|
||||
body: JSON.stringify({ ticker: ticker, path: 'fair-price' })
|
||||
});
|
||||
fairPrice = await response.json();
|
||||
|
||||
|
||||
@ -167,12 +167,12 @@ const getDarkPool = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'dark-pool'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/dark-pool', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -192,7 +192,7 @@ const getDarkPool = async (ticker) => {
|
||||
$: {
|
||||
if($assetType === 'stock' ? $stockTicker :$etfTicker && typeof window !== 'undefined') {
|
||||
isLoaded=false;
|
||||
const ticker = $assetType === 'stock' ? $stockTicker :$etfTicker
|
||||
const ticker = $assetType === 'stock' ? $stockTicker : $etfTicker
|
||||
const asyncFunctions = [
|
||||
getDarkPool(ticker)
|
||||
];
|
||||
|
||||
@ -137,12 +137,12 @@ const getEnterPriseValues = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'enterprise-values'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/enterprise-values', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -6,11 +6,6 @@
|
||||
//export let executiveList;
|
||||
let executiveList = [];
|
||||
|
||||
|
||||
let apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
let isLoaded = false;
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
@ -25,11 +20,11 @@ async function fetchData() {
|
||||
executiveList = $clientSideCache[$stockTicker]?.getExecutives;
|
||||
}
|
||||
else {
|
||||
const postData = { ticker: $stockTicker};
|
||||
const response = await fetch(apiURL+'/get-executives', {
|
||||
const postData = { ticker: $stockTicker, path: 'get-executives'};
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -179,12 +179,12 @@ function findLowestAndHighestPrice(data, lastDateStr) {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'fail-to-deliver'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/fail-to-deliver', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -24,12 +24,12 @@ const getFundamentalAnalysis = async (ticker) => {
|
||||
fundamentalAnalysisDict = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'fundamental-predictor-analysis'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/fundamental-predictor-analysis', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -154,17 +154,17 @@ use([BarChart, GridComponent, CanvasRenderer])
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'government-contract'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/government-contract', {
|
||||
const response = await fetch('/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
rawData = (await response.json());
|
||||
rawData = await response?.json();
|
||||
// Cache the data for this specific tickerID with a specific name 'getGovernmentContract'
|
||||
setCache(ticker, rawData, 'getGovernmentContract');
|
||||
}
|
||||
|
||||
@ -188,17 +188,17 @@ function changeStatement(event)
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'implied-volatility'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/implied-volatility', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
rawData = (await response.json());
|
||||
rawData = await response?.json();
|
||||
// Cache the data for this specific tickerID with a specific name 'getImpliedVolatility'
|
||||
setCache(ticker, rawData, 'getImpliedVolatility');
|
||||
}
|
||||
|
||||
@ -166,17 +166,17 @@ const getMarketMaker = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'market-maker'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/market-maker', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
rawData = await response.json();
|
||||
rawData = await response?.json();
|
||||
// Cache the data for this specific tickerID with a specific name 'getMarketMaker'
|
||||
setCache(ticker, rawData, 'getMarketMaker');
|
||||
}
|
||||
|
||||
@ -42,17 +42,17 @@ const getOptionsBubble = async (ticker) => {
|
||||
optionsDict = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'options-bubble'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/options-bubble', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
optionsDict = await response.json();
|
||||
optionsDict = await response?.json();
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getOptionsBubble'
|
||||
setCache(ticker, optionsDict, 'getOptionsBubble');
|
||||
|
||||
@ -152,12 +152,12 @@
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'options-net-flow-ticker'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/options-net-flow-ticker', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -145,12 +145,12 @@ const getPriceAnalysis = async (ticker) => {
|
||||
priceAnalysisDict = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'price-analysis'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/price-analysis', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -204,12 +204,12 @@ const getRetailVolume = async (ticker) => {
|
||||
historyData = rawData?.history;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'retail-volume'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/retail-volume', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
import InfoModal from "$lib/components/InfoModal.svelte";
|
||||
|
||||
export let userTier;
|
||||
export let apiURL;
|
||||
export let apiKey;
|
||||
|
||||
let isLoaded = false;
|
||||
|
||||
@ -128,18 +126,17 @@
|
||||
if (cachedData) {
|
||||
revenueSegmentation = cachedData;
|
||||
} else {
|
||||
const postData = { ticker: ticker };
|
||||
const postData = { ticker: ticker, path: 'revenue-segmentation' };
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + "/revenue-segmentation", {
|
||||
const response = await fetch("/api/ticker-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
revenueSegmentation = await response.json();
|
||||
revenueSegmentation = await response?.json();
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getRevenueSegmentation'
|
||||
setCache(ticker, revenueSegmentation, "getRevenueSegmentation");
|
||||
|
||||
@ -7,9 +7,6 @@ import { fade } from 'svelte/transition';
|
||||
let secFilingsList;
|
||||
|
||||
|
||||
let apiURL = import.meta.env.VITE_USEAST_API_URL;
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
|
||||
let displayList = [];
|
||||
let accordionOpen = {};
|
||||
@ -86,11 +83,11 @@ async function fetchData() {
|
||||
secFilingsList = $clientSideCache[$stockTicker]?.getSECFilings;
|
||||
}
|
||||
else {
|
||||
const postData = { ticker: $stockTicker};
|
||||
const response = await fetch(apiURL+'/get-sec-filings', {
|
||||
const postData = { ticker: $stockTicker, path: 'get-sec-filings'};
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -5,10 +5,6 @@
|
||||
import { onMount } from 'svelte';
|
||||
import Search from "lucide-svelte/icons/search";
|
||||
|
||||
|
||||
export let apiURL;
|
||||
export let apiKey;
|
||||
|
||||
let dataLoaded = false; // Flag to track data loading
|
||||
|
||||
let assetType = '';
|
||||
@ -27,10 +23,10 @@
|
||||
else {
|
||||
dataLoaded = true;
|
||||
// make the GET request to the endpoint
|
||||
const response = await fetch(apiURL+'/searchbar-data', {
|
||||
const response = await fetch('/api/searchbar-data', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json","X-API-KEY": apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -33,12 +33,12 @@ const getSentimentAnalysis = async (ticker) => {
|
||||
sentimentList = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'sentiment-analysis'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/sentiment-analysis', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -91,12 +91,12 @@ const getShareholders = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'shareholders'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/shareholders', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -121,17 +121,17 @@ const getShareStatistics = async (ticker) => {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'share-statistics'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/share-statistics', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
rawData = await response.json();
|
||||
rawData = await response?.json();
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getShareStatistics'
|
||||
setCache(ticker, rawData, 'getShareStatistics');
|
||||
|
||||
@ -170,19 +170,19 @@
|
||||
return option;
|
||||
}
|
||||
|
||||
async function getSwapData(ticker) {
|
||||
async function getSwapData(ticker) {
|
||||
const cachedData = getCache(ticker, 'getSwapData');
|
||||
if (cachedData) {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
try {
|
||||
const response = await fetch(`${data?.apiURL}/swap-ticker`, {
|
||||
const postData = {ticker: ticker, path: 'swap-ticker'}
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify({ ticker })
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
if (!response.ok) throw new Error('API request failed');
|
||||
rawData = await response.json();
|
||||
@ -194,7 +194,6 @@
|
||||
}
|
||||
$swapComponent = rawData?.length !== 0;
|
||||
}
|
||||
|
||||
|
||||
$: if ($stockTicker && typeof window !== 'undefined') {
|
||||
isLoaded = false;
|
||||
|
||||
@ -28,15 +28,14 @@ async function getTaRating(ticker) {
|
||||
rawData = cachedData;
|
||||
} else {
|
||||
try {
|
||||
const response = await fetch(data?.apiURL+'/stock-rating', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey
|
||||
},
|
||||
body: JSON.stringify({ ticker })
|
||||
body: JSON.stringify({ ticker: ticker, path: 'stock-rating' })
|
||||
});
|
||||
rawData = await response.json();
|
||||
rawData = await response?.json();
|
||||
|
||||
setCache(ticker, rawData, 'getTaRating');
|
||||
} catch (error) {
|
||||
|
||||
@ -34,12 +34,12 @@ const getTrendAnalysis = async (ticker) => {
|
||||
trendList = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, path: 'trend-analysis'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/trend-analysis', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -113,12 +113,12 @@ function getPlotOptions() {
|
||||
varDict = cachedData;
|
||||
} else {
|
||||
|
||||
const postData = {'ticker': ticker};
|
||||
const postData = {'ticker': ticker, 'path': 'value-at-risk'};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/value-at-risk', {
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -6,9 +6,7 @@
|
||||
import InfoModal from '$lib/components/InfoModal.svelte';
|
||||
|
||||
export let watchListId;
|
||||
export let apiKey;
|
||||
export let apiURL;
|
||||
|
||||
|
||||
|
||||
|
||||
const sortTickersByName = (tickerList) => {
|
||||
@ -126,18 +124,18 @@ async function getWatchlistData()
|
||||
const postData = {'watchListId': watchListId}
|
||||
|
||||
|
||||
const response = await fetch(apiURL+'/get-watchlist', {
|
||||
const response = await fetch('/api/get-watchlist', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json","X-API-KEY": apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
const output = await response?.json();
|
||||
|
||||
try {
|
||||
watchList = sortTickersByChange(output[0]);
|
||||
watchList = sortTickersByChange(output?.at(0));
|
||||
}
|
||||
catch(e) {
|
||||
watchList = []
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
export const load = ({ locals, cookies }) => {
|
||||
const { user, isUSRegion, apiURL, fastifyURL, wsURL, apiKey } = locals;
|
||||
const { user, isUSRegion, wsURL } = locals;
|
||||
|
||||
return {
|
||||
user: user || undefined,
|
||||
isUSRegion,
|
||||
cookieConsent: cookies?.get("cookie-consent"),
|
||||
apiURL,
|
||||
fastifyURL,
|
||||
wsURL,
|
||||
apiKey,
|
||||
};
|
||||
};
|
||||
|
||||
@ -628,7 +628,7 @@ $: {
|
||||
autocomplete="off"
|
||||
/>
|
||||
-->
|
||||
<Searchbar apiURL={data?.apiURL} apiKey={data?.apiKey}/>
|
||||
<Searchbar/>
|
||||
|
||||
<NotificationBell
|
||||
data={data}
|
||||
|
||||
24
src/routes/api/earnings-call-transcripts/+server.ts
Normal file
24
src/routes/api/earnings-call-transcripts/+server.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = {
|
||||
ticker: data?.ticker,
|
||||
quarter: data?.quarter,
|
||||
year: data?.year,
|
||||
};
|
||||
const response = await fetch(apiURL + "/earnings-call-transcripts", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/export-price-data/+server.ts
Normal file
20
src/routes/api/export-price-data/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
|
||||
const response = await fetch(apiURL + "/export-price-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/get-watchlist/+server.ts
Normal file
20
src/routes/api/get-watchlist/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { watchListId: data?.watchListId };
|
||||
const response = await fetch(apiURL + "/get-watchlist", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/historical-price/+server.ts
Normal file
20
src/routes/api/historical-price/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { ticker: data?.ticker, timePeriod: data?.timePeriod };
|
||||
const response = await fetch(apiURL + "/historical-price", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/info-text/+server.ts
Normal file
20
src/routes/api/info-text/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { parameter: data?.parameter };
|
||||
const response = await fetch(apiURL + "/info-text", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/options-daily-transactions/+server.ts
Normal file
20
src/routes/api/options-daily-transactions/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { transactionId: data?.transactionId };
|
||||
const response = await fetch(apiURL + "/options-daily-transactions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
17
src/routes/api/searchbar-data/+server.ts
Normal file
17
src/routes/api/searchbar-data/+server.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const response = await fetch(apiURL + "/searchbar-data", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
});
|
||||
|
||||
const output = await response?.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
21
src/routes/api/stock-screener-data/+server.ts
Normal file
21
src/routes/api/stock-screener-data/+server.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { ruleOfList: data?.ruleOfList };
|
||||
|
||||
const response = await fetch(apiURL + "/stock-screener-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response?.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
20
src/routes/api/ticker-data/+server.ts
Normal file
20
src/routes/api/ticker-data/+server.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async ({ request, locals }) => {
|
||||
const data = await request.json();
|
||||
const { apiURL, apiKey } = locals;
|
||||
|
||||
const postData = { ticker: data?.ticker };
|
||||
const response = await fetch(apiURL + "/" + data?.path, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = await response.json();
|
||||
|
||||
return new Response(JSON.stringify(output));
|
||||
};
|
||||
@ -25,10 +25,10 @@ async function loadSearchData() {
|
||||
else {
|
||||
|
||||
// make the GET request to the endpoint
|
||||
const response = await fetch(data?.apiURL+'/searchbar-data', {
|
||||
const response = await fetch('/api/searchbar-data', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json","X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -291,10 +291,10 @@
|
||||
timePeriod: timePeriod,
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL+'/historical-price', {
|
||||
const response = await fetch('/api/historical-price', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -1,153 +0,0 @@
|
||||
// lib/workers/test.ts
|
||||
|
||||
let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
|
||||
|
||||
async function getOneDayPrice(ticker: string, apiURL: string) {
|
||||
let oneDayPrice = [];
|
||||
|
||||
try {
|
||||
const postData = { ticker: ticker };
|
||||
const response = await fetch(apiURL + "/one-day-price", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
oneDayPrice = await response.json();
|
||||
|
||||
oneDayPrice = oneDayPrice?.map((item) => ({
|
||||
time: Date.parse(item?.time),
|
||||
open: item?.open !== null ? item?.open : NaN,
|
||||
high: item?.high !== null ? item?.high : NaN,
|
||||
low: item?.low !== null ? item?.low : NaN,
|
||||
close: item?.close !== null ? item?.close : NaN,
|
||||
}));
|
||||
|
||||
// Set worker status to finished and send chart data
|
||||
return oneDayPrice;
|
||||
} catch (error) {
|
||||
// Set worker status to idle and send error message
|
||||
return oneDayPrice;
|
||||
}
|
||||
}
|
||||
|
||||
async function getHistoricalPrice(ticker: string, apiURL: string) {
|
||||
let oneWeekPrice;
|
||||
let oneMonthPrice;
|
||||
let sixMonthPrice;
|
||||
let oneYearPrice;
|
||||
let threeYearPrice;
|
||||
|
||||
try {
|
||||
const postData = { ticker: ticker };
|
||||
const response = await fetch(apiURL + "/historical-price", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const pastPriceList = await response.json();
|
||||
|
||||
oneWeekPrice = pastPriceList["1W"]?.map(
|
||||
({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}),
|
||||
);
|
||||
oneMonthPrice = pastPriceList["1M"]?.map(
|
||||
({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}),
|
||||
);
|
||||
sixMonthPrice = pastPriceList["6M"]?.map(
|
||||
({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}),
|
||||
);
|
||||
oneYearPrice = pastPriceList["1Y"]?.map(
|
||||
({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}),
|
||||
);
|
||||
threeYearPrice = pastPriceList["MAX"]?.map(
|
||||
({ time, open, high, low, close }) => ({
|
||||
time: Date.parse(time),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
}),
|
||||
);
|
||||
|
||||
// Set worker status to finished and send chart data
|
||||
return {
|
||||
oneWeekPrice,
|
||||
oneMonthPrice,
|
||||
sixMonthPrice,
|
||||
oneYearPrice,
|
||||
threeYearPrice,
|
||||
pastPriceList,
|
||||
};
|
||||
} catch (error) {
|
||||
// Set worker status to idle and send error message
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
onmessage = async (event: MessageEvent) => {
|
||||
const ticker = event.data?.message?.ticker;
|
||||
const apiURL = event.data?.message?.apiURL;
|
||||
//console.log(ticker, apiURL);
|
||||
try {
|
||||
const [output, oneDayPrice] = await Promise.all([
|
||||
getHistoricalPrice(ticker, apiURL),
|
||||
getOneDayPrice(ticker, apiURL),
|
||||
]);
|
||||
|
||||
const oneWeekPrice = output?.oneWeekPrice;
|
||||
const oneMonthPrice = output?.oneMonthPrice;
|
||||
const sixMonthPrice = output?.sixMonthPrice;
|
||||
const oneYearPrice = output?.oneYearPrice;
|
||||
const threeYearPrice = output?.threeYearPrice;
|
||||
const pastPriceList = output?.pastPriceList;
|
||||
|
||||
const chartData = {
|
||||
oneDayPrice,
|
||||
oneWeekPrice,
|
||||
oneMonthPrice,
|
||||
sixMonthPrice,
|
||||
oneYearPrice,
|
||||
threeYearPrice,
|
||||
pastPriceList,
|
||||
};
|
||||
//console.log(pastPriceList)
|
||||
postMessage({ message: "success", chartData });
|
||||
} catch (e) {
|
||||
postMessage({ message: "error", e });
|
||||
}
|
||||
// Sending data back to the main thread
|
||||
//postMessage({ message: 'Data received in the worker'});
|
||||
};
|
||||
|
||||
export {};
|
||||
@ -29,10 +29,10 @@ async function loadSearchData() {
|
||||
else {
|
||||
|
||||
// make the GET request to the endpoint
|
||||
const response = await fetch(data?.apiURL+'/searchbar-data', {
|
||||
const response = await fetch('/api/searchbar-data', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json","X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -318,10 +318,10 @@ async function historicalPrice(timePeriod:string) {
|
||||
timePeriod: timePeriod,
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL+'/historical-price', {
|
||||
const response = await fetch('/api/historical-price', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -416,11 +416,11 @@ async function initializePrice() {
|
||||
async function getPrePostQuote() {
|
||||
|
||||
if(!$isOpen) {
|
||||
const postData = { ticker: $etfTicker};
|
||||
const response = await fetch(data?.apiURL+'/pre-post-quote', {
|
||||
const postData = { ticker: $etfTicker, path: 'pre-post-quote'};
|
||||
const response = await fetch('/api/ticker-data', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
@ -729,16 +729,15 @@ async function initializePrice() {
|
||||
timePeriod: timePeriod,
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL + "/export-price-data", {
|
||||
const response = await fetch("/api/export-price-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
const output = (await response?.json()) ?? [];
|
||||
const output = await response?.json() ?? [];
|
||||
|
||||
setCache($etfTicker, output, "exportPriceData" + timePeriod);
|
||||
return output;
|
||||
|
||||
@ -31,16 +31,15 @@ let activeIdx = 0;
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + "/options-daily-transactions", {
|
||||
const response = await fetch("/api/options-daily-transactions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
output = await response.json();
|
||||
output = await response?.json();
|
||||
|
||||
setCache(transactionId, output, "getDailyTransactions");
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ async function getInfoText(parameter, title) {
|
||||
infoText = cachedData;
|
||||
} else {
|
||||
const postData = { parameter };
|
||||
const response = await fetch(data?.apiURL + "/info-text", {
|
||||
const response = await fetch("/api/info-text", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@ -406,7 +406,7 @@ const loadWorker = async () => {
|
||||
};
|
||||
|
||||
const updateStockScreenerData = async () => {
|
||||
downloadWorker.postMessage({ ruleOfList: ruleOfList, apiURL: data?.apiURL, apiKey: data?.apiKey });
|
||||
downloadWorker.postMessage({ ruleOfList: ruleOfList});
|
||||
};
|
||||
|
||||
function handleAddRule() {
|
||||
|
||||
@ -22,7 +22,7 @@ const getStockScreenerData = async (rules, apiKey, apiURL) => {
|
||||
// Function to check and add missing EMA parameters
|
||||
const ensureAllEmaParameters = (params) => {
|
||||
const includedEmaParameters = params.filter((param) =>
|
||||
emaParameters.includes(param),
|
||||
emaParameters.includes(param)
|
||||
);
|
||||
if (includedEmaParameters.length > 0) {
|
||||
emaParameters.forEach((param) => {
|
||||
@ -47,11 +47,10 @@ const getStockScreenerData = async (rules, apiKey, apiURL) => {
|
||||
|
||||
// Fetch new data if it's not in the cache
|
||||
const postData = { ruleOfList: getRuleOfList };
|
||||
const response = await fetch(apiURL + "/stock-screener-data", {
|
||||
const response = await fetch("/api/stock-screener-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
@ -76,9 +75,9 @@ onmessage = async (event) => {
|
||||
value !== undefined &&
|
||||
(typeof value !== "object" ||
|
||||
Object.values(value)?.every(
|
||||
(subValue) => subValue !== null && subValue !== undefined,
|
||||
)),
|
||||
),
|
||||
(subValue) => subValue !== null && subValue !== undefined
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
postMessage({ message: "success", stockScreenerData });
|
||||
|
||||
@ -17,11 +17,10 @@
|
||||
return;
|
||||
} else {
|
||||
// make the GET request to the endpoint
|
||||
const response = await fetch(data?.apiURL + "/searchbar-data", {
|
||||
const response = await fetch("/api/searchbar-data", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -280,11 +280,10 @@ async function historicalPrice(timePeriod: string) {
|
||||
timePeriod: timePeriod,
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL + "/historical-price", {
|
||||
const response = await fetch("/api/historical-price", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
@ -375,12 +374,11 @@ async function historicalPrice(timePeriod: string) {
|
||||
|
||||
async function getPrePostQuote() {
|
||||
if (!$isOpen) {
|
||||
const postData = { ticker: $stockTicker };
|
||||
const response = await fetch(data?.apiURL + "/pre-post-quote", {
|
||||
const postData = { ticker: $stockTicker, path: 'pre-post-quote' };
|
||||
const response = await fetch("/api/ticker-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
@ -605,7 +603,7 @@ async function historicalPrice(timePeriod: string) {
|
||||
timePeriod: timePeriod,
|
||||
};
|
||||
|
||||
const response = await fetch(data?.apiURL + "/export-price-data", {
|
||||
const response = await fetch("/api/export-price-data", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@ -41,10 +41,10 @@
|
||||
year: year
|
||||
};
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + '/earnings-call-transcripts', {
|
||||
const response = await fetch('/api/earnings-call-transcripts', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
"Content-Type": "application/json", "X-API-KEY": data?.apiKey
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(postData)
|
||||
});
|
||||
|
||||
@ -31,11 +31,10 @@ let activeIdx = 0;
|
||||
};
|
||||
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(data?.apiURL + "/options-daily-transactions", {
|
||||
const response = await fetch("/api/options-daily-transactions", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": data?.apiKey,
|
||||
},
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
@ -208,7 +208,7 @@ updateYearRange()
|
||||
<!--Start RevenueSegmentation-->
|
||||
<Lazy>
|
||||
<div class="w-full pt-10 sm:pb-6 sm:pt-6 m-auto {!$revenueSegmentationComponent ? 'hidden' : ''}">
|
||||
<RevenueSegmentation apiURL={data?.apiURL} apiKey={data?.apiKey} userTier={data?.user?.tier} />
|
||||
<RevenueSegmentation userTier={data?.user?.tier} />
|
||||
</div>
|
||||
</Lazy>
|
||||
<!--End RevenueSegmentation-->
|
||||
|
||||
@ -1,209 +0,0 @@
|
||||
<script lang='ts'>
|
||||
import { goto } from '$app/navigation';
|
||||
import { screenWidth, numberOfUnreadNotification, etfTicker, stockTicker } from '$lib/store';
|
||||
import { abbreviateNumber} from '$lib/utils';
|
||||
import logo from '$lib/images/trending_logo.png';
|
||||
import { fly } from 'svelte/transition';
|
||||
|
||||
import InfiniteLoading from '$lib/components/InfiniteLoading.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
let rawData = data?.getTrendingStocks;
|
||||
let trendingList = rawData?.slice(0,20);
|
||||
|
||||
async function infiniteHandler({ detail: { loaded, complete } })
|
||||
{
|
||||
if (trendingList?.length === rawData?.length) {
|
||||
complete();
|
||||
} else {
|
||||
const nextIndex = trendingList?.length;
|
||||
const newArticles = rawData?.slice(nextIndex, nextIndex + 5);
|
||||
trendingList = [...trendingList, ...newArticles];
|
||||
loaded();
|
||||
}
|
||||
}
|
||||
|
||||
async function assetSelector(symbol, assetType)
|
||||
{
|
||||
if(assetType === 'etf')
|
||||
{
|
||||
etfTicker.update(value => symbol);
|
||||
goto(`/etf/${symbol}`)
|
||||
}
|
||||
else if(assetType === 'stock') {
|
||||
stockTicker.update(value => symbol);
|
||||
goto(`/stocks/${symbol}`)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
let charNumber = 25;
|
||||
|
||||
$: {
|
||||
if ($screenWidth < 640)
|
||||
{
|
||||
charNumber = 11;
|
||||
}
|
||||
else {
|
||||
charNumber = 25;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<!-- HEADER FOR BETTER SEO -->
|
||||
<svelte:head>
|
||||
<title> {$numberOfUnreadNotification > 0 ? `(${$numberOfUnreadNotification})` : ''} Today's Top Trending Stocks · stocknear</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
|
||||
<meta name="description" content="A list of the most popular stocks today based on pageviews. The list is updated every 15 min.">
|
||||
<!-- Other meta tags -->
|
||||
<meta property="og:title" content="Today's Top Trending Stocks · stocknear"/>
|
||||
<meta property="og:description" content="A list of the most popular stocks today based on pageviews. The list is updated every 15 min.">
|
||||
<meta property="og:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<!-- Add more Open Graph meta tags as needed -->
|
||||
|
||||
<!-- Twitter specific meta tags -->
|
||||
<meta name="twitter:card" content="summary_large_image"/>
|
||||
<meta name="twitter:title" content="Today's Top Trending Stocks · stocknear"/>
|
||||
<meta name="twitter:description" content="A list of the most popular stocks today based on pageviews. The list is updated every 15 min.">
|
||||
<meta name="twitter:image" content="https://stocknear-pocketbase.s3.amazonaws.com/logo/meta_logo.jpg"/>
|
||||
<!-- Add more Twitter meta tags as needed -->
|
||||
</svelte:head>
|
||||
|
||||
|
||||
<section in:fly={{ x: -10, duration: 150, delay:150 }} out:fly={{ x: 5, duration: 150 }} class="w-full max-w-4xl overflow-hidden m-auto min-h-screen pt-5 pb-40">
|
||||
<!--
|
||||
<div class="text-sm breadcrumbs ml-4">
|
||||
<ul>
|
||||
<li><a href="/" class="text-gray-300">Home</a></li>
|
||||
<li class="text-gray-300">Today's Top Trending Stocks</li>
|
||||
</ul>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="w-full max-w-4xl m-auto sm:bg-[#09090B] sm:rounded-xl h-auto pl-10 pr-10 pt-5 sm:pb-10 sm:pt-10 mt-3 mb-8">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-10">
|
||||
|
||||
<!-- Start Column -->
|
||||
<div>
|
||||
<div class="flex flex-row justify-center items-center">
|
||||
<h1 class="text-3xl sm:text-4xl text-white text-center font-bold mb-5">
|
||||
Trending Stocks
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<span class="text-white text-md font-medium text-center flex justify-center items-center ">
|
||||
Get the latest data on the top-viewed stock in the last 24 hours.
|
||||
</span>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- End Column -->
|
||||
|
||||
<!-- Start Column -->
|
||||
<div class="hidden sm:block relative m-auto mb-5 mt-5 sm:mb-0 sm:mt-0">
|
||||
<svg class="w-40 -my-10" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<filter id="glow">
|
||||
<feGaussianBlur stdDeviation="5" result="glow"/>
|
||||
<feMerge>
|
||||
<feMergeNode in="glow"/>
|
||||
<feMergeNode in="SourceGraphic"/>
|
||||
</feMerge>
|
||||
</filter>
|
||||
</defs>
|
||||
<path fill="#1E40AF" d="M57.6,-58.7C72.7,-42.6,81.5,-21.3,82,0.5C82.5,22.3,74.7,44.6,59.7,60.1C44.6,75.6,22.3,84.3,0,84.3C-22.3,84.2,-44.6,75.5,-61.1,60.1C-77.6,44.6,-88.3,22.3,-87.6,0.7C-86.9,-20.8,-74.7,-41.6,-58.2,-57.7C-41.6,-73.8,-20.8,-85.2,0.2,-85.4C21.3,-85.6,42.6,-74.7,57.6,-58.7Z" transform="translate(100 100)" filter="url(#glow)" />
|
||||
</svg>
|
||||
|
||||
|
||||
<div class="z-1 absolute -top-7 right-11">
|
||||
<img class="w-20" src={logo} alt="logo" loading="lazy">
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Column -->
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Page wrapper -->
|
||||
<div class="flex justify-center w-full max-w-5xl m-auto h-full overflow-hidden">
|
||||
|
||||
|
||||
|
||||
<!-- Content area -->
|
||||
<div class="w-screen sm:w-full relative flex flex-col flex-1 overflow-hidden overflow-x-auto">
|
||||
<table class="table table-sm sm:table-md table-compact rounded-none sm:rounded-md w-full border-bg-[#09090B] m-auto mt-4 overflow-x-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="text-slate-200 font-medium text-sm text-start">No.</td>
|
||||
<th class="text-slate-200 font-medium text-sm text-start">Symbol</th>
|
||||
<td class="text-slate-200 hidden sm:table-cell font-medium text-sm text-start">Company Name</td>
|
||||
<td class="text-slate-200 font-medium text-sm text-end">Views</td>
|
||||
<td class="text-slate-200 font-medium text-sm text-end">Market Cap</td>
|
||||
<td class="text-slate-200 font-medium text-end text-sm">Volume</td>
|
||||
<td class="text-slate-200 font-medium text-sm text-end">EPS</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each trendingList as item,index}
|
||||
<!-- row -->
|
||||
<tr on:click={() => assetSelector(item?.symbol, item?.assetType)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer">
|
||||
|
||||
<td class="text-gray-200 pb-3 text-md text-start">
|
||||
{index+1}
|
||||
</td>
|
||||
|
||||
<th class="text-blue-400 font-normal">
|
||||
{item?.symbol}
|
||||
</th>
|
||||
|
||||
<td class="text-gray-200 pb-3 hidden sm:table-cell">
|
||||
{item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name}
|
||||
</td>
|
||||
|
||||
<td class="text-end text-white">
|
||||
{item?.views}
|
||||
</td>
|
||||
|
||||
<td class="text-white text-end">
|
||||
{item?.marketCap !== null ? abbreviateNumber(item?.marketCap,true) : '-'}
|
||||
</td>
|
||||
|
||||
<td class="text-white text-end">
|
||||
{item?.volume !== null ? abbreviateNumber(item?.volume) : '-'}
|
||||
</td>
|
||||
|
||||
<td class="text-white text-end w-10">
|
||||
{item?.eps !== null ? item?.eps?.toFixed(2) : '-'}
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<InfiniteLoading on:infinite={infiniteHandler} />
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
import { getCache, setCache } from "$lib/store";
|
||||
|
||||
export const load = async ({ parent }) => {
|
||||
const getTrendingStocks = async () => {
|
||||
let output;
|
||||
|
||||
// Get cached data for the specific tickerID
|
||||
const cachedData = getCache("", "getTrendingStocks");
|
||||
if (cachedData) {
|
||||
output = cachedData;
|
||||
} else {
|
||||
const { apiKey, apiURL } = await parent();
|
||||
// make the POST request to the endpoint
|
||||
const response = await fetch(apiURL + "/trending", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-API-KEY": apiKey,
|
||||
},
|
||||
});
|
||||
|
||||
output = await response.json();
|
||||
|
||||
// Cache the data for this specific tickerID with a specific name 'getTrendingStocks'
|
||||
setCache("", output, "getTrendingStocks");
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// Make sure to return a promise
|
||||
return {
|
||||
getTrendingStocks: await getTrendingStocks(),
|
||||
};
|
||||
};
|
||||
@ -511,8 +511,6 @@ onDestroy( () => {
|
||||
|
||||
<WatchListCard
|
||||
watchListId={displayWatchList?.id}
|
||||
apiURL = {data?.apiURL}
|
||||
apiKey = {data?.apiKey}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user