class Kaesen::Market

Exchange markets. @abstract

Attributes

api_key[RW]
api_secret[RW]
name[RW]
url_private[RW]
url_public[RW]

Public Class Methods

new() click to toggle source
# File lib/kaesen/market.rb, line 9
def initialize
  @name = nil         # [String] name of exchange market
  @api_key    = nil   # [String]
  @api_secret = nil   # [String]
  @url_public  = nil  # [String]
  @url_private = nil  # [String]
end
unBigDecimal(x) click to toggle source

Pretty printer for data including BigDecimal @param [any] data that may include BigDecimal @return [any] data that does not include BigDecimal

# File lib/kaesen/market.rb, line 163
def self.unBigDecimal(x)
  if x.is_a?(Array)
    x.map{|y| unBigDecimal(y)}
  elsif x.is_a?(Hash)
    x.map{|k,v|
      [k, unBigDecimal(v)]
    }.to_h
  elsif x.is_a?(BigDecimal)
    x.to_f
  else
    x
  end
end

Public Instance Methods

balance() click to toggle source

Get account balance. @abstract @return [hash] account_balance_hash

jpy: [hash]
   amount: [BigDecimal] 総日本円
   available: [BigDecimal] 取引可能な日本円
btc [hash]
   amount: [BigDecimal] 総BTC
   available: [BigDecimal] 取引可能なBTC
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 63
def balance
  raise NotImplemented.new()
end
buy(rate, amount=BigDecimal.new("0.0")) click to toggle source

Buy the amount of Bitcoin at the rate. 指数注文 買い. @abstract @param [BigDecimal] rate @param [BigDecimal] amount @return [hash] history_order_hash

success: [bool]
id: [String] order id in the market
rate: [BigDecimal]
amount: [BigDecimal]
order_type: [String] "sell" or "buy"
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 93
def buy(rate, amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end
cancel(id) click to toggle source

Cancel an open order @abstract @param [int or string] order id @return [hash]

success: [bool] status
# File lib/kaesen/market.rb, line 148
def cancel(id)
  raise NotImplemented.new()
end
cancel_all() click to toggle source

Cancel all open orders @abstract @return [array]

success: [bool] status
# File lib/kaesen/market.rb, line 156
def cancel_all
  raise NotImplemented.new()
end
depth() click to toggle source

Get order book. @abstract @return [hash] array of market depth

asks: [Array] 売りオーダー
   price : [BigDecimal]
   size : [BigDecimal]
bids: [Array] 買いオーダー
   price : [BigDecimal]
   size : [BigDecimal]
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 45
def depth
  raise NotImplemented.new()
end
market_buy(amount=BigDecimal.new("0.0")) click to toggle source

Buy the amount of Bitcoin from the market. 成行注文 買い. @abstract @param [BigDecimal] amount @return [hash] history_order_hash

success: [bool]
id: [String] order id in the market
rate: [BigDecimal]
amount: [BigDecimal]
order_type: [String] "sell" or "buy"
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 108
def market_buy(amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end
market_sell(amount=BigDecimal.new("0.0")) click to toggle source

Sell the amount of Bitcoin to the market. 成行注文 売り. @abstract @param [BigDecimal] amount @return [hash] history_order_hash

success: [bool]
id: [String] order id in the market
rate: [BigDecimal]
amount: [BigDecimal]
order_type: [String] "sell" or "buy"
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 139
def market_sell(amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end
opens() click to toggle source

Get open orders. @abstract @return [Array] open_orders_array

@return [hash] history_order_hash
  success: [bool]
  id: [String] order id in the market
  rate: [BigDecimal]
  amount: [BigDecimal]
  order_type: [String] "sell" or "buy"
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 77
def opens
  raise NotImplemented.new()
end
sell(rate, amount=BigDecimal.new("0.0")) click to toggle source

Sell the amount of Bitcoin at the rate. 指数注文 売り. @abstract @param [BigDecimal] rate @param [BigDecimal] amount @return [hash] history_order_hash

success: [String] "true" or "false"
id: [String] order id in the market
rate: [BigDecimal]
amount: [BigDecimal]
order_type: [String] "sell" or "buy"
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 124
def sell(rate, amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end
ticker() click to toggle source

Get ticker information. @abstract @return [hash] ticker

ask: [BigDecimal] 最良売気配値
bid: [BigDecimal] 最良買気配値
last: [BigDecimal] 最近値(?用語要チェック), last price
high: [BigDecimal] 高値
low: [BigDecimal] 安値
volume: [BigDecimal] 取引量
ltimestamp: [int] Local Timestamp
# File lib/kaesen/market.rb, line 31
def ticker
  raise NotImplemented.new()
end

Private Instance Methods

have_key?() click to toggle source

Check the API key and API secret key.

# File lib/kaesen/market.rb, line 180
def have_key?
  raise "Your #{@name} API key is not set"    if @api_key.nil?
  raise "Your #{@name} API secret is not set" if @api_secret.nil?
end