# Path: speculator/features/TechnicalAnalysis.py
# class TechnicalAnalysis(abc.ABC):
#     """ Abstract class for calculating technical analysis indicators """
#     
#     @staticmethod
#     @abc.abstractmethod
#     def eval_algorithm(*args, **kwargs):
#         """ Evaluates TA algorithm """
# 
#     @staticmethod
#     @abc.abstractmethod
#     def eval_from_json(json):
#         """ Evaluates TA algorithm from JSON
# 
#         Args:
#             json: List of dates where each entry is a dict of raw market data.
#         """
# 
# Path: speculator/utils/poloniex.py
# def json_to_url(json, symbol):
# def chart_json(start, end, period, symbol):
# def parse_changes(json):
# def get_gains_losses(changes):
# def get_attribute(json, attr):
# def get_json_shift(year, month, day, unit, count, period, symbol):
# 
# Path: speculator/utils/stats.py
# def avg(vals, count=None):


from speculator.features.TechnicalAnalysis import TechnicalAnalysis
from speculator.utils import poloniex
from speculator.utils import stats
        such that,
            RS = avg(t-period gain) / avg(t-period loss)
    """

    def eval_algorithm(gains, losses):
        """ Evaluates the RSI algorithm

        Args:
            gains: List of price gains.
            losses: List of prices losses.

        Returns:
            Float between 0 and 100, momentum indicator
            of a market measuring the speed and change of price movements.
        """
        return 100 - (100 / (1 + RSI.eval_rs(gains, losses)))

    def eval_rs(gains, losses):
        """ Evaluates the RS variable in RSI algorithm

        Args:
            gains: List of price gains.
            losses: List of prices losses.

        Returns:
            Float of average gains over average losses.
        """
        # Number of days that the data was collected through
        count = len(gains) + len(losses)


# Path: speculator/features/TechnicalAnalysis.py
# class TechnicalAnalysis(abc.ABC):
#     """ Abstract class for calculating technical analysis indicators """
#     
#     @staticmethod
#     @abc.abstractmethod
#     def eval_algorithm(*args, **kwargs):
#         """ Evaluates TA algorithm """
# 
#     @staticmethod
#     @abc.abstractmethod
#     def eval_from_json(json):
#         """ Evaluates TA algorithm from JSON
# 
#         Args:
#             json: List of dates where each entry is a dict of raw market data.
#         """
# 
# Path: speculator/utils/poloniex.py
# def json_to_url(json, symbol):
# def chart_json(start, end, period, symbol):
# def parse_changes(json):
# def get_gains_losses(changes):
# def get_attribute(json, attr):
# def get_json_shift(year, month, day, unit, count, period, symbol):
# 
# Path: speculator/utils/stats.py
# def avg(vals, count=None):


# Path: speculator/features/RSI.py
from speculator.features.TechnicalAnalysis import TechnicalAnalysis
from speculator.utils import poloniex
from speculator.utils import stats

        such that,
            RS = avg(t-period gain) / avg(t-period loss)
    """

    def eval_algorithm(gains, losses):
        """ Evaluates the RSI algorithm

        Args:
            gains: List of price gains.
            losses: List of prices losses.

        Returns:
            Float between 0 and 100, momentum indicator
            of a market measuring the speed and change of price movements.
        """
        return 100 - (100 / (1 + RSI.eval_rs(gains, losses)))

    def eval_rs(gains, losses):
        """ Evaluates the RS variable in RSI algorithm

        Args:
            gains: List of price gains.
            losses: List of prices losses.

        Returns:
            Float of average gains over average losses.
        """
        # Number of days that the data was collected through
        count = len(gains) + len(losses)


        avg_gains = stats.avg(gains, count=count) if gains else 1