Method: CoinQuery#query_archive
- Defined in:
- lib/coinquery.rb
#query_archive(coin_name, rawdate) ⇒ Object
use the database archive to query the historical price of a coin e.g. query_archive :btc, ‘1 May 2021’
197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/coinquery.rb', line 197 def query_archive(coin_name, rawdate) uc = Unichron.new(rawdate.to_s, :little_endian) raise 'invalid date' unless uc.valid? date = uc.to_date coin_id = find_id coin_name id = coin_id + date.to_time.to_i.to_s r = @table.query "select * from coins where id == '#{id}'" r.first if r end |