finagg: Financial Aggregation for Python
finagg is an innovative Python package aimed at simplifying the process of accessing and utilizing financial data. It provides users with implementations of widely-used financial APIs, tools for integrating this data into SQL databases, and capabilities to transform the aggregated data into features suitable for analysis, artificial intelligence, and machine learning applications.
Installation
Getting started with finagg is straightforward. Users can install the latest stable version via pip:
pip install finagg
For those who want to explore the cutting-edge features still in development, the unstable version can be installed from GitHub:
git clone https://github.com/theOGognf/finagg.git
pip install ./finagg/
Additionally, users can opt to install recommended datasets such as economic data, company financials, and stock histories from third-party APIs into a local SQL database:
finagg install -ss economic -ts indices -z -r
The installation guides users on obtaining free API keys for each necessary API, storing these keys in a local .env
file. Further installation options are accessible through the command finagg install --help
.
Basic Usage
finagg facilitates direct interaction with various financial APIs. Below are some exemplary use cases:
-
Bureau of Economic Analysis (BEA) Data: Retrieve industry GDP information by year.
finagg.bea.api.gdp_by_industry.get(year=[2019]).head(5)
-
Federal Reserve Economic Data (FRED): Accessing economic series observations.
finagg.fred.api.series.observations.get("CPIAUCNS", realtime_start=0, realtime_end=-1, output_type=4).head(5)
-
Securities and Exchange Commission (SEC) Filings: Fetch company facts by ticker.
finagg.sec.api.company_facts.get(ticker="AAPL").head(5)
finagg's tools can utilize locally stored raw data for advanced analysis, such as obtaining economic features or quarterly report features from SEC data.
Configuration
Setting up finagg requires configuring API keys and user agents. API keys are necessary for accessing most APIs, and can be set as environment variables or passed programmatically. Paths for data storage and HTTP cache can also be customized through environment variables, ensuring flexibility in data management.
Dependencies
finagg relies on several dependencies to ensure seamless functionality:
- pandas for data manipulation.
- requests for handling HTTP requests.
- requests-cache to optimize API call efficiency.
- SQLAlchemy for database operations.
- yfinance for acquiring historical stock data.
Related Projects and FAQs
finagg exists alongside other financial tools and projects, including FinRL for reinforcement learning environments and OpenBBTerminal for financial analysis.
One frequent question is regarding feature availability for specific tickers or data series. This may be limited by the newness of APIs or insufficient data. Moreover, finagg supports Python versions 3.10 and up for optimal performance.
Understanding and harnessing the potential of finagg can greatly enhance one's ability to manage and analyze financial data efficiently.