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)
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)