# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):


import numpy as np
from pyti import catch_errors
from six.moves import range

    Formula:
    PVI0 = 1
    IF Vt > Vt-1
        PVIt = PVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * PVIt-1)
    ELSE:
        PVIt = PVIt-1
    """
    catch_errors.check_for_input_len_diff(close_data, volume)
    pvi = np.zeros(len(volume))
    pvi[0] = 1
    for idx in range(1, len(volume)):
        if volume[idx] > volume[idx-1]:
            pvi[idx] = volume_index_helper(pvi, idx, close_data)
        else:
            pvi[idx] = pvi[idx-1]
    return pvi


def negative_volume_index(close_data, volume):
    """
    Negative Volume Index (NVI).

    Formula:
    NVI0 = 1
    IF Vt < Vt-1
        NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1)
    ELSE:
        NVIt = NVIt-1
    """

# Path: pyti/catch_errors.py
# def check_for_period_error(data, period):
# def check_for_input_len_diff(*args):


# Path: pyti/volume_index.py
import numpy as np
from pyti import catch_errors
from six.moves import range


    Formula:
    PVI0 = 1
    IF Vt > Vt-1
        PVIt = PVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * PVIt-1)
    ELSE:
        PVIt = PVIt-1
    """
    catch_errors.check_for_input_len_diff(close_data, volume)
    pvi = np.zeros(len(volume))
    pvi[0] = 1
    for idx in range(1, len(volume)):
        if volume[idx] > volume[idx-1]:
            pvi[idx] = volume_index_helper(pvi, idx, close_data)
        else:
            pvi[idx] = pvi[idx-1]
    return pvi


def negative_volume_index(close_data, volume):
    """
    Negative Volume Index (NVI).

    Formula:
    NVI0 = 1
    IF Vt < Vt-1
        NVIt = NVIt-1 + (CLOSEt - CLOSEt-1 / CLOSEt-1 * NVIt-1)
    ELSE:
        NVIt = NVIt-1
    """

    catch_errors.check_for_input_len_diff(close_data, volume)