pyeconomics
A library for economic and financial analysis
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.5%) to scientific vocabulary
Scientific Fields
Repository
A library for economic and financial analysis
Basic Info
- Host: GitHub
- Owner: nathanramoscfa
- License: mit
- Language: Python
- Default Branch: main
- Size: 6.48 MB
Statistics
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 24
- Releases: 0
Metadata Files
README.md
PyEconomics
PyEconomics is a Python library for economic and financial analysis, designed to provide tools and models for analyzing various aspects of economic, financial, and fiscal policy. Whether you're a developer, economist, financial analyst, or researcher, PyEconomics aims to be your go-to resource for sophisticated economic modeling and analysis.
| Category | Badge |
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Testing |
|
| Package |
|
| Documentation |
|
| Release |
|
| Build Status |
|
| Maintainability |
|
| Code Style |
|
| Dependencies |
|
| Security |
|
Table of Contents
Introduction
PyEconomics is a versatile and comprehensive library that integrates various economic and financial models. It is designed to support the development and analysis of monetary policy rules, exchange rate models, macroeconomic and microeconomic models, discounted cash flow models, and much more.
Features
Current Features
- Monetary Policy Rules: Implementation of well-known monetary policy rules.
- Cache Management: Efficient caching for API calls to improve performance and reduce redundant data fetching.
Planned Features
- Exchange Rate Models: Models for predicting future exchange rates.
- Macroeconomic Models: Comprehensive macroeconomic models.
- Microeconomic Models: Detailed microeconomic models.
- Discounted Cash Flow Models: Advanced models for discounted cash flow analysis.
- Financial Models: Including CAPM and portfolio optimization.
- Fiscal Policy Models: Tools to analyze taxation, government spending, and public debt.
- Additional Economic Models: Support for behavioral economics, agent-based models, and international trade models.
Installation
To install PyEconomics, use pip:
sh
pip install pyeconomics
From Source
If you want to install the package from the source code, follow these steps:
Clone the repository:
sh git clone https://github.com/nathanramoscfa/pyeconomics.gitChange to the project directory:
sh cd pyeconomicsInstall the package:
sh pip install .
API Key
Some features of PyEconomics require access to the FRED API. To use these features, you need to configure your FRED API access.
A detailed step-by-step guide on obtaining and securely storing your FRED API key is available here:
Usage
Here are some basic examples of how to use PyEconomics for calculating and visualizing monetary policy rules.
Example 1: Calculate Current Policy Rule Estimates
```python
Import pyeconomics
import pyeconomics as pyecon
Calculate policy rule estimates
policyestimates = pyecon.calculatepolicyruleestimates(verbose=True) ```
Verbose Print Statement:
Example 2: Adjust Taylor Rule for Effective Lower Bound (ELB) and Policy Inertia
```python
Import pyeconomics
import pyeconomics as pyecon
Adjustment Parameters
rho = 0.7 # Policy Inertia Coefficient apply_elb = True # Apply Effective Lower Bound
adjustedpolicyestimates = pyecon.calculatepolicyruleestimates( rho=rho, applyelb=apply_elb, verbose=True ) ```
Verbose Print Statement:
Example 3: Calculate Current Taylor Rule Estimates
```python
Import pyeconomics modules
import pyeconomics as pyecon
Calculate policy rule estimates
policyestimates = pyecon.taylorrule(verbose=True) ```
Verbose Print Statement:
```text ==== Economic Indicators ================================================= Current Inflation: 3.04% Target Inflation: 2.00% Current Unemployment Rate: 3.90% Natural Unemployment Rate: 4.41% Long-Term Real Interest Rate: 2.10% Current Fed Rate: 5.50% As of Date: May 21, 2024
==== Gaps ================================================================ Inflation Gap: 1.04% Unemployment Gap: 0.51%
==== Taylor Rule ========================================================= Long-Term Real Interest Rate: 2.10% Current Inflation: + 3.04% Alpha * Inflation Gap: + 0.50 * 1.04%
Beta * Okun Factor * Unemployment Gap: + 0.50 * 2.00 * 0.51%
Unadjusted Taylor Rule Estimate: 6.17%
==== Adjusted Taylor Rule ================================================ Effective Lower Bound (ELB) Adjustment:
Maximum of Taylor Rule or ELB: max(6.17%, 0.12%)
Taylor Rule Adjusted for ELB: 6.17%
Policy Inertia Adjustment:
Policy Inertia Coefficient (rho): 0.70
Current Fed Rate: * 5.50%
Adjustment Coefficient (1 - rho): + (1 - 0.70)
Taylor Rule Adjusted for ELB: * 6.17%
Adjusted Taylor Rule Estimate: 5.70%
==== Policy Prescription ================================================= The Adjusted Taylor Rule Estimate is 0.20% higher than the Current Fed Rate. The Fed should consider raising the interest rate by 0.25%. ```
Example 4: Calculate and Plot Historical Policy Rule Estimates
```python
Import pyeconomics modules
import pyeconomics as pyecon
Calculate historical policy rates
historicalpolicyestimates = pyecon.calculatehistoricalpolicy_rates().dropna()
Plot historical policy rates
pyecon.plothistoricalruleestimates(historicalpolicy_estimates) ```
Example 5: Calculate and Plot the Adjusted Historical Policy Rules Adjusted
```python
Import pyeconomics modules
import pyeconomics as pyecon
Adjustment Parameters
rho = 0.7 # Policy Inertia Coefficient apply_elb = True # Apply Effective Lower Bound
Calculate adjusted historical policy rates
adjustedhistoricalpolicyestimates = pyecon.calculatehistoricalpolicyrates( rho=rho, applyelb=applyelb ).dropna()
Plot adjusted historical policy rates
pyecon.plothistoricalruleestimates( adjustedhistoricalpolicyestimates, adjusted=True) ```
Examples
For more comprehensive examples, refer to the examples directory in the repository.
Docker
To run PyEconomics using Docker, follow these steps:
Configure the .env File: Create a
.envfile in the root directory of pyeconomics with the following content:env FRED_API_KEY=your_fred_api_key_hereBuild the Docker Image: Navigate to your project directory and run the following command to build the Docker image:
sh docker build -t pyeconomics .Run the Docker Container: Run a container from your custom Docker image:
sh docker run --env-file .env -p 8888:8888 -it --rm pyeconomics
This will start a JupyterLab instance with the specified notebook open.
Access JupyterLab: In the command prompt output, you will see something like this:
plaintext To access the server, open this file in a browser: file:///root/.local/share/jupyter/runtime/jpserver-1-open.html Or copy and paste one of these URLs: http://e99fe8b9fbb5:8888/lab/tree/monetary_policy_rules/monetary_policy_rules.ipynb?token=your_token_here http://127.0.0.1:8888/lab/tree/monetary_policy_rules/monetary_policy_rules.ipynb?token=your_token_here
To open JupyterLab in your browser, hold the CTRL button and click the link
starting with: http://127.0.0.1:8888. Ignore the other links.
By using Docker, you ensure a consistent environment for running and testing PyEconomics.
Roadmap
The following models and categories are planned for future development. Contributions are welcome!
Monetary Policy Models
- Taylor Rule - Balanced Approach Rule - First Difference Rule - McCallum Rule - Orphanides Rule - Friedman Rule - Interest Rate Smoothing ModelsQuantity of Money Theory
- Fisher Equation - Cambridge Equation - Velocity of Money Models - Quantity Theory of Money (QTM) - Money Demand Function (Md)Economic Models to Predict Future Exchange Rates
- Purchasing Power Parity (PPP) - Interest Rate Parity (IRP) - Monetary Models of Exchange Rates - Portfolio Balance Models - Behavioral Equilibrium Exchange Rate (BEER) - Fundamental Equilibrium Exchange Rate (FEER)Macroeconomic Models
- IS-LM Model - AD-AS Model - Solow Growth Model - New Keynesian Models - RBC (Real Business Cycle) Model - DSGE (Dynamic Stochastic General Equilibrium) ModelsMicroeconomic Models
- Supply and Demand Models - Consumer Choice Theory - Production Theory - Cost Functions - Game Theory Models - Market Structure Models (Perfect Competition, Monopoly, Oligopoly)Discounted Cash Flow Models
- Dividend Discount Model (DDM) - Free Cash Flow to Equity (FCFE) - Free Cash Flow to Firm (FCFF) - Net Present Value (NPV) - Internal Rate of Return (IRR) - Adjusted Present Value (APV)Financial Models
- Capital Asset Pricing Model (CAPM) - Arbitrage Pricing Theory (APT) - Black-Scholes Option Pricing Model - Bond Valuation Models - Credit Risk Models (e.g., Merton Model) - Portfolio Optimization Models (e.g., Markowitz Model)Fiscal Policy Models
- Taxation and Government Spending Models - Budget Deficit Models - Public Debt Models - Fiscal Multiplier Models - Laffer Curve - Ricardian EquivalenceOther Well-Known Economic Models
- Behavioral Economics Models - Agent-Based Models - Environmental Economics Models - International Trade Models (e.g., Heckscher-Ohlin Model) - Labor Market Models - Health Economics ModelsContributing
Contributions are welcome! If you have a model you'd like to implement or an improvement to an existing model, please refer to our detailed Contributing Guide.
By participating in this project, you agree to abide by the Code of Conduct.
Thank you for your contributions!
Contact
If you have any questions, suggestions, or need support, feel free to reach out.
Nathan Ramos, CFA
Welcome to my GitHub! I'm Nathan, an independent Fintech Developer with a Chartered Financial Analyst (CFA) designation, specializing in Python-based financial analysis, quantitative strategies, and automated trading programs. Currently, I'm a fintech consultant open to new clients, especially in the realm of automated trading algorithms.
Connect with Me
- Email: nathan.ramos.github@gmail.com
- Twitter: @nathanramoscfa
Feel free to connect with me for any inquiries or collaboration opportunities.
Owner
- Name: Nathan Ramos, CFA
- Login: nathanramoscfa
- Kind: user
- Twitter: nathanramoscfa
- Repositories: 14
- Profile: https://github.com/nathanramoscfa
Fintech Developer specializing in Python-based financial analysis, quantitative strategies, and automated trading programs.
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "PyEconomics"
version: "0.2.0"
authors:
- family-names: "Ramos"
given-names: "Nathan"
email: "nathan.ramos.github@gmail.com"
affiliation: "Independent Fintech Developer"
date-released: "2024-05-20"
url: "https://github.com/nathanramoscfa/pyeconomics"
repository-code: "https://github.com/nathanramoscfa/pyeconomics"
license: "MIT"
abstract: |
PyEconomics is a Python library for economic and financial analysis,
designed to provide tools and models for analyzing various aspects of economic,
financial, and fiscal policy. Whether you're a developer, economist, financial
analyst, or researcher, PyEconomics aims to be your go-to resource for
sophisticated economic modeling and analysis.
keywords:
- economics
- financial analysis
- monetary policy
- exchange rate models
- macroeconomic models
- microeconomic models
- discounted cash flow
- financial models
- fiscal policy
GitHub Events
Total
- Watch event: 2
- Issue comment event: 10
- Push event: 11
- Pull request event: 7
- Fork event: 1
- Create event: 12
Last Year
- Watch event: 2
- Issue comment event: 10
- Push event: 11
- Pull request event: 7
- Fork event: 1
- Create event: 12
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 0
- Total pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- nathanramoscfa (30)
- dependabot[bot] (5)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 30 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 1
pypi.org: pyeconomics
A library for economic and financial analysis
- Homepage: https://github.com/nathanramoscfa/pyeconomics
- Documentation: https://pyeconomics.readthedocs.io/
- License: MIT License
-
Latest release: 0.2.5
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- fredapi *
- keyring *
- pandas *
- Dependencies ,
- pandas *
- actions/checkout v2 composite
- actions/setup-python v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- pypa/gh-action-pypi-publish v1.4.2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- codecov/codecov-action v3 composite
- python 3.12-slim build