Class: Trader::AccountProxy
- Inherits:
-
Object
- Object
- Trader::AccountProxy
- Defined in:
- lib/trade-o-matic/core/account_proxy.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#pair ⇒ Object
readonly
Returns the value of attribute pair.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
Instance Method Summary collapse
- #ask(_volume, _price = nil) ⇒ Object
- #backend ⇒ Object
- #base_balance ⇒ Object
- #bid(_volume, _price = nil) ⇒ Object
- #find_order(_id) ⇒ Object
-
#initialize(_account, _proxy, _pair) ⇒ AccountProxy
constructor
A new instance of AccountProxy.
- #list_orders ⇒ Object
- #market ⇒ Object
- #quote_balance ⇒ Object
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(_account, _proxy, _pair) @account = _account @proxy = _proxy @pair = _pair end |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
4 5 6 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 4 def account @account end |
#pair ⇒ Object (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 |
#proxy ⇒ Object (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 account.create_order(order).convert_to pair end |
#backend ⇒ Object
12 13 14 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 12 def backend account.backend end |
#base_balance ⇒ Object
20 21 22 23 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 20 def base_balance balance = account.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 account.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) account.find_order(_id).convert_to pair end |
#list_orders ⇒ Object
44 45 46 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 44 def list_orders() # TODO end |
#market ⇒ Object
16 17 18 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 16 def market account.market_for proxy # TODO: market conversion end |
#quote_balance ⇒ Object
25 26 27 28 |
# File 'lib/trade-o-matic/core/account_proxy.rb', line 25 def quote_balance balance = account.balance_for proxy.quote balance.convert_to pair.quote end |