10.12.2019 Views

Python for Finance

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8

• George, T.J., and Hwang, C., 2004, The 52-Week High and Momentum Investing,

Journal of Finance 54(5), 2145–2176, http://www.bauer.uh.edu/tgeorge/

papers/gh4-paper.pdf

• Hasbrouck, Joel, 1992, Using the TORQ database, New York University,

http://people.stern.nyu.edu/jhasbrou/Research/Working%20Papers/

TORQDOC3.PDF

• Jegadeesh, N., and Titman, S., 1993, Returns to Buying Winners and Selling Losers:

Implications for Stock Market Efficiency, Journal of Finance 48(1), 65–91,

http://www.e-m-h.org/JeTi93.pdf

• Moskowitz, T., and Grinblatt, M., 1999, Do industries explain momentum?

Journal of Finance 54(4), 2017–2069, http://faculty.som.yale.edu/

Tobiasmoskowitz/documents/DoIndustriesExplainMomentum.pdf

• Pastor and Stambaugh, 2003, Liqudity measure and expected stock returns, Journal

of Political Economy, 642-685, http://people.stern.nyu.edu/lpederse/

courses/LAP/papers/TransactionCosts/PastorStam.pdf

• Roll. R., 1984, A Simple Measure of the Effective Bid-Ask Spread in an Efficient

Market, Journal of Finance, 39, 1127-1139, http://onlinelibrary.wiley.

com/doi/10.1111/j.1540-6261.1984.tb03897.x/pdf

Appendix A – Python program to generate

GDP dataset usGDPquarterly2.pkl

The first program generates a Python dataset with a .pkl extension:

import pandas_datareader.data as web

import datetime

begdate = datetime.datetime(1900, 1, 1)

enddate = datetime.datetime(2017, 1, 27)

x= web.DataReader("GDP", "fred", begdate,enddate)

x.to_pickle("c:/temp/ugGDPquarterly2.pkl")

To retrieve the dataset, we use the pandas.read_pickle() function. See the

following code:

import pandas as pd

a=pd.read_pickle("c:/temp/usGDPquarterly2.pkl")

print(a.head())

print(a.tail())

GDP

DATE

1947-01-01 243.1

[ 281 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!