예제 #1
0
 def __get_default_args(self, func_name):
     """
     returns a dictionary of arg_name:default_values for the input function
     """
     func = ls_talib.__getattribute__(func_name)
     args, varargs, keywords, defaults = inspect.getargspec(func)
     # print(func.__name__)
     # print('args={0},varargs={1},keywords={2},defaults={3}'.format(
     #     args, varargs, keywords, defaults))
     if defaults:
         ret = dict(zip(reversed(args), reversed(defaults)))
         # 本来函数的default应该是周期,是整型.
         # 比如ret={'timeperiod1': 14, timeperiod2: 20}
         # 但是有一些函数的缺省值是字符串。这些函数
         # 是为了方便,可以使用不同的price来计算.
         # 比如TMA(prices, timeperiod=14, price='high')
         # 我们要去掉这些字符型的字典项
         numeric_value_dict = {
             key: val
             for key, val in ret.iteritems() if isinstance(val, int)
         }
         return numeric_value_dict
     else:
         # print func_name
         return {}
예제 #2
0
    def __call__(self, *args, **kwargs):
        if not self.parameters:
            self.parameters.update(**kwargs)

        if self.__name in _LS_FUNCTION_NAMES:
            func = ls_talib.__getattribute__(self.__name)
            return func(*args, **kwargs)
        else:
            return super(Function, self).__call__(*args, **kwargs)
예제 #3
0
    def __call__(self, *args, **kwargs):
        if not self.parameters:
            self.parameters.update(**kwargs)

        if self.__name in _LS_FUNCTION_NAMES:
            func = ls_talib.__getattribute__(self.__name)
            return func(*args, **kwargs)
        else:
            return super(Function, self).__call__(*args, **kwargs)
예제 #4
0
    def __init__(self, func_name, *args, **kwargs):
        """

        :type kwargs: object
        """
        self.__name = func_name.upper()
        self.__parameters = {}
        # self.__opt_inputs = OrderedDict()
        # self.__info = None

        if self.__name in _LS_FUNCTION_NAMES:
            self.__doc__ = ls_talib.__getattribute__(self.__name).func_doc

            # self.parameters = {}
        else:
            super(Function, self).__init__(func_name, *args, **kwargs)

        if kwargs:
            self.parameters = kwargs
예제 #5
0
    def __init__(self, func_name, *args, **kwargs):
        """

        :type kwargs: object
        """
        self.__name = func_name.upper()
        self.__parameters = {}
        # self.__opt_inputs = OrderedDict()
        # self.__info = None

        if self.__name in _LS_FUNCTION_NAMES:
            self.__doc__ = ls_talib.__getattribute__(self.__name).func_doc

            # self.parameters = {}
        else:
            super(Function, self).__init__(func_name, *args, **kwargs)

        if kwargs:
            self.parameters = kwargs
예제 #6
0
 def __get_default_args(self, func_name):
     """
     returns a dictionary of arg_name:default_values for the input function
     """
     func = ls_talib.__getattribute__(func_name)
     args, varargs, keywords, defaults = inspect.getargspec(func)
     # print(func.__name__)
     # print('args={0},varargs={1},keywords={2},defaults={3}'.format(
     #     args, varargs, keywords, defaults))
     if defaults:
         ret = dict(zip(reversed(args), reversed(defaults)))
         # 本来函数的default应该是周期,是整型.
         # 比如ret={'timeperiod1': 14, timeperiod2: 20}
         # 但是有一些函数的缺省值是字符串。这些函数
         # 是为了方便,可以使用不同的price来计算.
         # 比如TMA(prices, timeperiod=14, price='high')
         # 我们要去掉这些字符型的字典项
         numeric_value_dict = {
             key: val for key, val in ret.iteritems() if isinstance(val, int)}
         return numeric_value_dict
     else:
         # print func_name
         return {}