rbtc_arbitrage 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f1a7981428666494c3138632923d59f06720cf1
4
- data.tar.gz: 847d059ba92dc899dc8f911a8f8cc03412620f3c
3
+ metadata.gz: 07daa0eb22d5480600ae85fe4f3fd238edfdd1b6
4
+ data.tar.gz: 2da05c5ae42aef62072931662a029b766be303ca
5
5
  SHA512:
6
- metadata.gz: 95146a940a2d81ad26db01240834c98641ddd222ed66269329426d65a7248b8275a1484572d7f5718e960fe55e5d19a6592a1169defb4cd7d441a6095da6ecc7
7
- data.tar.gz: ebeb1d24b38a920554ef29f2fac54fea81c9676bf94c0263f93e86038195d4297c2a44aacfee4ead4a540716d36e8f4bf25af56d3d6df4f9b3ddcf1e194ec166
6
+ metadata.gz: c590d5321678e7c22a01160849184eb51f034aa4b0066a6ef0d741bf31a99371cbaf56c47f94eab32720d8b107c373c8ea19fb951fbb7a8afb5e88684a4d4639
7
+ data.tar.gz: 2e075aba0cb2fa8db5e5446adf93c31d51e0f415525861a3e3bed1728f2bdecd50b9529aa613b0e7ae7238e506e946c1ce88e5c6b6528d8ca4adc8f41e1e0d14
data/.travis.yml CHANGED
@@ -18,3 +18,4 @@ env:
18
18
  - secure: YLXu/SNHJrhqc6Go9Tk7A2Dwf8XncZtGfRKwSbMb6WdNNw/8Zfd49tcf6FbiJS/THah5j/x4+X6kcxbCzgxndfIqpJNSn5gndYLWHIMWZ4B+ppM76SyvqsyrCWWWBcbnuKI8/FhN+1jvdKCRC1XO5hFbdBLqXMXjrcqTFF78k/Y=
19
19
  - secure: IFyJX6lAmBpef0I50UPCy6L5IRxqRKoPhv74s5y0FPB4chrir7iMZ7Sd1IczxV7ly4Dt7hdALHP1qMTmkcGmTV6YOzwR46G4JAwWtX2xlf4OYk4jey7qjNsS6iijD6dvdYjqSKUuGaX3Til3kUOLcA3hhINvHxj5unv2pHB2W70=
20
20
  - secure: YiYtCBJNfgWuzQ059RMmZxM00bs4c/GuqaEaKufLPPByJHHt3z4jCNT5lurox/RIqSYTv+1Nvgor1xJZF4VPDIhtoCpVRe3g5Pvubrp4gWQry11ta0f1JhPSrm5ORlF1hpHPfzHHSh+/YVmKcO8agQAaIgfKcXDzsE6j5QqiGWQ=
21
+ - secure: TCrSkWTG2A7ZHxU/J82R1oRn3+ISYHOZmukvBT/OkOh35yjhtig3KhroYki67guCClVxov+ZPvCRUKgmsEoVng1ljk/ZXyyNf4QNVccEJxHCwIRiqs36jlC2ebd8g+JJUPrnnWGO/U5vBm+WlrOb4lFlIsBuCYI+FBAFYTPmKEs=
@@ -3,6 +3,7 @@ require 'mtgox'
3
3
  require_relative 'rbtc_arbitrage/campbx.rb'
4
4
  require 'bitstamp'
5
5
  require 'btce'
6
+ require 'coinbase'
6
7
  require_relative 'rbtc_arbitrage/client.rb'
7
8
  Dir["#{File.dirname(__FILE__)}/rbtc_arbitrage/**/*.rb"].each { |f| require(f) }
8
9
 
@@ -35,6 +35,10 @@ module RbtcArbitrage
35
35
  ENV["#{exchange.to_s.upcase}_ADDRESS"]
36
36
  end
37
37
 
38
+ def logger
39
+ @options[:logger]
40
+ end
41
+
38
42
  private
39
43
 
40
44
  def set_key config, key, default
@@ -0,0 +1,59 @@
1
+ module RbtcArbitrage
2
+ module Clients
3
+ class CoinbaseClient
4
+ include RbtcArbitrage::Client
5
+
6
+ # return a symbol as the name
7
+ # of this exchange
8
+ def exchange
9
+ :coinbase
10
+ end
11
+
12
+ # Returns an array of Floats.
13
+ # The first element is the balance in BTC;
14
+ # The second is in USD.
15
+ def balance
16
+ if @options[:verbose]
17
+ warning = "Coinbase doesn't provide a USD balance because"
18
+ warning << " it connects to your bank account. Be careful, "
19
+ warning << "because this will withdraw directly from your accounts."
20
+ logger.warn warning
21
+ end
22
+ @balance ||= [interface.balance.to_f, max_float]
23
+ end
24
+
25
+ # Configures the client's API keys.
26
+ def validate_env
27
+ validate_keys :coinbase_key, :coinbase_address
28
+ end
29
+
30
+ # `action` is :buy or :sell
31
+ def trade action
32
+ interface.send("#{action}!".to_sym, @options[:volume])
33
+ end
34
+
35
+ # `action` is :buy or :sell
36
+ # Returns a Numeric type.
37
+ def price action
38
+ method = "#{action}_price".to_sym
39
+ @price ||= interface.send(method).to_f
40
+ end
41
+
42
+ # Transfers BTC to the address of a different
43
+ # exchange.
44
+ def transfer client
45
+ interface.send_money client.address, @options[:volume]
46
+ end
47
+
48
+ def interface
49
+ @interface ||= Coinbase::Client.new(ENV['COINBASE_KEY'])
50
+ end
51
+
52
+ private
53
+
54
+ def max_float
55
+ Float::MAX
56
+ end
57
+ end
58
+ end
59
+ end
@@ -4,19 +4,21 @@ module RbtcArbitrage
4
4
  attr_accessor :buyer, :seller, :options
5
5
 
6
6
  def initialize config={}
7
- config = config.to_hash
8
- config.each { |k,v| config[k.to_sym] = v unless k.is_a?(Symbol) }
7
+ opts = {}
8
+ config.each do |key, val|
9
+ opts[(key.to_sym rescue key) || key] = val
10
+ end
9
11
  @buyer = {}
10
12
  @seller = {}
11
13
  @options = {}
12
- set_key config, :volume, 0.01
13
- set_key config, :cutoff, 2
14
- set_key config, :logger, Logger.new(STDOUT)
15
- set_key config, :verbose, true
16
- set_key config, :live, false
17
- exchange = config[:buyer] || :bitstamp
14
+ set_key opts, :volume, 0.01
15
+ set_key opts, :cutoff, 2
16
+ set_key opts, :logger, Logger.new(STDOUT)
17
+ set_key opts, :verbose, true
18
+ set_key opts, :live, false
19
+ exchange = opts[:buyer] || :bitstamp
18
20
  @buy_client = client_for_exchange(exchange)
19
- exchange = config[:seller] || :mtgox
21
+ exchange = opts[:seller] || :mtgox
20
22
  @sell_client = client_for_exchange(exchange)
21
23
  self
22
24
  end
@@ -1,3 +1,3 @@
1
1
  module RbtcArbitrage
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "thor"
29
29
  spec.add_dependency "btce", '0.2.4'
30
30
  spec.add_dependency "bitstamp"
31
+ spec.add_dependency "coinbase", '1.2.4'
31
32
  end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe RbtcArbitrage::Clients::CoinbaseClient do
