|
@ -1,12 +1,11 @@ |
|
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service'; |
|
|
import { SymbolProfileService } from '@ghostfolio/api/services/symbol-profile.service'; |
|
|
import { |
|
|
import { |
|
|
PROPERTY_LAST_DATA_GATHERING, |
|
|
PROPERTY_LAST_DATA_GATHERING, |
|
|
PROPERTY_LOCKED_DATA_GATHERING, |
|
|
PROPERTY_LOCKED_DATA_GATHERING |
|
|
ghostfolioFearAndGreedIndexSymbol |
|
|
|
|
|
} from '@ghostfolio/common/config'; |
|
|
} from '@ghostfolio/common/config'; |
|
|
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper'; |
|
|
import { DATE_FORMAT, resetHours } from '@ghostfolio/common/helper'; |
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
import { Inject, Injectable, Logger } from '@nestjs/common'; |
|
|
import { DataSource, MarketData } from '@prisma/client'; |
|
|
import { DataSource } from '@prisma/client'; |
|
|
import { |
|
|
import { |
|
|
differenceInHours, |
|
|
differenceInHours, |
|
|
format, |
|
|
format, |
|
@ -17,7 +16,6 @@ import { |
|
|
subDays |
|
|
subDays |
|
|
} from 'date-fns'; |
|
|
} from 'date-fns'; |
|
|
|
|
|
|
|
|
import { ConfigurationService } from './configuration.service'; |
|
|
|
|
|
import { DataProviderService } from './data-provider/data-provider.service'; |
|
|
import { DataProviderService } from './data-provider/data-provider.service'; |
|
|
import { DataEnhancerInterface } from './data-provider/interfaces/data-enhancer.interface'; |
|
|
import { DataEnhancerInterface } from './data-provider/interfaces/data-enhancer.interface'; |
|
|
import { ExchangeRateDataService } from './exchange-rate-data.service'; |
|
|
import { ExchangeRateDataService } from './exchange-rate-data.service'; |
|
@ -29,7 +27,6 @@ export class DataGatheringService { |
|
|
private dataGatheringProgress: number; |
|
|
private dataGatheringProgress: number; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
private readonly configurationService: ConfigurationService, |
|
|
|
|
|
@Inject('DataEnhancers') |
|
|
@Inject('DataEnhancers') |
|
|
private readonly dataEnhancers: DataEnhancerInterface[], |
|
|
private readonly dataEnhancers: DataEnhancerInterface[], |
|
|
private readonly dataProviderService: DataProviderService, |
|
|
private readonly dataProviderService: DataProviderService, |
|
@ -448,11 +445,7 @@ export class DataGatheringService { |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return [ |
|
|
return [...currencyPairsToGather, ...symbolProfilesToGather]; |
|
|
...this.getBenchmarksToGather(startDate), |
|
|
|
|
|
...currencyPairsToGather, |
|
|
|
|
|
...symbolProfilesToGather |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async reset() { |
|
|
public async reset() { |
|
@ -468,20 +461,6 @@ export class DataGatheringService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getBenchmarksToGather(startDate: Date): IDataGatheringItem[] { |
|
|
|
|
|
const benchmarksToGather: IDataGatheringItem[] = []; |
|
|
|
|
|
|
|
|
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) { |
|
|
|
|
|
benchmarksToGather.push({ |
|
|
|
|
|
dataSource: DataSource.RAKUTEN, |
|
|
|
|
|
date: startDate, |
|
|
|
|
|
symbol: ghostfolioFearAndGreedIndexSymbol |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return benchmarksToGather; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async getSymbols7D(): Promise<IDataGatheringItem[]> { |
|
|
private async getSymbols7D(): Promise<IDataGatheringItem[]> { |
|
|
const startDate = subDays(resetHours(new Date()), 7); |
|
|
const startDate = subDays(resetHours(new Date()), 7); |
|
|
|
|
|
|
|
@ -511,30 +490,22 @@ export class DataGatheringService { |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return [ |
|
|
return [...currencyPairsToGather, ...symbolProfilesToGather]; |
|
|
...this.getBenchmarksToGather(startDate), |
|
|
|
|
|
...currencyPairsToGather, |
|
|
|
|
|
...symbolProfilesToGather |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async getSymbolsProfileData(): Promise<IDataGatheringItem[]> { |
|
|
private async getSymbolsProfileData(): Promise<IDataGatheringItem[]> { |
|
|
const startDate = subDays(resetHours(new Date()), 7); |
|
|
|
|
|
|
|
|
|
|
|
const distinctOrders = await this.prismaService.order.findMany({ |
|
|
const distinctOrders = await this.prismaService.order.findMany({ |
|
|
distinct: ['symbol'], |
|
|
distinct: ['symbol'], |
|
|
orderBy: [{ symbol: 'asc' }], |
|
|
orderBy: [{ symbol: 'asc' }], |
|
|
select: { dataSource: true, symbol: true } |
|
|
select: { dataSource: true, symbol: true } |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
return [...this.getBenchmarksToGather(startDate), ...distinctOrders].filter( |
|
|
return distinctOrders.filter((distinctOrder) => { |
|
|
(distinctOrder) => { |
|
|
return ( |
|
|
return ( |
|
|
distinctOrder.dataSource !== DataSource.GHOSTFOLIO && |
|
|
distinctOrder.dataSource !== DataSource.GHOSTFOLIO && |
|
|
distinctOrder.dataSource !== DataSource.RAKUTEN |
|
|
distinctOrder.dataSource !== DataSource.RAKUTEN |
|
|
); |
|
|
); |
|
|
}); |
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async isDataGatheringNeeded() { |
|
|
private async isDataGatheringNeeded() { |
|
|