Skip to content

Commit 4a4c3b3

Browse files
committed
installation update
1 parent 5e43e1f commit 4a4c3b3

File tree

8 files changed

+14
-537
lines changed

8 files changed

+14
-537
lines changed

data/bbc.zip

2.8 MB
Binary file not shown.

data/earnings_calls.zip

9.82 MB
Binary file not shown.

installation/README.md

+13-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Installation instructions
22

3-
This book uses (mostly) Python 3.7 and numerous libraries that require installation. The first section covers how use Docker to pull an image that contains the necessary software and create a local container that allows you to run the notebooks without much further ado. The second section describes how to install the packages locally using the [Anaconda](https://www.anaconda.com/) distribution. If you are experienced and work a UNIX-based system, you can also create your own virtual environments and install the libraries required for different notebooks as needed. Then, we address how to work with [Jupyter](https://jupyter.org/) notebooks to view and execute the code examples. Finally, we list additional installation instructions for libraries that require non-python dependencies and discuss how to
3+
This book uses (mostly) Python 3.7 and numerous libraries that require installation. The first section covers how use Docker to pull an image that contains the necessary software and create a local container that allows you to run the notebooks. The second section describes how to install the packages locally using the [Anaconda](https://www.anaconda.com/) distribution. If you are experienced and work a UNIX-based system, you can also create your own virtual environments and install the libraries required for different notebooks as needed.
4+
5+
Then, we address how to work with [Jupyter](https://jupyter.org/) notebooks to view and execute the code examples. Finally, we list additional installation instructions for libraries that require non-python dependencies and discuss how to
46

57
## Run the code using a Docker images
68

@@ -10,13 +12,13 @@ This book uses (mostly) Python 3.7 and numerous libraries that require installat
1012
3. [Register](https://www.quandl.com/sign-up) for a (free) personal Quandl account to obtain an API key that you'll need in the next step.
1113
3. We'll be using an image based on the Ubuntu 20.04 OS with the Anaconda Python distribution installed. It also contains two conda environments, one to run Zipline and one for everything else. The following command does several things at once:
1214
```docker
13-
docker run -it -v $(pwd):/home/manning -e QUANDL_API_KEY=<yourkey> --name liveproject appliedai/manning:starter bash
15+
docker run -it -v $(pwd):/home/packt/ml4t -p 8888:8888 -e QUANDL_API_KEY=<your API key> --name ml4t appliedai/packt:latest bash
1416
```
15-
- it pulls the image from the Docker Hub account `appliedai` and the repository `manning` with the tag `starter`
16-
- creates a local container with the name `liveproject` and runs it in interactive mode,
17-
- mounts the current directory containing the starter project files as a volume in the directory `/home/manning` inside the container,
17+
- it pulls the image from the Docker Hub account `appliedai` and the repository `packt` with the tag `latest`
18+
- creates a local container with the name `ml4t` and runs it in interactive mode,
19+
- mounts the current directory containing the starter project files as a volume in the directory `/home/packt/ml4t` inside the container,
1820
- sets the environment variable `QUANDL_API_KEY` with the value of your key (that you need to fill in for `<yourkey>`), and
19-
- starts a `bash` terminal inside the container, resulting in a new command prompt.
21+
- starts a `bash` terminal inside the container, resulting in a new command prompt for the user `packt`.
2022
4. Now you are running a shell inside the container and can access the `conda environments`.
2123
- Run `conda env list` to see that there are a `base`, `ml4t` (default), and a `ml4t-`zipline` environment.
2224
- You can switch to another environment using `conda activate <env_name>`.
@@ -30,19 +32,12 @@ This book uses (mostly) Python 3.7 and numerous libraries that require installat
3032
- You should see numerous messages as Zipline processes around 3,000 stock price series
3133
5. Now we would like to test Zipline and the [juypter](https://jupyter.org/) setup. You can run notebooks using either the traditional or the more recent Jupyter Lab 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:
3234
```bash
33-
jupyter notebook --ip 0.0.0.0 --port 8888 --no-browser --allow-root
34-
jupyter lab --ip 0.0.0.0 --port 8888 --no-browser --allow-root
35+
jupyter notebook --ip 0.0.0.0 --no-browser --allow-root
36+
jupyter lab --ip 0.0.0.0 --no-browser --allow-root
3537
```
38+
- There are also `alias` shortcuts for each so you don't have to type them: `nb` for the `jupyter notebook` version, and `lab` for the `jupyter lab` version.
3639
- The terminal will display a few messages and at the end indicate what to paste into your browser to access the jupyter server from the current working directory.
37-
6. To test Zipline, run the ```zipline_test.ipynb``` notebook. It contains the example from the Zipline tutorial referenced in step 5 and should display the backtest results at the end.
38-
39-
40-
# docker run -it -v $(pwd):/home/packt --name ml4t packt bash
41-
# jupyter lab --ip 0.0.0.0 --port 8888 --no-browser --allow-root
42-
43-
Zipline: no assets traded;
44-
!zipline ingest -b quantopian-quandl
45-
edit DB (!)
40+
6. You can modify any of the environments using the standard conda workflow outlined below; see Docker docs for how to persist containers after making changes.
4641

4742
## How to install the required libraries using `conda` environments
4843

@@ -72,8 +67,7 @@ Here, we will create an environment from a file to ensure you install the versio
7267

7368
| Part(s) | Chapters | File | Path |
7469
|---------|----------|---------------|----------------------------------------------------|
75-
| 1 & 2 | 2-13 | ml4t.yml | environments/{linux\|macos\|windows}/ml4t.yml |
76-
| 3 | 14-16 | ml4t_text.yml | environments/{linux\|macos\|windows}/ml4t_text.yml |
70+
| 1, 2 & 3 | 2-16 | ml4t.yml | environments/{linux\|macos\|windows}/ml4t.yml |
7771
| 4 | 17-22 | ml4t_dl.yml | environments/{linux\|macos\|windows}/ml4t_dl.yml |
7872

7973
To create the environment with the name `ml4t` (specified in the file) for `linux`, just run:

installation/environments/linux/ml4t-dl-gpu.yml

-9
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@ dependencies:
110110
- json5=0.9.5
111111
- jsonschema=3.2.0
112112
- jupyter=1.0.0
113-
- jupyter_client=6.1.3
114-
- jupyter_console=6.1.0
115-
- jupyter_contrib_core=0.3.3
116-
- jupyter_contrib_nbextensions=0.5.1
117-
- jupyter_core=4.6.3
118-
- jupyter_highlight_selected_word=0.2.0
119-
- jupyter_latex_envs=1.4.6
120-
- jupyter_nbextensions_configurator=0.4.1
121113
- jupyterlab=2.1.5
122114
- jupyterlab_server=1.1.5
123115
- keras-preprocessing=1.1.0
@@ -311,5 +303,4 @@ dependencies:
311303
- pyqtwebengine==5.12.1
312304
- toml==0.10.1
313305
- typing-extensions==3.7.4.2
314-
prefix: /home/stefan/.pyenv/versions/miniconda3-latest/envs/ml4t-dl
315306

installation/environments/linux/ml4t-dl-simple.yml

-257
This file was deleted.

installation/environments/linux/ml4t-dl.yml

-8
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,6 @@ dependencies:
102102
- jsonschema=3.2.0
103103
- jupyter=1.0.0
104104
- jupyter_client=6.1.3
105-
- jupyter_console=6.1.0
106-
- jupyter_contrib_core=0.3.3
107-
- jupyter_contrib_nbextensions=0.5.1
108-
- jupyter_core=4.6.3
109-
- jupyter_highlight_selected_word=0.2.0
110-
- jupyter_latex_envs=1.4.6
111-
- jupyter_nbextensions_configurator=0.4.1
112105
- jupyterlab=2.1.5
113106
- jupyterlab_server=1.1.5
114107
- jxrlib=1.1
@@ -292,5 +285,4 @@ dependencies:
292285
- pymdptoolbox==4.0b3
293286
- toml==0.10.1
294287
- typing-extensions==3.7.4.2
295-
prefix: /home/stefan/.pyenv/versions/miniconda3-latest/envs/ml4t-dl
296288

installation/environments/linux/ml4t.yml

+1-10
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ dependencies:
131131
- json5=0.9.5
132132
- jsonschema=3.2.0
133133
- jupyter=1.0.0
134-
- jupyter_client=6.1.3
135-
- jupyter_console=6.1.0
136-
- jupyter_contrib_core=0.3.3
137-
- jupyter_contrib_nbextensions=0.5.1
138-
- jupyter_core=4.6.3
139-
- jupyter_highlight_selected_word=0.2.0
140-
- jupyter_latex_envs=1.4.6
141-
- jupyter_nbextensions_configurator=0.4.1
142134
- jupyterlab=2.1.5
143135
- jupyterlab_server=1.1.5
144136
- jxrlib=1.1
@@ -374,11 +366,10 @@ dependencies:
374366
- inflection==0.5.0
375367
- more-itertools==8.3.0
376368
- mplfinance==0.12.5a2
377-
- pyfolio==0.9.2+73.gcfdf82a
369+
- pyfolio
378370
- pyqt5-sip==4.19.18
379371
- pyqtchart==5.12
380372
- pyqtwebengine==5.12.1
381373
- quandl==3.5.0
382374
- yellowbrick==1.1
383-
prefix: /home/stefan/.pyenv/versions/miniconda3-latest/envs/ml4t
384375

0 commit comments

Comments
 (0)