Exemplo n.º 1
0
def market (give_asset, get_asset):

    # Your Pending Orders Matches.
    addresses = []
    for bunch in bitcoin.get_wallet():
        addresses.append(bunch[:2][0])
    filters = [
        ('tx0_address', 'IN', addresses),
        ('tx1_address', 'IN', addresses)
    ]
    awaiting_btcs = util.api('get_order_matches', {'filters': filters, 'filterop': 'OR', 'status': 'pending'})
    table = PrettyTable(['Matched Order ID', 'Time Left'])
    for order_match in awaiting_btcs:
        order_match = format_order_match(db, order_match)
        table.add_row(order_match)
    print('Your Pending Order Matches')
    print(table)
    print('\n')

    # Open orders.
    orders = util.api('get_orders', {'status': 'open'})
    table = PrettyTable(['Give Quantity', 'Give Asset', 'Price', 'Price Assets', 'Required BTC Fee', 'Provided BTC Fee', 'Time Left', 'Tx Hash'])
    for order in orders:
        if give_asset and order['give_asset'] != give_asset: continue
        if get_asset and order['get_asset'] != get_asset: continue
        order = format_order(order)
        table.add_row(order)
    print('Open Orders')
    table = table.get_string(sortby='Price')
    print(table)
    print('\n')

    # Open bets.
    bets = util.api('get_bets', {'status': 'open'})
    table = PrettyTable(['Bet Type', 'Feed Address', 'Deadline', 'Target Value', 'Leverage', 'Wager', 'Odds', 'Time Left', 'Tx Hash'])
    for bet in bets:
        bet = format_bet(bet)
        table.add_row(bet)
    print('Open Bets')
    print(table)
    print('\n')

    # Feeds
    broadcasts = util.api('get_broadcasts', {'status': 'valid'})
    table = PrettyTable(['Feed Address', 'Timestamp', 'Text', 'Value', 'Fee Fraction'])
    seen_addresses = []
    for broadcast in broadcasts:
        # Only show feeds with broadcasts in the last two weeks.
        last_block_time = util.last_block(db)['block_time']
        if broadcast['timestamp'] + config.TWO_WEEKS < last_block_time:
            continue
        # Always show only the latest broadcast from a feed address.
        if broadcast['source'] not in seen_addresses:
            feed = format_feed(broadcast)
            table.add_row(feed)
            seen_addresses.append(broadcast['source'])
        else:
            continue
    print('Feeds')
    print(table)
Exemplo n.º 2
0
        print('\taddress, quantity, escrow')
        for holder in util.get_holders(db, args.asset):
            quantity = holder['address_quantity']
            if not quantity: continue
            quantity = util.devise(db, quantity, args.asset, 'output')
            if holder['escrow']: escrow = holder['escrow']
            else: escrow = 'None'
            print('\t' + str(holder['address']) + ',' + str(quantity) + ',' + escrow)


    elif args.action == 'wallet':
        total_table = PrettyTable(['Asset', 'Balance'])
        totals = {}

        print()
        for bunch in bitcoin.get_wallet():
            address, btc_balance = bunch[:2]
            get_address = util.get_address(db, address=address)
            balances = get_address['balances']
            table = PrettyTable(['Asset', 'Balance'])
            empty = True
            if btc_balance:
                table.add_row(['BTC', btc_balance])  # BTC
                if 'BTC' in totals.keys(): totals['BTC'] += btc_balance
                else: totals['BTC'] = btc_balance
                empty = False            
            for balance in balances:
                asset = balance['asset']
                balance = D(util.devise(db, balance['quantity'], balance['asset'], 'output'))
                if balance:
                    if asset in totals.keys(): totals[asset] += balance
Exemplo n.º 3
0
            print('\taddress, quantity, escrow')
            for holder in util.holders(db, args.asset):
                quantity = holder['address_quantity']
                if not quantity: continue
                quantity = util.devise(db, quantity, args.asset, 'output')
                if holder['escrow']: escrow = holder['escrow']
                else: escrow = 'None'
                print('\t' + str(holder['address']) + ',' + str(quantity) + ',' + escrow)


    elif args.action == 'wallet':
        total_table = PrettyTable(['Asset', 'Balance'])
        totals = {}

        print()
        for bunch in bitcoin.get_wallet():
            address, btc_balance = bunch[:2]
            address_data = get_address(db, address=address)
            balances = address_data['balances']
            table = PrettyTable(['Asset', 'Balance'])
            empty = True
            if btc_balance:
                table.add_row(['BTC', btc_balance])  # BTC
                if 'BTC' in totals.keys(): totals['BTC'] += btc_balance
                else: totals['BTC'] = btc_balance
                empty = False            
            for balance in balances:
                asset = balance['asset']
                try:
                    balance = D(util.devise(db, balance['quantity'], balance['asset'], 'output'))
                except: