Class: RbtcArbitrage::Clients::BitstampClient
- Inherits:
-
Object
- Object
- RbtcArbitrage::Clients::BitstampClient
show all
- Includes:
- RbtcArbitrage::Client
- Defined in:
- lib/rbtc_arbitrage/clients/bitstamp_client.rb
Instance Attribute Summary
#options
Instance Method Summary
collapse
#address, #buy, #initialize, #logger, #sell, #validate_keys
Instance Method Details
#balance ⇒ Object
6
7
8
9
10
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 6
def balance
return @balance if @balance
balances = Bitstamp.balance
@balance = [balances[0].to_f, balances[1].to_f]
end
|
#exchange ⇒ Object
21
22
23
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 21
def exchange
:bitstamp
end
|
#price(action) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 25
def price action
return @price if @price
action = {
buy: :ask,
sell: :bid,
}[action]
@price = Bitstamp.ticker.send(action).to_f
end
|
#trade(action) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 34
def trade action
price(action) unless @price multiple = {
buy: 1,
sell: -1,
}[action]
bitstamp_options = {
price: (@price + 0.001 * multiple),
amount: @options[:volume],
}
Bitstamp.orders.send(action, bitstamp_options)
end
|
#transfer(other_client) ⇒ Object
47
48
49
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 47
def transfer other_client
Bitstamp.transfer(@options[:volume], other_client.address)
end
|
#validate_env ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/rbtc_arbitrage/clients/bitstamp_client.rb', line 12
def validate_env
validate_keys :bitstamp_key, :bitstamp_client_id, :bitstamp_secret
Bitstamp.setup do |config|
config.client_id = ENV["BITSTAMP_CLIENT_ID"]
config.key = ENV["BITSTAMP_KEY"]
config.secret = ENV["BITSTAMP_SECRET"]
end
end
|