Feature/support activities import by isin for yahoo finance (#2597)

* Add support to import activities by isin

* Update changelog
pull/2599/head
Thomas Kaul 1 year ago committed by GitHub
parent 35f98b9d2d
commit 1b7e3a1e47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added support to import activities by `isin` in the _Yahoo Finance_ service
- Added a new tag with the major version to the docker image on _Docker Hub_
### Changed

@ -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)) {
try {
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,

1 Date Code DataSource Currency Price Quantity Action Fee Note
3 16-09-2021 MSFT YAHOO USD 298.580 5 buy 19.00 My first order 🤓
4 17/11/2021 MSFT YAHOO USD 0.62 5 dividend 0.00
5 01.01.2022 Penthouse Apartment MANUAL USD 500000.0 1 item 0.00
6 20500606 MSFT 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,

Loading…
Cancel
Save