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

#api_key, #api_secret, #name, #url_private, #url_public

Instance Method Summary collapse

Methods inherited from Market

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

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Monetago

Returns a new instance of Monetago.

Yields:

  • (_self)

Yield Parameters:



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kaesen/monetago.rb', line 18

def initialize(options = {})
  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

  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
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] ローカルタイムスタンプ



69
70
71
72
73
74
75
76
# File 'lib/kaesen/monetago.rb', line 69

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] タイムスタンプ



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/kaesen/monetago.rb', line 46

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