# 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/trade.py
# class Trade(object):
#     """
#     Trade object has access to a trade's datetime, action, symbol, price,
#     shares, money, fee, and slippage.
#     """
#     def __init__(self, datetime, action, symbol, price, shares, money, fee, slippage):
#         self.datetime = datetime
#         self.action = action
#         self.symbol = symbol
#         self.price = price
#         self.shares = shares
#         self.money = money
#         self.fee = fee
#         self.slippage = slippage
#         self.logger = logger.Logger(self.__class__.__name__)
#         self.logger.info('Initialized - %s' %self)
# 
#     def __str__(self):
#         return 'Trade(datetime=%s, action=%s, symbol=%s, price=%s, shares=%s, \
# money=%s, fee=%s, slippage=%s)' \
#                 %(self.datetime, self.action, self.symbol, self.price, \
#                   self.shares, self.money, self.fee, self.slippage)
#     def __repr__(self):
#         return 'Trade(' + str([self.datetime, self.action, self.symbol, \
#                                self.price, self.shares, self.money, self.fee, self.slippage]) + ')'
# 
# Path: nowtrade/action.py
# LONG = 1
# 
# LONG_EXIT = -1
# 
# SHORT = 2
# 
# SHORT_EXIT = -2


import numpy as np
import pandas as pd
from nowtrade import logger
from nowtrade.trade import Trade
from nowtrade.action import LONG, LONG_EXIT, SHORT, SHORT_EXIT
            data_frame['CHANGE_VALUE_%s' %symbol] = pd.Series(index=data_frame.index)
        if 'CHANGE_PERCENT_%s' %symbol not in data_frame:
            data_frame['CHANGE_PERCENT_%s' %symbol] = pd.Series(index=data_frame.index)
        trade = self.ongoing_trades[symbol]
        action = data_frame['ACTIONS_%s' %symbol][-1]
        exiting = action == LONG_EXIT or action == SHORT_EXIT
        if trade and exiting: # Exiting Ongoing Trade
            _exiting_ongoing_trade(data_frame, trade, action)
        elif trade: # Ongoing Trade
            _ongoing_trade(data_frame, trade)
        elif data_frame['ACTIONS_%s' %symbol][-1] != 0: # New Enter/Exit Trade
            _new_trade(data_frame, symbol, self.trading_profile, self.available_money)
        else: # Not in trade
            data_frame['PL_%s' %symbol][-1] = np.nan
            data_frame['CHANGE_VALUE_%s' %symbol][-1] = np.nan
            data_frame['CHANGE_PERCENT_%s' %symbol][-1] = np.nan
        self._require_finalize_calculations = True

    def handle_action(self, symbol, data_frame):
        """
        Perform all necessary operations to keep track of a new action in
        the market.
        """
        datetime = data_frame.index[-1]
        data = data_frame.iloc[-1]
        action = data['ACTIONS_%s' %symbol]
        if action == LONG:
            self.long(data, datetime, symbol)
        elif action == SHORT:
            self.short(data, datetime, symbol)

# 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/trade.py
# class Trade(object):
#     """
#     Trade object has access to a trade's datetime, action, symbol, price,
#     shares, money, fee, and slippage.
#     """
#     def __init__(self, datetime, action, symbol, price, shares, money, fee, slippage):
#         self.datetime = datetime
#         self.action = action
#         self.symbol = symbol
#         self.price = price
#         self.shares = shares
#         self.money = money
#         self.fee = fee
#         self.slippage = slippage
#         self.logger = logger.Logger(self.__class__.__name__)
#         self.logger.info('Initialized - %s' %self)
# 
#     def __str__(self):
#         return 'Trade(datetime=%s, action=%s, symbol=%s, price=%s, shares=%s, \
# money=%s, fee=%s, slippage=%s)' \
#                 %(self.datetime, self.action, self.symbol, self.price, \
#                   self.shares, self.money, self.fee, self.slippage)
#     def __repr__(self):
#         return 'Trade(' + str([self.datetime, self.action, self.symbol, \
#                                self.price, self.shares, self.money, self.fee, self.slippage]) + ')'
# 
# Path: nowtrade/action.py
# LONG = 1
# 
# LONG_EXIT = -1
# 
# SHORT = 2
# 
# SHORT_EXIT = -2


# Path: nowtrade/report.py
import numpy as np
import pandas as pd
from nowtrade import logger
from nowtrade.trade import Trade
from nowtrade.action import LONG, LONG_EXIT, SHORT, SHORT_EXIT

            data_frame['CHANGE_VALUE_%s' %symbol] = pd.Series(index=data_frame.index)
        if 'CHANGE_PERCENT_%s' %symbol not in data_frame:
            data_frame['CHANGE_PERCENT_%s' %symbol] = pd.Series(index=data_frame.index)
        trade = self.ongoing_trades[symbol]
        action = data_frame['ACTIONS_%s' %symbol][-1]
        exiting = action == LONG_EXIT or action == SHORT_EXIT
        if trade and exiting: # Exiting Ongoing Trade
            _exiting_ongoing_trade(data_frame, trade, action)
        elif trade: # Ongoing Trade
            _ongoing_trade(data_frame, trade)
        elif data_frame['ACTIONS_%s' %symbol][-1] != 0: # New Enter/Exit Trade
            _new_trade(data_frame, symbol, self.trading_profile, self.available_money)
        else: # Not in trade
            data_frame['PL_%s' %symbol][-1] = np.nan
            data_frame['CHANGE_VALUE_%s' %symbol][-1] = np.nan
            data_frame['CHANGE_PERCENT_%s' %symbol][-1] = np.nan
        self._require_finalize_calculations = True

    def handle_action(self, symbol, data_frame):
        """
        Perform all necessary operations to keep track of a new action in
        the market.
        """
        datetime = data_frame.index[-1]
        data = data_frame.iloc[-1]
        action = data['ACTIONS_%s' %symbol]
        if action == LONG:
            self.long(data, datetime, symbol)
        elif action == SHORT:
            self.short(data, datetime, symbol)

        elif action == LONG_EXIT: