Set custom series name
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?
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.
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?
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. :)
@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?
How would you override it in the code? With if block? Is not what I've proposed cleaner solution with less lines of code?
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.
Ok that will work.
Any updates on this?