Cointools
This is a collection of Ruby scripts and library classes that let you check cryptocurrency prices on various services (currently Cryptowatch).
Installation
To use the scripts from the command line, install the gem:
gem install cointools
To use the code as a library, add it to your Gemfile:
gem 'cointools'
Usage
Cryptowatch
To check past price of a given coin on a chosen exchange, pass the exchange and market name and a properly formatted timestamp:
cryptowatch bitfinex btcusd "2017-12-17 13:00"
To check the current price, skip the timestamp:
cryptowatch bitfinex btcusd
You can fetch a list of available exchanges and markets using these commands:
cryptowatch --list-exchanges
cryptowatch --list-markets bithumb
In code:
require 'cointools'
cryptowatch = CoinTools::Cryptowatch.new
exchange = cryptowatch.exchanges.first
list = cryptowatch.get_markets(exchange)
market = list.select { |x| x =~ /ltc/ && x !~ /btc/ }.first.upcase
result = cryptowatch.get_price(exchange, market, Time.now - 86400)
puts "#{market} yesterday: #{result.price}"
result = cryptowatch.get_current_price(exchange, market)
puts "#{market} today: #{result.price}"
The result object contains the requested price and (for historical prices) the actual timestamp of the found price, which might slightly differ from the timestamp passed in the argument (the earlier the date, the less precise the result).
Credits & contributing
Copyright © 2018 Kuba Suder. Licensed under Very Simple Public License, my custom license that's basically a simplified version of the MIT license that fits in 3 lines.
If you'd like to help me extend the scripts with some additional features or add support for new services, send me a pull request.