rbtc_arbitrage_simple 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +23 -0
  5. data/Gemfile +18 -0
  6. data/Gemfile.lock +156 -0
  7. data/Guardfile +8 -0
  8. data/LICENSE.txt +22 -0
  9. data/Procfile +1 -0
  10. data/README.md +88 -0
  11. data/Rakefile +10 -0
  12. data/bin/rbtc_simple +4 -0
  13. data/dummy_web_server.rb +9 -0
  14. data/lib/rbtc_arbitrage.rb +15 -0
  15. data/lib/rbtc_arbitrage/campbx.rb +98 -0
  16. data/lib/rbtc_arbitrage/cli.rb +19 -0
  17. data/lib/rbtc_arbitrage/client.rb +48 -0
  18. data/lib/rbtc_arbitrage/clients/btce_client.rb +62 -0
  19. data/lib/rbtc_arbitrage/clients/campbx_client.rb +48 -0
  20. data/lib/rbtc_arbitrage/clients/client.rb.example +46 -0
  21. data/lib/rbtc_arbitrage/clients/coinbase_client.rb +63 -0
  22. data/lib/rbtc_arbitrage/clients/mtgox_client.rb +56 -0
  23. data/lib/rbtc_arbitrage/trader.rb +123 -0
  24. data/lib/rbtc_arbitrage/version.rb +3 -0
  25. data/rbtc_arbitrage.gemspec +30 -0
  26. data/spec/cli_spec.rb +8 -0
  27. data/spec/client_spec.rb +33 -0
  28. data/spec/clients/btce_client_spec.rb +93 -0
  29. data/spec/clients/campbx_client_spec.rb +66 -0
  30. data/spec/clients/coinbase_client_spec.rb +66 -0
  31. data/spec/clients/mtgox_client_spec.rb +53 -0
  32. data/spec/rbtc_arbitrage_spec.rb +11 -0
  33. data/spec/spec_helper.rb +34 -0
  34. data/spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_balance/fetches_the_balance_correctly.yml +96 -0
  35. data/spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_price/fetches_price_for_buy_correctly.yml +52 -0
  36. data/spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_price/fetches_price_for_sell_correctly.yml +52 -0
  37. data/spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_price/fetches_prices_correctly.yml +44 -0
  38. data/spec/support/cassettes/RbtcArbitrage_Clients_BtceClient/_balance/should_raise_if_bad_API_keys.yml +53 -0
  39. data/spec/support/cassettes/RbtcArbitrage_Clients_BtceClient/_price/calls_btc-e.yml +91 -0
  40. data/spec/support/cassettes/RbtcArbitrage_Clients_BtceClient/_price/fetches_price_for_buy_correctly.yml +47 -0
  41. data/spec/support/cassettes/RbtcArbitrage_Clients_BtceClient/_price/fetches_price_for_sell_correctly.yml +47 -0
  42. data/spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_balance/fetches_the_balance_correctly.yml +95 -0
  43. data/spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_buy_correctly.yml +49 -0
  44. data/spec/support/cassettes/RbtcArbitrage_Clients_CampbxClient/_price/fetches_price_for_sell_correctly.yml +49 -0
  45. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_balance/fetches_the_balance_correctly.yml +109 -0
  46. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml +215 -0
  47. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml +56 -0
  48. data/spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml +56 -0
  49. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml +77 -0
  50. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml +44 -0
  51. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml +44 -0
  52. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_prices_correctly.yml +85 -0
  53. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/should_raise_SecurityError_if_not_live.yml +88 -0
  54. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_BTC.yml +81 -0
  55. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_USD.yml +81 -0
  56. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/should_fetch_balance.yml +88 -0
  57. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/shouldn_t_raise_security_error.yml +166 -0
  58. data/spec/support/cassettes/RbtcArbitrage_Trader/_fetch_prices/gets_the_right_price_set.yml +173 -0
  59. data/spec/trader_spec.rb +228 -0
  60. metadata +249 -0
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://campbx.com/api/xticker.php
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sun, 22 Dec 2013 20:54:39 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=d98aba474beb6580e3a16963937d1feab1387745679008; expires=Mon, 23-Dec-2019
33
+ 23:50:00 GMT; path=/; domain=.campbx.com; HttpOnly
34
+ X-Frame-Options:
35
+ - SAMEORIGIN
36
+ Cache-Control:
37
+ - no-cache, must-revalidate, max-age=3600
38
+ Vary:
39
+ - Accept-Encoding
40
+ Expires:
41
+ - Sun, 22 Dec 2013 21:54:38 GMT
42
+ Cf-Ray:
43
+ - e0fb55dc03e012d
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"Last Trade":"629.99","Best Bid":"611.00","Best Ask":"634.49"}'
47
+ http_version:
48
+ recorded_at: Sun, 22 Dec 2013 20:54:39 GMT
49
+ recorded_with: VCR 2.7.0
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://campbx.com/api/xticker.php
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - cloudflare-nginx
23
+ Date:
24
+ - Sun, 22 Dec 2013 20:54:40 GMT
25
+ Content-Type:
26
+ - application/json
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Set-Cookie:
32
+ - __cfduid=ddfbcf00e20688eca7437a961caf31c281387745680288; expires=Mon, 23-Dec-2019
33
+ 23:50:00 GMT; path=/; domain=.campbx.com; HttpOnly
34
+ X-Frame-Options:
35
+ - SAMEORIGIN
36
+ Cache-Control:
37
+ - no-cache, must-revalidate, max-age=3600
38
+ Vary:
39
+ - Accept-Encoding
40
+ Expires:
41
+ - Sun, 22 Dec 2013 21:54:39 GMT
42
+ Cf-Ray:
43
+ - e0fb565c0b4012d
44
+ body:
45
+ encoding: UTF-8
46
+ string: '{"Last Trade":"629.99","Best Bid":"611.00","Best Ask":"634.49"}'
47
+ http_version:
48
+ recorded_at: Sun, 22 Dec 2013 20:54:40 GMT
49
+ recorded_with: VCR 2.7.0
@@ -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