Ufc
Main entry point for the UFC (US Free Financial Data Collector) library.
This class provides a unified facade for accessing financial data from multiple sources:
Yahoo Finance: Real-time quotes, historical data, company fundamentals, options chains, stock screener, earnings calendar, and WebSocket streaming
FRED: Federal Reserve Economic Data including GDP, unemployment, inflation, and other economic indicators
Business Insider: ISIN to ticker symbol conversion
The library is inspired by Python's yfinance and fredapi libraries, providing similar functionality for Kotlin/JVM applications.
Quick Start
// Create client without FRED API
val ufc = Ufc.create()
val quote = ufc.quote("AAPL")
println("Price: ${quote.pricing?.price}")
// Or with FRED API key
val config = UfcConfig(fredApiKey = "your-api-key")
val ufcWithFred = Ufc.create(config)Usage Examples
// Get multiple quotes
val quotes = ufc.quote(listOf("AAPL", "GOOGL", "MSFT"))
// Get historical chart data
val chart = ufc.chart(
symbol = "AAPL",
interval = Interval.OneDay,
period = Period.OneYear
)
// Get company fundamentals
val summary = ufc.quoteSummary(
"AAPL",
QuoteSummaryModule.PRICE,
QuoteSummaryModule.FINANCIAL_DATA
)
// Screen stocks
val gainers = ufc.screener(PredefinedScreener.DAY_GAINERS, count = 10)
// Get FRED economic data (requires API key)
val gdp = ufc.series("GDP")Resource Management
This class implements AutoCloseable and should be used with try-with-resources or Kotlin's use function to ensure proper cleanup of HTTP clients and WebSocket connections:
Ufc.create().use { ufc ->
val quote = ufc.quote("AAPL")
// ...
}See also
Properties
Business Insider client for ISIN lookups
FRED client for economic data (null if API key not provided)
WebSocket streaming client for real-time price updates
Yahoo Finance client for market data and company information
Functions
Retrieves the earnings calendar for a specific company.
Retrieves time-series fundamental data for financial statement line items.
Looks up securities by query string with optional type filtering.
Retrieves market summary data for a specific market.
Retrieves market trading hours and status for a specific market.
Retrieves options chain data for a specific symbol and expiration date.
Retrieves detailed company information using Yahoo's QuoteSummary modules.
Screens stocks using a predefined screener enum.
Screens stocks using a predefined screener ID.
Screens stocks using a custom query with filtering criteria.
Searches for a ticker symbol using an ISIN (International Securities Identification Number).
Retrieves economic data series from the Federal Reserve Economic Data (FRED) API.
Retrieves earnings calendar visualization data for a symbol.