# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/function_helper.py
# def fill_for_noncomputable_vals(input_data, result_data):
#     non_computable_values = np.repeat(
#         np.nan, len(input_data) - len(result_data)
#         )
#     filled_result_data = np.append(non_computable_values, result_data)
#     return filled_result_data
# 
# Path: pyti/exponential_moving_average.py
# def exponential_moving_average(data, period):
#     """
#     Exponential Moving Average.
# 
#     Formula:
#     p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +...
#                 /   1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +...
# 
#     where: w = 2 / (N + 1)
#     """
#     catch_errors.check_for_period_error(data, period)
#     emas = [exponential_moving_average_helper(
#             data[idx - period + 1:idx + 1], period) for idx in range(period - 1, len(data))]
#     emas = fill_for_noncomputable_vals(data, emas)
#     return emas


import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from pyti.exponential_moving_average import (
    exponential_moving_average as ema
    )
from six.moves import range
from __future__ import absolute_import


def double_smoothed_stochastic(data, period):
    """
    Double Smoothed Stochastic.

    Formula:
    dss = 100 *  EMA(Close - Lowest Low) / EMA(Highest High - Lowest Low)
    """
    catch_errors.check_for_period_error(data, period)
    lows = [data[idx] - np.min(data[idx+1-period:idx+1]) for idx in range(period-1, len(data))]

# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/function_helper.py
# def fill_for_noncomputable_vals(input_data, result_data):
#     non_computable_values = np.repeat(
#         np.nan, len(input_data) - len(result_data)
#         )
#     filled_result_data = np.append(non_computable_values, result_data)
#     return filled_result_data
# 
# Path: pyti/exponential_moving_average.py
# def exponential_moving_average(data, period):
#     """
#     Exponential Moving Average.
# 
#     Formula:
#     p0 + (1 - w) * p1 + (1 - w)^2 * p2 + (1 + w)^3 * p3 +...
#                 /   1 + (1 - w) + (1 - w)^2 + (1 - w)^3 +...
# 
#     where: w = 2 / (N + 1)
#     """
#     catch_errors.check_for_period_error(data, period)
#     emas = [exponential_moving_average_helper(
#             data[idx - period + 1:idx + 1], period) for idx in range(period - 1, len(data))]
#     emas = fill_for_noncomputable_vals(data, emas)
#     return emas


# Path: pyti/double_smoothed_stochastic.py
import numpy as np
from pyti import catch_errors
from pyti.function_helper import fill_for_noncomputable_vals
from pyti.exponential_moving_average import (
    exponential_moving_average as ema
    )
from six.moves import range

from __future__ import absolute_import


def double_smoothed_stochastic(data, period):
    """
    Double Smoothed Stochastic.

    Formula:
    dss = 100 *  EMA(Close - Lowest Low) / EMA(Highest High - Lowest Low)
    """
    catch_errors.check_for_period_error(data, period)
    lows = [data[idx] - np.min(data[idx+1-period:idx+1]) for idx in range(period-1, len(data))]

    sm_lows = ema(ema(lows, period), period)