From 9cd29befafe83d23ac8236c5494d3e6318136d09 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 12 Feb 2021 12:07:19 +1100 Subject: [PATCH 01/13] add artifact upload of _build folder --- .github/workflows/publish.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e98db956..1ce648b7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,6 +43,11 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: _build/html/ cname: python-programming.quantecon.org + - name: Upload "_build" folder (cache) + uses: actions/upload-artifact@v2 + with: + name: build-cache + path: _build - name: Prepare lecture-python-programming.notebooks sync shell: bash -l {0} run: | From 3eefb9223c517fbe4be067758edf9435d3c3e47d Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 17 Feb 2021 09:38:12 +1100 Subject: [PATCH 02/13] ENH: download build artifact from publish.yml (#123) * download build artifact from publish.yml * update main to master * enable copy updates * don't throw error if mkdir target exists from cache --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7b5ca291..2b144d92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,13 @@ jobs: - name: Display Pip Versions shell: bash -l {0} run: pip list + - name: Download "build" folder (cache) + uses: dawidd6/action-download-artifact@v2 + with: + workflow: publish.yml + branch: master + name: build-cache + path: _build - name: Build HTML shell: bash -l {0} run: | @@ -29,8 +36,8 @@ jobs: shell: bash -l {0} run: | jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter - mkdir _build/html/_notebooks - cp _build/jupyter/*.ipynb _build/html/_notebooks + mkdir -p _build/html/_notebooks + cp -u _build/jupyter/*.ipynb _build/html/_notebooks - name: Preview Deploy to Netlify uses: nwtgck/actions-netlify@v1.1 with: From 1c959fea06f64c7082193e2b8d1cc4feb23fa040 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 10 Mar 2021 13:54:31 +1100 Subject: [PATCH 03/13] apply fix to propogate environment to lecture-python-programming.notebooks repo --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1ce648b7..c5dffe74 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,6 +53,7 @@ jobs: run: | mkdir -p _build/lecture-python-programming.notebooks cp -a _notebook_repo/. _build/lecture-python-programming.notebooks + cp environment.yml _build/lecture-python-programming.notebooks cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks ls -a _build/lecture-python-programming.notebooks - name: Commit latest notebooks to lecture-python-programming.notebooks From decb8ffa4d24df30605e092868919709069d3aa4 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 10 Mar 2021 14:17:04 +1100 Subject: [PATCH 04/13] ENH: add execution statistics (#124) * add execution statistics * add jupytext header --- lectures/_toc.yml | 3 ++- lectures/status.md | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 lectures/status.md diff --git a/lectures/_toc.yml b/lectures/_toc.yml index bdf030c6..32014a21 100644 --- a/lectures/_toc.yml +++ b/lectures/_toc.yml @@ -31,4 +31,5 @@ - part: Other chapters: - - file: troubleshooting \ No newline at end of file + - file: troubleshooting + - file: status \ No newline at end of file diff --git a/lectures/status.md b/lectures/status.md new file mode 100644 index 00000000..99704b78 --- /dev/null +++ b/lectures/status.md @@ -0,0 +1,20 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# Execution Statistics + +This table contains the latest execution statistics. + +```{nb-exec-table} +``` + +These lectures are built on `linux` instances through `github actions` so are +executed using the following [hardware specifications](https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners#supported-runners-and-hardware-resources) \ No newline at end of file From 8278cb304cce01adfd86e3125c141a9ad0ac2d07 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 10 Mar 2021 15:30:55 +1100 Subject: [PATCH 05/13] update anaconda (#126) --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 55a26b67..ab8a9276 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - default dependencies: - python=3.8 - - anaconda=2020.07 + - anaconda=2020.11 - pip - pip: - jupyter-book From 8ac9a58b83f8ec108c9343f5b1992ecdde7abfcd Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 10 Mar 2021 16:14:43 +1100 Subject: [PATCH 06/13] prevent environment from propogating to lecture-python-programming.notebooks during publish --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c5dffe74..790283fa 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,7 +53,7 @@ jobs: run: | mkdir -p _build/lecture-python-programming.notebooks cp -a _notebook_repo/. _build/lecture-python-programming.notebooks - cp environment.yml _build/lecture-python-programming.notebooks + # cp environment.yml _build/lecture-python-programming.notebooks cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks ls -a _build/lecture-python-programming.notebooks - name: Commit latest notebooks to lecture-python-programming.notebooks From ab66c1db405d66fac7efcd2c375f4e38d5726b88 Mon Sep 17 00:00:00 2001 From: mmcky Date: Wed, 10 Mar 2021 16:24:55 +1100 Subject: [PATCH 07/13] update environment for mybinder --- .github/workflows/publish.yml | 1 - _notebook_repo/environment.yml | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 790283fa..1ce648b7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -53,7 +53,6 @@ jobs: run: | mkdir -p _build/lecture-python-programming.notebooks cp -a _notebook_repo/. _build/lecture-python-programming.notebooks - # cp environment.yml _build/lecture-python-programming.notebooks cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks ls -a _build/lecture-python-programming.notebooks - name: Commit latest notebooks to lecture-python-programming.notebooks diff --git a/_notebook_repo/environment.yml b/_notebook_repo/environment.yml index de38000a..30527822 100644 --- a/_notebook_repo/environment.yml +++ b/_notebook_repo/environment.yml @@ -4,14 +4,4 @@ channels: dependencies: - python=3.8 - anaconda - - pip - - pip: - - git+https://github.com/executablebooks/jupyter-book.git - - sphinxext-rediraffe - - git+https://github.com/executablebooks/sphinx-multitoc-numbering - - git+https://github.com/executablebooks/sphinx-exercise.git - - joblib - - interpolation - - git+https://github.com/QuantEcon/sphinx-tojupyter.git - - git+https://github.com/QuantEcon/quantecon-book-theme.git From fa442f6ba0271b13b6e8f2a49076c7cc34e4d0c7 Mon Sep 17 00:00:00 2001 From: AakashGC Date: Mon, 22 Mar 2021 17:51:56 +1100 Subject: [PATCH 08/13] =?UTF-8?q?=E2=9C=A8=20NEW:=20Adding=20launch=20urls?= =?UTF-8?q?=20in=20config=20to=20test=20on=20qe-theme=20CI=20#127?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lectures/_config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lectures/_config.yml b/lectures/_config.yml index ce878150..d33f2283 100644 --- a/lectures/_config.yml +++ b/lectures/_config.yml @@ -28,6 +28,12 @@ sphinx: description: This website presents a set of lectures on python programming for economics, designed and written by Thomas J. Sargent and John Stachurski. keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski google_analytics_id: UA-54984338-9 + launch_buttons: + notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"] + binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org) + jupyterhub_url : https://datahub.berkeley.edu # The URL of the JupyterHub (e.g., https://datahub.berkeley.edu) + thebe : false # Add a thebe button to pages (requires the repository to run on Binder) + colab_url : https://colab.research.google.com # The URL of Google Colab (https://colab.research.google.com) rediraffe_redirects: index_toc.md: intro.md tojupyter_static_file_path: ["source/_static", "_static"] From c379e3972171b4afb7ab2cd6052def1d2b635808 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 9 Apr 2021 11:52:47 +1000 Subject: [PATCH 09/13] update news item on front page (#129) --- lectures/intro.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lectures/intro.md b/lectures/intro.md index 7a33c11e..89f5cf9f 100644 --- a/lectures/intro.md +++ b/lectures/intro.md @@ -17,8 +17,9 @@ This website presents a set of lectures on Python programming for economics and ```{admonition} News [QuantEcon](https://quantecon.org) is moving to the [Jupyter Book](https://jupyterbook.org/intro.html) build system for all of its projects. We are a founding member of the -[Executable Books Project](https://github.com/executablebooks) and this -is the first in the QuantEcon lecture series to migrate. Please send feedback to [contact@quantecon.org](mailto:contact@quantecon.org) +[Executable Books Project](https://github.com/executablebooks), an international collaboration to +build open source tools that facilitate publishing using the Jupyter +ecosystem. Please send feedback to [contact@quantecon.org](mailto:contact@quantecon.org) ``` For an overview of the series, see [this page](https://quantecon.org/python-lectures/) From 40fa981b77fb13ac1c10666e4a8d8210e4f08360 Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 13 Apr 2021 10:32:57 +1000 Subject: [PATCH 10/13] NEWS: Add NYU Computational Social Science Course (#131) * add news article for course * edits for news item * replace is with are --- lectures/intro.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lectures/intro.md b/lectures/intro.md index 89f5cf9f..169fa3f0 100644 --- a/lectures/intro.md +++ b/lectures/intro.md @@ -14,7 +14,7 @@ kernelspec: This website presents a set of lectures on Python programming for economics and finance, designed and written by [Thomas J. Sargent](http://www.tomsargent.com/) and [John Stachurski](http://johnstachurski.net/). This is the first text in the series, which focuses on programming in Python. -```{admonition} News +```{admonition} New Build System [QuantEcon](https://quantecon.org) is moving to the [Jupyter Book](https://jupyterbook.org/intro.html) build system for all of its projects. We are a founding member of the [Executable Books Project](https://github.com/executablebooks), an international collaboration to @@ -22,6 +22,16 @@ build open source tools that facilitate publishing using the Jupyter ecosystem. Please send feedback to [contact@quantecon.org](mailto:contact@quantecon.org) ``` +```{admonition} News +Tom Sargent, Chase Coleman, and Spencer Lyon have put together The [NYU Computational Social +Science: Certificate Program](http://www.tomsargent.com/nyu_css.html). +It uses many [quantecon](https://quantecon.org/lectures/index.html) +resources. The program aims to prepare students for either a graduate program in the social +sciences or for a career as a data analyst or computational social scientist. + +[Applications and additional information are available here](https://as.nyu.edu/content/nyu-as/as/departments/computational-social-science.html) +``` + For an overview of the series, see [this page](https://quantecon.org/python-lectures/) ```{tableofcontents} From b0719b55c9cbe2d1dce017bcbbb2448dbcae08fe Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 13 Apr 2021 13:42:47 +1000 Subject: [PATCH 11/13] harmonise publishing workflows to new QuantEcon workflow (#132) --- .github/workflows/publish.yml | 12 +++++++++--- environment.yml | 12 +++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1ce648b7..b18c2915 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,10 +1,11 @@ name: Build & Publish to GH Pages on: push: - branches: - - master + tags: + - 'publish*' jobs: publish: + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') runs-on: ubuntu-latest steps: - name: Checkout @@ -17,7 +18,7 @@ jobs: miniconda-version: 'latest' python-version: 3.8 environment-file: environment.yml - activate-environment: lecture-python-programming + activate-environment: quantecon - name: Display Conda Environment Versions shell: bash -l {0} run: conda list @@ -32,6 +33,11 @@ jobs: shell: bash -l {0} run: | jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter + zip -r download-notebooks.zip _build/jupyter + - uses: actions/upload-artifact@v2 + with: + name: download-notebooks + path: download-notebooks.zip - name: Copy Download Notebooks for GH-PAGES shell: bash -l {0} run: | diff --git a/environment.yml b/environment.yml index ab8a9276..5b5a2f2b 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: lecture-python-programming +name: quantecon channels: - default dependencies: @@ -7,10 +7,12 @@ dependencies: - pip - pip: - jupyter-book - - sphinxext-rediraffe - sphinx-multitoc-numbering - - joblib - - interpolation - - sphinx-tojupyter - quantecon-book-theme + - sphinx-tojupyter + - sphinxext-rediraffe + - sphinx-exercise + - jupytext + - ghp-import + - jupinx From 47b29f473bbd53e2e3fb623624d58e2dfadbf1dd Mon Sep 17 00:00:00 2001 From: mmcky Date: Tue, 13 Apr 2021 20:40:08 +1000 Subject: [PATCH 12/13] [pandas] update pandas to use yfinance and minor edits (#133) * update pandas to use yfinance and minor edits * fix read function for yahoo finance * remove margin as not supported in quantecon-book-theme * add a space for title --- lectures/pandas.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lectures/pandas.md b/lectures/pandas.md index baf87644..0d06e311 100644 --- a/lectures/pandas.md +++ b/lectures/pandas.md @@ -34,6 +34,7 @@ In addition to what’s in Anaconda, this lecture will need the following librar tags: [hide-output] --- !pip install --upgrade pandas-datareader +!pip install --upgrade yfinance ``` ## Overview @@ -385,18 +386,28 @@ Note that pandas offers many other file type alternatives. Pandas has [a wide variety](https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html) of top-level methods that we can use to read, excel, json, parquet or plug straight into a database server. -### Using {index}`pandas_datareader ` to Access Data +### Using {index}`pandas_datareader ` and {index}`yfinance ` to Access Data ```{index} single: Python; pandas-datareader ``` -The maker of pandas has also authored a library called pandas_datareader that gives programmatic access to many data sources straight from the Jupyter notebook. +The maker of pandas has also authored a library called +[pandas_datareader](https://pandas-datareader.readthedocs.io/en/latest/) that +gives programmatic access to many data sources straight from the Jupyter notebook. While some sources require an access key, many of the most important (e.g., FRED, [OECD](https://data.oecd.org/), [EUROSTAT](https://ec.europa.eu/eurostat/data/database) and the World Bank) are free to use. +We will also use [yfinance](https://pypi.org/project/yfinance/) to fetch data from Yahoo finance +in the exercises. + For now let's work through one example of downloading and plotting data --- this time from the World Bank. +```{note} +There are also other [python libraries](https://data.worldbank.org/products/third-party-apps) +available for working with world bank data such as [wbgapi](https://pypi.org/project/wbgapi/) +``` + The World Bank [collects and organizes data](http://data.worldbank.org/indicator) on a huge range of indicators. For example, [here's](http://data.worldbank.org/indicator/GC.DOD.TOTL.GD.ZS/countries) some data on government debt as a ratio to GDP. @@ -426,7 +437,7 @@ With these imports: ```{code-cell} python3 import datetime as dt -from pandas_datareader import data +import yfinance as yf ``` Write a program to calculate the percentage price change over 2019 for the following shares: @@ -460,7 +471,8 @@ def read_data(ticker_list, ticker = pd.DataFrame() for tick in ticker_list: - prices = data.DataReader(tick, 'yahoo', start, end) + stock = yf.Ticker(tick) + prices = stock.history(start=start, end=end) closing_prices = prices['Close'] ticker[tick] = closing_prices From 78f70fb86b85e5c43192c42dfe03b09c1739dc7a Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 16 Apr 2021 13:17:52 +1000 Subject: [PATCH 13/13] update environment for quantecon (#134) --- environment.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/environment.yml b/environment.yml index 5b5a2f2b..38cdc94b 100644 --- a/environment.yml +++ b/environment.yml @@ -15,4 +15,6 @@ dependencies: - jupytext - ghp-import - jupinx + # Temporary Fixes + - tornado>=6.1