GriffinAustin / pynance

Lightweight Python library for assembling and analysing financial data
MIT License
317 stars 43 forks source link

Show relative performance #24

Closed aisthesis closed 8 years ago

aisthesis commented 8 years ago

Given input data for various equities, create a DataFrame showing performance relative to a standardized starting point.

arkadasgupta commented 8 years ago

i thought this function would return comparative performances across different equities, i.e. how they performed compared to one another, not compared to itself. Is the current version useful?

anyway, looks good as such

aisthesis commented 8 years ago

that's what it does. You pass it an array of DataFrames, where each contains the data for a particular equity. The function then takes the selection column from each df, divides it by the first entry (so all equities start uniformly at a price of 1.0) and inserts it as a column into the output DataFrame.

If you plot it (which is one of the most import use cases), you would get something very similar to the chart provided on yahoo! when you do a comparison among multiple equities. By normalizing the initial value to 1.0, you only see the performance of the list relative to the initial value.

arkadasgupta commented 8 years ago

i think what i had a problem with was that, each equity starts from 1. For example, GOOG would start at 700+ whereas FSLR would start at ~70. Should both be considered to start at 1?

In % growth terms it makes sense i guess, but in absolute dollar value, 1% gain on 1 would be 10x of 1% gain on the other.

aisthesis commented 8 years ago

yes, that's the point of this functionality: to show 1% gain on the same scale for both. You still have absolute pricing in the data you get using pn.data.get().

For example, GOOG starts hypothetically at 700.00 on the start date and FSLR at 70.00. Now suppose on the second day each goes up by 1%. GOOG is now at 707.00 and FSLR at 70.70. The DataFrame provided by this function will then show as first 2 entries for both [1.0, 1.01].

arkadasgupta commented 8 years ago

No I got that. Just wondering if it could be misleading. In any case, most portfolios would probably balance out by having 10x shares of FSLR compared to GOOG. :)