Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Set custom series name #16

Open
damianoporta opened this issue Sep 10, 2018 · 8 comments
Open

Set custom series name #16

damianoporta opened this issue Sep 10, 2018 · 8 comments

Comments

@damianoporta
Copy link

Hi, first of all THANK YOU FOR THIS AWESOME LIBRARY
A question:
how can we set custom series name? At the moment it seems not possible setting a custom series name, we must rename it after return. Do you think could be useful to pass an optional parameter to set a custom series name?

@peerchemist
Copy link
Owner

Hi,

no I did not make it possible to have a custom series name. Perhaps that is usable indeed. I'll get it done when I catch some spare time.

@damianoporta
Copy link
Author

damianoporta commented Sep 10, 2018

Hi, i can fork the repo and create a PR.

we can add the name parameter with None value
and then change each indicator like this:
name=name or '{0} period SMA'.format(period)

what do you think?

@peerchemist
Copy link
Owner

It should have default value, so if user does not provide any it prints out what it prints out now.

def SMA(self, ohlc, periods, column='close', name='SMA')

then you can override with name='simple_moving_average' if you like.

So sure, I happy to merge in your PR. :)

@damianoporta
Copy link
Author

@peerchemist i think your series names are good, i do not think we need to change them, just let the user renames it if needed. For example at the moment the SMA name is: '{0} period SMA'.format(period) we can use it as default and override it if the optional parameter is used. No?

@peerchemist
Copy link
Owner

How would you override it in the code? With if block? Is not what I've proposed cleaner solution with less lines of code?

@damianoporta
Copy link
Author

    def SMA(cls, ohlc, period=41, column='close', name=None):
        """
        Simple moving average - rolling mean in pandas lingo. Also known as 'MA'.
        The simple moving average (SMA) is the most basic of the moving averages used for trading.
        """

        return pd.Series(ohlc[column].rolling(center=False, window=period,
                         min_periods=period - 1).mean(),
name=name or '{0} period SMA'.format(period))

is this not good for you? WIth this code we did not add any new line.

@peerchemist
Copy link
Owner

Ok that will work.

@peerchemist
Copy link
Owner

Any updates on this?

@peerchemist peerchemist added this to the 1.0 milestone Mar 20, 2020
@peerchemist peerchemist modified the milestones: 1.0, 1.1 Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants