-
Notifications
You must be signed in to change notification settings - Fork 14
/
common.py
46 lines (34 loc) · 1.09 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Common code for reuse in notebooks
"""
def systemInfo():
""" print versions of most important modules """
import imp
modules = ['tradingWithPython','pandas','ibapi','ib']
for name in modules:
print(5*'-',name,5*'-')
try:
result = imp.find_module(name)
except ImportError as e:
print(e)
continue
pkg = imp.load_module(name,*result)
print('Version: ',pkg.__version__)
print('Location:', pkg.__file__)
def prettifyNotebook(figsize=[8,6], max_rows=10, precision=2):
"""
cosmetic tweaks to make notebook look pretty
"""
import matplotlib.pyplot as plt
plt.style.use('ggplot')
# bigger fitures
import matplotlib
matplotlib.rcParams['figure.figsize'] = figsize
# limint number of rows shown by pandas
import pandas as pd
pd.options.display.max_rows = max_rows
# set two-digit precision, we usually don't need more for financial data
pd.options.display.precision = precision
if __name__=="__main__":
#systemInfo()
prettifyNotebook()