class RbtcArbitrage::Clients::CoinbaseClient
Public Instance Methods
address()
click to toggle source
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 54 def address @address ||= interface.receive_address.address end
balance()
click to toggle source
Returns an array of Floats. The first element is the balance in BTC; The second is in USD.
# 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()
click to toggle source
return a symbol as the name of this exchange
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 8 def exchange :coinbase end
interface()
click to toggle source
# 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)
click to toggle source
‘action` is :buy or :sell Returns a Numeric type.
# 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)
click to toggle source
‘action` is :buy or :sell
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 32 def trade action interface.send("#{action}!".to_sym, @options[:volume]) end
transfer(client)
click to toggle source
Transfers BTC to the address of a different exchange.
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 45 def transfer client interface.send_money client.address, @options[:volume] end
validate_env()
click to toggle source
Configures the client’s API keys.
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 27 def validate_env validate_keys :coinbase_key, :coinbase_address end
Private Instance Methods
max_float()
click to toggle source
# File lib/rbtc_arbitrage/clients/coinbase_client.rb, line 60 def max_float Float::MAX end