percent_daily_volume_order = Decimal(conf_file['percent_daily_volume_order']) percent_daily_volume_total = Decimal(conf_file['percent_daily_volume_total']) max_btc_to_trade_order = Decimal(conf_file['max_btc_to_trade_order']) max_ltc_to_trade_order = Decimal(conf_file['max_ltc_to_trade_order']) percent_of_variation = Decimal(conf_file['percent_of_variation']) outlier_percentage = Decimal(conf_file['outlier_percent']) loops_to_clean_dust = int(conf_file['loops_to_clean_dust']) max_ltc_to_trade_total = Decimal(0) max_btc_to_trade_total = Decimal(0) final_total_btc = Decimal(0) final_total_ltc = Decimal(0) total_funds_spent = Decimal(0) max_funds_to_spend = Decimal(0) api = AuthenticatedSession('keyfile.txt') marketData = urllib2.urlopen(urllib2.Request('http://pubapi.cryptsy.com/api.php?method=marketdatav2')) all_market_data = json.loads(marketData.read()) daily_volume_market = {'BTC':Decimal(0), 'LTC':Decimal(0), 'USD':Decimal(0)} all_market_data = gather_extra_market_data(api, all_market_data) """ Looping through all the market data coin_market = each of the trading pairs ie. LTC/BTC all_market_data = results from cryptsy API, only data
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
from cryptsy.private import AuthenticatedSession from cryptsy.common import CryptsyError import urllib2 import json from decimal import * api = AuthenticatedSession("keyfile.txt") balances = api.getinfo() balances = balances['balances_available'] api.cancelallorders() """ 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 = Decimal(0) print 'before loop' for markets in all_market_data.iterkeys(): for coin in balances.iterkeys(): if coin == all_market_data[markets]['primarycode']: try: api.createorder(all_market_data[markets]['marketid'], 'Sell', balances[coin], round(Decimal(all_market_data[markets]['lasttradeprice']), 9)) print 'Selling', balances[coin], all_market_data[markets]['primarycode'] except (CryptsyError, Exception) as e: print 'less than 0.00000010'