Deploy JupyterHub for Group

Prerequisites

I suppose you have:

  • A Linux/Unix based Workstation
  • A static LAN IP, like 202.116.12.34 (usually provided by CampusNet Service Center)
  • conda environment (Python 3.4 or greater)
  • nodejs/npm
    On Debian/Ubuntu, issue sudo apt-get install npm nodejs-legacy to install.
  • Jupyter Notebook (usually it is preinstalled in conda root environment)

Install JupyterHub

Issue these:

1
2
conda install -c conda-forge jupyterhub
conda install notebook

Edit config file

You can generate a default configuration file with jupyterhub --generate-config, then edit it following the instructions on official site. Here, if you are going to deploy JupyterHub for a class of students or your research group, my config file can be a good reference:

Read More

Operate Financial Database with PyTables

According to recent trends in financial data analysis area, more and more people begin to use Python in their project. The powerful packages, such as NumPy, Pandas and TensorFlow, all contribute to Python’s prevalence.

However, the I/O functions of Python can not meet people’s need of fast storing and retrieving very large amount of data. That’s why PyTables appears. You can find a fine introduction to PyTables on its official FAQ page.

PyTables is a package for managing hierarchical datasets designed to efficiently cope with extremely large amounts of data. It is …

To avoid repetition of official tutorials, I will directly show how to operate a financial database here.

  • Preparation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from tables import open_file
import numpy as np
bar_dtype = np.dtype([
('bar_id', np.int64),
('open', np.float64),
('high', np.float64),
('low', np.float64),
('close', np.float64),
('amount', np.float64),
('volume', np.int64)
])
security_name = 'AAPL'
# 10 minute-bars
security_bars = np.zeros(10, dtype=bar_dtype)
security_attrs = {
'price_limit': 10,
'trading_unit': 5
}

Read More