def main(): api_key = '123456789' api_secret = 'abcdefggijkl' nonce_file_path = '/path/to/nonce.json' # brce trade api btce_trade = btce.TradeAPI(api_key, api_secret, nonce_file_path) info = btce_trade.user_info() trans_hist = btce_trade.tx_history() print(info, trans_hist) # btce public api ticker = btce.ticker('btc_usd') depth = btce.depth('ltc_btc') print(ticker, depth) # poloniex trade api poloniex_trade = poloniex.TradeAPI(api_key, api_secret, nonce_file_path) balances = poloniex_trade.balances() btc_deposit_addr = poloniex_trade.generate_deposit_address('btc') print(balances, btc_deposit_addr) # poloniex public api vol24 = poloniex.vol_24hr() ticker = poloniex.ticker() print(vol24, ticker)
print 'LTC: ' + str(funds['ltc']) + '\t\tIN USD: ' + str(funds['ltc'] * ltc_usd) print 'TRC: ' + str(funds['trc']) + '\tIN USD: ' + str(funds['trc'] * trc_btc * btc_usd) print 'NMC: ' + str(funds['nmc']) + '\t\tIN USD: ' + str(funds['nmc'] * nmc_btc * btc_usd) print 'PPC: ' + str(funds['ppc']) + '\t\tIN USD: ' + str(funds['ppc'] * ppc_btc * btc_usd) worth = portfolio_worth(ticker_data, info) print 'Portfolio networth: %s USD' % str(worth) count = 0 while True: ticker_data = {} if count % field_count == 0: print fields for ticker in tickers: try: data = btce.ticker(ticker) except: print 'error with ticker [%s]' % str(ticker) continue if data: ticker_string = '' servertime = data['server_time'] gmt = time.gmtime(servertime) gmt = time.strftime(timestring, gmt) ticker_string = gmt for field in fields: if field != 'server_time': ticker_string = ticker_string + '\t' + str(data[field]) print ticker print ticker_string ticker_data[tuple(ticker)] = data
#!/usr/bin/python import sys import math import btce from time import strftime, localtime nbuckets = 20 norm = 80 pair = sys.argv[1] ticker = btce.ticker(pair) print "Curency pair:", pair for param in ["sell", "buy", "last", "low", "high"]: print "\t", param, ticker[param] depth = btce.depth(pair) for type in ["bids", "asks"]: d = depth[type] rates = map(lambda x: x[0], d) rate_min = min(rates) rate_max = max(rates) rate_delta = rate_max - rate_min print type buckets = [0 for x in range(nbuckets)] for x in map(lambda x: [int((x[0] - rate_min) / rate_delta * (nbuckets - 1)), x[1]], d): buckets[x[0]] = buckets[x[0]] + x[1] bucket_max = max(buckets) buckets = map(lambda x: (x / bucket_max) * norm, buckets)
import btce import json import json_ascii from time import strftime, localtime info = btce.getinfo() #print 'Info: ', info print "Funds:" for currency in ['BTC', 'USD', 'LTC']: print "\t", currency, info['funds'][currency.lower()] print #print 'Trade_History: ', btce.trade_history() #print 'Order_List', btce.order_list() #print 'Depth: ', btce.depth('btc_usd') #print 'All Trades: ', btce.trades('btc_usd') #print 'Trans_History', btce.trans_history() ticker = btce.ticker('btc_usd') print 'Ticker: ', ticker if info['open_orders']: print "Open orders (" + str(info['open_orders']) + "):" print "id\t\tdirection\tamount\t\trate\t\ttime" orders = btce.order_list() for id, data in orders.items()['return']: pair = data['pair'].split('_') if data['type'] == 'buy': pair[0], pair[1] = pair[1], pair[0] print str(id) + "\t\t" + pair[0] + '->' + pair[1] + "\t" + str(data['amount']) + "\t\t" + str(data['rate']) + "\t\t" + strftime('%d.%m.%Y %H:%M:%S', localtime(data['timestamp_created']))