Beispiel #1
0
def getcoins(sc):
	from Cryptsy import Cryptsy
	from pprint import pprint
	import time
	import sys
	
	from config import pub,priv,targetcoin,targetcoinlabel,mytime,targetamount,targetprice
	coin_currency_id=0
	print "keys..."
	c = Cryptsy(pub, priv)
	
	print "api check..."
	if c.currency(3)['data']['name'] != 'BitCoin':
		sys.exit('api changed!')
	
	print "check bal..."
	if c.balance(3)['data']['available'].values()[0] < .02:
		sys.exit('get more BTC!')
	
	for item in c.markets()['data']:
		if item['label'] == targetcoinlabel:
			coin_currency_id= item['coin_currency_id']
	if coin_currency_id == 0:
		sys.exit("Cant get coin_currency_id from targetcoinlabel in config!")
	print "get price..."
	price=c.currency_markets(coin_currency_id)['data']['markets'][0]['last_trade']['price'] *.0025 + c.currency_markets(coin_currency_id)['data']['markets'][0]['last_trade']['price']
	print "Price: %s." % price
	price = str(price)
	#if price >= 3.0e-5:
	#	sys.exit("Price too high!")
	
	marketid=str(c.currency_markets(coin_currency_id)['data']['markets'][0]['id'])
	print "Marketid: %s" % marketid		
	
	if price <= targetprice:
		print "BUY!"
		c.order_create(marketid,targetamount,'buy',price)
	sc.enter(int(mytime), 1, getcoins, (sc,))
Beispiel #2
0
                    Cryptsy_Handle.order_remove( Transaction_Ledger[n][0] );

        if ( Transaction_Ledger[n][4] == "sell" ):
            if ( Transaction_Ledger[n][2] != i_sell_for_this_much ):
                moved_sell = Cryptsy_Handle.order_move( Transaction_Ledger[n][0] , i_sell_for_this_much , Transaction_Ledger[n][1] );
                if ( moved_sell.values()[1] == True ):
                    Transaction_Ledger[n][0] = moved_sell.values()[0].values()[0];
                    Transaction_Ledger[n][2] = i_sell_for_this_much;
                    Transaction_Ledger[n][3] = i_sell_for_this_much * Transaction_Ledger[n][1];
                else:
                    Cryptsy_Handle.order_remove( Transaction_Ledger[n][0] );
                

    # Place an order to buy more coins!
    num_buy = limit / i_buy_for_this_much;
    order = Cryptsy_Handle.order_create( market_ID , num_buy , "buy" , i_buy_for_this_much );
    if ( order.values()[1] ):
        
        # If placing the order was successful, append it to the list of orders made
        Transaction_Ledger.append( order.values()[0].values()[0] , num_buy , i_buy_for_this_much , num_buy * i_buy_for_this_much , "buy" );

        # Update the spending limit
        limit = limit - num_buy * i_buy_for_this_much

    # Place an order to sell all the coins we have
    num_to_sell = Cryptsy_Handle.balance( 124 ).values()[0].values()[0].values()[0];
    if ( num_to_sell * i_sell_for_this_much > minimum order ):
        order = Cryptsy_Handle.order_create( market_ID , num_to_sell , "sell" , i_sell_for_this_much );

        if ( order.values()[1] ):