# 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
# LONG = 1
# 
# SHORT = 2
# 
# NO_ACTION = 0
# 
# LONG_EXIT = -1
# 
# SHORT_EXIT = -2
# 
# ACTIONS_MAP = {1: 'LONG',
#                2: 'SHORT',
#                0: 'NO_ACTION',
#                -1: 'LONG_EXIT',
#                -2: 'SHORT_EXIT'}
# 
# Path: nowtrade/report.py
# class InvalidExit(Exception):
# class Report(object):
#     def __init__(self, strategy, trading_profile):
#     def add_preprocess_metrics(self, symbol, data_frame):
#     def handle_action(self, symbol, data_frame):
#     def long(self, data, datetime, symbol):
#     def short(self, data, datetime, symbol):
#     def long_exit(self, data, datetime, symbol):
#     def short_exit(self, data, datetime, symbol):
#     def finalize_calculations(self):
#     def get_sharpe_ratio(self, periods=252, benchmark=None):
#     def get_average_bars(self, data_frame):
#     def overview(self):
#     def pretty_overview(self):
# def _new_trade(data_frame, symbol, trading_profile, available_money):
# def _ongoing_trade(data_frame, trade):
# def _exiting_ongoing_trade(data_frame, trade, action):


import pandas as pd
from nowtrade import logger
from nowtrade.action import LONG, SHORT, NO_ACTION, LONG_EXIT, SHORT_EXIT, ACTIONS_MAP
from nowtrade import report

class Strategy(object):
    """
    All strategies perform the enter and exit actions on the OPEN of the bar.
    On every day, criterias are checked, and actions are queued up for the next
    open. This prevents lookahead bias.
    """
    def __init__(self, dataset, criteria_groups, trading_profile):
        self.dataset = dataset
        self.criteria_groups = criteria_groups
        self.trading_profile = trading_profile
        self.name = 'Strategy'
        self.report = report.Report(self, self.trading_profile)
        self.realtime_data_frame = pd.DataFrame() # Used for backtesting
        self.first_pass = True # Flag to execute certain actions on first bar of backtest
        self.upcoming_actions = {}
        self.logger = logger.Logger(self.__class__.__name__)
        self.logger.info('Initialized - %s' %self)

    def __str__(self):
        return 'Strategy(dataset=%s, criteria_groups=%s, trading_profile=%s)' \
                %(self.dataset, self.criteria_groups, self.trading_profile)
    def __repr__(self):
        return 'Strategy(dataset=%s, criteria_groups=%s, trading_profile=%s)' \
                %(self.dataset, self.criteria_groups, self.trading_profile)

    def simulate(self):
        """
        The entry point to start the strategy simulation.
        """

# 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
# LONG = 1
# 
# SHORT = 2
# 
# NO_ACTION = 0
# 
# LONG_EXIT = -1
# 
# SHORT_EXIT = -2
# 
# ACTIONS_MAP = {1: 'LONG',
#                2: 'SHORT',
#                0: 'NO_ACTION',
#                -1: 'LONG_EXIT',
#                -2: 'SHORT_EXIT'}
# 
# Path: nowtrade/report.py
# class InvalidExit(Exception):
# class Report(object):
#     def __init__(self, strategy, trading_profile):
#     def add_preprocess_metrics(self, symbol, data_frame):
#     def handle_action(self, symbol, data_frame):
#     def long(self, data, datetime, symbol):
#     def short(self, data, datetime, symbol):
#     def long_exit(self, data, datetime, symbol):
#     def short_exit(self, data, datetime, symbol):
#     def finalize_calculations(self):
#     def get_sharpe_ratio(self, periods=252, benchmark=None):
#     def get_average_bars(self, data_frame):
#     def overview(self):
#     def pretty_overview(self):
# def _new_trade(data_frame, symbol, trading_profile, available_money):
# def _ongoing_trade(data_frame, trade):
# def _exiting_ongoing_trade(data_frame, trade, action):


# Path: nowtrade/strategy.py
import pandas as pd
from nowtrade import logger
from nowtrade.action import LONG, SHORT, NO_ACTION, LONG_EXIT, SHORT_EXIT, ACTIONS_MAP
from nowtrade import report


class Strategy(object):
    """
    All strategies perform the enter and exit actions on the OPEN of the bar.
    On every day, criterias are checked, and actions are queued up for the next
    open. This prevents lookahead bias.
    """
    def __init__(self, dataset, criteria_groups, trading_profile):
        self.dataset = dataset
        self.criteria_groups = criteria_groups
        self.trading_profile = trading_profile
        self.name = 'Strategy'
        self.report = report.Report(self, self.trading_profile)
        self.realtime_data_frame = pd.DataFrame() # Used for backtesting
        self.first_pass = True # Flag to execute certain actions on first bar of backtest
        self.upcoming_actions = {}
        self.logger = logger.Logger(self.__class__.__name__)
        self.logger.info('Initialized - %s' %self)

    def __str__(self):
        return 'Strategy(dataset=%s, criteria_groups=%s, trading_profile=%s)' \
                %(self.dataset, self.criteria_groups, self.trading_profile)
    def __repr__(self):
        return 'Strategy(dataset=%s, criteria_groups=%s, trading_profile=%s)' \
                %(self.dataset, self.criteria_groups, self.trading_profile)

    def simulate(self):
        """
        The entry point to start the strategy simulation.
        """

        self.logger.info('Simulating strategy...')