Data - compare (pynance.data.compare)

pynance.data.compare.compare(eq_dfs, columns=None, selection='Adj Close')[source]

Get the relative performance of multiple equities.

New in version 0.5.0.

Parameters:

eq_dfs : list or tuple of DataFrame

Performance data for multiple equities over a consistent time frame.

columns : iterable of str, default None

Labels to use for the columns of the output DataFrame. The labels, if provided, should normally be the names of the equities whose performance is being compared.

selection : str, default ‘Adj Close’

Column containing prices to be compared. Defaults to ‘Adj Close’.

Returns:

rel_perf : DataFrame

A DataFrame whose columns contain normalized data for each equity represented in eq_dfs. The initial price for each equity will be normalized to 1.0.

Notes

Each set of data passed in eq_dfs is assumed to have the same start and end dates as the other data sets.

Examples

import pynance as pn

eqs = ('FSLR', 'SCTY', 'SPWR')
eq_dfs = []
for eq in eqs:
    eq_dfs.append(pn.data.get(eq, '2016'))
rel_perf = pn.data.compare(eq_dfs, eqs)