Class: RbtcArbitrage::Clients::CampbxClient
- Inherits:
-
Object
- Object
- RbtcArbitrage::Clients::CampbxClient
show all
- Includes:
- RbtcArbitrage::Client
- Defined in:
- lib/rbtc_arbitrage/clients/campbx_client.rb
Instance Attribute Summary
#options
Instance Method Summary
collapse
#buy, #initialize, #logger, #sell, #validate_keys
Instance Method Details
#address ⇒ Object
43
44
45
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 43
def address
@address ||= interface.get_btc_address["Success"]
end
|
#balance ⇒ Object
10
11
12
13
14
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 10
def balance
return @balance if @balance
funds = interface.my_funds
[funds["Total BTC"].to_f, funds["Total USD"].to_f]
end
|
#exchange ⇒ Object
6
7
8
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 6
def exchange
:campbx
end
|
#interface ⇒ Object
16
17
18
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 16
def interface
@interface ||= CampBX::API.new(ENV['CAMPBX_KEY'],ENV['CAMPBX_SECRET'])
end
|
#price(action) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 30
def price action
return @price if @price
action = {
buy: "Best Ask",
sell: "Best Bid",
}[action]
@price = interface.xticker[action].to_f
end
|
#trade(action) ⇒ Object
25
26
27
28
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 25
def trade action
trade_mode = "Quick#{action.to_s.capitalize}"
interface.trade_enter trade_mode, @options[:volume], price(action)
end
|
#transfer(client) ⇒ Object
39
40
41
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 39
def transfer client
interface.send_btc client.address, @options[:volume]
end
|
#validate_env ⇒ Object
20
21
22
23
|
# File 'lib/rbtc_arbitrage/clients/campbx_client.rb', line 20
def validate_env
validate_keys :campbx_key, :campbx_secret
end
|