@ -1,6 +1,4 @@ 
				
			 
			
		
	
		
		
			
				
					 
					 
					import  {  LookupItem  }  from  '@ghostfolio/api/app/symbol/interfaces/lookup-item.interface' ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					import  {  
					 
					 
					import  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					  isCrypto ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					  isGhostfolioScraperApiSymbol ,  
					 
					 
					  isGhostfolioScraperApiSymbol ,  
				
			 
			
		
	
		
		
			
				
					 
					 
					  isRakutenRapidApiSymbol  
					 
					 
					  isRakutenRapidApiSymbol  
				
			 
			
		
	
		
		
			
				
					 
					 
					}  from  '@ghostfolio/common/helper' ;  
					 
					 
					}  from  '@ghostfolio/common/helper' ;  
				
			 
			
		
	
	
		
		
			
				
					
						
							
								 
							 
						
						
							
								 
							 
						
						
					 
					@ -132,73 +130,45 @@ export class DataProviderService implements DataProviderInterface { 
				
			 
			
		
	
		
		
			
				
					 
					 
					      [ symbol :  string ] :  {  [ date : string ] :  IDataProviderHistoricalResponse  } ;  
					 
					 
					      [ symbol :  string ] :  {  [ date : string ] :  IDataProviderHistoricalResponse  } ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					    }  =  { } ;  
					 
					 
					    }  =  { } ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    const  promises : Promise < {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      data :  {  [ date : string ] :  IDataProviderHistoricalResponse  } ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      symbol :  string ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    } > [ ]  =  [ ] ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					    for  ( const  {  dataSource ,  symbol  }  of  aDataGatheringItems )  {  
					 
					 
					    for  ( const  {  dataSource ,  symbol  }  of  aDataGatheringItems )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					      switch  ( dataSource )  {  
					 
					 
					      const  dataProvider  =  this . getDataProvider ( dataSource ) ;  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					        case  DataSource . ALPHA_VANTAGE :  {  
					 
					 
					      if  ( dataProvider . canHandle ( symbol ) )  {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					          if  ( this . configurationService . get ( 'ALPHA_VANTAGE_API_KEY' ) )  {  
					 
					 
					        promises . push (  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					            const  data  =  await  this . alphaVantageService . getHistorical (  
					 
					 
					          dataProvider  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					              [ symbol ] ,  
					 
					 
					            . getHistorical ( [ symbol ] ,  undefined ,  from ,  to )  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					              undefined ,  
					 
					 
					            . then ( ( data )  = >  ( {  data : data?. [ symbol ] ,  symbol  } ) )  
				
			 
			
				
				
			
		
	
		
		
			
				
					 
					 
					              from ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              to  
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					        ) ;  
					 
					 
					        ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					            result [ symbol ]  =  data ? . [ symbol ] ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          break ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        case  DataSource . GHOSTFOLIO :  {  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          if  ( isGhostfolioScraperApiSymbol ( symbol ) )  {  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            const  data  =  await  this . ghostfolioScraperApiService . getHistorical (  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              [ symbol ] ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              undefined ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              from ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              to  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            ) ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            result [ symbol ]  =  data ? . [ symbol ] ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          break ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        case  DataSource . RAKUTEN :  {  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          if  (  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            isRakutenRapidApiSymbol ( symbol )  &&  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            this . configurationService . get ( 'RAKUTEN_RAPID_API_KEY' )  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          )  {  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            const  data  =  await  this . rakutenRapidApiService . getHistorical (  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              [ symbol ] ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              undefined ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              from ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					              to  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            ) ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            result [ symbol ]  =  data ? . [ symbol ] ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          break ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        }  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					        case  DataSource . YAHOO :  {  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          const  data  =  await  this . yahooFinanceService . getHistorical (  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            [ symbol ] ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            undefined ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            from ,  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					            to  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          ) ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          result [ symbol ]  =  data ? . [ symbol ] ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					          break ;  
					 
					 
					 
				
			 
			
		
	
		
		
			
				
					 
					 
					      }  
					 
					 
					      }  
				
			 
			
		
	
		
		
			
				
					 
					 
					    }  
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    const  allData  =  await  Promise . all ( promises ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    for  ( const  {  data ,  symbol  }  of  allData )  {  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      result [ symbol ]  =  data ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					    }  
					 
					 
					    }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					    return  result ;  
					 
					 
					    return  result ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					  }  
					 
					 
					  }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					 
					 
					  public  async  search ( aSymbol : string )  {  
					 
					 
					  public  async  search ( aSymbol : string )  {  
				
			 
			
		
	
		
		
			
				
					
					 
					 
					    return  this . getDataProvider ( ) . search ( aSymbol ) ;  
					 
					 
					    return  this . getDataProvider (  
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      this . configurationService . get ( 'DATA_SOURCES' ) [ 0 ]  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					    ) . search ( aSymbol ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					  }  
					 
					 
					  }  
				
			 
			
		
	
		
		
			
				
					 
					 
					
 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					  private  getDataProvider() {  
					 
					 
					  private  getDataProvider ( providerName : DataSource )  {  
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					    switch  ( this . configurationService . get ( 'DATA_SOURCES' ) [ 0 ] )  {  
					 
					 
					    switch  ( providerName )  {  
				
			 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 
					 
					      case  DataSource . ALPHA_VANTAGE :  
					 
					 
					      case  DataSource . ALPHA_VANTAGE :  
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  this . alphaVantageService ;  
					 
					 
					        return  this . alphaVantageService ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      case  DataSource . YAHOO :  
					 
					 
					      case  DataSource . YAHOO :  
				
			 
			
		
	
		
		
			
				
					 
					 
					        return  this . yahooFinanceService ;  
					 
					 
					        return  this . yahooFinanceService ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      case  DataSource . RAKUTEN :  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        return  this . rakutenRapidApiService ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					      case  DataSource . GHOSTFOLIO :  
				
			 
			
		
	
		
		
			
				
					 
					 
					 
					 
					 
					        return  this . ghostfolioScraperApiService ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					      default :  
					 
					 
					      default :  
				
			 
			
		
	
		
		
			
				
					 
					 
					        throw  new  Error ( 'No data provider has been found.' ) ;  
					 
					 
					        throw  new  Error ( 'No data provider has been found.' ) ;  
				
			 
			
		
	
		
		
			
				
					 
					 
					    }  
					 
					 
					    }