# 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
            self.report.add_preprocess_metrics(str(symbol), self.realtime_data_frame)
            # Update Report
            self.report.handle_action(symbol, self.realtime_data_frame)
        self.first_pass = False
        # Process criteria
        cg_data = {}
        for crit_group in self.criteria_groups:
            if crit_group.symbol not in cg_data:
                cg_data[crit_group.symbol] = []
            cg_result = crit_group.get_result(self.realtime_data_frame)
            cg_data[crit_group.symbol].append(cg_result)
        self.logger.debug('Criteria Group Data: %s' %cg_data)
        # Determine action based on all criteria group results
        for symbol in cg_data:
            symbol_action = self._determine_action(cg_data[symbol])
            self.logger.debug('Upcoming Action for %s: %s' %(symbol, symbol_action))
            # Do the action on the Open of the next bar
            self.upcoming_actions[symbol] = symbol_action
        self.logger.debug('New data:\n%s' %self.realtime_data_frame.tail(1).to_string())

    def get_next_action(self):
        """
        Estimated shares and money required is based on the Close of the last bar.
        The action should always be executed on the Open of the next bar.
        """
        actions = {}
        for symbol in self.upcoming_actions:
            action = self.upcoming_actions[symbol]
            estimated_enter_value = self.realtime_data_frame['%s_Open' %symbol][-1]
            estimated_shares = self.trading_profile.trading_amount.get_shares(\

# 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

            self.report.add_preprocess_metrics(str(symbol), self.realtime_data_frame)
            # Update Report
            self.report.handle_action(symbol, self.realtime_data_frame)
        self.first_pass = False
        # Process criteria
        cg_data = {}
        for crit_group in self.criteria_groups:
            if crit_group.symbol not in cg_data:
                cg_data[crit_group.symbol] = []
            cg_result = crit_group.get_result(self.realtime_data_frame)
            cg_data[crit_group.symbol].append(cg_result)
        self.logger.debug('Criteria Group Data: %s' %cg_data)
        # Determine action based on all criteria group results
        for symbol in cg_data:
            symbol_action = self._determine_action(cg_data[symbol])
            self.logger.debug('Upcoming Action for %s: %s' %(symbol, symbol_action))
            # Do the action on the Open of the next bar
            self.upcoming_actions[symbol] = symbol_action
        self.logger.debug('New data:\n%s' %self.realtime_data_frame.tail(1).to_string())

    def get_next_action(self):
        """
        Estimated shares and money required is based on the Close of the last bar.
        The action should always be executed on the Open of the next bar.
        """
        actions = {}
        for symbol in self.upcoming_actions:
            action = self.upcoming_actions[symbol]
            estimated_enter_value = self.realtime_data_frame['%s_Open' %symbol][-1]
            estimated_shares = self.trading_profile.trading_amount.get_shares(\

                               estimated_enter_value, self.report.available_money)