about to start
This commit is contained in:
parent
11eb470e5f
commit
133f37e755
3 changed files with 14 additions and 16 deletions
|
|
@ -77,8 +77,8 @@
|
||||||
"port": 6379,
|
"port": 6379,
|
||||||
"db": 1
|
"db": 1
|
||||||
},
|
},
|
||||||
"workers": 1,
|
"workers": 10,
|
||||||
"concurrency": 1,
|
"concurrency": 4,
|
||||||
"enableScheduledJobs": true,
|
"enableScheduledJobs": true,
|
||||||
"defaultJobOptions": {
|
"defaultJobOptions": {
|
||||||
"attempts": 3,
|
"attempts": 3,
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ export async function updatePrices(
|
||||||
input: {
|
input: {
|
||||||
qmSearchCode: string;
|
qmSearchCode: string;
|
||||||
lastRecordDate?: Date;
|
lastRecordDate?: Date;
|
||||||
|
symbol: string;
|
||||||
|
exchange: string;
|
||||||
},
|
},
|
||||||
_context?: ExecutionContext
|
_context?: ExecutionContext
|
||||||
): Promise<{
|
): Promise<{
|
||||||
|
|
@ -38,7 +40,7 @@ export async function updatePrices(
|
||||||
message: string;
|
message: string;
|
||||||
data?: any;
|
data?: any;
|
||||||
}> {
|
}> {
|
||||||
const { qmSearchCode, lastRecordDate } = input;
|
const { qmSearchCode, lastRecordDate, symbol, exchange } = input;
|
||||||
|
|
||||||
this.logger.info(`Fetching daily prices ${qmSearchCode}`, { qmSearchCode });
|
this.logger.info(`Fetching daily prices ${qmSearchCode}`, { qmSearchCode });
|
||||||
|
|
||||||
|
|
@ -70,8 +72,6 @@ export async function updatePrices(
|
||||||
// https://app.quotemedia.com/datatool/getEnhancedChartData.json?zeroTradeDays=false&start=2025-06-22&interval=1&marketSession=mkt&freq=day&adjusted=true&adjustmentType=none&unadjusted=false&datatype=int&symbol=AAPL
|
// https://app.quotemedia.com/datatool/getEnhancedChartData.json?zeroTradeDays=false&start=2025-06-22&interval=1&marketSession=mkt&freq=day&adjusted=true&adjustmentType=none&unadjusted=false&datatype=int&symbol=AAPL
|
||||||
// TODO: Update with correct prices endpoint
|
// TODO: Update with correct prices endpoint
|
||||||
const apiUrl = `${QM_CONFIG.PRICES_URL}?${searchParams.toString()}`;
|
const apiUrl = `${QM_CONFIG.PRICES_URL}?${searchParams.toString()}`;
|
||||||
|
|
||||||
console.log('QM Symbol Info API URL:', apiUrl);
|
|
||||||
const response = await fetch(apiUrl, {
|
const response = await fetch(apiUrl, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: session.headers,
|
headers: session.headers,
|
||||||
|
|
@ -103,6 +103,8 @@ export async function updatePrices(
|
||||||
// Store prices in a separate collection
|
// Store prices in a separate collection
|
||||||
const processedPrices = priceData.map((price: any) => ({
|
const processedPrices = priceData.map((price: any) => ({
|
||||||
...price,
|
...price,
|
||||||
|
symbol,
|
||||||
|
exchange,
|
||||||
qmSearchCode,
|
qmSearchCode,
|
||||||
dateTime: new Date(price.date),
|
dateTime: new Date(price.date),
|
||||||
}));
|
}));
|
||||||
|
|
@ -191,7 +193,7 @@ export async function schedulePriceUpdates(
|
||||||
symbolsQueued: number;
|
symbolsQueued: number;
|
||||||
errors: number;
|
errors: number;
|
||||||
}> {
|
}> {
|
||||||
const { limit = 10000, forceUpdate = false } = input;
|
const { limit = 100, forceUpdate = false } = input;
|
||||||
const tracker = await getOperationTracker(this);
|
const tracker = await getOperationTracker(this);
|
||||||
|
|
||||||
this.logger.info('Scheduling price updates', { limit, forceUpdate });
|
this.logger.info('Scheduling price updates', { limit, forceUpdate });
|
||||||
|
|
@ -218,7 +220,7 @@ export async function schedulePriceUpdates(
|
||||||
const symbolDocs = await this.mongodb.find('qmSymbols', {
|
const symbolDocs = await this.mongodb.find('qmSymbols', {
|
||||||
qmSearchCode: { $in: staleSymbols }
|
qmSearchCode: { $in: staleSymbols }
|
||||||
}, {
|
}, {
|
||||||
projection: { qmSearchCode: 1, operations: 1 }
|
projection: { qmSearchCode: 1, operations: 1, symbol: 1, exchange: 1 },
|
||||||
});
|
});
|
||||||
|
|
||||||
let queued = 0;
|
let queued = 0;
|
||||||
|
|
@ -227,15 +229,11 @@ export async function schedulePriceUpdates(
|
||||||
// Schedule individual update jobs for each symbol
|
// Schedule individual update jobs for each symbol
|
||||||
for (const doc of symbolDocs) {
|
for (const doc of symbolDocs) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(doc.qmSearchCode !== 'A') {
|
|
||||||
// this.logger.warn(`Skipping symbol with missing qmSearchCode ${doc.qmSearchCode}`, { doc });
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.scheduleOperation('update-prices', {
|
await this.scheduleOperation('update-prices', {
|
||||||
qmSearchCode: doc.qmSearchCode,
|
qmSearchCode: doc.qmSearchCode,
|
||||||
lastRecordDate: doc.operations?.price_update?.lastRecordDate
|
lastRecordDate: doc.operations?.price_update?.lastRecordDate,
|
||||||
|
symbol: doc.symbol,
|
||||||
|
exchange: doc.exchange
|
||||||
}, {
|
}, {
|
||||||
priority: 7, // High priority for price data
|
priority: 7, // High priority for price data
|
||||||
delay: queued * 500 // 0.5 seconds between jobs
|
delay: queued * 500 // 0.5 seconds between jobs
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,8 @@ export const QM_CONFIG = {
|
||||||
|
|
||||||
// Session management settings
|
// Session management settings
|
||||||
export const SESSION_CONFIG = {
|
export const SESSION_CONFIG = {
|
||||||
MIN_SESSIONS: 2,
|
MIN_SESSIONS: 100,
|
||||||
MAX_SESSIONS: 2,
|
MAX_SESSIONS: 100,
|
||||||
MAX_FAILED_CALLS: 3,
|
MAX_FAILED_CALLS: 3,
|
||||||
SESSION_TIMEOUT: 5000, // 10 seconds
|
SESSION_TIMEOUT: 5000, // 10 seconds
|
||||||
API_TIMEOUT: 30000, // 15 seconds
|
API_TIMEOUT: 30000, // 15 seconds
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue