|
|
@ -325,6 +325,8 @@ export class DataProviderService { |
|
|
|
result |
|
|
|
)) { |
|
|
|
response[symbol] = dataProviderResponse; |
|
|
|
let quotesCacheTTL = |
|
|
|
this.getAppropriateCacheTTL(dataProviderResponse); |
|
|
|
|
|
|
|
this.redisCacheService.set( |
|
|
|
this.redisCacheService.getQuoteKey({ |
|
|
@ -332,7 +334,7 @@ export class DataProviderService { |
|
|
|
symbol |
|
|
|
}), |
|
|
|
JSON.stringify(dataProviderResponse), |
|
|
|
this.configurationService.get('CACHE_QUOTES_TTL') |
|
|
|
quotesCacheTTL |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@ -384,6 +386,25 @@ export class DataProviderService { |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
private getAppropriateCacheTTL(dataProviderResponse: IDataProviderResponse) { |
|
|
|
let quotesCacheTTL = this.configurationService.get('CACHE_QUOTES_TTL'); |
|
|
|
|
|
|
|
if (dataProviderResponse.dataSource === 'MANUAL') { |
|
|
|
quotesCacheTTL = 14400; // 4h Cache for Manual Service
|
|
|
|
} else if (dataProviderResponse.marketState === 'closed') { |
|
|
|
let date = new Date(); |
|
|
|
let dayOfWeek = date.getDay(); |
|
|
|
if (dayOfWeek === 0 || dayOfWeek === 6) { |
|
|
|
quotesCacheTTL = 14400; |
|
|
|
} else if (date.getHours() > 16) { |
|
|
|
quotesCacheTTL = 14400; |
|
|
|
} else { |
|
|
|
quotesCacheTTL = 900; |
|
|
|
} |
|
|
|
} |
|
|
|
return quotesCacheTTL; |
|
|
|
} |
|
|
|
|
|
|
|
public async search({ |
|
|
|
includeIndices = false, |
|
|
|
query, |
|
|
|