Class: RbtcArbitrage::Clients::CoinbaseClient
- Inherits:
-
Object
- Object
- RbtcArbitrage::Clients::CoinbaseClient
- Includes:
- RbtcArbitrage::Client
- Defined in:
- lib/rbtc_arbitrage/clients/coinbase_client.rb
Instance Attribute Summary
Attributes included from RbtcArbitrage::Client
Instance Method Summary collapse
- #address ⇒ Object
-
#balance ⇒ Object
Returns an array of Floats.
-
#exchange ⇒ Object
return a symbol as the name of this exchange.
- #interface ⇒ Object
-
#price(action) ⇒ Object
‘action` is :buy or :sell Returns a Numeric type.
-
#trade(action) ⇒ Object
‘action` is :buy or :sell.
-
#transfer(client) ⇒ Object
Transfers BTC to the address of a different exchange.
-
#validate_env ⇒ Object
Configures the client’s API keys.
Methods included from RbtcArbitrage::Client
#buy, #initialize, #logger, #sell, #validate_keys
Instance Method Details
#address ⇒ Object
54 55 56 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 54 def address @address ||= interface.receive_address.address end |
#balance ⇒ Object
Returns an array of Floats. The first element is the balance in BTC; The second is in USD.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 15 def balance if @options[:verbose] warning = "Coinbase doesn't provide a USD balance because" warning << " it connects to your bank account. Be careful, " warning << "because this will withdraw directly from your accounts" warning << "when you trade live." logger.warn warning end @balance ||= [max_float, max_float] end |
#exchange ⇒ Object
return a symbol as the name of this exchange
8 9 10 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 8 def exchange :coinbase end |
#interface ⇒ Object
49 50 51 52 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 49 def interface secret = ENV['COINBASE_SECRET'] || '' @interface ||= Coinbase::Client.new(ENV['COINBASE_KEY'], secret) end |
#price(action) ⇒ Object
‘action` is :buy or :sell Returns a Numeric type.
38 39 40 41 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 38 def price action method = "#{action}_price".to_sym @price ||= interface.send(method).to_f end |
#trade(action) ⇒ Object
‘action` is :buy or :sell
32 33 34 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 32 def trade action interface.send("#{action}!".to_sym, @options[:volume]) end |
#transfer(client) ⇒ Object
Transfers BTC to the address of a different exchange.
45 46 47 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 45 def transfer client interface.send_money client.address, @options[:volume] end |
#validate_env ⇒ Object
Configures the client’s API keys.
27 28 29 |
# File 'lib/rbtc_arbitrage/clients/coinbase_client.rb', line 27 def validate_env validate_keys :coinbase_key, :coinbase_address end |