Last Updated: February 25, 2016
·
412
· xanza

Coinbase Buy/Sell Monitor

If you're like me, then you spend all day in a terminal. I like to watch the bitcoin market when I have some downtime, too. Being an active bitcoin trader, and the bitcoin market being volatile as it is, it's a good idea to keep an eye on it to make sure you're not hemorrhaging money.

Prerequisites

Fish shell is simply my favorite shell, which is why this protip requires it.

httpie makes curl requests super easy.

Jq processes JSON data for manipulation in a super easy way.

btc.fish

function btc --description 'show the current buy/sell price of btc based on Coinbase prices'
    http GET https://api.coinbase.com/v2/prices/buy | jq '{buy: .data.amount}'
    http GET https://api.coinbase.com/v2/prices/sell | jq '{sell: .data.amount}'
end

watch_btc.fish

function watch_btc
    while true
        btc
        sleep 600
    end
end

That's pretty much it. Just call watch_btc and every 600 seconds (10 minutes) you'll pull and display the current buy and sell price for BTC.

Preview

Picture