work on intraday
This commit is contained in:
parent
960daf4cad
commit
c9a679d9a5
6 changed files with 197 additions and 85 deletions
|
|
@ -10,7 +10,7 @@ export const QM_SESSION_IDS = {
|
|||
SYMBOL: '1e1d7cb1de1fd2fe52684abdea41a446919a5fe12776dfab88615ac1ce1ec2f6', // getProfiles
|
||||
PRICES: '5ad521e05faf5778d567f6d0012ec34d6cdbaeb2462f41568f66558bc7b4ced9', // getEnhancedChartData
|
||||
FINANCIALS: '4e4f1565fb7c9f2a8b4b32b9aa3137af684f3da8a2ce97799d3a7117b14f07be', // getFinancialsEnhancedBySymbol
|
||||
FILINGS: 'a863d519e38f80e45d10e280fb1afc729816e23f0218db2f3e8b23005a9ad8dd', // getCompanyFilings
|
||||
// FILINGS: 'a863d519e38f80e45d10e280fb1afc729816e23f0218db2f3e8b23005a9ad8dd', // getCompanyFilings
|
||||
// INTRADAY: '', //
|
||||
// '5ad521e05faf5778d567f6d0012ec34d6cdbaeb2462f41568f66558bc7b4ced9' // getEhnachedChartData
|
||||
// '5ad521e05faf5778d567f6d0012ec34d6cdbaeb2462f41568f66558bc7b4ced9': [], //4488d072b
|
||||
|
|
@ -50,7 +50,19 @@ export const SESSION_CONFIG = {
|
|||
API_TIMEOUT: 30000, // 15 seconds
|
||||
} as const;
|
||||
|
||||
export function getQmHeaders(): Record<string, string> {
|
||||
export function getQmHeaders(type?: string): Record<string, string> {
|
||||
// if(type?.toUpperCase() === 'FILINGS') {
|
||||
// return {
|
||||
// 'User-Agent': getRandomUserAgent(),
|
||||
// Accept: '*/*',
|
||||
// 'Accept-Language': 'en-US,en;q=0.5',
|
||||
// 'Sec-Fetch-Mode': 'cors',
|
||||
// Origin: 'https://client.quotemedia.com',
|
||||
// Referer: 'https://client.quotemedia.com/',
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
// };
|
||||
// }
|
||||
|
||||
return {
|
||||
'User-Agent': getRandomUserAgent(),
|
||||
Accept: '*/*',
|
||||
|
|
@ -60,3 +72,55 @@ export function getQmHeaders(): Record<string, string> {
|
|||
Referer: 'https://www.quotemedia.com/',
|
||||
};
|
||||
}
|
||||
|
||||
function parseLocalDate(dateString: string): Date {
|
||||
const [year, month, day] = dateString.split('-').map(Number);
|
||||
return new Date(year || 0, (month || 0) - 1, day);
|
||||
}
|
||||
|
||||
// Get start of week (Monday)
|
||||
export function getWeekStart(dateInput: Date | string): Date {
|
||||
// Handle string input properly
|
||||
let date: Date;
|
||||
if (typeof dateInput === 'string') {
|
||||
date = parseLocalDate(dateInput);
|
||||
} else {
|
||||
// Create new date with local time components
|
||||
date = new Date(dateInput.getFullYear(), dateInput.getMonth(), dateInput.getDate());
|
||||
}
|
||||
|
||||
const day = date.getDay();
|
||||
|
||||
if (day !== 1) {
|
||||
const diff = date.getDate() - day + (day === 0 ? -6 : 1);
|
||||
date.setDate(diff);
|
||||
}
|
||||
|
||||
date.setHours(0, 0, 0, 0);
|
||||
return date;
|
||||
}
|
||||
|
||||
// Get end of week (Sunday)
|
||||
export function getWeekEnd(dateInput: Date | string): Date {
|
||||
let date: Date;
|
||||
|
||||
// Handle string input properly
|
||||
if (typeof dateInput === 'string') {
|
||||
date = parseLocalDate(dateInput);
|
||||
} else {
|
||||
// Create new date with local time components
|
||||
date = new Date(dateInput.getFullYear(), dateInput.getMonth(), dateInput.getDate());
|
||||
}
|
||||
|
||||
const day = date.getDay();
|
||||
|
||||
// If not already Sunday, calculate days until Sunday
|
||||
if (day !== 0) {
|
||||
const daysToSunday = 7 - day;
|
||||
date.setDate(date.getDate() + daysToSunday);
|
||||
}
|
||||
|
||||
// Set to end of day
|
||||
date.setHours(23, 59, 59, 999);
|
||||
return date;
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
export interface QMSession {
|
||||
uuid: string; // Unique identifier for the session
|
||||
proxy: string;
|
||||
headers: HeadersInit;
|
||||
headers: Record<string, string>; // Headers to use for requests
|
||||
successfulCalls: number;
|
||||
failedCalls: number;
|
||||
lastUsed: Date;
|
||||
|
|
@ -49,7 +49,7 @@ export interface QMAuthResponse {
|
|||
export interface CachedSession {
|
||||
uuid: string;
|
||||
proxy: string;
|
||||
headers: HeadersInit;
|
||||
headers: Record<string, string>;
|
||||
successfulCalls: number;
|
||||
failedCalls: number;
|
||||
lastUsed: string; // ISO string for Redis storage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue