@fin.cx/opendata
Version:
A comprehensive TypeScript library for accessing business data and real-time financial information. Features include German company data management with MongoDB integration, JSONL bulk processing, automated Handelsregister interactions, and real-time stoc
105 lines (104 loc) • 2.96 kB
TypeScript
import type { IFundamentalsProvider, IFundamentalsProviderConfig, IFundamentalsProviderRegistry, IStockFundamentals, IFundamentalsRequest } from './interfaces/fundamentals.js';
/**
* Service for managing fundamental data providers and caching
* Parallel to StockPriceService but for fundamental data instead of prices
*/
export declare class FundamentalsService implements IFundamentalsProviderRegistry {
private providers;
private cache;
private logger;
private cacheConfig;
constructor(cacheConfig?: {
ttl?: number;
maxEntries?: number;
});
/**
* Register a fundamentals provider
*/
register(provider: IFundamentalsProvider, config?: IFundamentalsProviderConfig): void;
/**
* Unregister a provider
*/
unregister(providerName: string): void;
/**
* Get a specific provider by name
*/
getProvider(name: string): IFundamentalsProvider | undefined;
/**
* Get all registered providers
*/
getAllProviders(): IFundamentalsProvider[];
/**
* Get enabled providers sorted by priority
*/
getEnabledProviders(): IFundamentalsProvider[];
/**
* Get fundamental data for a single ticker
*/
getFundamentals(ticker: string): Promise<IStockFundamentals>;
/**
* Get fundamental data for multiple tickers
*/
getBatchFundamentals(tickers: string[]): Promise<IStockFundamentals[]>;
/**
* Unified data fetching method
*/
getData(request: IFundamentalsRequest): Promise<IStockFundamentals | IStockFundamentals[]>;
/**
* Enrich fundamentals with calculated metrics using current price
*/
enrichWithPrice(fundamentals: IStockFundamentals, price: number): Promise<IStockFundamentals>;
/**
* Enrich batch fundamentals with prices
*/
enrichBatchWithPrices(fundamentalsList: IStockFundamentals[], priceMap: Map<string, number>): Promise<IStockFundamentals[]>;
/**
* Check health of all providers
*/
checkProvidersHealth(): Promise<Map<string, boolean>>;
/**
* Get provider statistics
*/
getProviderStats(): Map<string, {
successCount: number;
errorCount: number;
lastError?: string;
lastErrorTime?: Date;
}>;
/**
* Clear all cached data
*/
clearCache(): void;
/**
* Set cache TTL
*/
setCacheTTL(ttl: number): void;
/**
* Get cache statistics
*/
getCacheStats(): {
size: number;
maxEntries: number;
ttl: number;
};
/**
* Fetch with retry logic
*/
private fetchWithRetry;
/**
* Generate cache key for request
*/
private getCacheKey;
/**
* Get from cache if not expired
*/
private getFromCache;
/**
* Add to cache with TTL
*/
private addToCache;
/**
* Get human-readable request description
*/
private getRequestDescription;
}