from cryptsy.private import AuthenticatedSession import cryptsy.public import json import urllib2 from decimal import * api = AuthenticatedSession('keyfile.txt') marketData = urllib2.urlopen(urllib2.Request('http://pubapi.cryptsy.com/api.php?method=marketdatav2')) all_market_data = json.loads(marketData.read()) all_market_data = all_market_data['return']['markets'] total_btc_in_account = Decimal(0) total_ltc_in_account = Decimal(0) for market in all_market_data.iterkeys(): print all_market_data[market]['marketid'] orders = api.myorders(all_market_data[market]['marketid']) for order in orders: if order.type == 'Sell': if all_market_data[market]['secondarycode'] == 'LTC': total_ltc_in_account += Decimal(order.total) else: total_btc_in_account += Decimal(order.total) print total_ltc_in_account print total_btc_in_account
sell_order_data = all_market_data[coin_market]['sellorders'] tracking = {'total_spent':Decimal(0), 'total_bought':Decimal(0)} total_quantity_open = Decimal(0) maximum_sell_price = (daily_high - last_trade_price) * percent_of_variation + last_trade_price maximum_sell_volume_order = round(Decimal(daily_volume) * percent_daily_volume_order, 9) print '--------------' print currency_symbol print '--------------' runtimelog.write('\n--------------\n' + str(currency_symbol) + '\n--------------\n') """ Grabbing Balances in account """ open_orders = api.myorders(market_id) """ Calculating if the quantity of open orders is less than n\% of the DTV """ #print 'GRABBING CURRENT ORDER INFO' for orders in open_orders: if orders.type == 'Sell': #print 'TOTAL QUANTITY OPEN', total_quantity_open #print 'ORDER QUANTITY', orders.quantity total_quantity_open += Decimal(orders.quantity) #print 'ORDER PRICE', orders.price #print 'MAXIMUM SELL PRICE', maximum_sell_price if Decimal(orders.price) < maximum_sell_price: #print 'Switching maximum price of ', maximum_sell_price, 'to', Decimal(orders.price) maximum_sell_price = Decimal(orders.price)