def parse_trade_book(msg, msg_data):
    # book trades
    if(msg['category'] == 'order_matches' and
       ((msg['command'] == 'update' and msg_data['status'] == 'completed') or  # for a trade with BTC involved, but that is settled (completed)
        ('forward_asset' in msg_data and msg_data['forward_asset'] != config.BTC and msg_data['backward_asset'] != config.BTC)
        )
       ):  # or for a trade without BTC on either end

        if msg['command'] == 'update' and msg_data['status'] == 'completed':
            # an order is being updated to a completed status (i.e. a BTCpay has completed)
            tx0_hash, tx1_hash = msg_data['order_match_id'][:64], msg_data['order_match_id'][65:]
            # get the order_match this btcpay settles
            order_match = util.jsonrpc_api(
                "get_order_matches",
                {'filters': [
                 {'field': 'tx0_hash', 'op': '==', 'value': tx0_hash},
                 {'field': 'tx1_hash', 'op': '==', 'value': tx1_hash}]
                 }, abort_on_error=False)['result'][0]
        else:
            assert msg_data['status'] == 'completed'  # should not enter a pending state for non BTC matches
            order_match = msg_data

        forward_asset_info = config.mongo_db.tracked_assets.find_one({'asset': order_match['forward_asset']})
        backward_asset_info = config.mongo_db.tracked_assets.find_one({'asset': order_match['backward_asset']})
        assert forward_asset_info and backward_asset_info
        base_asset, quote_asset = util.assets_to_asset_pair(order_match['forward_asset'], order_match['backward_asset'])

        # don't create trade records from order matches with BTC that are under the dust limit
        if((order_match['forward_asset'] == config.BTC and
            order_match['forward_quantity'] <= config.ORDER_BTC_DUST_LIMIT_CUTOFF)
           or (order_match['backward_asset'] == config.BTC and
               order_match['backward_quantity'] <= config.ORDER_BTC_DUST_LIMIT_CUTOFF)):
            logger.debug("Order match %s ignored due to %s under dust limit." % (order_match['tx0_hash'] + order_match['tx1_hash'], config.BTC))
            return 'ABORT_THIS_MESSAGE_PROCESSING'

        # take divisible trade quantities to floating point
        forward_quantity = blockchain.normalize_quantity(order_match['forward_quantity'], forward_asset_info['divisible'])
        backward_quantity = blockchain.normalize_quantity(order_match['backward_quantity'], backward_asset_info['divisible'])

        # compose trade
        trade = {
            'block_index': config.state['cur_block']['block_index'],
            'block_time': config.state['cur_block']['block_time_obj'],
            'message_index': msg['message_index'],  # secondary temporaral ordering off of when
            'order_match_id': order_match['tx0_hash'] + '_' + order_match['tx1_hash'],
            'order_match_tx0_index': order_match['tx0_index'],
            'order_match_tx1_index': order_match['tx1_index'],
            'order_match_tx0_address': order_match['tx0_address'],
            'order_match_tx1_address': order_match['tx1_address'],
            'base_asset': base_asset,
            'quote_asset': quote_asset,
            'base_quantity': order_match['forward_quantity'] if order_match['forward_asset'] == base_asset else order_match['backward_quantity'],
            'quote_quantity': order_match['backward_quantity'] if order_match['forward_asset'] == base_asset else order_match['forward_quantity'],
            'base_quantity_normalized': forward_quantity if order_match['forward_asset'] == base_asset else backward_quantity,
            'quote_quantity_normalized': backward_quantity if order_match['forward_asset'] == base_asset else forward_quantity,
        }
        d = D(trade['quote_quantity_normalized']) / D(trade['base_quantity_normalized'])
        d = d.quantize(EIGHT_PLACES, rounding=decimal.ROUND_HALF_EVEN, context=decimal.Context(prec=30))
        trade['unit_price'] = float(d)

        d = D(trade['base_quantity_normalized']) / D(trade['quote_quantity_normalized'])
        d = d.quantize(EIGHT_PLACES, rounding=decimal.ROUND_HALF_EVEN, context=decimal.Context(prec=30))
        trade['unit_price_inverse'] = float(d)

        config.mongo_db.trades.insert(trade)
        logger.info("Procesed Trade from tx %s :: %s" % (msg['message_index'], trade))