Exemplo n.º 1
0
# -*- coding: utf-8 -*-

from cexapi import Api
from settings import username, api_key, api_secret

a = Api(username, api_key, api_secret)

bt = a.ticker('GHS/BTC')
nt = a.ticker('GHS/NMC')
b = a.balance()

print '-'*20

print 'Current GHS price is %s BTC' % bt.lastn
print 'Have %s GHS' % b.ghs_available
print 'Which is worth %s BTC if sold now' % (b.ghs_available * bt.lastn)

print '-'*20

print 'Have %s BTC' % b.btc_available
print 'Current GHS price is %s BTC' % bt.lastn
btc_price = bt.lastn + 0.0001
buy_btc = (b.btc_available / btc_price) / 1.05
print 'Can therefore buy %s GHS with BTC' % buy_btc
if buy_btc > 0.001:
    print 'Placing order for %s GHS at %s BTC/GHS' % (buy_btc, btc_price)
    order_id = a.place_order('buy', amount=buy_btc, price=btc_price, couple='GHS/BTC')['id']
    print 'Order id %s successfully placed' % order_id
else:
    print 'Cannot buy enough - skipping GHS/BTC'
Exemplo n.º 2
0
# -*- coding: utf-8 -*-

from cexapi import Api
from settings import username, api_key, api_secret

demo = Api(username, api_key, api_secret)

#print demo.ticker('GHS/BTC')

print demo.balance()

#print "Ticker (BF1/BTC)"
#print demo.ticker('BF1/BTC')

#print "Order book (GHS/BTC)"
#print demo.order_book()  # or demo.order_book('GHS/BTC')

#print "Order book (BF1/BTC)"
#print demo.order_book('BF1/BTC')

#print "Trade history since=100 (GHS/BTC)"
#print demo.trade_history(100)  # or (100,'GHS/BTC')

#print "Trade history since=100 (BF1/BTC)"
#print demo.trade_history(100, 'BF1/BTC')

#print "Balance"


#print "Open orders (GHS/BTC)"
#print demo.current_orders()  # or ('GHS/BTC')