Class: Bitfinex::Models::MarginInfo

Inherits:
Model
  • Object
show all
Defined in:
lib/models/margin_info.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#apply

Constructor Details

#initialize(data) ⇒ MarginInfo

Returns a new instance of MarginInfo.



9
10
11
# File 'lib/models/margin_info.rb', line 9

def initialize (data)
  super(data, {}, [])
end

Instance Attribute Details

#buyObject

Returns the value of attribute buy.



7
8
9
# File 'lib/models/margin_info.rb', line 7

def buy
  @buy
end

#gross_balanceObject

Returns the value of attribute gross_balance.



7
8
9
# File 'lib/models/margin_info.rb', line 7

def gross_balance
  @gross_balance
end

#margin_balanceObject

Returns the value of attribute margin_balance.



6
7
8
# File 'lib/models/margin_info.rb', line 6

def margin_balance
  @margin_balance
end

#margin_netObject

Returns the value of attribute margin_net.



6
7
8
# File 'lib/models/margin_info.rb', line 6

def margin_net
  @margin_net
end

#sellObject

Returns the value of attribute sell.



7
8
9
# File 'lib/models/margin_info.rb', line 7

def sell
  @sell
end

#symbolObject

Returns the value of attribute symbol.



7
8
9
# File 'lib/models/margin_info.rb', line 7

def symbol
  @symbol
end

#tradable_balanceObject

Returns the value of attribute tradable_balance.



7
8
9
# File 'lib/models/margin_info.rb', line 7

def tradable_balance
  @tradable_balance
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/models/margin_info.rb', line 6

def type
  @type
end

#user_plObject

Returns the value of attribute user_pl.



6
7
8
# File 'lib/models/margin_info.rb', line 6

def user_pl
  @user_pl
end

#user_swapsObject

Returns the value of attribute user_swaps.



6
7
8
# File 'lib/models/margin_info.rb', line 6

def user_swaps
  @user_swaps
end

Class Method Details

.unserialize(arr) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/models/margin_info.rb', line 38

def self.unserialize (arr)
  type = arr[0]

  if type == 'base'
    payload = arr[1]

    return {
      :type => type,
      :user_pl => payload[0],
      :user_swaps => payload[1],
      :margin_balance => payload[2],
      :margin_net => payload[3]
    }
  else
    symbol = arr[1]
    payload = arr[2]

    return {
      :type => type,
      :symbol => symbol,
      :tradable_balance => payload[0],
      :gross_balance => payload[1],
      :buy => payload[2],
      :sell => payload[3]
    }
  end
end

Instance Method Details

#serializeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/models/margin_info.rb', line 13

def serialize ()
  if self.type == 'base'
    return [
      self.type,
      [
        self.user_pl,
        self.user_swaps,
        self.margin_balance,
        self.margin_net
      ]
    ]
  else
    return [
      self.type,
      self.symbol,
      [
        self.tradable_balance,
        self.gross_balance,
        self.buy,
        self.sell
      ]
    ]
  end
end