Is there an API for price estimation?
while amount &gt; 0:
        amount_i = int(mtgox_depth['bids'][index]['amount_int'])
        price_i = int(mtgox_depth['bids'][index]['price_int'])
        if amount_i &lt; amount:
            total_value += amount_i * price_i
            amount -= amount_i
        elif amount_i &gt;= amount:
            total_value += amount * price_i
            amount = 0
        index -= 1
    spot = int(total_value / float(total_amount))
    return spot


Something like this, where mtgox_depth is a json object of https://mtgox.com/api/1/BTCUSD/depth?raw, should work for you.