Introduction
Fast and easy way to get all data about all coins in any fiat value.
Get data for analyze or use it to make a brand new crypto app.
After scrapping prices in CSV file, and printing colorized output,
you can access each rate with #price(coin)
. No configuration, just run.
- Collect prices of defined coins from cryptocompare.com
- Save data into object
- Save to CSV and print colorized output
- Print-only without saving
- Save-only without printing
How to install
Make sure you have ruby and git installed:
git clone https://github.com/decentralizuj/crates.git
cd crates
bundle install
How to run
If you want to edit default coins:
> (5): COINS = %w[ ... ].freeze
Run from terminal:
$ ruby bin/crates usd eur rsd
$ ruby bin/crates usd eur rsd --no-save
$ ruby bin/crates usd eur rsd --no-print
How to use
Initialize new object with your own configuration. If you want to use defaults:
-
-
-
Otherwise, #new accept 'currency' as argument, and an 'options hash':
- first parameter is currency, defauilt is 'EUR'
- other accepted options are:
print: boolean
save: boolean
coins: array
Example:
COINS = %w[ BTC XMR LTC ETH ZEC ].freeze
PRINT = true
SAVE = true
@rates = C::Rates.new( :eur, coins: COINS, print: PRINT, save: SAVE )
@rates.get
CURRENCIES = %w[ USD EUR RSD ].freeze
CURRENCIES.each do |currency|
@rates.get currency
end
This will print/save data as configured, while making prices easily
accessible with Rates#price(:symbol).
@rates.prices
@rates.price(:btc)
@rates.price('xmr')
C::Rates has two setter methods:
@rates.currency = 'EUR'
@rates.coins = %w[BTC XMR LTC]
Other available objects are:
@rates.currency
@rates.coins
@rates.save?
@rates.print?
@rates.count
@rates.url
@rates.reponse
@rates.data
@rates.table
TO-DO
This gem is start of app that I am working on to help me with auto-trades.
At the moment I use it to notify me when price change more then 2% from last trade.
Then I perform crypto-to-crypto trade, and wait for price to change again.
To make it reliable and worth of using, plan is to add next functions:
- add more sources to get data from them
- scrap more data into tables (only data I need)
- add support for API-KEYS
- rotate sources if requests are sent too often
- add support for proxy and headers rotation
- create charts from prices at given time (each 10min etc)
- create GIF animation from charts per time (each 30 min etc)
PREVIEW