Class: Coinigy::Account
Overview
Represents an Account of a user subscription to Coinigy
Instance Attribute Summary collapse
-
#auth_active ⇒ Object
Returns the value of attribute auth_active.
-
#auth_id ⇒ Object
Returns the value of attribute auth_id.
-
#auth_key ⇒ Object
Returns the value of attribute auth_key.
-
#auth_nickname ⇒ Object
Returns the value of attribute auth_nickname.
-
#auth_optional1 ⇒ Object
Returns the value of attribute auth_optional1.
-
#auth_secret ⇒ Object
Returns the value of attribute auth_secret.
-
#auth_trade ⇒ Object
Returns the value of attribute auth_trade.
-
#auth_updated ⇒ Object
Returns the value of attribute auth_updated.
-
#exch_id ⇒ Object
Returns the value of attribute exch_id.
-
#exch_name ⇒ Object
Returns the value of attribute exch_name.
-
#exch_trade_enabled ⇒ Object
Returns the value of attribute exch_trade_enabled.
-
#exchange ⇒ Object
Exchange relation.
-
#subscription ⇒ Object
Relations.
Attributes inherited from Model
Instance Method Summary collapse
-
#activate(flag = true) ⇒ Object
Activates or deactivates the account.
- #attributes ⇒ Object
-
#balance(refresh = false) ⇒ Object
Returns the balance of this account.
- #buy(market_pair, limit_price, quantity) ⇒ Object
-
#delete ⇒ Object
Deletes this account.
- #sell(market_pair, limit_price, quantity) ⇒ Object
-
#trading(flag = true) ⇒ Object
Activates or deactivates the trading flag for the account.
Methods inherited from Model
#errors?, #initialize, #inspect, #save
Constructor Details
This class inherits a constructor from Coinigy::Model
Instance Attribute Details
#auth_active ⇒ Object
Returns the value of attribute auth_active
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_active @auth_active end |
#auth_id ⇒ Object
Returns the value of attribute auth_id
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_id @auth_id end |
#auth_key ⇒ Object
Returns the value of attribute auth_key
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_key @auth_key end |
#auth_nickname ⇒ Object
Returns the value of attribute auth_nickname
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_nickname @auth_nickname end |
#auth_optional1 ⇒ Object
Returns the value of attribute auth_optional1
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_optional1 @auth_optional1 end |
#auth_secret ⇒ Object
Returns the value of attribute auth_secret
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_secret @auth_secret end |
#auth_trade ⇒ Object
Returns the value of attribute auth_trade
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_trade @auth_trade end |
#auth_updated ⇒ Object
Returns the value of attribute auth_updated
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def auth_updated @auth_updated end |
#exch_id ⇒ Object
Returns the value of attribute exch_id
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def exch_id @exch_id end |
#exch_name ⇒ Object
Returns the value of attribute exch_name
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def exch_name @exch_name end |
#exch_trade_enabled ⇒ Object
Returns the value of attribute exch_trade_enabled
4 5 6 |
# File 'lib/coinigy/account.rb', line 4 def exch_trade_enabled @exch_trade_enabled end |
#exchange ⇒ Object
Exchange relation
17 18 19 |
# File 'lib/coinigy/account.rb', line 17 def exchange @exchange end |
#subscription ⇒ Object
Relations
17 18 19 |
# File 'lib/coinigy/account.rb', line 17 def subscription @subscription end |
Instance Method Details
#activate(flag = true) ⇒ Object
Activates or deactivates the account
39 40 41 |
# File 'lib/coinigy/account.rb', line 39 def activate(flag = true) send_to_server { subscription.client.activate_api_key(auth_id, flag ? 1 : 0) } end |
#attributes ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/coinigy/account.rb', line 19 def attributes { "auth_id" => auth_id, "auth_key" => auth_key, "auth_optional1" => auth_optional1, "auth_nickname" => auth_nickname, "exch_name" => exch_name, "auth_secret" => auth_secret, "auth_active" => auth_active, "auth_updated" => auth_updated, "auth_trade" => auth_trade, "exch_trade_enabled" => exch_trade_enabled, "exch_id" => exch_id } end |
#balance(refresh = false) ⇒ Object
Returns the balance of this account
49 50 51 52 |
# File 'lib/coinigy/account.rb', line 49 def balance(refresh = false) return subscription.client.refresh_balance(auth_id).data if refresh subscription.balances([auth_id]) end |
#buy(market_pair, limit_price, quantity) ⇒ Object
54 55 56 |
# File 'lib/coinigy/account.rb', line 54 def buy(market_pair, limit_price, quantity) place_order(Coinigy::Order::BUY, market_pair, limit_price, quantity) end |
#delete ⇒ Object
Deletes this account
44 45 46 |
# File 'lib/coinigy/account.rb', line 44 def delete send_to_server { subscription.client.delete_api_key(auth_id) } end |
#sell(market_pair, limit_price, quantity) ⇒ Object
58 59 60 |
# File 'lib/coinigy/account.rb', line 58 def sell(market_pair, limit_price, quantity) place_order(Coinigy::Order::SELL, market_pair, limit_price, quantity) end |
#trading(flag = true) ⇒ Object
Activates or deactivates the trading flag for the account
34 35 36 |
# File 'lib/coinigy/account.rb', line 34 def trading(flag = true) send_to_server { subscription.client.activate_trading_key(auth_id, flag ? 1 : 0) } end |