# Path: nowtrade/logger.py
# CRITICAL = logging.CRITICAL
# ERROR = logging.ERROR
# WARNING = logging.WARNING
# INFO = logging.INFO
# DEBUG = logging.DEBUG
# class Logger(object):
#     def __init__(self, name, log_file=configuration.LOG_FILE, \
#                  console_lvl=configuration.LOGGING_DEFAULT_CONSOLE, \
#                  file_lvl=configuration.LOGGING_DEFAULT_FILE):
#     def get_logger_level(self, name, default, out):
#     def get_console_level(self, name, default):
#     def get_file_level(self, name, default):
#     def set_file_level(self, lvl):
#     def set_console_level(self, lvl):
#     def debug(self, message):
#     def info(self, message):
#     def warning(self, message):
#     def error(self, message):
#     def critical(self, message):
#     def exception(self, message):
#     def __getstate__(self):
#     def __setstate__(self, data):
# 
# Path: nowtrade/action.py
# class Long(Action):
#     """
#     Long Action represents going long in the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'long')
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return LONG
# 
# class Short(Action):
#     """
#     Short Action represents shorting in the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'short')
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return SHORT
# 
# class LongExit(Action):
#     """
#     Long Exit Action represents exiting a long position from the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'longexit')
#     def __eq__(self, other):
#         other = str(other).replace(' ', '').replace('_', '').replace('-', '').lower()
#         return other == 'longexit' or other == 'exitlong'
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return LONG_EXIT
# 
# class ShortExit(Action):
#     """
#     Short Exit Action represents exiting a short position from the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'shortexit')
#     def __eq__(self, other):
#         other = str(other).replace(' ', '').replace('_', '').replace('-', '').lower()
#         return other == 'shortexit' or other == 'exitshort'
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return SHORT_EXIT
# 
# Path: nowtrade/technical_indicator.py
# class TechnicalIndicator(object):
#     """
#     The base class for all technical indicators.
#     """
#     def __init__(self):
#         self.logger = logger.Logger(self.__class__.__name__)
#     def results(self, data_frame):
#         """
#         This needs to be implemented for all technical indicators.
#         All the calculations happen here.
#         """
#         pass


import numpy as np
from nowtrade import logger
from nowtrade.action import Long, Short, LongExit, ShortExit
from nowtrade.technical_indicator import TechnicalIndicator
        return self.label
    def apply(self, data_frame):
        """
        Apply the Below criteria to the data_frame provided.
        @return Series(bool) The criteria status
        """
        if len(data_frame) < self.lookback:
            return False
        # Second value is not a technical indicator, simply a number to compare
        if isinstance(self.param2, (int, long, float)):
            return data_frame[self.param1][-self.lookback] < self.param2
        else:
            return data_frame[self.param1][-self.lookback] < data_frame[self.param2][-self.lookback]

class Equals(Criteria):
    """
    Criteria used to determine if a technical indicator or symbol OHLCV is
    currently equal to another technical indicator, symbol OHLCV, or value.
    """
    def __init__(self, param1, param2, lookback=1):
        Criteria.__init__(self)
        if isinstance(param1, TechnicalIndicator):
            param1 = param1.value
        if isinstance(param2, TechnicalIndicator):
            param2 = param2.value
        self.param1 = param1 # Technical indicator label
        self.param2 = param2 # Technical indicator label or int or long or float
        self.lookback = lookback
        self.label = 'Equals_%s_%s_%s' %(param1, param2, lookback)
        self.num_bars_required = lookback

# Path: nowtrade/logger.py
# CRITICAL = logging.CRITICAL
# ERROR = logging.ERROR
# WARNING = logging.WARNING
# INFO = logging.INFO
# DEBUG = logging.DEBUG
# class Logger(object):
#     def __init__(self, name, log_file=configuration.LOG_FILE, \
#                  console_lvl=configuration.LOGGING_DEFAULT_CONSOLE, \
#                  file_lvl=configuration.LOGGING_DEFAULT_FILE):
#     def get_logger_level(self, name, default, out):
#     def get_console_level(self, name, default):
#     def get_file_level(self, name, default):
#     def set_file_level(self, lvl):
#     def set_console_level(self, lvl):
#     def debug(self, message):
#     def info(self, message):
#     def warning(self, message):
#     def error(self, message):
#     def critical(self, message):
#     def exception(self, message):
#     def __getstate__(self):
#     def __setstate__(self, data):
# 
# Path: nowtrade/action.py
# class Long(Action):
#     """
#     Long Action represents going long in the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'long')
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return LONG
# 
# class Short(Action):
#     """
#     Short Action represents shorting in the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'short')
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return SHORT
# 
# class LongExit(Action):
#     """
#     Long Exit Action represents exiting a long position from the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'longexit')
#     def __eq__(self, other):
#         other = str(other).replace(' ', '').replace('_', '').replace('-', '').lower()
#         return other == 'longexit' or other == 'exitlong'
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return LONG_EXIT
# 
# class ShortExit(Action):
#     """
#     Short Exit Action represents exiting a short position from the market.
#     """
#     def __init__(self):
#         Action.__init__(self, 'shortexit')
#     def __eq__(self, other):
#         other = str(other).replace(' ', '').replace('_', '').replace('-', '').lower()
#         return other == 'shortexit' or other == 'exitshort'
#     def raw(self):
#         """
#         A raw (int) representation of the action.
#         """
#         return SHORT_EXIT
# 
# Path: nowtrade/technical_indicator.py
# class TechnicalIndicator(object):
#     """
#     The base class for all technical indicators.
#     """
#     def __init__(self):
#         self.logger = logger.Logger(self.__class__.__name__)
#     def results(self, data_frame):
#         """
#         This needs to be implemented for all technical indicators.
#         All the calculations happen here.
#         """
#         pass


# Path: nowtrade/criteria.py
import numpy as np
from nowtrade import logger
from nowtrade.action import Long, Short, LongExit, ShortExit
from nowtrade.technical_indicator import TechnicalIndicator

        return self.label
    def apply(self, data_frame):
        """
        Apply the Below criteria to the data_frame provided.
        @return Series(bool) The criteria status
        """
        if len(data_frame) < self.lookback:
            return False
        # Second value is not a technical indicator, simply a number to compare
        if isinstance(self.param2, (int, long, float)):
            return data_frame[self.param1][-self.lookback] < self.param2
        else:
            return data_frame[self.param1][-self.lookback] < data_frame[self.param2][-self.lookback]

class Equals(Criteria):
    """
    Criteria used to determine if a technical indicator or symbol OHLCV is
    currently equal to another technical indicator, symbol OHLCV, or value.
    """
    def __init__(self, param1, param2, lookback=1):
        Criteria.__init__(self)
        if isinstance(param1, TechnicalIndicator):
            param1 = param1.value
        if isinstance(param2, TechnicalIndicator):
            param2 = param2.value
        self.param1 = param1 # Technical indicator label
        self.param2 = param2 # Technical indicator label or int or long or float
        self.lookback = lookback
        self.label = 'Equals_%s_%s_%s' %(param1, param2, lookback)
        self.num_bars_required = lookback

        self.logger.info('Initialized - %s' %self)