|
|
@ -8,7 +8,7 @@ import {
|
|
|
|
} from '@ghostfolio/common/helper';
|
|
|
|
} from '@ghostfolio/common/helper';
|
|
|
|
import { Granularity } from '@ghostfolio/common/types';
|
|
|
|
import { Granularity } from '@ghostfolio/common/types';
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { AssetClass, DataSource } from '@prisma/client';
|
|
|
|
import { AssetClass, Currency, DataSource } from '@prisma/client';
|
|
|
|
import * as bent from 'bent';
|
|
|
|
import * as bent from 'bent';
|
|
|
|
import { format } from 'date-fns';
|
|
|
|
import { format } from 'date-fns';
|
|
|
|
import * as yahooFinance from 'yahoo-finance';
|
|
|
|
import * as yahooFinance from 'yahoo-finance';
|
|
|
@ -147,8 +147,23 @@ export class YahooFinanceService implements DataProviderInterface {
|
|
|
|
200
|
|
|
|
200
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const result = await get();
|
|
|
|
const searchResult = await get();
|
|
|
|
items = result.quotes
|
|
|
|
|
|
|
|
|
|
|
|
const symbols: string[] = searchResult.quotes
|
|
|
|
|
|
|
|
.filter((quote) => {
|
|
|
|
|
|
|
|
// filter out undefined symbols
|
|
|
|
|
|
|
|
return quote.symbol;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.filter(({ quoteType }) => {
|
|
|
|
|
|
|
|
return quoteType === 'EQUITY' || quoteType === 'ETF';
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.map(({ symbol }) => {
|
|
|
|
|
|
|
|
return symbol;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const marketData = await this.get(symbols);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
items = searchResult.quotes
|
|
|
|
.filter((quote) => {
|
|
|
|
.filter((quote) => {
|
|
|
|
return quote.isYahooFinance;
|
|
|
|
return quote.isYahooFinance;
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -162,7 +177,12 @@ export class YahooFinanceService implements DataProviderInterface {
|
|
|
|
.filter(({ quoteType, symbol }) => {
|
|
|
|
.filter(({ quoteType, symbol }) => {
|
|
|
|
if (quoteType === 'CRYPTOCURRENCY') {
|
|
|
|
if (quoteType === 'CRYPTOCURRENCY') {
|
|
|
|
// Only allow cryptocurrencies in USD
|
|
|
|
// Only allow cryptocurrencies in USD
|
|
|
|
return symbol.includes('USD');
|
|
|
|
return symbol.includes(Currency.USD);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!marketData[symbol]?.currency) {
|
|
|
|
|
|
|
|
// Only allow symbols with supported currency
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|