Class: Trader::AccountProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/trade-o-matic/core/account_proxy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_account, _proxy, _pair) ⇒ AccountProxy

Returns a new instance of AccountProxy.



6
7
8
9
10
# File 'lib/trade-o-matic/core/account_proxy.rb', line 6

def initialize(, _proxy, _pair)
  @account = 
  @proxy = _proxy
  @pair = _pair
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



4
5
6
# File 'lib/trade-o-matic/core/account_proxy.rb', line 4

def 
  @account
end

#pairObject (readonly)

Returns the value of attribute pair.



4
5
6
# File 'lib/trade-o-matic/core/account_proxy.rb', line 4

def pair
  @pair
end

#proxyObject (readonly)

Returns the value of attribute proxy.



4
5
6
# File 'lib/trade-o-matic/core/account_proxy.rb', line 4

def proxy
  @proxy
end

Instance Method Details

#ask(_volume, _price = nil) ⇒ Object



35
36
37
38
# File 'lib/trade-o-matic/core/account_proxy.rb', line 35

def ask(_volume, _price=nil)
  order = Order.new_ask(pair, _volume, _price).convert_to proxy
  .create_order(order).convert_to pair
end

#backendObject



12
13
14
# File 'lib/trade-o-matic/core/account_proxy.rb', line 12

def backend
  .backend
end

#base_balanceObject



20
21
22
23
# File 'lib/trade-o-matic/core/account_proxy.rb', line 20

def base_balance
  balance = .balance_for proxy.base
  balance.convert_to pair.base
end

#bid(_volume, _price = nil) ⇒ Object



30
31
32
33
# File 'lib/trade-o-matic/core/account_proxy.rb', line 30

def bid(_volume, _price=nil)
  order = Order.new_bid(pair, _volume, _price).convert_to proxy
  .create_order(order).convert_to pair
end

#find_order(_id) ⇒ Object



40
41
42
# File 'lib/trade-o-matic/core/account_proxy.rb', line 40

def find_order(_id)
  .find_order(_id).convert_to pair
end

#list_ordersObject



44
45
46
# File 'lib/trade-o-matic/core/account_proxy.rb', line 44

def list_orders()
  # TODO
end

#marketObject



16
17
18
# File 'lib/trade-o-matic/core/account_proxy.rb', line 16

def market
  .market_for proxy # TODO: market conversion
end

#quote_balanceObject



25
26
27
28
# File 'lib/trade-o-matic/core/account_proxy.rb', line 25

def quote_balance
  balance = .balance_for proxy.quote
  balance.convert_to pair.quote
end