The Python Quants

Python Quant Platform

Brief Overview and Introduction (needs Python 2.7 on the platform)

Dr. Yves J. Hilpisch

The Python Quants GmbH

analytics@pythonquants.com

www.pythonquants.com

The Platform

General Aspects and Trials

The Python Quant Platform is developed and maintained by The Python Quants GmbH. It offers Web-/browser-based data and financial analytics for individuals, teams and organizations. Free registrations are possible under http://trial.quant-platform.com.

PQP Registration

You can freely choose your your_user_name and password. You can then login under http://analytics.quant-platform.com, using trial as company in combination with your_user_name and password.

PQP login

Please note that trial/test accounts are only for illustration purposes and they can be closed at any time (with all data, code, etc. be permanently deleted).

Please read also the Terms & Conditions as well as our Privacy Policy.

If you have questions about the platform or any troubles, you can reach us under platform@pythonquants.com.

Platform Components & Features

At the moment, the Python Quant Platform comprises the following components and features:

  • IPython Notebook: interactive data and financial analytics in the browser with full Python integration and much more (cf. IPython home page).
  • Anaconda Python Distribution: complete Python stack for financial, scientific and data analytics workflows/applications (cf. Anaconda page); you can easily switch between Python 2.7 and 3.4.
  • Other Data Science Languages: you can also use R or Julia on the platform.
  • DX Analytics: our library for advanced financial and derivatives analytics with Python based on Monte Carlo simulation.
  • File Manager: a GUI-based File Manager to upload, download, copy, remove, rename files on the platform.
  • Full Fledged Code Editing: there is a code and text editor available which support the most common languages, among others, by syntax highlightling.
  • Application Development & Deployment: you can not only do interactive data and financial analytics, you find everything to develop real (Web-based) applications and to deploy them.
  • Chat/Forum: there is a simple chat/forum application available via which you can share thoughts, documents and more.
  • Collaboration: the platform features user/group administration as well as file sharing via public folders.
  • Linux Server: the platform is powered by Linux servers to which you have full shell access.
  • Platform Deployment: the platform is easily scalable since it is cloud-based and can also be easily deployed on your own servers (via Docker containers).

PQP Overview

IPython Notebook

In the left panel of the platform, you find the current working path indicated (in black) as well as the current folder and file structure (as links in purple). Note that in this panel only IPython Notebook files are displayed. Here you can navigate the current folder structure by clicking on a link. Clicking on the double points ".." brings you one level up in the structure. Clicking the refresh button right next to the double points updates the folder/file structure. Clicking on a file link opens the IPython Notebook file.

Basic Approach

You find a link to open a new notebook on top of the left panel. With IPython notebooks, like with this one, you can interactively code Python and do data/financial analytics.

In [1]:
print ("Hello Quant World.")
Hello Quant World.

In [2]:
# simple calculations
3 + 4 * 2
Out[2]:
11
In [3]:
# working with NumPy arrays
import numpy as np
rn = np.random.standard_normal(100)
rn[:10]
Out[3]:
array([ 0.82494901,  0.16332511,  0.76873293,  1.14726731, -2.19660228,
        0.73128696,  0.06199284,  1.31718399, -0.9857746 ,  0.04518282])
In [4]:
# plotting
import matplotlib.pyplot as plt
%matplotlib inline
plt.plot(rn.cumsum())
plt.grid(True)

If you are new to IPython Notebook, you could start on the IPython home page and might want to check out the videos that are linked there (cf. video page).

Efficient Financial Analytics

Combining the pandas library with IPython Notebook makes for a powerful financial analytics environment.

In [5]:
import pandas as pd
import pandas.io.data as web
In [6]:
AAPL = web.DataReader('AAPL', data_source='google')
  # reads data from Google Finance
AAPL['42d'] = pd.rolling_mean(AAPL['Close'], 42)
AAPL['252d'] = pd.rolling_mean(AAPL['Close'], 252)
  # 42d and 252d trends
