Example #1
0
def purchase():
    logging.info("buy")
    # extract payout address from client address
    client_payout_addr = request.args.get('payout_address')
    # price movement: up or down
    action = request.args.get('action')

    if not client_payout_addr:
        return "Required: payout_address. You know, for when you win."
    if not action:
        return "Required: action"

    usd_rate = machine_app.get_quote()

    # add to book
    if action == 'up':
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ,
                             usd_rate, True)
    else:
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ,
                             usd_rate, False)

    try:
        txid = machine_app.wallet.send_to(client_payout_addr, change)
    except ValueError:
        txid = machine_app.wallet.send_to(client_payout_addr,
                                          machine_app.PAYMENT_REQ)
        return "Ugh, dust problem. Payment refunded"
    return "Paid %d. BTCUSD is currently %.5f and will go %s." % \
            (machine_app.PAYMENT_REQ - change, usd_rate, action)
Example #2
0
def purchase():
    logging.info("buy")
    # extract payout address from client address
    client_payout_addr = request.args.get('payout_address')
    # price movement: up or down
    action = request.args.get('action')

    if not client_payout_addr:
        return "Required: payout_address. You know, for when you win."
    if not action:
        return "Required: action"

    usd_rate = machine_app.get_quote()

    # add to book
    if action == 'up':
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, True)
    else:
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, False)

    try:
        txid = machine_app.wallet.send_to(client_payout_addr, change)
    except ValueError:
        txid = machine_app.wallet.send_to(client_payout_addr, machine_app.PAYMENT_REQ)
        return "Ugh, dust problem. Payment refunded"
    return "Paid %d. BTCUSD is currently %.5f and will go %s." % \
            (machine_app.PAYMENT_REQ - change, usd_rate, action)
Example #3
0
def purchase():
    # extract payout address from client address
    client_payout_addr = request.args.get('payout_address')
    # price movement: up or down
    action = request.args.get('action')

    usd_rate = machine_app.get_quote()

    # add to book
    if action == 'up':
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, True)
    else:
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, False)
    return '%d' % change
def purchase():
    # extract payout address from client address
    client_payout_addr = request.args.get('payout_address')
    # price movement: up or down
    action = request.args.get('action')

    usd_rate = machine_app.get_quote()

    # add to book
    if action == 'up':
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ,
                             usd_rate, True)
    else:
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ,
                             usd_rate, False)
    return '%d' % change
Example #5
0
def purchase():
    logging.info("buy")
    # extract payout address from client address
    client_payout_addr = request.args.get('payout_address')
    # price movement: up or down
    action = request.args.get('action')

    usd_rate = machine_app.get_quote()

    # add to book
    if action == 'up':
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, True)
    else:
        change = add_to_book(conn, client_payout_addr, machine_app.PAYMENT_REQ, usd_rate, False)

    txid = machine_app.wallet.send_to(client_payout_addr, change)
    return "Paid %d. BTCUSD is currently %.5f and will go %s." % \
            (machine_app.PAYMENT_REQ - change, usd_rate, action)
Example #6
0
def price_quote():
    logging.info("quote")
    q = machine_app.get_quote()
    buy_price, sell_price = get_book_quote(conn, q)
    return 'BTCUSD: %.5f  buy: %.5f, sell: %.5f' % (q, buy_price, sell_price)
Example #7
0
def btc_quote():
    logging.info("btc_quote")
    q = machine_app.get_quote()
    return '%.5f' % q
Example #8
0
def price_quote():
    logging.info("quote")
    q = machine_app.get_quote()
    buy_price, sell_price = get_book_quote(conn, q)
    return 'BTCUSD: %.5f  buy: %.5f, sell: %.5f' % (q, buy_price, sell_price)
Example #9
0
def btc_quote():
    logging.info("btc_quote")
    q = machine_app.get_quote()
    return '%.5f' % q
Example #10
0
def btc_quote():
    q = machine_app.get_quote()
    return '%.5f' % q
Example #11
0
def btc_quote():
    q = machine_app.get_quote()
    return '%.5f' % q