Class: Kaesen::Monetago

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

Overview

Kaesen Wrapper Class www.monetago.com/#/api/ API制限. More than 500 requests per 10 minutes will result in IP ban. . For real-time data please refer to the MonetaGo WebSocket API.

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

#initializeMonetago

Returns a new instance of Monetago.



18
19
20
21
22
23
24
25
# File 'lib/kaesen/monetago.rb', line 18

def initialize()
  super()
  @name        = "Monetago"
  @api_key     = ENV["MONETAGO_KEY"]
  @api_secret  = ENV["MONETAGO_SECRET"]
  @url_public  = "https://api.monetago.com:8400/ajax/v1"
  @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] ローカルタイムスタンプ



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

def depth
  h = post_ssl(@url_public + "/GetOrderBook")
  {
    "asks"       => h["asks"].map{|x| [BigDecimal.new(x["px"].to_s), BigDecimal.new(x["qty"].to_s)]},
    "bids"       => h["bids"].map{|x| [BigDecimal.new(x["px"].to_s), BigDecimal.new(x["qty"].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] ローカルタイムスタンプtimestamp: [int] タイムスタンプ



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

def ticker
  h = post_ssl(@url_public + "/GetTicker", {product_pair: 'BTCJPY'})
  {
    "ask"        => BigDecimal.new(h["ask"].to_s),
    "bid"        => BigDecimal.new(h["bid"].to_s),
    "last"       => BigDecimal.new(h["last"].to_s),
    "high"       => BigDecimal.new(h["high"].to_s),
    "low"        => BigDecimal.new(h["low"].to_s),
    "volume"     => BigDecimal.new(h["volume"].to_s),
    "ltimestamp" => Time.now.to_i,
  }
end