├── .gitignore ├── Dockerfile ├── README.md ├── data └── xml │ ├── 1990.xml │ ├── 1991.xml │ ├── 1992.xml │ ├── 1993.xml │ ├── 1994.xml │ ├── 1995.xml │ ├── 1996.xml │ ├── 1997.xml │ ├── 1998.xml │ ├── 1999.xml │ ├── 2000.xml │ ├── 2001.xml │ ├── 2002.xml │ ├── 2003.xml │ ├── 2004.xml │ ├── 2005.xml │ ├── 2006.xml │ ├── 2007.xml │ ├── 2008.xml │ ├── 2009.xml │ ├── 2010.xml │ ├── 2011.xml │ ├── 2012.xml │ ├── 2013.xml │ ├── 2014.xml │ ├── 2015.xml │ ├── 2016.xml │ ├── 2017.xml │ ├── 2018.xml │ └── 2019.xml ├── docker-compose.yml ├── images ├── ycr_07_08.png ├── ycr_2018.png ├── ycr_2018_2019.png ├── ycr_2019.png └── ycr_all.png ├── requirements.txt └── yield-curve.ipynb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .ipynb_checkpoints 3 | .idea/* 4 | venv/ 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Retrieve image from Dockerhub 2 | FROM jupyter/datascience-notebook:latest 3 | 4 | # Install Vim 5 | USER root 6 | RUN sudo apt-get update 7 | RUN sudo apt-get -y install git curl vim python- 8 | 9 | # Install pip 10 | RUN mkdir /opt/yield 11 | WORKDIR /opt/yield 12 | COPY requirements.txt /opt/yield/requirements.txt 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # YIELD CURVE 2 | 3 | A Python/Jupyter notebook project to understand the Yield Curve and its potential for forecasting a recession. Yield 4 | curve rates between 1990 and present are from the [U.S. Department of the Treasury](https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield) 5 | 6 | ## Getting Started 7 | 8 | * Git clone the repository 9 | * Create a virtual environment and run `$ pip install -r requirements.txt` 10 | * Update the `docker-compose.yml` volumes to point to your local instance and cd to where the repo is stored 11 | * Run the following: 12 | ``` 13 | $ docker-compose build 14 | $ docker-compose up 15 | ``` 16 | You can access the project at `http://localhost:8888/notebooks/yield%20curve.ipynb` and you'll need to provide a token that appears in the docker logs. To bring down the project, run `$ docker-compose down` and to destroy the containers, run `$ docker-compose kill`. 17 | 18 | ## Forecasting a Recession 19 | A deeper dive into [U.S. Department of the Treasury](https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yield) Yield Curve data and it's predictive capaiblities. 20 | 21 | In an efficiently performing market, long-term bonds have higher bond yield rates than shorter-term bonds, T-notes, and T-bills as the market expects greater risk in investing in long-term bonds (a lot can happen in 30 years). However, when the yield curve inverts, the bond yield rates for shorter-term bonds are higher than long-term bond yield rates. An Inverted Yield Curve is used as one predictor of a recession as it captures the nervousness of investors about the near term market outlook. 22 | 23 | In my analysis, an Inverted Yield Curve occurs when the ratio of long-term bond rates (i.e. 30 years, 10 years) versus short-term bonds (6 months, 1 year, 3 years, etc.) is between 0 and 1. The yield curve last inverted between 2006 and 2007. 24 | 25 | ### Yield Curve Ratios for Years 1990 to Present 26 | ![Yield Curve Ratios for Years 1990 to Present](/images/ycr_all.png?raw=true) 27 | 28 | 29 | ### Yield Curve Ratios Demonstrating Inversion from 2006 to 2007 30 | ![Yield Curve Ratios for Years 2006 to 2007](/images/ycr_07_08.png?raw=true) 31 | 32 | 33 | ### Yield Curve Ratios for 2019 34 | The ratio of 10 year bonds/6 month bonds and 10 year/1 year bonds inverted in May 2019 35 | ![Yield Curve Ratios for 2019](/images/ycr_2019.png?raw=true) 36 | 37 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | notebook: 5 | build: . 6 | ports: 7 | - "8888:8888" 8 | volumes: 9 | - "~/Projects/yield-curve:/opt/yield" 10 | -------------------------------------------------------------------------------- /images/ycr_07_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skasim/yield-curve/d22633920d00685103227bd05f98eaa1df797581/images/ycr_07_08.png -------------------------------------------------------------------------------- /images/ycr_2018.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skasim/yield-curve/d22633920d00685103227bd05f98eaa1df797581/images/ycr_2018.png -------------------------------------------------------------------------------- /images/ycr_2018_2019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skasim/yield-curve/d22633920d00685103227bd05f98eaa1df797581/images/ycr_2018_2019.png -------------------------------------------------------------------------------- /images/ycr_2019.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skasim/yield-curve/d22633920d00685103227bd05f98eaa1df797581/images/ycr_2019.png -------------------------------------------------------------------------------- /images/ycr_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skasim/yield-curve/d22633920d00685103227bd05f98eaa1df797581/images/ycr_all.png -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | matplotlib 3 | requests 4 | notebook --------------------------------------------------------------------------------