Feature/improve market state logic for forex in eod historical data service (#3550)
This commit is contained in:
parent
bc2fd9c970
commit
35b4aef06f
@ -246,7 +246,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
for (const { close, code, timestamp } of quotes) {
|
for (const { close, code, timestamp } of quotes) {
|
||||||
let currency: string;
|
let currency: string;
|
||||||
|
|
||||||
if (code.endsWith('.FOREX')) {
|
if (this.isForex(code)) {
|
||||||
currency = this.convertFromEodSymbol(code)?.replace(
|
currency = this.convertFromEodSymbol(code)?.replace(
|
||||||
DEFAULT_CURRENCY,
|
DEFAULT_CURRENCY,
|
||||||
''
|
''
|
||||||
@ -272,7 +272,10 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
currency,
|
currency,
|
||||||
dataSource: this.getName(),
|
dataSource: this.getName(),
|
||||||
marketPrice: close,
|
marketPrice: close,
|
||||||
marketState: isToday(new Date(timestamp * 1000)) ? 'open' : 'closed'
|
marketState:
|
||||||
|
this.isForex(code) || isToday(new Date(timestamp * 1000))
|
||||||
|
? 'open'
|
||||||
|
: 'closed'
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
Logger.error(
|
Logger.error(
|
||||||
@ -311,7 +314,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
items: searchResult
|
items: searchResult
|
||||||
.filter(({ currency, symbol }) => {
|
.filter(({ currency, symbol }) => {
|
||||||
// Remove 'NA' currency and exchange rates
|
// Remove 'NA' currency and exchange rates
|
||||||
return currency?.length === 3 && !symbol.endsWith('.FOREX');
|
return currency?.length === 3 && !this.isForex(symbol);
|
||||||
})
|
})
|
||||||
.map(
|
.map(
|
||||||
({
|
({
|
||||||
@ -349,7 +352,7 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
private convertFromEodSymbol(aEodSymbol: string) {
|
private convertFromEodSymbol(aEodSymbol: string) {
|
||||||
let symbol = aEodSymbol;
|
let symbol = aEodSymbol;
|
||||||
|
|
||||||
if (symbol.endsWith('.FOREX')) {
|
if (this.isForex(symbol)) {
|
||||||
symbol = symbol.replace('GBX', 'GBp');
|
symbol = symbol.replace('GBX', 'GBp');
|
||||||
symbol = symbol.replace('.FOREX', '');
|
symbol = symbol.replace('.FOREX', '');
|
||||||
}
|
}
|
||||||
@ -451,6 +454,10 @@ export class EodHistoricalDataService implements DataProviderInterface {
|
|||||||
return searchResult;
|
return searchResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isForex(aCode: string) {
|
||||||
|
return aCode?.endsWith('.FOREX') || false;
|
||||||
|
}
|
||||||
|
|
||||||
private parseAssetClass({
|
private parseAssetClass({
|
||||||
Exchange,
|
Exchange,
|
||||||
Type
|
Type
|
||||||
|
Loading…
x
Reference in New Issue
Block a user