# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/simple_moving_average.py
# def simple_moving_average(data, period):
#     """
#     Simple Moving Average.
# 
#     Formula:
#     SUM(data / N)
#     """
#     catch_errors.check_for_period_error(data, period)
#     # Mean of Empty Slice RuntimeWarning doesn't affect output so it is
#     # supressed
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", category=RuntimeWarning)
#         sma = [np.mean(data[idx-(period-1):idx+1]) for idx in range(0, len(data))]
#     sma = fill_for_noncomputable_vals(data, sma)
#     return sma
# 
# Path: pyti/typical_price.py
# def typical_price(close_data, high_data, low_data):
#     """
#     Typical Price.
# 
#     Formula:
#     TPt = (HIGHt + LOWt + CLOSEt) / 3
#     """
#     catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
#     tp = [(high_data[idx] + low_data[idx] + close_data[idx]) / 3 for idx in range(0, len(close_data))]
#     return np.array(tp)


import numpy as np
from pyti import catch_errors
from pyti.simple_moving_average import (
    simple_moving_average as sma
    )
from pyti.typical_price import typical_price
from __future__ import absolute_import


def band_width(high_data, low_data, period):
    """
    Bandwidth.

    Formula:
    BW = SMA(H - L)
    """
    catch_errors.check_for_input_len_diff(high_data, low_data)
    diff = np.array(high_data) - np.array(low_data)
    bw = sma(diff, period)
    return bw


def center_band(close_data, high_data, low_data, period):
    """
    Center Band.

    Formula:
    CB = SMA(TP)
    """
    tp = typical_price(close_data, high_data, low_data)

# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):
# 
# Path: pyti/simple_moving_average.py
# def simple_moving_average(data, period):
#     """
#     Simple Moving Average.
# 
#     Formula:
#     SUM(data / N)
#     """
#     catch_errors.check_for_period_error(data, period)
#     # Mean of Empty Slice RuntimeWarning doesn't affect output so it is
#     # supressed
#     with warnings.catch_warnings():
#         warnings.simplefilter("ignore", category=RuntimeWarning)
#         sma = [np.mean(data[idx-(period-1):idx+1]) for idx in range(0, len(data))]
#     sma = fill_for_noncomputable_vals(data, sma)
#     return sma
# 
# Path: pyti/typical_price.py
# def typical_price(close_data, high_data, low_data):
#     """
#     Typical Price.
# 
#     Formula:
#     TPt = (HIGHt + LOWt + CLOSEt) / 3
#     """
#     catch_errors.check_for_input_len_diff(close_data, high_data, low_data)
#     tp = [(high_data[idx] + low_data[idx] + close_data[idx]) / 3 for idx in range(0, len(close_data))]
#     return np.array(tp)


# Path: pyti/keltner_bands.py
import numpy as np
from pyti import catch_errors
from pyti.simple_moving_average import (
    simple_moving_average as sma
    )
from pyti.typical_price import typical_price

from __future__ import absolute_import


def band_width(high_data, low_data, period):
    """
    Bandwidth.

    Formula:
    BW = SMA(H - L)
    """
    catch_errors.check_for_input_len_diff(high_data, low_data)
    diff = np.array(high_data) - np.array(low_data)
    bw = sma(diff, period)
    return bw


def center_band(close_data, high_data, low_data, period):
    """
    Center Band.

    Formula:
    CB = SMA(TP)
    """
    tp = typical_price(close_data, high_data, low_data)

    cb = sma(tp, period)