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,
|
||||
"db": 1
|
||||
},
|
||||
"workers": 1,
|
||||
"concurrency": 1,
|
||||
"workers": 10,
|
||||
"concurrency": 4,
|
||||
"enableScheduledJobs": true,
|
||||
"defaultJobOptions": {
|
||||
"attempts": 3,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ export async function updatePrices(
|
|||
input: {
|
||||
qmSearchCode: string;
|
||||
lastRecordDate?: Date;
|
||||
symbol: string;
|
||||
exchange: string;
|
||||
},
|
||||
_context?: ExecutionContext
|
||||
): Promise<{
|
||||
|
|
@ -38,7 +40,7 @@ export async function updatePrices(
|
|||
message: string;
|
||||
data?: any;
|
||||
}> {
|
||||
const { qmSearchCode, lastRecordDate } = input;
|
||||
const { qmSearchCode, lastRecordDate, symbol, exchange } = input;
|
||||
|
||||
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
|
||||
// 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,
|
||||
|
|
@ -103,6 +103,8 @@ export async function updatePrices(
|
|||
// Store prices in a separate collection
|
||||
const processedPrices = priceData.map((price: any) => ({
|
||||
...price,
|
||||
symbol,
|
||||
exchange,
|
||||
qmSearchCode,
|
||||
dateTime: new Date(price.date),
|
||||
}));
|
||||
|
|
@ -191,7 +193,7 @@ export async function schedulePriceUpdates(
|
|||
symbolsQueued: number;
|
||||
errors: number;
|
||||
}> {
|
||||
const { limit = 10000, forceUpdate = false } = input;
|
||||
const { limit = 100, forceUpdate = false } = input;
|
||||
const tracker = await getOperationTracker(this);
|
||||
|
||||
this.logger.info('Scheduling price updates', { limit, forceUpdate });
|
||||
|
|
@ -218,7 +220,7 @@ export async function schedulePriceUpdates(
|
|||
const symbolDocs = await this.mongodb.find('qmSymbols', {
|
||||
qmSearchCode: { $in: staleSymbols }
|
||||
}, {
|
||||
projection: { qmSearchCode: 1, operations: 1 }
|
||||
projection: { qmSearchCode: 1, operations: 1, symbol: 1, exchange: 1 },
|
||||
});
|
||||
|
||||
let queued = 0;
|
||||
|
|
@ -227,15 +229,11 @@ export async function schedulePriceUpdates(
|
|||
// Schedule individual update jobs for each symbol
|
||||
for (const doc of symbolDocs) {
|
||||
try {
|
||||
|
||||
if(doc.qmSearchCode !== 'A') {
|
||||
// this.logger.warn(`Skipping symbol with missing qmSearchCode ${doc.qmSearchCode}`, { doc });
|
||||
continue;
|
||||
}
|
||||
|
||||
await this.scheduleOperation('update-prices', {
|
||||
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
|
||||
delay: queued * 500 // 0.5 seconds between jobs
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ export const QM_CONFIG = {
|
|||
|
||||
// Session management settings
|
||||
export const SESSION_CONFIG = {
|
||||
MIN_SESSIONS: 2,
|
||||
MAX_SESSIONS: 2,
|
||||
MIN_SESSIONS: 100,
|
||||
MAX_SESSIONS: 100,
|
||||
MAX_FAILED_CALLS: 3,
|
||||
SESSION_TIMEOUT: 5000, // 10 seconds
|
||||
API_TIMEOUT: 30000, // 15 seconds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue