TulipCharts / tulipy

[NOT ACTIVELY MAINTAINED] Tulipy - Financial Technical Analysis Indicator Library (Python bindings for Tulip Charts)
https://github.com/TulipCharts/tulipindicators
GNU Lesser General Public License v3.0
330 stars 83 forks source link

print_info(indicator): options names returned are not very accurate #29

Closed xuanngo2001 closed 5 years ago

xuanngo2001 commented 5 years ago

For print_info(indicator) function provided in the readme.md, options names returned are not very accurate. For example, print_info(macd), it displays space in options names instead of underscore.

Type: indicator
Full Name: Moving Average Convergence/Divergence
Inputs: ['real']
Options: ['short period', 'long period', 'signal period']
Outputs: ['macd', 'macd_signal', 'macd_histogram']

I'm not sure whether to modify print_info() or indicator.options. Notice that Outputs returns names with underscore.

codeplea commented 5 years ago

It's showing names as they are in Tulip Indicators. They are defined here.

Some of the names have percent signs in them too. e.g., Stochastic Oscillator has the "%k period" option.

Why are spaces in the name a problem? Maybe for consistency the output names should have the underscores replaced with spaces.

xuanngo2001 commented 5 years ago

Because I use the print_info() to discover what are the available input parameters. In the case of print_info(macd), to use it in Python, I have to call it as follows:

(macd, macd_signal, macd_histogram) = ti.macd(macd_input, short_period=2,
                                                            long_period=5, 
                                                            signal_period=9)

When options print ['short period', 'long period', 'signal period'], you have to guess on the correct permutation. Is it short_period, shortperiod?

I haven't use the Stochastic Oscillator yet but if it prints "%k period". Then, what is the correct parameter? Is it k_period? kperiod? period?

cirla commented 5 years ago

I have to clean the names to make them valid python identifiers, but I wanted to preserve the .inputs, .outputs, and .options as they are in the original Tulip Indicators.

Instead of using the demo print_info function from the README, you could use inspect, e.g.:

# python 3
>>> inspect.signature(tulipy.macd)
<Signature (real, short_period, long_period, signal_period)>
# python 2
>>> inspect.getargspec(tulipy.macd)
ArgSpec(args=['real', 'short_period', 'long_period', 'signal_period'], varargs=None, keywords=None, defaults=None)

I'll see if I can find some time to add the parameter names to the function docstrings as well, so you could just print(tulipy.macd.__doc__).