Notebooks for financial economics. Keywords: IPython notebook pandas statistics GDP inflation CPI PCE Fed FRED Ferbus unemployment wage income debt Case-Shiller housing asset portfolio equities SPX bonds TIPS rates currency Eurozone euro yen FX USD EUR JPY XAU gold Brent WTI oil Holt-Winters time-series forecasting econometrics
@lnsongxf hi, the preferred way for installation is just to clone the project under a directory in your PYTHONPATH. Best way to establish that editable variable is installing Anaconda beforehand which will resolve complex package dependencies. Then https://git.io/fecon-intro will help. Please message me if there are any other problems -- will revise the documentation accordingly.
Another way is non-native but direct cross-platform, Docker container : https://hub.docker.com/r/rsvp/fecon235/ -- Anaconda and git are pre-installed so just pull from origin/master to get latest fecon235 updates.
Quick look at equities in France since 2014, which covers Hollande malaise, Le Pen market fears, and Macron as President:
>>> fr = get('s4ewq')
:: Retrieved from Google Finance: EWQ
>>> fr14 = fr['2014':]
>>> roundit(gemrat(fr14))
[-0.6532, 1.6122, 19.0886, 15.7456, 256, 857]
>>> plot(fr14, 'FR_eq_2014-Macron')
The geometric mean rate is sub-zero, despite recent rally. The volatility is reasonable 19%, but the kurtosis is rather high at 15.7 (vs. 3 for a Gaussian). The function gemrat will be included in our next release.
It is very interesting that Berkshire Hathaway has accumulated more than 100 million shares of Apple recently, which has a geometric mean rate of 16.6% over the last ten years -- extraordinary growth:
>>> gm2gem(get('s4aapl'))
Geometric mean rate: 16.5693
Arithmetic mean rate: 22.4526
sigma: 32.8234
kurtosis (Pearson): 10.3151
GM(2), sigma1: 24.0206
GM(2), sigma2: 82.0585
GM(2), q: 0.0813
GM(2), b: 2.5
yearly: 256
N: 2512
and the above does not include dividend yield of 1.6%. The Gaussian mixture model deduces two volatilities: 24% and 82%, the latter occurring with probability 0.0813.
In contrast, BRK.A pays no dividends and has less a third of Apple's geometric growth (only 4.7% over the same period). It seems strange for value equities that Berkshire returns exhibit extremely high kurtosis of 21.4 (which compares to 3 for an ordinary Gaussian, and 10.3 for Apple).
gemrat()
function, see https://git.io/gmix -- the section on monthly geometric returns is insightful for asset allocation: comparison across real estate, stocks, bonds, gold, and FX from the viewpoint of USD-based investor.
Our inflation measure is a composite of CPI and PCE, both core and headline versions for each.
>>> infl = get(m4infl)
>>> roundit(gemrat(infl['2015':], yearly=12))
[1.6045, 1.6052, 0.3525, 5.8699, 12, 28]
The volatility is so low (0.35%) that the geometric and arithmetic rates of inflation are very close: 1.6%. The Fed target is 2%, core PCE basis, so they are currently off by about 1 standard deviation. Yellen in her recent testimony seemed puzzled given the labor market situation.
To score the Federal Reserve's performance under its dual mandate for inflation and unemployment, rerun this Jupyter notebook using current data, https://git.io/fed
Re: #2 -- Git shell script to list commit dates, given path/filename(s)
The system's modification time for a committed file may not
be the actual commit date and time! This can be verified
if you checkout an older branch and switch back.
There is no nice builtin git utility, so I wrote one:
https://git.io/git-lu
Fed Funds forecast one-year out is 1.50% using forefunds('17z', '18z')
so if the street is right about a rate hike at the December 13 presser, then 2018 looks like a very flat year in terms of US interest rates.
[Please see https://git.io/fedfunds for forecasting the Fed Funds rate using futures contracts on LIBOR.]
In terms of the US bond market, the Fed will begin to reduce its assets from QE, and thus the market sentiment is extremely bearish. As evidence, here is the plot of get(w4cotr_bonds)
which translates data from the CFTC Commitment of Traders Reports:
[The notebook https://git.io/cotr discerns how various asset classes are positioned in the market.] So overall for 2018, the yield curve is more likely to widen.