|
@ -44,29 +44,27 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { |
|
|
return response; |
|
|
return response; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let trackinsightSymbol = await this.searchTrackinsightSymbol( |
|
|
|
|
|
symbol, |
|
|
|
|
|
requestTimeout |
|
|
|
|
|
); |
|
|
|
|
|
if (trackinsightSymbol === '') { |
|
|
|
|
|
trackinsightSymbol = await this.searchTrackinsightSymbol( |
|
|
|
|
|
symbol.split('.')?.[0], |
|
|
|
|
|
requestTimeout |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const profile = await fetch( |
|
|
const profile = await fetch( |
|
|
`${TrackinsightDataEnhancerService.baseUrl}/funds/${symbol}.json`, |
|
|
`${TrackinsightDataEnhancerService.baseUrl}/funds/${trackinsightSymbol}.json`, |
|
|
{ |
|
|
{ |
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
} |
|
|
} |
|
|
) |
|
|
|
|
|
.then((res) => res.json()) |
|
|
|
|
|
.catch(() => { |
|
|
|
|
|
return fetch( |
|
|
|
|
|
`${TrackinsightDataEnhancerService.baseUrl}/funds/${ |
|
|
|
|
|
symbol.split('.')?.[0] |
|
|
|
|
|
}.json`,
|
|
|
|
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout( |
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
) |
|
|
.then((res) => res.json()) |
|
|
.then((res) => res.json()) |
|
|
.catch(() => { |
|
|
.catch(() => { |
|
|
return {}; |
|
|
return {}; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const isin = profile?.isin?.split(';')?.[0]; |
|
|
const isin = profile?.isin?.split(';')?.[0]; |
|
|
|
|
|
|
|
@ -75,19 +73,7 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const holdings = await fetch( |
|
|
const holdings = await fetch( |
|
|
`${TrackinsightDataEnhancerService.baseUrl}/holdings/${symbol}.json`, |
|
|
`${TrackinsightDataEnhancerService.baseUrl}/holdings/${trackinsightSymbol}.json`, |
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout( |
|
|
|
|
|
this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => res.json()) |
|
|
|
|
|
.catch(() => { |
|
|
|
|
|
return fetch( |
|
|
|
|
|
`${TrackinsightDataEnhancerService.baseUrl}/holdings/${ |
|
|
|
|
|
symbol.split('.')?.[0] |
|
|
|
|
|
}.json`,
|
|
|
|
|
|
{ |
|
|
{ |
|
|
signal: AbortSignal.timeout( |
|
|
signal: AbortSignal.timeout( |
|
|
this.configurationService.get('REQUEST_TIMEOUT') |
|
|
this.configurationService.get('REQUEST_TIMEOUT') |
|
@ -98,7 +84,6 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { |
|
|
.catch(() => { |
|
|
.catch(() => { |
|
|
return {}; |
|
|
return {}; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
holdings?.weight < TrackinsightDataEnhancerService.holdingsWeightTreshold |
|
|
holdings?.weight < TrackinsightDataEnhancerService.holdingsWeightTreshold |
|
@ -173,6 +158,29 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { |
|
|
return Promise.resolve(response); |
|
|
return Promise.resolve(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async searchTrackinsightSymbol( |
|
|
|
|
|
symbol, |
|
|
|
|
|
requestTimeout = this.configurationService.get('REQUEST_TIMEOUT') |
|
|
|
|
|
) { |
|
|
|
|
|
return await fetch( |
|
|
|
|
|
`https://www.trackinsight.com/search-api/search_v2/${symbol}/_/ticker/default/0/3`, |
|
|
|
|
|
{ |
|
|
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => res.json()) |
|
|
|
|
|
.then((jsonRes) => { |
|
|
|
|
|
if (jsonRes['results']['count'] === 1) { |
|
|
|
|
|
// Return the only ticker that matches the one in the search
|
|
|
|
|
|
return jsonRes['results']['docs'][0]['ticker']; |
|
|
|
|
|
} |
|
|
|
|
|
return ''; |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(() => { |
|
|
|
|
|
return ''; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public getName() { |
|
|
public getName() { |
|
|
return 'TRACKINSIGHT'; |
|
|
return 'TRACKINSIGHT'; |
|
|
} |
|
|
} |
|
|