4
+ let(:client) { RbtcArbitrage::Clients::CoinbaseClient.new }
5
+ let(:coinbase) { client.interface }
6
+
7
+ it { client.exchange.should == :coinbase }
8
+
9
+ describe "#balance" do
10
+ it "fetches the balance correctly", :vcr do
11
+ balance = coinbase.balance.to_f
12
+ expected = [balance, Float::MAX]
13
+ client.balance.should eql(expected)
14
+ client.balance.each do |b|
15
+ b.should be_a(Float)
16
+ end
17
+ end
18
+
19
+ it "should warn about USD balance" do
20
+ client.options[:verbose] = true
21
+ client.options[:logger].should_receive :warn
22
+ client.instance_variable_set :@balance, [1, 1]
23
+ client.balance
24
+ end
25
+ end
26
+
27
+ describe "#price" do
28
+ [:buy, :sell].each do |action|
29
+ it "fetches price for #{action} correctly", :vcr do
30
+ client.price(action).should be_a(Float)
31
+ end
32
+ end
33
+
34
+ it "calls coinbase", :vcr do
35
+ client.price(:buy).should == coinbase.buy_price.to_f
36
+ client.instance_variable_set :@price, nil
37
+ client.price(:sell).should == coinbase.sell_price.to_f
38
+ end
39
+ end
40
+
41
+ describe "#trade" do
42
+ it "calls coinbase" do
43
+ coinbase.should_receive(:sell!).with(0.01)
44
+ client.trade(:sell)
45
+
46
+ coinbase.should_receive(:buy!).with(0.01)
47
+ client.trade(:buy)
48
+ end
49
+ end
50
+
51
+ describe "#transfer" do
52
+ it "calls coinbase correctly" do
53
+ sell_client = RbtcArbitrage::Clients::BitstampClient.new
54
+ coinbase.should_receive(:send_money).with(sell_client.address, 0.01)
55
+ client.transfer(sell_client)
56
+ end
57
+ end
58
+ end
data/spec/spec_helper.rb CHANGED
@@ -27,7 +27,6 @@ VCR.configure do |c|
27
27
  end
28
28
 
29
29
  RSpec.configure do |config|
30
- config.treat_symbols_as_metadata_keys_with_true_values = true
31
30
  config.run_all_when_everything_filtered = true
32
31
  config.filter_run :focus
33
32
  config.order = 'random'
