Browse Source

Address review feedback

pull/8428/head
KenTandrian 3 weeks ago
parent
commit
37e8da48ca
  1. 16
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts
  2. 5
      apps/api/src/services/data-provider/data-provider.service.ts
  3. 4
      libs/common/src/lib/helper.ts

16
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

@ -120,7 +120,11 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
yahooSymbol = symbol; yahooSymbol = symbol;
} else if (isin) { } else if (isin) {
const { quotes } = await this.yahooFinance.search(isin); const { quotes } = await this.yahooFinance.search(isin);
yahooSymbol = (quotes?.[0] as { symbol?: string })?.symbol; const firstQuote = quotes?.[0];
if (firstQuote?.isYahooFinance) {
yahooSymbol = firstQuote.symbol;
}
} }
if (!yahooSymbol) { if (!yahooSymbol) {
@ -209,7 +213,7 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
}); });
if (!assetProfile?.price?.symbol) { if (!assetProfile?.price?.symbol) {
return undefined; throw new Error(`No price data found for ${symbol}`);
} }
const { assetClass, assetSubClass } = this.parseAssetClass({ const { assetClass, assetSubClass } = this.parseAssetClass({
@ -317,11 +321,11 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
quoteType?: string; quoteType?: string;
shortName?: string | null; shortName?: string | null;
}): { }): {
assetClass?: AssetClass; assetClass: AssetClass;
assetSubClass?: AssetSubClass; assetSubClass: AssetSubClass;
} { } {
let assetClass: AssetClass | undefined; let assetClass: AssetClass;
let assetSubClass: AssetSubClass | undefined; let assetSubClass: AssetSubClass;
switch (quoteType?.toLowerCase()) { switch (quoteType?.toLowerCase()) {
case 'cryptocurrency': case 'cryptocurrency':

5
apps/api/src/services/data-provider/data-provider.service.ts

@ -132,10 +132,7 @@ export class DataProviderService implements OnModuleInit {
] = { ] = {
...assetProfile, ...assetProfile,
symbol, symbol,
name: formatAssetProfileName({ name: formatAssetProfileName(assetProfile)
assetSubClass: assetProfile.assetSubClass ?? undefined,
name: assetProfile.name ?? undefined
})
}; };
} }
}) })

4
libs/common/src/lib/helper.ts

@ -334,8 +334,8 @@ export function formatAssetProfileName({
assetSubClass, assetSubClass,
name name
}: { }: {
assetSubClass?: AssetSubClass; assetSubClass?: AssetSubClass | null;
name?: string; name?: string | null;
}) { }) {
if (assetSubClass === 'CRYPTOCURRENCY') { if (assetSubClass === 'CRYPTOCURRENCY') {
// Remove DEFAULT_CURRENCY at the end of cryptocurrency names // Remove DEFAULT_CURRENCY at the end of cryptocurrency names

Loading…
Cancel
Save