|
|
@ -1,6 +1,5 @@
|
|
|
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
|
|
|
import { DataProviderService } from '@ghostfolio/api/services/data-provider.service';
|
|
|
|
import { GhostfolioScraperApiService } from '@ghostfolio/api/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service';
|
|
|
|
import { PrismaService } from '@ghostfolio/api/services/prisma.service';
|
|
|
|
import { convertFromYahooSymbol } from '@ghostfolio/api/services/data-provider/yahoo-finance/yahoo-finance.service';
|
|
|
|
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { Injectable } from '@nestjs/common';
|
|
|
|
import { Currency, DataSource } from '@prisma/client';
|
|
|
|
import { Currency, DataSource } from '@prisma/client';
|
|
|
|
|
|
|
|
|
|
|
@ -11,7 +10,7 @@ import { SymbolItem } from './interfaces/symbol-item.interface';
|
|
|
|
export class SymbolService {
|
|
|
|
export class SymbolService {
|
|
|
|
public constructor(
|
|
|
|
public constructor(
|
|
|
|
private readonly dataProviderService: DataProviderService,
|
|
|
|
private readonly dataProviderService: DataProviderService,
|
|
|
|
private readonly ghostfolioScraperApiService: GhostfolioScraperApiService
|
|
|
|
private readonly prismaService: PrismaService
|
|
|
|
) {}
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
|
|
public async get(aSymbol: string): Promise<SymbolItem> {
|
|
|
|
public async get(aSymbol: string): Promise<SymbolItem> {
|
|
|
@ -37,17 +36,29 @@ export class SymbolService {
|
|
|
|
results.items = items;
|
|
|
|
results.items = items;
|
|
|
|
|
|
|
|
|
|
|
|
// Add custom symbols
|
|
|
|
// Add custom symbols
|
|
|
|
const scraperConfigurations = await this.ghostfolioScraperApiService.getScraperConfigurations();
|
|
|
|
const ghostfolioSymbolProfiles =
|
|
|
|
scraperConfigurations.forEach((scraperConfiguration) => {
|
|
|
|
await this.prismaService.symbolProfile.findMany({
|
|
|
|
if (scraperConfiguration.name.toLowerCase().startsWith(aQuery)) {
|
|
|
|
select: {
|
|
|
|
results.items.push({
|
|
|
|
dataSource: true,
|
|
|
|
|
|
|
|
name: true,
|
|
|
|
|
|
|
|
symbol: true
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
AND: [
|
|
|
|
|
|
|
|
{
|
|
|
|
dataSource: DataSource.GHOSTFOLIO,
|
|
|
|
dataSource: DataSource.GHOSTFOLIO,
|
|
|
|
name: scraperConfiguration.name,
|
|
|
|
name: {
|
|
|
|
symbol: scraperConfiguration.symbol
|
|
|
|
startsWith: aQuery
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const ghostfolioSymbolProfile of ghostfolioSymbolProfiles) {
|
|
|
|
|
|
|
|
results.items.push(ghostfolioSymbolProfile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
return results;
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|