In [7]:
AAPL[['Close', '42d', '252d']].plot(figsize=(10, 5))
Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f1b60faadd0>

Below you find a complete talk/tutorial about interactive financial analytics with Python.

In [8]:
from IPython.display import YouTubeVideo
YouTubeVideo('XyqlduIcc2g', width=700, height=400)
Out[8]:

Using R from within IPython

Loading the R extension for IPython.

In [9]:
# only Python 2.7
%load_ext rpy2.ipython

Pushing data to R.

In [10]:
AAPL_close = AAPL['Close'].values
In [11]:
%Rpush AAPL_close

Plotting data with R.

In [12]:
%R plot(AAPL_close, pch=20, col='red'); grid(); title("AAPL closing values")

Using Julia from within Python

Julia is, for example, often faster for iterative function formulations. As an example, consider the Fibonacci sequence.

In [13]:
%%julia
# recursive formulation in Julia
fib_rec(n) = n < 2 ? n : fib_rec(n - 1) + fib_rec(n - 2)
@elapsed fib_rec(40)
fib_rec (generic function with 1 method)
0.78789074

In [14]:
# same in Python
def fib_rec(n):
    if n < 2:
        return n
    else:
        return fib_rec(n - 1) + fib_rec(n - 2)
%time fib_rec(40)
CPU times: user 30.4 s, sys: 61 ms, total: 30.5 s
Wall time: 30.3 s

Out[14]:
102334155

DX Analytics

DX Analytics is a Python library for advanced financial and derivatives analytics written by The Python Quants. It is particularly suited to model multi-risk derivatives and to do a consistent valuation of portfolios of complex derivatives. It mainly uses Monte Carlo simulation since it is the only numerical method capable of valuing and risk managing complex, multi-risk derivatives books.

In [15]:
# only Python 2.7
import dx
%run dx_example.py
  # sets up market environments
  # and defines derivative instrument
In [16]:
max_call.payoff_func
  # payoff of a maximum call option
  # on two underlyings (European exercise)
Out[16]:
"np.maximum(np.maximum(maturity_value['gbm'], maturity_value['jd']) - 34., 0)"
In [17]:
max_call.vega('jd')
  # numerical Vega with respect
  # to one risk factor
Out[17]:
2.7000000000001023

We are going to generate a Vega surface for one risk factor with respect to the initial values of both risk factors.

In [18]:
asset_1 = np.arange(28., 46.1, 2.)
asset_2 = asset_1
a_1, a_2 = np.meshgrid(asset_1, asset_2)
value = np.zeros_like(a_1)
In [19]:
%%time
vega_gbm = np.zeros_like(a_1)
for i in range(np.shape(vega_gbm)[0]):
    for j in range(np.shape(vega_gbm)[1]):
        max_call.update('gbm', initial_value=a_1[i, j])
        max_call.update('jd', initial_value=a_2[i, j])
        vega_gbm[i, j] = max_call.vega('gbm')
CPU times: user 3.93 s, sys: 2 ms, total: 3.93 s
Wall time: 3.93 s

In [20]:
dx.plot_greeks_3d([a_1, a_2, vega_gbm], ['gbm', 'jd', 'vega gbm'])
  # Vega surface plot

File Manager

The File Manager allows the easy, GUI-based file management on the platform.

Left Column

In the left column you can navigate the file system. For instance, you find a folder called public which you can use to share files with others.

PQP File Manager

Right Column

In the right column, you find the contents of the folder currently active in the left column. The content is updated by clicking on the refresh butotn. You can, for example, drag and drop files and folders as well as upload files from you local disk. For uploading, you have to do the following:

  1. press the add files button
  2. select (multiple) file(s) from your local disk
  3. press the upload button

For downloading from a Web source, do:

  1. press the add URL button
  2. insert the URL as copied e.g. from the browser
  3. press the OK button

