pyfolio icon indicating copy to clipboard operation
pyfolio copied to clipboard

Add API for registering a function to get SPY

Open twiecki opened this issue 11 years ago • 4 comments

twiecki avatar Jul 23 '15 18:07 twiecki

I thought @ssanderson was heading this up, but I can take a stab at it. Any thoughts on how we should go about it? I'm thinking just a global settings dict in utils with get_symbol_rets as the default function is simplest but I'm sure there is a more graceful method.

humdings avatar Jul 27 '15 15:07 humdings

@humdings I think get_symbol_rets should continue to be the top-level entrypoint for the rest of PyFolio, but its implementation should look like:

def get_symbol_rets(...l):
    # Get the currently registered symbol retrieval function.
    return settings['returns'](...)

and then we need a registration function that looks like:

def register_returns_func(f):
    settings['returns'] = f

The registration function should document the expected signature of the function being registered.

We should follow similar patterns for any other data that PyFolio pulls from the Internet. It may be worth encapsulating the config in an object more complex than a dict, but we can always go back and change it later if need be, since the particular storage mechanism won't be public API.

ssanderson avatar Jul 27 '15 16:07 ssanderson

Initial PR for this is here https://github.com/quantopian/pyfolio/pull/92/

I'm wondering if it should be moved to a different location pyfolio.settings.py?

humdings avatar Jul 27 '15 19:07 humdings

PR merged. Thanks @humdings!

twiecki avatar Jul 29 '15 09:07 twiecki