Class: Kaesen::Market Abstract

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

Overview

This class is abstract.

Exchange markets.

Direct Known Subclasses

Bitflyer, Btcbox, Coincheck, Kraken, Lakebtc, Monetago, Quoine, Zaif

Defined Under Namespace

Classes: APIErrorException, ConnectionFailedException, JSONException

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMarket

Returns a new instance of Market.



9
10
11
12
13
14
15
# 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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/kaesen/market.rb', line 7

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



7
8
9
# File 'lib/kaesen/market.rb', line 7

def api_secret
  @api_secret
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/kaesen/market.rb', line 6

def name
  @name
end

#url_privateObject

Returns the value of attribute url_private.



7
8
9
# File 'lib/kaesen/market.rb', line 7

def url_private
  @url_private
end

#url_publicObject

Returns the value of attribute url_public.



7
8
9
# File 'lib/kaesen/market.rb', line 7

def url_public
  @url_public
end

Class Method Details

.unBigDecimal(x) ⇒ any

Pretty printer for data including BigDecimal

Parameters:

  • data (any)

    that may include BigDecimal

Returns:

  • (any)

    data that does not include BigDecimal



163
164
165
166
167
168
169
170
171
172
173
174
175
# 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

Instance Method Details

#balancehash

This method is abstract.

Get account balance.

Returns:

  • (hash)

    account_balance_hash jpy: [hash]

    amount: [BigDecimal] 総日本円
    available: [BigDecimal] 取引可能な日本円
    

    btc [hash]

    amount: [BigDecimal] 総BTC
    available: [BigDecimal] 取引可能なBTC
    

    ltimestamp: [int] Local Timestamp

Raises:

  • (NotImplemented)


63
64
65
# File 'lib/kaesen/market.rb', line 63

def balance
  raise NotImplemented.new()
end

#buy(rate, amount = BigDecimal.new("0.0")) ⇒ hash

This method is abstract.

Buy the amount of Bitcoin at the rate. 指数注文 買い.

Parameters:

  • rate (BigDecimal)
  • amount (BigDecimal) (defaults to: BigDecimal.new("0.0"))

Returns:

  • (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

Raises:

  • (NotImplemented)


93
94
95
# File 'lib/kaesen/market.rb', line 93

def buy(rate, amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end

#cancel(id) ⇒ hash

This method is abstract.

Cancel an open order

Parameters:

  • order (int or string)

    id

Returns:

  • (hash)

    success: [bool] status

Raises:

  • (NotImplemented)


148
149
150
# File 'lib/kaesen/market.rb', line 148

def cancel(id)
  raise NotImplemented.new()
end

#cancel_allarray

This method is abstract.

Cancel all open orders

Returns:

  • (array)

    success: [bool] status

Raises:

  • (NotImplemented)


156
157
158
# File 'lib/kaesen/market.rb', line 156

def cancel_all
  raise NotImplemented.new()
end

#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] Local Timestamp

Raises:

  • (NotImplemented)


45
46
47
# File 'lib/kaesen/market.rb', line 45

def depth
  raise NotImplemented.new()
end

#market_buy(amount = BigDecimal.new("0.0")) ⇒ hash

This method is abstract.

Buy the amount of Bitcoin from the market. 成行注文 買い.

Parameters:

  • amount (BigDecimal) (defaults to: BigDecimal.new("0.0"))

Returns:

  • (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

Raises:

  • (NotImplemented)


108
109
110
# 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")) ⇒ hash

This method is abstract.

Sell the amount of Bitcoin to the market. 成行注文 売り.

Parameters:

  • amount (BigDecimal) (defaults to: BigDecimal.new("0.0"))

Returns:

  • (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

Raises:

  • (NotImplemented)


139
140
141
# File 'lib/kaesen/market.rb', line 139

def market_sell(amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end

#opensArray

This method is abstract.

Get open orders.

Returns:

  • (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

Raises:

  • (NotImplemented)


77
78
79
# File 'lib/kaesen/market.rb', line 77

def opens
  raise NotImplemented.new()
end

#sell(rate, amount = BigDecimal.new("0.0")) ⇒ hash

This method is abstract.

Sell the amount of Bitcoin at the rate. 指数注文 売り.

Parameters:

  • rate (BigDecimal)
  • amount (BigDecimal) (defaults to: BigDecimal.new("0.0"))

Returns:

  • (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

Raises:

  • (NotImplemented)


124
125
126
# File 'lib/kaesen/market.rb', line 124

def sell(rate, amount=BigDecimal.new("0.0"))
  raise NotImplemented.new()
end

#tickerhash

This method is abstract.

Get ticker information.

Returns:

  • (hash)

    ticker ask: [BigDecimal] 最良売気配値bid: [BigDecimal] 最良買気配値last: [BigDecimal] 最近値(?用語要チェック), last price high: [BigDecimal] 高値low: [BigDecimal] 安値volume: [BigDecimal] 取引量ltimestamp: [int] Local Timestamp

Raises:

  • (NotImplemented)


31
32
33
# File 'lib/kaesen/market.rb', line 31

def ticker
  raise NotImplemented.new()
end