Class: Kaesen::Lakebtc
Overview
Lakebtc Wrapper Class www.lakebtc.com/s/api
Constant Summary collapse
- @@nonce =
0
Instance Attribute Summary
Attributes inherited from Market
#api_key, #api_secret, #name, #url_private, #url_public
Instance Method Summary collapse
-
#depth ⇒ hash
abstract
Get order book.
-
#initialize(options = {}) {|_self| ... } ⇒ Lakebtc
constructor
A new instance of Lakebtc.
-
#ticker ⇒ hash
Get ticker information.
Methods inherited from Market
#balance, #buy, #cancel, #cancel_all, #market_buy, #market_sell, #opens, #sell, unBigDecimal
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Lakebtc
Returns a new instance of Lakebtc.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kaesen/lakebtc.rb', line 14 def initialize( = {}) super() @name = "Lakebtc" @api_key = ENV["LAKEBTC_KEY"] @api_secret = ENV["LAKEBTC_SECRET"] @url_public = "https://www.LakeBTC.com/api_v1" @url_private = @url_public .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end |
Instance Method Details
#depth ⇒ hash
This method is abstract.
Get order book.
67 68 69 70 71 72 73 74 |
# File 'lib/kaesen/lakebtc.rb', line 67 def depth h = get_ssl(@url_public + "/bcorderbook?symbol=btcjpy") # the id of BTCJPY is 5. { "asks" => h["asks"].map{|a,b| [BigDecimal.new(a.to_s), BigDecimal.new(b.to_s)]}, # to_s でないと誤差が生じる "bids" => h["bids"].map{|a,b| [BigDecimal.new(a.to_s), BigDecimal.new(b.to_s)]}, # to_s でないと誤差が生じる "ltimestamp" => Time.now.to_i, } end |
#ticker ⇒ hash
Get ticker information.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kaesen/lakebtc.rb', line 42 def ticker h = get_ssl(@url_public + "/ticker") # the id of BTCJPY is 5. h = h["JPY"] { "ask" => BigDecimal.new(h["ask"].to_s), "bid" => BigDecimal.new(h["bid"].to_s), "last" => BigDecimal.new(h["last"].to_s), # "high" # "low" # "volume" "ltimestamp" => Time.now.to_i, # "vwap" } end |