@ -10,6 +10,7 @@ import {
Prisma,
SymbolProfile
} from '@prisma/client';
import { isISIN } from 'class-validator';
import { countries } from 'countries-list';
import yahooFinance from 'yahoo-finance2';
import type { Price } from 'yahoo-finance2/dist/esm/src/modules/quoteSummary-iface';
@ -156,7 +157,20 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
const response: Partial<SymbolProfile> = {};
try {
const symbol = this.convertToYahooFinanceSymbol(aSymbol);
let symbol = aSymbol;
if (isISIN(symbol)) {
const { quotes } = await yahooFinance.search(symbol);
if (quotes.length === 1) {
symbol = quotes[0].symbol;
}
} catch {}
} else {
symbol = this.convertToYahooFinanceSymbol(symbol);
const assetProfile = await yahooFinance.quoteSummary(symbol, {
modules: ['price', 'summaryProfile', 'topHoldings']
});
@ -176,7 +190,7 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
shortName: assetProfile.price.shortName,
symbol: assetProfile.price.symbol
response.symbol = aSymbol;
response.symbol = assetProfile.price.symbol;
if (assetSubClass === AssetSubClass.MUTUALFUND) {
response.sectors = [];
@ -30,7 +30,7 @@ export class YahooFinanceService implements DataProviderInterface {
public async getAssetProfile(
aSymbol: string
): Promise<Partial<SymbolProfile>> {
const { assetClass, assetSubClass, currency, name } =
const { assetClass, assetSubClass, currency, name, symbol } =
await this.yahooFinanceDataEnhancerService.getAssetProfile(aSymbol);
return {
@ -38,8 +38,8 @@ export class YahooFinanceService implements DataProviderInterface {
assetSubClass,
currency,
name,
dataSource: this.getName(),
symbol: aSymbol
symbol,
dataSource: this.getName()
};
@ -3,4 +3,4 @@ Date,Code,DataSource,Currency,Price,Quantity,Action,Fee,Note
16-09-2021,MSFT,YAHOO,USD,298.580,5,buy,19.00,My first order 🤓
17/11/2021,MSFT,YAHOO,USD,0.62,5,dividend,0.00,
01.01.2022,Penthouse Apartment,MANUAL,USD,500000.0,1,item,0.00,
20500606,MSFT,YAHOO,USD,0.00,0,buy,0.00,
20500606,US5949181045,YAHOO,USD,0.00,0,buy,0.00,
@ -24,7 +24,7 @@
"currency": "USD",
"dataSource": "YAHOO",
"date": "2050-06-05T22:00:00.000Z",
"symbol": "MSFT"
"symbol": "US5949181045"
},
{
"accountId": null,