Skip to content

Instantly share code, notes, and snippets.

@yhilpisch
Last active February 27, 2020 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save yhilpisch/1fb0b9a3da5f29a419ed72d8b5a8d019 to your computer and use it in GitHub Desktop.
Save yhilpisch/1fb0b9a3da5f29a419ed72d8b5a8d019 to your computer and use it in GitHub Desktop.

Intermediate Python for Finance Training

This is the Gist for the Intermediate Python for Finance Training in London, 28.-29. November 2017.

Notebooks & Code Files

Additional files (eg Jupyter Notebooks) are found under:

https://gist.github.com/d06a4e0987e45c0a8219136f027c3769 (day 1)

https://gist.github.com/26b02c85c5d3b67034bd55b29e12e549 (day 2)

Slides

http://hilpisch.com/intpython.pdf

Python Cheat Sheets

Recommended Books

  • Matt Harrison (2017): Illustrated Guide to Python 3.
  • Luciano Ramalho (2015): Fluent Python. O'Reilly.
  • Jake VanderPlas (2016): Python Data Science Handbook. O'Reilly.
  • Gael Varoquaux et al. (2017): SciPy Lecture Notes. http://www.scipy-lectures.org/

The Python Quants

http://twitter.com/dyjh

team@tpq.io | http://tpq.io

http://pyalgo.tpq.io | http://certificate.tpq.io

Program Overview

The training is over two days, with a total of four modules and eight sections.

Every section is about 90 minutes long, followed by a short break or a longer (lunch) break.

The style of the training is interactive throughout, meaning that the material is developed live during the sections.

The participants will also work on exercises related to the topics of the singe sections.

Day 1

Module 1 — Python

This module is a review of Python infrastructure elements and basic Python idioms.

The goal of this module is to be able to set up a proper Python environment, to know about basic tools and to be aware of basic Python functionality.

Module 2 — NumPy

This module covers numerical operations and algorithms with NumPy for finance.

NumPy is a central package in numerical and financial analysis. It allows for the performant implementation of financial algorithms based on concise, vectorized code.

The goal of this module is to understand the benefits of NumPy compared to pure Python code in finance.

Day 2

Module 3 — pandas

This module is about data analysis and visualization with pandas for finance.

pandas has become the central data analysis tool in the Python ecosystem. It is powerful, among others, in handling financial time series data, in visualizing such data and implementing algorithms on such data sets.

The goal of this module is to be aware of the capabilities of pandas and to be able to apply pandas to typical financial analytics tasks.

Module 4 — OOP

The final module addresses object-oriented programming (OOP) in Python based on finance examples.

OOP is a powerful programming paradigm with many benefits over simple procedural implementations. Among others, it allows a simplified modeling of real-world and financial object, to avoid redundancies, to simplify code maintenance and re-usability.

The goal of this module is to be aware of basic OOP features in Python and to implement financial algorithms in a re-usable fashion.

The Python Quants

http://twitter.com/dyjh

team@tpq.io | http://tpq.io

http://pyalgo.tpq.io | http://certificate.tpq.io

Setting up a Python Environment

Windows

Miniconda

How to install Miniconda:

https://conda.io/docs/user-guide/install/windows.html

The installer is found under:

https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe

Python

See http://conda.io

Also see https://conda.io/docs/_downloads/conda-cheatsheet.pdf

And: https://conda.io/docs/user-guide/tasks/manage-environments.html

To create an environment execute in the terminal ("command prompt"):

conda create -n base python=3.6
activate base

To install Python packages and start Jupyter execute in the terminal:

conda install ipython jupyter numpy pandas scikit-learn matplotlib pytables
pip install win-unicode-console
set PYTHONIOENCODING=UTF-8
jupyter notebook

Mac OS

System

For installing the brew package manager, follow the instructions under:

https://brew.sh/

Installing system tools in a terminal/on the shell:

brew install wget htop screen [MORE IF NEEDED]

Miniconda

To download and install it:

wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash miniconda.sh

Open new terminal to activate the Python installation.

Python

See http://conda.io

Also see https://conda.io/docs/_downloads/conda-cheatsheet.pdf

To create an environment execute:

conda create -n base python=3.6
source activate base

To install Python packages and start Jupyter execute in the terminal:

conda install ipython jupyter numpy pandas scikit-learn matplotlib pytables
jupyter notebook

Linux

System

Doing system updates and installing system tools in the terminal/on the shell:

apt-get update
apt-get upgrade
apt-get install wget bzip2 screen vim gcc [MORE IF NEEDED]

Miniconda

To download and install it:

wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh

Open a new terminal/shell instance to activate the Python installation.

Python

See http://conda.io

Aslo see https://conda.io/docs/_downloads/conda-cheatsheet.pdf

To create an environment execute:

conda create -n base python=3.6
source activate base

To install Python packages and start Jupyter execute in the terminal:

conda install ipython jupyter numpy pandas scikit-learn matplotlib pytables
jupyter notebook

The Python Quants

http://twitter.com/dyjh

team@tpq.io | http://tpq.io

http://pyalgo.tpq.io | http://certificate.tpq.io

Some Docker Basics

[As an alternative to using the local operating system.]

Installation

Detailed installation instructions are found under:

https://docs.docker.com/engine/installation/

Linux/Mac

To test whether it is installed, open a terminal window and type:

docker version

To run a docker container, type for instance:

docker run -ti -h fpq -p 8888:8888 ubuntu:latest /bin/bash

Windows

Open the Docker Quickstart Terminal.

To run a docker container type:

docker run -ti -h fpq -p 8888:8888 -e MACHINE_IP=$(docker-machine ip) ubuntu:latest /bin/bash

The Python Quants

http://twitter.com/dyjh

team@tpq.io | http://tpq.io

http://pyalgo.tpq.io | http://certificate.tpq.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment