# 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
        else:
            self.losing_trades += 1
            self.average_losing_gain += gains
            self.gross_loss += profit_loss
        self.trades += 1

    def short_exit(self, data, datetime, symbol):
        """
        Perform SHORT_EXIT action in the market.
        """
        if not self.ongoing_trades[symbol]:
            raise InvalidExit('Did not simulate ShortExit for %s on %s \
                    - probably not enough capital' %(symbol, datetime))
        trade = self.ongoing_trades[symbol]
        self.ongoing_trades[symbol] = None
        price = data['%s_Open' %symbol]
        fee = self.trading_profile.trading_fee.get_fee(price, trade.shares)
        money = price * trade.shares
        slippage = money * self.trading_profile.slippage / 100
        self.total_fees += fee
        self.total_slippage += slippage
        profit_loss = trade.money - money # Made this much off the trade
        profit_loss -= trade.fee # Minus Fees In
        profit_loss -= fee # Minus Fees Out
        profit_loss -= trade.slippage # Minus Slippage In
        profit_loss -= slippage # Minus Slippage Out
        self.available_money += (money - fee - slippage)
        gains = profit_loss / (money - fee - slippage)
        self.average_gain += gains
        self.capital += profit_loss

# 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

        else:
            self.losing_trades += 1
            self.average_losing_gain += gains
            self.gross_loss += profit_loss
        self.trades += 1

    def short_exit(self, data, datetime, symbol):
        """
        Perform SHORT_EXIT action in the market.
        """
        if not self.ongoing_trades[symbol]:
            raise InvalidExit('Did not simulate ShortExit for %s on %s \
                    - probably not enough capital' %(symbol, datetime))
        trade = self.ongoing_trades[symbol]
        self.ongoing_trades[symbol] = None
        price = data['%s_Open' %symbol]
        fee = self.trading_profile.trading_fee.get_fee(price, trade.shares)
        money = price * trade.shares
        slippage = money * self.trading_profile.slippage / 100
        self.total_fees += fee
        self.total_slippage += slippage
        profit_loss = trade.money - money # Made this much off the trade
        profit_loss -= trade.fee # Minus Fees In
        profit_loss -= fee # Minus Fees Out
        profit_loss -= trade.slippage # Minus Slippage In
        profit_loss -= slippage # Minus Slippage Out
        self.available_money += (money - fee - slippage)
        gains = profit_loss / (money - fee - slippage)
        self.average_gain += gains
        self.capital += profit_loss

        self.trade_history[symbol].append(Trade(datetime,