ulvis.paste.net

Paste Search Dynamic
Recent pastes
Bitcoin Price Monitor
  1. #!/bin/sh
  2. # BuyOrSell: Program to determine whether to buy or to sell Bitcoin
  3. # Requires wget
  4. # This program is open source, and I do not guarantee the accuracy, fitness, usability, or effectiveness of this code.
  5.  
  6. getprice() {
  7. data=$(wget -qO - 'blockchain.info/tobtc?currency=USD&value=1000000' | tr -d ,)
  8. echo 1000000 / $data | bc -lq
  9. }
  10. price=$(getprice)
  11. sleep 10
  12. while true; do
  13.     oldprice=$price
  14.     price=$(getprice)
  15.     [ $(echo "$oldprice > $price" | bc) = 1 ] && echo BUY
  16.     [ $(echo "$oldprice < $price" | bc) = 1 ] && echo SELL
  17.     sleep 10
  18. done
Parsed in 0.005 seconds