Via a right click, you can:

  • delete a file/folder
  • rename a file/folder
  • zip a file/folder
  • unzip a zip file
  • download a file
  • generate a new file in the current folder
  • generate a new folder in the current folder

Via a double click on a file, you can open and edit it (for those files where it is possible, e.g. Python, HTML or CSS files).

All file operations are only implementable based on the respective user's rights on the operating system level. For example, everybody can copy a file to the public folder. This file can then be read and executed by everybody, but only the "owner" of the file can overwrite or delete it.

Code Editor

This component of the platform allows the editing of a multitude of different file types (e.g. Python, HTML or CSS).

PQP Python Code Editing

Shell Access

This component of the platform allows the shell-based access to the Linux server. This part of the platform requires a separate login for security reasons (credentials available upon request).

IPython Shell

For example, you can also interactively code on the shell via IPython Shell. The IPython Shell version is started by simply typing ipython in the system shell.

PQP IPython

Text Editing and Coding

Via the system shell you can of course edit and kind of text document and file with computer code, e.g. Python. To this end, you can use Vim which is started via typing vim filename on the system shell or alternatively Nano (started by nano filename).

PQP Vim Editing

File Operations and Git Repositories

Of course, you can do anything else via the system shell given your personal rights on the operating system level. Among others, you can:

  • do file operations (copying, renaming, moving, etc.)
  • use Git repositories (to clone/pull projects, commit and push them)

Application Development & Deployment

Via the Python Quant Platform you can develop and deploy also your (Web) applications. Here is an example that shows real-time streaming of financial data.

PQP Web App Example

Further Resources

Consulting and Development Services

The Python Quants group – i.e. The Python Quants GmbH, Germany, and The Python Quants LLC., New York City – provide consulting and development services with a focus on Python for Finance. The team consists of Python and Financial experts with comprehensive experience in the financial industry and in particular in the Quant Finance space.

For example, The Python Quants have designed and implemented a Python-based Tutorial for Eurex, one of the leading derivatives exchanges in the world. The tutorial is about volatility derivatives and is called VSTOXX Advanced Services and is available under http://www.eurexchange.com/vstoxx/. There are is also strategy backtesting application available under http://www.eurexchange.com/vstoxx/app2/

Python for Quant Finance Trainings

The Python Quants group offers trainings on a global basis. Training offerings include, among others:

  • Python for Finance
  • Derivatives Analytics with Python
  • Performance Python

During trainings, the Python Quant Platform is used for a frictionless start and a highly interactive, collaborative training experience.

There is also a complete Python for Finance Online Course available under http://quantshub.com. See the trailer of the online course below.

In [21]:
YouTubeVideo('kpIoNpm97UY', width=700, height=400)
Out[21]:

Python for Quant Finance Books

There are two books available from The Python Quants group about Python for Quant Finance.

Python for Finance

If you are working in (Quant) Finance and want to use Python for developing interactive analytics workflows or more complex financial applications, then this book is the right source for you. You can order at it at Amazon or at O'Reilly.

Python for Finance

Derivatives Analytics with Python

The other book by The Python Quants group is about advanced, market-based derivatives analytics and uses Python to illustrate and implement all numerical methods introduced (Fourier-based option pricing, Monte Carlo simulation, option model calibration, hedging).

Derivatives Analytics with Python

The book will be published in 2015 by Wiley Finance.

See the Wiley book page.

Community and Conferences

Members of The Python Quant group are actively involved in the Python community and organize different meetup groups both in Europe as well as in New York City:

The Python Quants also organize the largest "For Python Quants" conference in the world. At the recent NYC conference in March 2014, more than 220 people have been in attendance (cf. http://nyc2014.forpythonquants.com). The last one took place in London on 28. November 2014 (cf. http://lon2014.forpythonquants.com).

Contact us

Please contact us if you have any questions or want to get involved in our Python community events.