@ -5,20 +5,18 @@ import {
IDataProviderHistoricalResponse ,
IDataProviderResponse
} from '@ghostfolio/api/services/interfaces/interfaces' ;
import { PrismaService } from '@ghostfolio/api/services/prisma.service' ;
import { ghostfolioFearAndGreedIndexSymbol } from '@ghostfolio/common/config' ;
import { DATE_FORMAT , get Today, get Yesterday } from '@ghostfolio/common/helper' ;
import { DATE_FORMAT , get Yesterday } from '@ghostfolio/common/helper' ;
import { Granularity } from '@ghostfolio/common/types' ;
import { Injectable , Logger } from '@nestjs/common' ;
import { DataSource , SymbolProfile } from '@prisma/client' ;
import bent from 'bent' ;
import { format , subMonths , subWeeks , subYears } from 'date-fns' ;
import { format } from 'date-fns' ;
@Injectable ( )
export class RapidApiService implements DataProviderInterface {
public constructor (
private readonly configurationService : ConfigurationService ,
private readonly prismaService : PrismaService
private readonly configurationService : ConfigurationService
) { }
public canHandle ( symbol : string ) {
@ -47,41 +45,6 @@ export class RapidApiService implements DataProviderInterface {
if ( symbol === ghostfolioFearAndGreedIndexSymbol ) {
const fgi = await this . getFearAndGreedIndex ( ) ;
try {
// Rebuild historical data
// TODO: can be removed after all data from the last year has been gathered
// (introduced on 27.03.2021)
await this . prismaService . marketData . create ( {
data : {
symbol ,
dataSource : this.getName ( ) ,
date : subWeeks ( getToday ( ) , 1 ) ,
marketPrice : fgi.oneWeekAgo.value
}
} ) ;
await this . prismaService . marketData . create ( {
data : {
symbol ,
dataSource : this.getName ( ) ,
date : subMonths ( getToday ( ) , 1 ) ,
marketPrice : fgi.oneMonthAgo.value
}
} ) ;
await this . prismaService . marketData . create ( {
data : {
symbol ,
dataSource : this.getName ( ) ,
date : subYears ( getToday ( ) , 1 ) ,
marketPrice : fgi.oneYearAgo.value
}
} ) ;
///////////////////////////////////////////////////////////////////////////
} catch { }
return {
[ ghostfolioFearAndGreedIndexSymbol ] : {
[ format ( getYesterday ( ) , DATE_FORMAT ) ] : {