Class: Kaesen::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kaesen/client.rb', line 8

def initialize
  @markets = []   # [Array]:
                  #   [Market] instance of markets
  @tickers = {}   # [Hash]
                  #   [String]: market name
                  #   [Hash]: hash of ticker
  @depths = {}   # [Hash]:
                  #   [String]: market name
                  #   [Hash]: hash of depth
  @balances = {}  # [Hash]:
                  #   [String]: market name
                  #   [Hash]: hash of depth
end

Instance Attribute Details

#balanceObject (readonly)

Returns the value of attribute balance.



5
6
7
# File 'lib/kaesen/client.rb', line 5

def balance
  @balance
end

#depthObject (readonly)

Returns the value of attribute depth.



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

def depth
  @depth
end

#marketsObject (readonly)

Returns the value of attribute markets.



3
4
5
# File 'lib/kaesen/client.rb', line 3

def markets
  @markets
end

#tickerObject (readonly)

Returns the value of attribute ticker.



4
5
6
# File 'lib/kaesen/client.rb', line 4

def ticker
  @ticker
end

Instance Method Details

#get(market_name) ⇒ Market

get the instance of market with key

Returns:



31
32
33
34
35
36
# File 'lib/kaesen/client.rb', line 31

def get(market_name)
  @markets.each{|m|
    return m if m.name == market_name
  }
  return nil
end

#push(market) ⇒ Object

register the instance of market



24
25
26
# File 'lib/kaesen/client.rb', line 24

def push(market)
  @markets.push(market)
end

#update_balanceshash

Update asset information.

Returns:

  • (hash)

    hash of balance



58
59
60
61
62
63
# File 'lib/kaesen/client.rb', line 58

def update_balances()
  @markets.each{|m|
    @balances[m.name] = m.balance
  }
  @balances
end

#update_depthshash

Update market information.

Returns:

  • (hash)

    hash of depth



49
50
51
52
53
54
# File 'lib/kaesen/client.rb', line 49

def update_depths()
  @markets.each{|m|
    @depths[m.name] = m.depth
  }
  @depths
end

#update_tickershash

Update market information.

Returns:

  • (hash)

    hash of ticker



40
41
42
43
44
45
# File 'lib/kaesen/client.rb', line 40

def update_tickers()
  @markets.each{|m|
    @tickers[m.name] = m.ticker
  }
  @tickers
end