# NOTEBOOK settings and system details: [00-tpl v14.12.21] # Assume that the backend is LINUX (our particular distro is Ubuntu, running bash shell): print '\n :: TIMESTAMP of last notebook execution:' !date print '\n :: IPython version:' !ipython --version # Automatically reload modified modules: %load_ext autoreload %autoreload 2 # 0 disables autoreload. # Generate plots inside notebook: %matplotlib inline # DISPLAY options from IPython.display import Image # e.g. Image(filename='holt-winters-equations.png', embed=True) # url= also works from IPython.display import YouTubeVideo # e.g. YouTubeVideo('1j_HxD4iLn8', start='43', width=600, height=400) from IPython.display import HTML # useful for snippets # e.g. HTML('') import pandas as pd print '\n :: pandas version:' print pd.__version__ # pandas DataFrames are represented as text by default; enable HTML representation: # [Deprecated: pd.core.format.set_printoptions( notebook_repr_html=True ) ] pd.set_option( 'display.notebook_repr_html', False ) # MATH display, use %%latex, rather than the following: # from IPython.display import Math # from IPython.display import Latex print '\n :: Working directory (set as $workd):' workd, = !pwd print workd + '\n' from yi_1tools import * from yi_plot import * from yi_timeseries import * from yi_fred import * # Daily frequency: eurusd = getfred( d4eurusd ) # Note that the synthetic preprend back to 1971 is only for monthly data. plotfred( eurusd ) # Monthly frequency (daily frequency is not available): eursyn = getfred( m4eurusd ) plotfred(eursyn, 'EURUSD synthetic') # Define the day before QE-EU: qeeu = '2015-01-21' # What is the EURUSD low since QE-EU announcement? # On the day before, on 2015-01-21, the rate was 1.1584. stats( eurusd[qeeu:] ) syntrend = trend( eursyn ) plotfred( syntrend ) # Detrend: plotfred( eursyn - syntrend ) tailvalue( syntrend ) # Forecast monthly for next 24 months: holtfred( eursyn ) # Look at geometric return since 2006: georet( eurusd[t06:] ) # We retrieve the monthly frequency: usdjpy = getfred( m4usdjpy ) # Since monthly eursysn is expressed in terms of EURUSD: eurjpy = todf( eursyn * usdjpy ) plotfred( eurjpy, 'EURJPY synthetic' ) # Verify trend claim: ej95trend = trend( eurjpy['1995-01-01':] ) # The plot is uninteresting, just a straight line along 129.50 ! # Look at the slope and the std for confirmation: ej95trend.describe() # Euro strength against the yen on a scale of 100: int((tailvalue( eurjpy ) - 90) / 0.80) # 2014-12-22: 71 One month prior to QE-EU, EURJPY = 146.83 # 2015-01-21: 58 One day prior to QE-EU, EURJPY = 136.52 # 2015-04-01: 51 Two months after QE-EU, EURJPY = 130.80 # 2015-05-18: 55 Four months after QE-EU georet( eurjpy[t06:], 12 )