@@ -0,0 +1,109 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://coinbase.com/api/v1/account/balance
6
+ headers: {}
7
+ response:
8
+ status:
9
+ code: 200
10
+ message: OK
11
+ headers:
12
+ Server:
13
+ - cloudflare-nginx
14
+ Date:
15
+ - Mon, 23 Dec 2013 01:42:04 GMT
16
+ Content-Type:
17
+ - application/json; charset=utf-8
18
+ Transfer-Encoding:
19
+ - chunked
20
+ Connection:
21
+ - keep-alive
22
+ Set-Cookie:
23
+ - __cfduid=d9faf92bd27e293c2b04658e27fc1eea11387762924181; expires=Mon, 23-Dec-2019
24
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
25
+ - request_method=GET; path=/; secure
26
+ Status:
27
+ - 200 OK
28
+ Strict-Transport-Security:
29
+ - max-age=31536000
30
+ - max-age=31536000
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Etag:
34
+ - '"0aaa6e856f86a20a74cd625cd583960f"'
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ X-Request-Id:
38
+ - 612f6dd78e2ed682b0cf33c4cb32a384
39
+ X-Runtime:
40
+ - '0.024974'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Rack-Cache:
46
+ - miss
47
+ Vary:
48
+ - Accept-Encoding
49
+ Cf-Ray:
50
+ - e115a63abe30295
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"amount":"0.39332963","currency":"BTC"}'
54
+ http_version:
55
+ recorded_at: Mon, 23 Dec 2013 01:42:03 GMT
56
+ - request:
57
+ method: get
58
+ uri: https://coinbase.com/api/v1/account/balance
59
+ headers: {}
60
+ response:
61
+ status:
62
+ code: 200
63
+ message: OK
64
+ headers:
65
+ Server:
66
+ - cloudflare-nginx
67
+ Date:
68
+ - Mon, 23 Dec 2013 01:42:05 GMT
69
+ Content-Type:
70
+ - application/json; charset=utf-8
71
+ Transfer-Encoding:
72
+ - chunked
73
+ Connection:
74
+ - keep-alive
75
+ Set-Cookie:
76
+ - __cfduid=d1af7669c762757c89c6a8863c9952e661387762924925; expires=Mon, 23-Dec-2019
77
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
78
+ - request_method=GET; path=/; secure
79
+ Status:
80
+ - 200 OK
81
+ Strict-Transport-Security:
82
+ - max-age=31536000
83
+ - max-age=31536000
84
+ X-Ua-Compatible:
85
+ - IE=Edge,chrome=1
86
+ Etag:
87
+ - '"0aaa6e856f86a20a74cd625cd583960f"'
88
+ Cache-Control:
89
+ - max-age=0, private, must-revalidate
90
+ X-Request-Id:
91
+ - d35d32621cf9f8464b0bfa22dfed087d
92
+ X-Runtime:
93
+ - '0.022264'
94
+ X-Frame-Options:
95
+ - SAMEORIGIN
96
+ X-Content-Type-Options:
97
+ - nosniff
98
+ X-Rack-Cache:
99
+ - miss
100
+ Vary:
101
+ - Accept-Encoding
102
+ Cf-Ray:
103
+ - e115a685bf50295
104
+ body:
105
+ encoding: UTF-8
106
+ string: '{"amount":"0.39332963","currency":"BTC"}'
107
+ http_version:
108
+ recorded_at: Mon, 23 Dec 2013 01:42:04 GMT
109
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,215 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://coinbase.com/api/v1/prices/buy
6
+ headers: {}
7
+ response:
8
+ status:
9
+ code: 200
10
+ message: OK
11
+ headers:
12
+ Server:
13
+ - cloudflare-nginx
14
+ Date:
15
+ - Mon, 23 Dec 2013 01:50:02 GMT
16
+ Content-Type:
17
+ - application/json; charset=utf-8
18
+ Transfer-Encoding:
19
+ - chunked
20
+ Connection:
21
+ - keep-alive
22
+ Set-Cookie:
23
+ - __cfduid=ddaa6e4bf7ecb198302cf54b54705b1131387763401454; expires=Mon, 23-Dec-2019
24
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
25
+ - request_method=GET; path=/; secure
26
+ Status:
27
+ - 200 OK
28
+ Strict-Transport-Security:
29
+ - max-age=31536000
30
+ - max-age=31536000
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Etag:
34
+ - '"21c3685567c83fb6123bfaa4d9ea14f5"'
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ X-Request-Id:
38
+ - 6f5e05003d57c4f27106b08346d40e92
39
+ X-Runtime:
40
+ - '0.231970'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Rack-Cache:
46
+ - miss
47
+ Vary:
48
+ - Accept-Encoding
49
+ Cf-Ray:
50
+ - e11660a84d90296
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"subtotal":{"amount":"634.03","currency":"USD"},"fees":[{"coinbase":{"amount":"6.34","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"640.52","currency":"USD"},"amount":"640.52","currency":"USD"}'
54
+ http_version:
55
+ recorded_at: Mon, 23 Dec 2013 01:50:01 GMT
56
+ - request:
57
+ method: get
58
+ uri: https://coinbase.com/api/v1/prices/buy
59
+ headers: {}
60
+ response:
61
+ status:
62
+ code: 200
63
+ message: OK
64
+ headers:
65
+ Server:
66
+ - cloudflare-nginx
67
+ Date:
68
+ - Mon, 23 Dec 2013 01:50:03 GMT
69
+ Content-Type:
70
+ - application/json; charset=utf-8
71
+ Transfer-Encoding:
72
+ - chunked
73
+ Connection:
74
+ - keep-alive
75
+ Set-Cookie:
76
+ - __cfduid=d599c599d9a0afa96ebc108372a7338501387763402504; expires=Mon, 23-Dec-2019
77
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
78
+ - request_method=GET; path=/; secure
79
+ Status:
80
+ - 200 OK
81
+ Strict-Transport-Security:
82
+ - max-age=31536000
83
+ - max-age=31536000
84
+ X-Ua-Compatible:
85
+ - IE=Edge,chrome=1
86
+ Etag:
87
+ - '"21c3685567c83fb6123bfaa4d9ea14f5"'
88
+ Cache-Control:
89
+ - max-age=0, private, must-revalidate
90
+ X-Request-Id:
91
+ - 8f1a06fc780cb3eff298c0e95b5b725b
92
+ X-Runtime:
93
+ - '0.458310'
94
+ X-Frame-Options:
95
+ - SAMEORIGIN
96
+ X-Content-Type-Options:
97
+ - nosniff
98
+ X-Rack-Cache:
99
+ - miss
100
+ Vary:
101
+ - Accept-Encoding
102
+ Cf-Ray:
103
+ - e11661132770296
104
+ body:
105
+ encoding: UTF-8
106
+ string: '{"subtotal":{"amount":"634.03","currency":"USD"},"fees":[{"coinbase":{"amount":"6.34","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"640.52","currency":"USD"},"amount":"640.52","currency":"USD"}'
107
+ http_version:
108
+ recorded_at: Mon, 23 Dec 2013 01:50:02 GMT
109
+ - request:
110
+ method: get
111
+ uri: https://coinbase.com/api/v1/prices/sell
112
+ headers: {}
113
+ response:
114
+ status:
115
+ code: 200
116
+ message: OK
117
+ headers:
118
+ Server:
119
+ - cloudflare-nginx
120
+ Date:
121
+ - Mon, 23 Dec 2013 01:50:04 GMT
122
+ Content-Type:
123
+ - application/json; charset=utf-8
124
+ Transfer-Encoding:
125
+ - chunked
126
+ Connection:
127
+ - keep-alive
128
+ Set-Cookie:
129
+ - __cfduid=da4ea8419396ce80064daee243fa1fa351387763403732; expires=Mon, 23-Dec-2019
130
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
131
+ - request_method=GET; path=/; secure
132
+ Status:
133
+ - 200 OK
134
+ Strict-Transport-Security:
135
+ - max-age=31536000
136
+ - max-age=31536000
137
+ X-Ua-Compatible:
138
+ - IE=Edge,chrome=1
139
+ Etag:
140
+ - '"a2bef70e39b2d17967c8ca9791524579"'
141
+ Cache-Control:
142
+ - max-age=0, private, must-revalidate
143
+ X-Request-Id:
144
+ - 62d3d1b1273638380afc79bd0d9d2525
145
+ X-Runtime:
146
+ - '0.224874'
147
+ X-Frame-Options:
148
+ - SAMEORIGIN
149
+ X-Content-Type-Options:
150
+ - nosniff
151
+ X-Rack-Cache:
152
+ - miss
153
+ Vary:
154
+ - Accept-Encoding
155
+ Cf-Ray:
156
+ - e116618e67f0296
157
+ body:
158
+ encoding: UTF-8
159
+ string: '{"subtotal":{"amount":"632.52","currency":"USD"},"fees":[{"coinbase":{"amount":"6.33","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"626.04","currency":"USD"},"amount":"626.04","currency":"USD"}'
160
+ http_version:
161
+ recorded_at: Mon, 23 Dec 2013 01:50:03 GMT
162
+ - request:
163
+ method: get
164
+ uri: https://coinbase.com/api/v1/prices/sell
165
+ headers: {}
166
+ response:
167
+ status:
168
+ code: 200
169
+ message: OK
170
+ headers:
171
+ Server:
172
+ - cloudflare-nginx
173
+ Date:
174
+ - Mon, 23 Dec 2013 01:50:06 GMT
175
+ Content-Type:
176
+ - application/json; charset=utf-8
177
+ Transfer-Encoding:
178
+ - chunked
179
+ Connection:
180
+ - keep-alive
181
+ Set-Cookie:
182
+ - __cfduid=d3866b19f4121fd78614bbc73b874cb1a1387763405942; expires=Mon, 23-Dec-2019
183
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
184
+ - request_method=GET; path=/; secure
185
+ Status:
186
+ - 200 OK
187
+ Strict-Transport-Security:
188
+ - max-age=31536000
189
+ - max-age=31536000
190
+ X-Ua-Compatible:
191
+ - IE=Edge,chrome=1
192
+ Etag:
193
+ - '"a2bef70e39b2d17967c8ca9791524579"'
194
+ Cache-Control:
195
+ - max-age=0, private, must-revalidate
196
+ X-Request-Id:
197
+ - dfbf6c7596d2b6f6de5078a8d29ad4f5
198
+ X-Runtime:
199
+ - '0.267502'
200
+ X-Frame-Options:
201
+ - SAMEORIGIN
202
+ X-Content-Type-Options:
203
+ - nosniff
204
+ X-Rack-Cache:
205
+ - miss
206
+ Vary:
207
+ - Accept-Encoding
208
+ Cf-Ray:
209
+ - e116626b2b10296
210
+ body:
211
+ encoding: UTF-8
212
+ string: '{"subtotal":{"amount":"632.52","currency":"USD"},"fees":[{"coinbase":{"amount":"6.33","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"626.04","currency":"USD"},"amount":"626.04","currency":"USD"}'
213
+ http_version:
214
+ recorded_at: Mon, 23 Dec 2013 01:50:05 GMT
215
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://coinbase.com/api/v1/prices/buy
6
+ headers: {}
7
+ response:
8
+ status:
9
+ code: 200
10
+ message: OK
11
+ headers:
12
+ Server:
13
+ - cloudflare-nginx
14
+ Date:
15
+ - Mon, 23 Dec 2013 01:46:11 GMT
16
+ Content-Type:
17
+ - application/json; charset=utf-8
18
+ Transfer-Encoding:
19
+ - chunked
20
+ Connection:
21
+ - keep-alive
22
+ Set-Cookie:
23
+ - __cfduid=de180eda480bef28c6b1572e925ddcd721387763171524; expires=Mon, 23-Dec-2019
24
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
25
+ - request_method=GET; path=/; secure
26
+ Status:
27
+ - 200 OK
28
+ Strict-Transport-Security:
29
+ - max-age=31536000
30
+ - max-age=31536000
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Etag:
34
+ - '"a804177e060807151cd66a68563f9ca7"'
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ X-Request-Id:
38
+ - 905bf73eff8d4954c758c3c7c5032a5e
39
+ X-Runtime:
40
+ - '0.039337'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Rack-Cache:
46
+ - miss
47
+ Vary:
48
+ - Accept-Encoding
49
+ Cf-Ray:
50
+ - e11606d945f0296
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"subtotal":{"amount":"633.49","currency":"USD"},"fees":[{"coinbase":{"amount":"6.33","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"639.97","currency":"USD"},"amount":"639.97","currency":"USD"}'
54
+ http_version:
55
+ recorded_at: Mon, 23 Dec 2013 01:46:11 GMT
56
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://coinbase.com/api/v1/prices/sell
6
+ headers: {}
7
+ response:
8
+ status:
9
+ code: 200
10
+ message: OK
11
+ headers:
12
+ Server:
13
+ - cloudflare-nginx
14
+ Date:
15
+ - Mon, 23 Dec 2013 01:46:12 GMT
16
+ Content-Type:
17
+ - application/json; charset=utf-8
18
+ Transfer-Encoding:
19
+ - chunked
20
+ Connection:
21
+ - keep-alive
22
+ Set-Cookie:
23
+ - __cfduid=d2936097f4b45fff147030c15439c297f1387763172302; expires=Mon, 23-Dec-2019
24
+ 23:50:00 GMT; path=/; domain=.coinbase.com; HttpOnly
25
+ - request_method=GET; path=/; secure
26
+ Status:
27
+ - 200 OK
28
+ Strict-Transport-Security:
29
+ - max-age=31536000
30
+ - max-age=31536000
31
+ X-Ua-Compatible:
32
+ - IE=Edge,chrome=1
33
+ Etag:
34
+ - '"f6ca8cefd54471be46d774df727e0885"'
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ X-Request-Id:
38
+ - 5780757a2e6a97f8de4347b0a7d38234
39
+ X-Runtime:
40
+ - '0.264541'
41
+ X-Frame-Options:
42
+ - SAMEORIGIN
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Rack-Cache:
46
+ - miss
47
+ Vary:
48
+ - Accept-Encoding
49
+ Cf-Ray:
50
+ - e11607274740296
51
+ body:
52
+ encoding: UTF-8
53
+ string: '{"subtotal":{"amount":"629.48","currency":"USD"},"fees":[{"coinbase":{"amount":"6.29","currency":"USD"}},{"bank":{"amount":"0.15","currency":"USD"}}],"total":{"amount":"623.04","currency":"USD"},"amount":"623.04","currency":"USD"}'
54
+ http_version:
55
+ recorded_at: Mon, 23 Dec 2013 01:46:12 GMT
56
+ recorded_with: VCR 2.8.0
data/spec/trader_spec.rb CHANGED
@@ -25,6 +25,7 @@ describe RbtcArbitrage::Trader do
25
25
  RbtcArbitrage.clients.each do |client|
26
26
  describe client do
27
27
  keys = ["KEY", "SECRET"]
28
+ keys.pop if client.new.exchange == :coinbase
28
29
  keys << "ADDRESS" unless client.instance_methods(false).include?(:address)
29
30
  client = client.new
30
31
  prefix = client.exchange.to_s.upcase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbtc_arbitrage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hank Stoever
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: coinbase
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 1.2.4
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 1.2.4
139
153
  description: A gem for conducting arbitrage with Bitcoin.
140
154
  email:
141
155
  - hstove@gmail.com
@@ -162,6 +176,7 @@ files:
162
176
  - lib/rbtc_arbitrage/clients/btce_client.rb
163
177
  - lib/rbtc_arbitrage/clients/campbx_client.rb
164
178
  - lib/rbtc_arbitrage/clients/client.rb.example
179
+ - lib/rbtc_arbitrage/clients/coinbase_client.rb
165
180
  - lib/rbtc_arbitrage/clients/mtgox_client.rb
166
181
  - lib/rbtc_arbitrage/trader.rb
167
182
  - lib/rbtc_arbitrage/version.rb
@@ -171,6 +186,7 @@ files:
171
186
  - spec/clients/bitstamp_client_spec.rb
172
187
  - spec/clients/btce_client_spec.rb
173
188
  - spec/clients/campbx_client_spec.rb
189
+ - spec/clients/coinbase_client_spec.rb
174
190
  - spec/clients/mtgox_client_spec.rb
175
191
  - spec/rbtc_arbitrage_spec.rb
176
192
  - spec/spec_helper.rb
@@ -185,6 +201,10 @@ files:
185
201
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_balance/fetches_the_balance_correctly.yml
186
202
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_buy_correctly.yml
187
203
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_sell_correctly.yml
204
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_balance/fetches_the_balance_correctly.yml
205
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml
206
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml
207
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml
188
208
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml
189
209
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml
190
210
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml
@@ -227,6 +247,7 @@ test_files:
227
247
  - spec/clients/bitstamp_client_spec.rb
228
248
  - spec/clients/btce_client_spec.rb
229
249
  - spec/clients/campbx_client_spec.rb
250
+ - spec/clients/coinbase_client_spec.rb
230
251
  - spec/clients/mtgox_client_spec.rb
231
252
  - spec/rbtc_arbitrage_spec.rb
232
253
  - spec/spec_helper.rb
@@ -241,6 +262,10 @@ test_files:
241
262
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_balance/fetches_the_balance_correctly.yml
242
263
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_buy_correctly.yml
243
264
  - spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_sell_correctly.yml
265
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_balance/fetches_the_balance_correctly.yml
266
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml
267
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml
268
+ - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml
244
269
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml
245
270
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml
246
271
  - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml