Skip to content

Commit

Permalink
Merge pull request stefan-jansen#242 from ryanrussell/main
Browse files Browse the repository at this point in the history
docs(various): Fix typos. Also closes stefan-jansen#233
  • Loading branch information
stefan-jansen authored Jul 26, 2022
2 parents 024b21b + a0afa21 commit f4b4f2d
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@
"# msft.get_splits(proxy=PROXY_SERVER)\n",
"# msft.get_balance_sheet(proxy=PROXY_SERVER)\n",
"# msft.get_cashflow(proxy=PROXY_SERVER)\n",
"# msgt.option_chain(proxy=PROXY_SERVER)"
"# msft.option_chain(proxy=PROXY_SERVER)"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions 05_strategy_evaluation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ As a result, there are several approaches to optimize portfolios that include th
- [The minimum-variance portfolio](#the-minimum-variance-portfolio)
- [The Black-Litterman approach](#the-black-litterman-approach)
- [How to size your bets – the Kelly rule](#how-to-size-your-bets--the-kelly-rule)
- [Alternatives to MV Optimizatino with Python](#alternatives-to-mv-optimizatino-with-python)
- [Alternatives to MV Optimization with Python](#alternatives-to-mv-optimization-with-python)
* [Hierarchical Risk Parity](#hierarchical-risk-parity)
3. [Trading and managing a portfolio with `Zipline`](#trading-and-managing-a-portfolio-with-zipline)
* [Code Examples: Backtests with trades and portfolio optimization ](#code-examples-backtests-with-trades-and-portfolio-optimization-)
Expand Down Expand Up @@ -86,7 +86,7 @@ The challenges with accurate inputs for the mean-variance optimization problem h

#### The 1/N portfolio

Simple portfolios providae useful benchmarks to gauge the added value of complex models that generate the risk of overfitting. The simplest strategy—an equally-weighted portfolio—has been shown to be one of the best performers.
Simple portfolios provide useful benchmarks to gauge the added value of complex models that generate the risk of overfitting. The simplest strategy—an equally-weighted portfolio—has been shown to be one of the best performers.

#### The minimum-variance portfolio

Expand Down Expand Up @@ -123,7 +123,7 @@ This novel approach developed by [Marcos Lopez de Prado](http://www.quantresearc
- concentration, and
- underperformance.

Hierarchical Risk Parity (HRP) applies graph theory and machine-learning to build a diversified portfolio based on the information contained in the covariance matrix. However, unlike quadratic optimizers, HRP does not require the invertibility of the covariance matrix. In fact, HRP can compute a portfolio on an ill-degenerated or even a singular covariance matrix—an impossible feat for quadratic optimizers. Monte Carlo experiments show that HRP delivers lower out-ofsample variance than CLA, even though minimum variance is CLA’s optimization objective. HRP also produces less risky portfolios out of sample compared to traditional risk parity methods. We will discuss HRP in more detail in [Chapter 13](../13_unsupervised_learning) when we discuss applications of unsupervised learning, including hiearchical clustering, to trading.
Hierarchical Risk Parity (HRP) applies graph theory and machine-learning to build a diversified portfolio based on the information contained in the covariance matrix. However, unlike quadratic optimizers, HRP does not require the invertibility of the covariance matrix. In fact, HRP can compute a portfolio on an ill-degenerated or even a singular covariance matrix—an impossible feat for quadratic optimizers. Monte Carlo experiments show that HRP delivers lower out-of-sample variance than CLA, even though minimum variance is CLA’s optimization objective. HRP also produces less risky portfolios out of sample compared to traditional risk parity methods. We will discuss HRP in more detail in [Chapter 13](../13_unsupervised_learning) when we discuss applications of unsupervised learning, including hierarchical clustering, to trading.

- [Building diversified portfolios that outperform out of sample](https://jpm.pm-research.com/content/42/4/59.short), Marcos López de Prado, The Journal of Portfolio Management 42, no. 4 (2016): 59-69.
- [Hierarchical Clustering Based Asset Allocation](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2840729), Thomas Raffinot, 2016
Expand All @@ -149,6 +149,6 @@ Pyfolio facilitates the analysis of portfolio performance and risk in-sample and

### Code Example: `pyfolio` evaluation from a `Zipline` backtest

The notebook [pyfolio_demo](03_pyfolio_demo.ipynb) illustrates how to extract the `pyfolio` input from the backtest conducted in the previous folder. It then proceeds to calcuate several performance metrics and tear sheets using `pyfolio`
The notebook [pyfolio_demo](03_pyfolio_demo.ipynb) illustrates how to extract the `pyfolio` input from the backtest conducted in the previous folder. It then proceeds to calculate several performance metrics and tear sheets using `pyfolio`

- This notebook requires the `conda` environment `backtest`. Please see the [installation instructions](../installation/README.md) for running the latest Docker image or alternative ways to set up your environment.
2 changes: 1 addition & 1 deletion 08_ml4t_workflow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The most prominent challenge to backtest validity, including to published result

De Lopez Prado and David Bailey derived a deflated SR to compute the probability that the SR is statistically significant while controlling for the inflationary effect of multiple testing, non-normal returns, and shorter sample lengths.

The pyton script [deflated_sharpe_ratio](01_multiple_testing/deflated_sharpe_ratio.py) in the directory [multiple_testing](01_multiple_testing) contains the Python implementation with references for the derivation of the related formulas.
The python script [deflated_sharpe_ratio](01_multiple_testing/deflated_sharpe_ratio.py) in the directory [multiple_testing](01_multiple_testing) contains the Python implementation with references for the derivation of the related formulas.

### References

Expand Down
4 changes: 2 additions & 2 deletions 09_time_series_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The pandas library includes very flexible functionality to define various window

Autocorrelation (also called serial correlation) adapts the concept of correlation to the time series context: just as the correlation coefficient measures the strength of a linear relationship between two variables, the autocorrelation coefficient measures the extent of a linear relationship between time series values separated by a given lag.

We present the following tools to measure autorcorrelation:
We present the following tools to measure autocorrelation:
- autocorrelation function (ACF)
- partial autocorrelation function (PACF)
- correlogram as a plot of ACF or PACF against the number of lags.
Expand Down Expand Up @@ -132,7 +132,7 @@ The development of a volatility model for an asset-return series consists of fou

### Code examples: volatility forecasts

The notebook [arch_garch_models](03_arch_garch_models.ipynb) demonstrates the usage of the ARCH library to estimate time series models for volatility foreccasting with NASDAQ data.
The notebook [arch_garch_models](03_arch_garch_models.ipynb) demonstrates the usage of the ARCH library to estimate time series models for volatility forecasting with NASDAQ data.

### Resources

Expand Down
2 changes: 1 addition & 1 deletion 10_bayesian_machine_learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Relevant use cases of a Bayesian SR include the analysis of differences between

The last [chapter](../09_time_series_models) introduced pairs trading as a popular trading strategy that relies on the **cointegration** of two or more assets. Given such assets, we need to estimate the hedging ratio to decide on the relative magnitude of long and short positions. A basic approach uses linear regression.

The notebook [rolling_regression](04_rolling_regression.ipynb) llustrates how Bayesian linear regression tracks changes in the relationship between two assets over time. It follows Thomas Wiecki’s example (see 'Resources' below).
The notebook [rolling_regression](04_rolling_regression.ipynb) illustrates how Bayesian linear regression tracks changes in the relationship between two assets over time. It follows Thomas Wiecki’s example (see 'Resources' below).

### Code Example: Stochastic Volatility Models

Expand Down
2 changes: 1 addition & 1 deletion 13_unsupervised_learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ The manifold hypothesis emphasizes that high-dimensional data often lies on or n

### Code Example: what a manifold looks like

The notebook [manifold_learning_intro](02_manifold_learning/01_manifold_learning_intro.ipynb) contains several exampoles, including the two-dimensional swiss roll that illustrates the topological structure of manifolds.
The notebook [manifold_learning_intro](02_manifold_learning/01_manifold_learning_intro.ipynb) contains several examples, including the two-dimensional swiss roll that illustrates the topological structure of manifolds.

### Code Example: Local Linear Embedding

Expand Down
2 changes: 1 addition & 1 deletion 14_working_with_text_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ The notebook [nlp_pipeline_with_spaCy](01_nlp_pipeline_with_spaCy.ipynb) demonst

#### Data
- [BBC Articles](http://mlg.ucd.ie/datasets/bbc.html), use raw text files
- [TED2013](http://opus.nlpl.eu/TED2013.php), a parallel corpus of TED talk subtitles in 15 langugages
- [TED2013](http://opus.nlpl.eu/TED2013.php), a parallel corpus of TED talk subtitles in 15 languages

### Code example: NLP with TextBlob

Expand Down
2 changes: 1 addition & 1 deletion 15_topic_modeling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The notebook [lda_financial_news](07_lda_financial_news.ipynb) shows how to summ

### Applications

- [Applications of Topic Models](https://mimno.infosci.cornell.edu/papers/2017_fntir_tm_applications.pdf), Jordan Boyd-Graber, Yuening Hu, David Minmo, 2017
- [Applications of Topic Models](https://mimno.infosci.cornell.edu/papers/2017_fntir_tm_applications.pdf), Jordan Boyd-Graber, Yuening Hu, David Mimno, 2017
- [High Quality Topic Extraction from Business News Explains Abnormal Financial Market Volatility](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3675119/pdf/pone.0064846.pdf)
- [What are You Saying? Using Topic to Detect Financial Misreporting](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2803733)
- [LDA in the browser - javascript implementation](https://github.com/mimno/jsLDA)
Expand Down
4 changes: 2 additions & 2 deletions 16_word_embeddings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ The notebook [financial_news_preprocessing](03_financial_news_preprocessing.ipyn

### Skip-gram architecture in TensorFlow 2 and visualization with TensorBoard

The notebook [financal_news_word2vec_tensorflow](04_financal_news_word2vec_tensorflow.ipynb) illustrates how to build a word2vec model using the Keras interface of TensorFlow 2 that we will introduce in much more detail in the next chapter.
The notebook [financial_news_word2vec_tensorflow](04_financial_news_word2vec_tensorflow.ipynb) illustrates how to build a word2vec model using the Keras interface of TensorFlow 2 that we will introduce in much more detail in the next chapter.

### How to train embeddings faster with Gensim

The TensorFlow implementation is very transparent in terms of its architecture, but it is not particularly fast. The natural language processing (NLP) library [gensim](https://radimrehurek.com/gensim/) that we also used for topic modeling in the last chapter, offers better performance and more closely resembles the C-based word2vec implementation provided by the original authors.

The notebook [inancial_news_word2vec_gensim](05_financial_news_word2vec_gensim.ipynb) shows how to learn word vectors more efficiently.
The notebook [financial_news_word2vec_gensim](05_financial_news_word2vec_gensim.ipynb) shows how to learn word vectors more efficiently.

## Code Example: word Vectors from SEC Filings using gensim

Expand Down
2 changes: 1 addition & 1 deletion 17_deep_learning/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Additional options include:

### How to Leverage GPU Optimization

All popular Deep Learning libraries support the use of GPU, and some also allow for parallel training on multiple GPU. The most common types of GPU are produced by NVIDA, and configuration requires installation and setup of the CUDA environment. The process continues to evolve and can be somewhat challenging depending on your computational environment.
All popular Deep Learning libraries support the use of GPU, and some also allow for parallel training on multiple GPU. The most common types of GPU are produced by NVIDIA, and configuration requires installation and setup of the CUDA environment. The process continues to evolve and can be somewhat challenging depending on your computational environment.

A more straightforward way to leverage GPU is via the the Docker virtualization platform. There are numerous images available that you can run in local container managed by Docker that circumvents many of the driver and version conflicts that you may otherwise encounter. Tensorflow provides docker images on its website that can also be used with Keras.

Expand Down
4 changes: 2 additions & 2 deletions 20_autoencoders_for_conditional_risk_factors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In the process, the parameters of a hidden layer h become the code that represen
For a good overview, see Chapter 14 in Deep Learning:
- [Autoencoders](http://www.deeplearningbook.org/contents/autoencoders.html), Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning Book, MIT Press 2016

The TensorFlow's Keras interfacte makes it fairly straightforward to build various types of autoencoders and the following examples are adapted from Keras' tutorials.
The TensorFlow's Keras interface makes it fairly straightforward to build various types of autoencoders and the following examples are adapted from Keras' tutorials.

- [Building Autoencoders in Keras](https://blog.keras.io/building-autoencoders-in-keras.html)

Expand All @@ -44,7 +44,7 @@ The notebook [deep_autoencoders](01_deep_autoencoders.ipynb) illustrates how to

As discussed in Chapter 18, [CNNs: Time Series as Images and Satellite Image Classification](../18_convolutional_neural_nets), fully-connected feedforward architectures are not well suited to capture local correlations typical to data with a grid-like structure. Instead, autoencoders can also use convolutional layers to learn a hierarchical feature representation. Convolutional autoencoders leverage convolutions and parameter sharing to learn hierarchical patterns and features irrespective of their location, translation, or changes in size.

The notebook [convolutional_denoising_autoencoders](02_convolutional_denoising_autoencoders.ipynb) goes on to demonstrate how to implement convolutional and denoising autencoders to recover corrupted image inputs.
The notebook [convolutional_denoising_autoencoders](02_convolutional_denoising_autoencoders.ipynb) goes on to demonstrate how to implement convolutional and denoising autoencoders to recover corrupted image inputs.

### Seq2seq autoencoders to extract time-series features for trading

Expand Down
10 changes: 5 additions & 5 deletions installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> There is still incomplete support for MacOS using M1/Silicone chips. Some packages compatible with new architecture are only available via `conda`/`mamba`, others only via `pip`. As a result, there is no single installation script yet - I hope to be able to simplify this as the support across the PyData ecosystem matures. For now, please create separate `conda`/`pip`-based environments to install packages as needed and supported.
> Update September 10, 2021: New OS-agnostic environment files `ml4t-base.[txt, yml]` for `pip` (Linux, MacOS) and `conda` (Linux, MacOS, Windows) installs available that include the latest [Zipline](https://github.com/stefan-jansen/zipline-reloaded), [Alphalens](https://github.com/stefan-jansen/alphalens-reloaded) and [Pyfolio](https://github.com/stefan-jansen/pyfolio-reloaded) versions. These files are OS-agnostic because they include only the main libraries and not OS-specific dependencies, leaving the selection of the latest compatible versions and OS-specific depencies to your package manager of choice.
> Update September 10, 2021: New OS-agnostic environment files `ml4t-base.[txt, yml]` for `pip` (Linux, MacOS) and `conda` (Linux, MacOS, Windows) installs available that include the latest [Zipline](https://github.com/stefan-jansen/zipline-reloaded), [Alphalens](https://github.com/stefan-jansen/alphalens-reloaded) and [Pyfolio](https://github.com/stefan-jansen/pyfolio-reloaded) versions. These files are OS-agnostic because they include only the main libraries and not OS-specific dependencies, leaving the selection of the latest compatible versions and OS-specific dependencies to your package manager of choice.
> Update April 25, 2021: The [new Zipline version](https://github.com/stefan-jansen/zipline-reloaded) permits running the backtest notebooks without Docker on all operating systems; the installation instructions now refer to Windows/MacOS/Linux environment files.
Expand Down Expand Up @@ -112,7 +112,7 @@ brew install lightgbm swig xz ta-lib
On Ubuntu, pre-requisites can be fulfilled via `apt`. For TA-Lib, the [necessary steps](https://artiya4u.medium.com/installing-ta-lib-on-ubuntu-944d8ca24eae) are:

```bash
# nstall the build tool
# install the build tool
sudo apt install build-essential wget -y
# Download and extract the source code
Expand Down Expand Up @@ -165,7 +165,7 @@ This section covers how to set up notebook extension that facilitate working in
#### Set up jupyter extensions
jupyter notebooks can use a range of [extentsion](https://github.com/ipython-contrib/jupyter_contrib_nbextensions) provided by the community. There are many useful ones that are described in the [documentation](https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/).
jupyter notebooks can use a range of [extension](https://github.com/ipython-contrib/jupyter_contrib_nbextensions) provided by the community. There are many useful ones that are described in the [documentation](https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/).
The notebooks in this repo are formatted to use the [Table of Contents (2)](https://jupyter-contrib-nbextensions.readthedocs.io/en/latest/nbextensions/toc2/README.html) extension. For the best experience, activate it using the Configurator in the [Nbextensions](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator) tab available in your browser after starting the jupyter server. Modify the settings to check the option 'Leave h1 items out of ToC' if not set by default.
Expand Down Expand Up @@ -311,7 +311,7 @@ Now you are running a shell inside the container and can access both [conda envi

The `backtest` environment is necessary because the latest version of Zipline 1.4.1 only support Python 3.6 and older versions of various other dependencies that partly also require compilation. I hope to update Zipline in the future to run on Python 3.8 as well.

We use the environment `ml4t` except for a dozen notebooks related to backtesting that use Zipline directly inputs generated by Zipline. The noteooks that require the `backtest` environment contain a notification.
We use the environment `ml4t` except for a dozen notebooks related to backtesting that use Zipline directly inputs generated by Zipline. The notebooks that require the `backtest` environment contain a notification.

> If you want to use a GPU for the deep learning examples, you can run `conda install tensorflow-gpu` if you have the proper [CUDA version](https://www.tensorflow.org/install/source#gpu) installed.
> **Alternatively**, you can leverage [TensorFlow's Docker](https://www.tensorflow.org/install/docker) images and install any additional libraries there; the DL examples don't require anything that's overly complicated to install.
Expand Down Expand Up @@ -356,7 +356,7 @@ That's all. Unfortunately, you (had to..) repeat this everytime you run `zipline

### Working with notebooks int the Docker container

You can run [juypter](https://jupyter.org/) notebooks using either the traditional [notebook](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) or the more recent [Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/) interface; both are available in all `conda` environments. Moreover, you start jupyter from the `base` environment and switch the environment from the notebook due to the `nb_conda_kernels` package (see [docs](https://github.com/Anaconda-Platform/nb_conda_kernels).
You can run [jupyter](https://jupyter.org/) notebooks using either the traditional [notebook](https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/what_is_jupyter.html) or the more recent [Jupyter Lab](https://jupyterlab.readthedocs.io/en/stable/) interface; both are available in all `conda` environments. Moreover, you start jupyter from the `base` environment and switch the environment from the notebook due to the `nb_conda_kernels` package (see [docs](https://github.com/Anaconda-Platform/nb_conda_kernels).

To get started, run one of the following two commands:
```bash
Expand Down

0 comments on commit f4b4f2d

Please sign in to comment.