Bearish is a package for querying financial and price data from various equities across different countries, and persisting it into a well-structured SQLite database for further data analysis and stock screening.
This package is intended for active retail investors with a strong passion for data analysis, who require well-structured, clean, and large datasets locally to:
- Run custom technical and fundamental analysis
- Perform in-depth data analysis
- Identify patterns and investment insights
- Build custom screeners
Bearish is not designed for real-time trading, but for extensive analysis of historical and current financial data.
Bearish is designed to collect large-scale data from exchanges in different countries. It fetches data politely β meaning it does not make large-scale concurrent API calls and instead respects the rate limits and policies of each data provider. So, patience is required during large data retrieval.
The data fetched includes:
- Historical price data
- Company fundamentals
- Balance sheets, income statements, and more
All data is stored in a local SQLite database from which you can query, analyze, and build insights.
Bearish pulls data from multiple sources:
- π¦ FinanceDatabase for basic ticker information
- π InvestPy for country-level equity listings
- π yFinance as the primary source of prices and fundamentals
- π Financial Modeling Prep (FMP)
- π AlphaVantage
- π Tiingo
Ticker information is enriched using additional sources like yFinance, FMP, etc.
Bearish is also extensible β you can add support for any data source or API.
By default, Bearish relies primarily on yFinance due to limitations in free-tier APIs of other providers. However, if you have a premium subscription, you can use other sources more fully.
Install Bearish with pip:
pip install bearishpy
Fetch and store stock data for selected countries:
bearish run /path/to/sqlite/db Belgium France --api-keys=config.json
β This command:
- Loads tickers from FinanceDatabase and InvestPy
- Filters relevant equities from the selected countries
- Enriches the data with fundamentals and prices
- Stores everything in your local SQLite database
β±οΈ This operation can take some time depending on the size of the countryβs exchange β data is fetched "politely", not in bulk.
Once your database is populated, future updates are quicker.
The config.json
contains the API keys of the different providers (if needed):
{
"FMPAssets": "your Financial Modeling Prep API key",
"FMP": "your Financial Modeling Prep API key",
"AlphaVantage": "your Alphavantage API key",
"Tiingo": "your Tiingo API key"
}
To update only the price data:
bearish prices /path/to/sqlite/db Belgium France --api-keys=config.json
To update financial and fundamental data:
bearish financials /path/to/sqlite/db Belgium France --api-keys=config.json
To fetch and store data for specific tickers:
bearish run /path/to/sqlite/db US --filters NVDA,TSLA,RHM.DE --api-keys=config.json
You must always provide the country where each ticker is traded along with the desired tickers as filters.
Feature | Description |
---|---|
π Country-level support | Fetch equities from any exchange |
π§ Fundamental data | Balance sheets, cash flow, income statements |
π Price history | Up-to-date historical prices |
ποΈ Local database | Data saved in SQLite for offline analysis |
π Extensible | Plug in your own APIs or providers |
π§ͺ Designed for analysis | Ideal for custom screeners and research |
Contributions are welcome! Feel free to open issues or submit pull requests to improve Bearish.
Bearish is released under the MIT License.