finished prices
This commit is contained in:
parent
2f5eaef19c
commit
0b33e9a8b6
4 changed files with 13 additions and 10 deletions
|
|
@ -57,7 +57,7 @@ export async function updatePrices(
|
|||
// Build API request for daily prices
|
||||
const searchParams = new URLSearchParams({
|
||||
zeroTradeDays: 'false',
|
||||
start: lastRecordDate?.toISOString().split('T')[0] ?? '1960-01-01',
|
||||
start: lastRecordDate ? new Date(lastRecordDate).toISOString().split('T')[0] + '' : '1960-01-01',
|
||||
interval: '1',
|
||||
marketSession: 'mkt',
|
||||
freq: 'day',
|
||||
|
|
@ -70,7 +70,8 @@ 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
|
||||
// TODO: Update with correct prices endpoint
|
||||
const apiUrl = `${QM_CONFIG.PRICES_URL}?${searchParams.toString()}`;
|
||||
|
||||
|
||||
console.log('QM Symbol Info API URL:', apiUrl);
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: session.headers,
|
||||
|
|
@ -190,7 +191,7 @@ export async function schedulePriceUpdates(
|
|||
symbolsQueued: number;
|
||||
errors: number;
|
||||
}> {
|
||||
const { limit = 1, forceUpdate = false } = input;
|
||||
const { limit = 10000, forceUpdate = false } = input;
|
||||
const tracker = await getOperationTracker(this);
|
||||
|
||||
this.logger.info('Scheduling price updates', { limit, forceUpdate });
|
||||
|
|
@ -217,7 +218,7 @@ export async function schedulePriceUpdates(
|
|||
const symbolDocs = await this.mongodb.find('qmSymbols', {
|
||||
qmSearchCode: { $in: staleSymbols }
|
||||
}, {
|
||||
projection: { symbol: 1, symbolId: 1, qmSearchCode: 1 }
|
||||
projection: { qmSearchCode: 1, operations: 1 }
|
||||
});
|
||||
|
||||
let queued = 0;
|
||||
|
|
@ -226,13 +227,15 @@ export async function schedulePriceUpdates(
|
|||
// Schedule individual update jobs for each symbol
|
||||
for (const doc of symbolDocs) {
|
||||
try {
|
||||
if (!doc.symbolId) {
|
||||
this.logger.warn(`Symbol ${doc.symbol} missing symbolId, skipping`);
|
||||
|
||||
if(doc.qmSearchCode !== 'A') {
|
||||
// this.logger.warn(`Skipping symbol with missing qmSearchCode ${doc.qmSearchCode}`, { doc });
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.scheduleOperation('update-prices', {
|
||||
qmSearchCode: doc.qmSearchCode
|
||||
qmSearchCode: doc.qmSearchCode,
|
||||
lastRecordDate: doc.operations?.price_update?.lastRecordDate
|
||||
}, {
|
||||
priority: 7, // High priority for price data
|
||||
delay: queued * 500 // 0.5 seconds between jobs
|
||||
|
|
@ -240,7 +243,7 @@ export async function schedulePriceUpdates(
|
|||
|
||||
queued++;
|
||||
} catch (error) {
|
||||
this.logger.error(`Failed to schedule price update for ${doc.symbol}`, { error });
|
||||
this.logger.error(`Failed to schedule price update for ${doc.qmSearchCode}`, { error });
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ export async function updateSymbolInfo(
|
|||
} as Record<string, string>);
|
||||
|
||||
const apiUrl = `${QM_CONFIG.SYMBOL_URL}?${searchParams.toString()}`;
|
||||
|
||||
const response = await fetch(apiUrl, {
|
||||
method: 'GET',
|
||||
headers: session.headers,
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export class QMHandler extends BaseHandler<DataIngestionServices> {
|
|||
@Operation('update-prices')
|
||||
updatePrices = updatePrices;
|
||||
|
||||
@Disabled()
|
||||
// @Disabled()
|
||||
@ScheduledOperation('schedule-price-updates', '0 */6 * * *', {
|
||||
priority: 8,
|
||||
immediately: false,
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ export class QMOperationTracker {
|
|||
const filter: any = {
|
||||
$or: [
|
||||
{ [`operations.${operationName}.lastRunAt`]: { $lt: cutoffDate } },
|
||||
{ [`operations.${operationName}.lastRunAt`]: { $exists: false } },
|
||||
{ [`operations.${operationName}`]: { $exists: false } }
|
||||
]
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue