# 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
    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
        avg_losses = stats.avg(losses,count=count) if losses else 1
        if avg_losses == 0:
            return avg_gains
        else:
            return avg_gains / avg_losses

    def eval_from_json(json):
        """ Evaluates RSI from JSON (typically Poloniex API response)

        Args:
            json: List of dates where each entry is a dict of raw market data.

        Returns:
            Float between 0 and 100, momentum indicator
            of a market measuring the speed and change of price movements.
        """

# 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

    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
        avg_losses = stats.avg(losses,count=count) if losses else 1
        if avg_losses == 0:
            return avg_gains
        else:
            return avg_gains / avg_losses

    def eval_from_json(json):
        """ Evaluates RSI from JSON (typically Poloniex API response)

        Args:
            json: List of dates where each entry is a dict of raw market data.

        Returns:
            Float between 0 and 100, momentum indicator
            of a market measuring the speed and change of price movements.
        """

        changes = poloniex.get_gains_losses(poloniex.parse_changes(json))