feat(StockDataService): Add unified StockDataService and BaseProviderService with new stockdata interfaces, provider integrations, tests and README updates
This commit is contained in:
65
ts/stocks/interfaces/stockdata.ts
Normal file
65
ts/stocks/interfaces/stockdata.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import type { IStockPrice } from './stockprice.js';
|
||||
import type { IStockFundamentals } from './fundamentals.js';
|
||||
|
||||
/**
|
||||
* Combined stock data with price and fundamentals
|
||||
* All calculated metrics (market cap, P/E, P/B) are automatically included
|
||||
*/
|
||||
export interface IStockData {
|
||||
/** Stock ticker symbol */
|
||||
ticker: string;
|
||||
|
||||
/** Price information */
|
||||
price: IStockPrice;
|
||||
|
||||
/** Fundamental data (optional - may not be available for all stocks) */
|
||||
fundamentals?: IStockFundamentals;
|
||||
|
||||
/** When this combined data was fetched */
|
||||
fetchedAt: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration for StockDataService
|
||||
*/
|
||||
export interface IStockDataServiceConfig {
|
||||
/** Cache configuration */
|
||||
cache?: {
|
||||
/** TTL for price data (default: 24 hours) */
|
||||
priceTTL?: number;
|
||||
/** TTL for fundamentals data (default: 90 days) */
|
||||
fundamentalsTTL?: number;
|
||||
/** Max cache entries (default: 10000) */
|
||||
maxEntries?: number;
|
||||
};
|
||||
|
||||
/** Provider timeouts */
|
||||
timeout?: {
|
||||
/** Timeout for price providers (default: 10000ms) */
|
||||
price?: number;
|
||||
/** Timeout for fundamentals providers (default: 30000ms) */
|
||||
fundamentals?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Request type for getting complete stock data
|
||||
*/
|
||||
export interface ICompleteStockDataRequest {
|
||||
ticker: string;
|
||||
/** Whether to include fundamentals (default: true) */
|
||||
includeFundamentals?: boolean;
|
||||
/** Whether to enrich fundamentals with price calculations (default: true) */
|
||||
enrichFundamentals?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch request for multiple stocks
|
||||
*/
|
||||
export interface ICompleteStockDataBatchRequest {
|
||||
tickers: string[];
|
||||
/** Whether to include fundamentals (default: true) */
|
||||
includeFundamentals?: boolean;
|
||||
/** Whether to enrich fundamentals with price calculations (default: true) */
|
||||
enrichFundamentals?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user