# Path: utils.py

# 
# Path: order.py
# class Order(object):
#     def __init__(self, price, volume, type=None, pair=None, orderID=None, timestamp=None):
#         """
#         markets are usually expressed in terms of BASE_ALT where you buy
#         and sell units of BASE with ALT.
#         price = price (in units alt) of 1 unit of base
#         volume = total volume of base desired
#         orderID = necessary for tracking & cancelling & ignoring already executed orders when backtesting
#         """
#         self.p = price
#         self.v = volume
#         self.type = type # buy or sell
#         self.pair = pair # market we are trading on
#         self.id = orderID
#         self.time = timestamp


import config
from utils import total_base_volume
from order import Order
            print('Can\'t afford min vol trade - insufficient bidder balance!')
            print('\t %s +%f %s' % (bidder.xchg.name, bidder_min_base_vol - bidder_base_balance, base))
            poor = True

        if (asker_base_afford < min_base_vol):
            print('Can\'t afford min vol trade - insufficient asker balance!')
            print('\t %s +%f %s' % (asker.xchg.name, (asker_min_base_vol-asker_base_afford)*self.prices[asker.xchg.name]['ask'], alt))
            poor = True

        if poor:
            return None

        """
        size the volume of base traded
        """
        asker_tx = 1.0 - asker.xchg.trading_fee
        bidder_tx = 1.0 - bidder.xchg.trading_fee

        # TODO - weird shit going on here, fix this!!

        # the line below computes how much base we could trade if we had unlimited balance
        # but are limited by the order volumes of base between the exchanges.
        # we receive a maximum of asks[0].v * asker_tx units of base from the asker
        # and we can sell a maximum of bids[0].v to the bidder
        max_base_xchg = min(bids[0].v, asks[0].v * asker_tx)
        # computes how much base we could trade if we had unlimited volume, limited balance
        max_base_balance = min(bidder_base_balance, asker_base_afford)
        # how much we will end up buying and selling
        base_vol = min(max_base_xchg, max_base_balance)


# Path: utils.py

# 
# Path: order.py
# class Order(object):
#     def __init__(self, price, volume, type=None, pair=None, orderID=None, timestamp=None):
#         """
#         markets are usually expressed in terms of BASE_ALT where you buy
#         and sell units of BASE with ALT.
#         price = price (in units alt) of 1 unit of base
#         volume = total volume of base desired
#         orderID = necessary for tracking & cancelling & ignoring already executed orders when backtesting
#         """
#         self.p = price
#         self.v = volume
#         self.type = type # buy or sell
#         self.pair = pair # market we are trading on
#         self.id = orderID
#         self.time = timestamp


# Path: ProfitCalculator.py
import config
from utils import total_base_volume
from order import Order

            print('Can\'t afford min vol trade - insufficient bidder balance!')
            print('\t %s +%f %s' % (bidder.xchg.name, bidder_min_base_vol - bidder_base_balance, base))
            poor = True

        if (asker_base_afford < min_base_vol):
            print('Can\'t afford min vol trade - insufficient asker balance!')
            print('\t %s +%f %s' % (asker.xchg.name, (asker_min_base_vol-asker_base_afford)*self.prices[asker.xchg.name]['ask'], alt))
            poor = True

        if poor:
            return None

        """
        size the volume of base traded
        """
        asker_tx = 1.0 - asker.xchg.trading_fee
        bidder_tx = 1.0 - bidder.xchg.trading_fee

        # TODO - weird shit going on here, fix this!!

        # the line below computes how much base we could trade if we had unlimited balance
        # but are limited by the order volumes of base between the exchanges.
        # we receive a maximum of asks[0].v * asker_tx units of base from the asker
        # and we can sell a maximum of bids[0].v to the bidder
        max_base_xchg = min(bids[0].v, asks[0].v * asker_tx)
        # computes how much base we could trade if we had unlimited volume, limited balance
        max_base_balance = min(bidder_base_balance, asker_base_afford)
        # how much we will end up buying and selling
        base_vol = min(max_base_xchg, max_base_balance)


        bidder_order = Order(bids[0].p, base_vol)