April 2019
Intermediate to advanced
426 pages
11h 13m
English
One of the classic measures of security performance is its returns over a prior period. A simple method for calculating returns in pandas is pct_change, where the percentage change from the previous row is computed for every row in the DataFrame.
In the following example, we use ABN stock data to plot a simple graph of daily percentage returns:
In [ ]: %matplotlib inline import quandl quandl.ApiConfig.api_key = QUANDL_API_KEY df = quandl.get('EURONEXT/ABN.4') daily_changes = df.pct_change(periods=1) daily_changes.plot();
A line plot of daily percentage returns is shown as follows:

In the quandl.get() method, we postfix ...