Initial commit
This commit is contained in:
21
lib/peatio/kline_db.rb
Normal file
21
lib/peatio/kline_db.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
module KlineDB
|
||||
class << self
|
||||
|
||||
def redis
|
||||
@redis ||= Redis.new(
|
||||
url: ENV["REDIS_URL"],
|
||||
db: 1
|
||||
)
|
||||
end
|
||||
|
||||
def kline(market, period)
|
||||
key = "peatio:#{market}:k:#{period}"
|
||||
length = redis.llen(key)
|
||||
data = redis.lrange(key, length - 5000, -1).map{|str| JSON.parse(str)}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user