Class: Kaesen::Quoine

Inherits:
Market
  • Object
show all
Defined in:
lib/kaesen/quoine.rb

Overview

Quoine Wrapper Class developers.quoine.com/ API制限API users should not make more than 300 requests per 5 minute. Requests go beyond the limit will return with a 429 status

Constant Summary collapse

@@nonce =
0

Instance Attribute Summary

Attributes inherited from Market

#name

Instance Method Summary collapse

Methods inherited from Market

#balance, #buy, #cancel, #cancel_all, #market_buy, #market_sell, #opens, #sell, unBigDecimal

Constructor Details

#initializeQuoine

Returns a new instance of Quoine.



16
17
18
19
20
21
22
23
# File 'lib/kaesen/quoine.rb', line 16

def initialize()
  super()
  @name        = "Quoine"
  @api_key     = ENV["QUOINE_KEY"]
  @api_secret  = ENV["QUOINE_SECRET"]
  @url_public  = "https://api.quoine.com"
  @url_private = @url_public
end

Instance Method Details

#depthhash

This method is abstract.

Get order book.

Returns:

  • (hash)

    array of market depth asks: [Array] 売りオーダー

    price : [BigDecimal]
    size : [BigDecimal]
    

    bids: [Array] 買いオーダー

    price : [BigDecimal]
    size : [BigDecimal]
    

    ltimestamp: [int] ローカルタイムスタンプ



63
64
65
66
67
68
69
70
# File 'lib/kaesen/quoine.rb', line 63

def depth
  h = get_ssl(@url_public + "/products/5/price_levels") # the id of BTCJPY is 5.
  {
    "asks"       => h["buy_price_levels"].map{|a,b| [BigDecimal.new(a.to_s), BigDecimal.new(b.to_s)]}, # to_s でないと誤差が生じる
    "bids"       => h["sell_price_levels"].map{|a,b| [BigDecimal.new(a.to_s), BigDecimal.new(b.to_s)]}, # to_s でないと誤差が生じる
    "ltimestamp" => Time.now.to_i,
  }
end

#tickerhash

Get ticker information.

Returns:

  • (hash)

    ticker ask: [BigDecimal] 最良売気配値bid: [BigDecimal] 最良買気配値last: [BigDecimal] 最近値(?用語要チェック), last price high: [BigDecimal] 高値low: [BigDecimal] 安値volume: [BigDecimal] 取引量ltimestamp: [int] ローカルタイムスタンプvwap: [BigDecimal] 過去24時間の加重平均



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/kaesen/quoine.rb', line 39

def ticker
  h = get_ssl(@url_public + "/products/code/CASH/BTCJPY") # the id of BTCJPY is 5.
  {
    "ask"        => BigDecimal.new(h["market_ask"].to_s),
    "bid"        => BigDecimal.new(h["market_bid"].to_s),
    "last"       => BigDecimal.new(h["last_traded_price"].to_s),
    # "high"
    # "low"
    "volume"     => BigDecimal.new(h["volume_24h"].to_s), # of the previous 24 hours
    "ltimestamp" => Time.now.to_i,
    # "vwap"
  }
end