rbtc_arbitrage_simple 1.4.4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +16 -14
  3. data/Gemfile.lock +17 -21
  4. data/lib/rbtc_arbitrage.rb +3 -1
  5. data/lib/rbtc_arbitrage/campbx.rb +3 -4
  6. data/lib/rbtc_arbitrage/cli.rb +2 -2
  7. data/lib/rbtc_arbitrage/clients/coinbase_client.rb +3 -2
  8. data/lib/rbtc_arbitrage/trader.rb +21 -75
  9. data/lib/rbtc_arbitrage/trader/logger.rb +31 -0
  10. data/lib/rbtc_arbitrage/trader/notifier.rb +60 -0
  11. data/lib/rbtc_arbitrage/version.rb +1 -1
  12. data/rbtc_arbitrage.gemspec +1 -1
  13. data/spec/clients/coinbase_client_spec.rb +2 -3
  14. data/spec/rbtc_arbitrage_spec.rb +1 -1
  15. data/spec/spec_helper.rb +2 -1
  16. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/should_raise_SecurityError_if_not_live.yml +30 -25
  17. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_BTC.yml +38 -24
  18. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_USD.yml +40 -26
  19. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/should_fetch_balance.yml +30 -25
  20. data/spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/shouldn_t_raise_security_error.yml +72 -53
  21. data/spec/support/cassettes/RbtcArbitrage_Trader/_fetch_prices/gets_the_right_price_set.yml +60 -50
  22. data/spec/trader_spec.rb +8 -8
  23. metadata +10 -19
  24. data/lib/rbtc_arbitrage/clients/mtgox_client.rb +0 -56
  25. data/spec/clients/mtgox_client_spec.rb +0 -53
  26. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml +0 -77
  27. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml +0 -44
  28. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml +0 -44
  29. data/spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_prices_correctly.yml +0 -85
@@ -21,7 +21,7 @@ http_interactions:
21
21
  Server:
22
22
  - cloudflare-nginx
23
23
  Date:
24
- - Mon, 23 Dec 2013 16:49:49 GMT
24
+ - Mon, 24 Mar 2014 01:13:06 GMT
25
25
  Content-Type:
26
26
  - application/json
27
27
  Transfer-Encoding:
@@ -29,7 +29,7 @@ http_interactions:
29
29
  Connection:
30
30
  - keep-alive
31
31
  Set-Cookie:
32
- - __cfduid=dd0db16ca7e6b42fc3eb5b46af612a9151387817388611; expires=Mon, 23-Dec-2019
32
+ - __cfduid=d76110a73ab8f1d70a4ca08e20e2e7a691395623585834; expires=Mon, 23-Dec-2019
33
33
  23:50:00 GMT; path=/; domain=.campbx.com; HttpOnly
34
34
  X-Frame-Options:
35
35
  - SAMEORIGIN
@@ -38,53 +38,58 @@ http_interactions:
38
38
  Vary:
39
39
  - Accept-Encoding
40
40
  Expires:
41
- - Mon, 23 Dec 2013 17:49:47 GMT
41
+ - Mon, 24 Mar 2014 02:13:00 GMT
42
42
  Cf-Ray:
43
- - e168c16d2920657
43
+ - 10ff01137a98012b-SJC
44
44
  body:
45
45
  encoding: UTF-8
46
- string: '{"Last Trade":"625.01","Best Bid":"625.01","Best Ask":"637.97"}'
46
+ string: '{"Last Trade":"588.64","Best Bid":"581.87","Best Ask":"592.71"}'
47
47
  http_version:
48
- recorded_at: Mon, 23 Dec 2013 16:49:48 GMT
48
+ recorded_at: Mon, 24 Mar 2014 01:13:06 GMT
49
49
  - request:
50
50
  method: get
51
- uri: https://data.mtgox.com/api/1/BTCUSD/ticker
51
+ uri: https://btc-e.com/api/2/btc_usd/ticker
52
52
  body:
53
53
  encoding: US-ASCII
54
54
  string: ''
55
55
  headers:
56
- Accept:
57
- - application/json
58
- User-Agent:
59
- - mtgox gem 1.1.0
60
56
  Accept-Encoding:
61
57
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
58
+ Accept:
59
+ - '*/*'
60
+ User-Agent:
61
+ - Ruby
62
62
  response:
63
63
  status:
64
64
  code: 200
65
65
  message: OK
66
66
  headers:
67
67
  Server:
68
- - nginx/1.4.4
69
- Content-Type:
70
- - application/json; charset=utf-8
71
- Access-Control-Allow-Origin:
72
- - '*'
73
- Content-Length:
74
- - '1399'
75
- Cache-Control:
76
- - public, max-age=8
77
- Expires:
78
- - Mon, 23 Dec 2013 16:49:57 GMT
68
+ - cloudflare-nginx
79
69
  Date:
80
- - Mon, 23 Dec 2013 16:49:49 GMT
70
+ - Mon, 24 Mar 2014 01:13:06 GMT
71
+ Content-Type:
72
+ - text/html; charset=utf-8
73
+ Transfer-Encoding:
74
+ - chunked
81
75
  Connection:
82
76
  - keep-alive
77
+ Set-Cookie:
78
+ - __cfduid=df2596c95314fafd31bfb7ac290e51c271395623586272; expires=Mon, 23-Dec-2019
79
+ 23:50:00 GMT; path=/; domain=.btc-e.com; HttpOnly
80
+ X-Frame-Options:
81
+ - DENY
82
+ Expires:
83
+ - Thu, 01 Jan 1970 00:00:01 GMT
84
+ Cache-Control:
85
+ - no-cache
86
+ Cf-Ray:
87
+ - 10ff0116371f0701-SJC
83
88
  body:
84
89
  encoding: UTF-8
85
- string: '{"result":"success","return":{"high":{"value":"685.99999","value_int":"68599999","display":"$686.00","display_short":"$686.00","currency":"USD"},"low":{"value":"630.00000","value_int":"63000000","display":"$630.00","display_short":"$630.00","currency":"USD"},"avg":{"value":"662.16647","value_int":"66216647","display":"$662.17","display_short":"$662.17","currency":"USD"},"vwap":{"value":"662.16836","value_int":"66216836","display":"$662.17","display_short":"$662.17","currency":"USD"},"vol":{"value":"12450.68479794","value_int":"1245068479794","display":"12,450.68\u00a0BTC","display_short":"12,450.68\u00a0BTC","currency":"BTC"},"last_local":{"value":"655.00000","value_int":"65500000","display":"$655.00","display_short":"$655.00","currency":"USD"},"last_orig":{"value":"489.00000","value_int":"48900000","display":"489.00\u00a0\u20ac","display_short":"489.00\u00a0\u20ac","currency":"EUR"},"last_all":{"value":"667.72950","value_int":"66772950","display":"$667.73","display_short":"$667.73","currency":"USD"},"last":{"value":"655.00000","value_int":"65500000","display":"$655.00","display_short":"$655.00","currency":"USD"},"buy":{"value":"661.50000","value_int":"66150000","display":"$661.50","display_short":"$661.50","currency":"USD"},"sell":{"value":"667.47499","value_int":"66747499","display":"$667.47","display_short":"$667.47","currency":"USD"},"item":"BTC","now":"1387817367194043"}}'
90
+ string: '{"ticker":{"high":577,"low":561.21503,"avg":569.107515,"vol":1379596.28313,"vol_cur":2424.76982,"last":563.988,"buy":564.989,"sell":563.988,"updated":1395623584,"server_time":1395623586}}'
86
91
  http_version:
87
- recorded_at: Mon, 23 Dec 2013 16:49:49 GMT
92
+ recorded_at: Mon, 24 Mar 2014 01:13:06 GMT
88
93
  - request:
89
94
  method: get
90
95
  uri: https://campbx.com/api/xticker.php
@@ -106,7 +111,7 @@ http_interactions:
106
111
  Server:
107
112
  - cloudflare-nginx
108
113
  Date:
109
- - Mon, 23 Dec 2013 16:49:50 GMT
114
+ - Mon, 24 Mar 2014 01:13:07 GMT
110
115
  Content-Type:
111
116
  - application/json
112
117
  Transfer-Encoding:
@@ -114,7 +119,7 @@ http_interactions:
114
119
  Connection:
115
120
  - keep-alive
116
121
  Set-Cookie:
117
- - __cfduid=d67869f8544a1a1a0579be7bc107d34161387817389952; expires=Mon, 23-Dec-2019
122
+ - __cfduid=d9414509e184dccd66043c1662004bf651395623586779; expires=Mon, 23-Dec-2019
118
123
  23:50:00 GMT; path=/; domain=.campbx.com; HttpOnly
119
124
  X-Frame-Options:
120
125
  - SAMEORIGIN
@@ -123,51 +128,56 @@ http_interactions:
123
128
  Vary:
124
129
  - Accept-Encoding
125
130
  Expires:
126
- - Mon, 23 Dec 2013 17:49:49 GMT
131
+ - Mon, 24 Mar 2014 02:13:01 GMT
127
132
  Cf-Ray:
128
- - e168c1f372b012d
133
+ - 10ff01195aaf012b-SJC
129
134
  body:
130
135
  encoding: UTF-8
131
- string: '{"Last Trade":"625.01","Best Bid":"625.01","Best Ask":"637.97"}'
136
+ string: '{"Last Trade":"588.64","Best Bid":"581.87","Best Ask":"592.71"}'
132
137
  http_version:
133
- recorded_at: Mon, 23 Dec 2013 16:49:49 GMT
138
+ recorded_at: Mon, 24 Mar 2014 01:13:07 GMT
134
139
  - request:
135
140
  method: get
136
- uri: https://data.mtgox.com/api/1/BTCUSD/ticker
141
+ uri: https://btc-e.com/api/2/btc_usd/ticker
137
142
  body:
138
143
  encoding: US-ASCII
139
144
  string: ''
140
145
  headers:
141
- Accept:
142
- - application/json
143
- User-Agent:
144
- - mtgox gem 1.1.0
145
146
  Accept-Encoding:
146
147
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
148
+ Accept:
149
+ - '*/*'
150
+ User-Agent:
151
+ - Ruby
147
152
  response:
148
153
  status:
149
154
  code: 200
150
155
  message: OK
151
156
  headers:
152
157
  Server:
153
- - nginx/1.4.4
154
- Content-Type:
155
- - application/json; charset=utf-8
156
- Access-Control-Allow-Origin:
157
- - '*'
158
- Content-Length:
159
- - '1399'
160
- Cache-Control:
161
- - public, max-age=7
162
- Expires:
163
- - Mon, 23 Dec 2013 16:49:57 GMT
158
+ - cloudflare-nginx
164
159
  Date:
165
- - Mon, 23 Dec 2013 16:49:50 GMT
160
+ - Mon, 24 Mar 2014 01:13:07 GMT
161
+ Content-Type:
162
+ - text/html; charset=utf-8
163
+ Transfer-Encoding:
164
+ - chunked
166
165
  Connection:
167
166
  - keep-alive
167
+ Set-Cookie:
168
+ - __cfduid=de6b54b6272917ce3756f74ef16b49db41395623587505; expires=Mon, 23-Dec-2019
169
+ 23:50:00 GMT; path=/; domain=.btc-e.com; HttpOnly
170
+ X-Frame-Options:
171
+ - DENY
172
+ Expires:
173
+ - Thu, 01 Jan 1970 00:00:01 GMT
174
+ Cache-Control:
175
+ - no-cache
176
+ Cf-Ray:
177
+ - 10ff011decac0701-SJC
168
178
  body:
169
179
  encoding: UTF-8
170
- string: '{"result":"success","return":{"high":{"value":"685.99999","value_int":"68599999","display":"$686.00","display_short":"$686.00","currency":"USD"},"low":{"value":"630.00000","value_int":"63000000","display":"$630.00","display_short":"$630.00","currency":"USD"},"avg":{"value":"662.16647","value_int":"66216647","display":"$662.17","display_short":"$662.17","currency":"USD"},"vwap":{"value":"662.16836","value_int":"66216836","display":"$662.17","display_short":"$662.17","currency":"USD"},"vol":{"value":"12450.68479794","value_int":"1245068479794","display":"12,450.68\u00a0BTC","display_short":"12,450.68\u00a0BTC","currency":"BTC"},"last_local":{"value":"655.00000","value_int":"65500000","display":"$655.00","display_short":"$655.00","currency":"USD"},"last_orig":{"value":"489.00000","value_int":"48900000","display":"489.00\u00a0\u20ac","display_short":"489.00\u00a0\u20ac","currency":"EUR"},"last_all":{"value":"667.72950","value_int":"66772950","display":"$667.73","display_short":"$667.73","currency":"USD"},"last":{"value":"655.00000","value_int":"65500000","display":"$655.00","display_short":"$655.00","currency":"USD"},"buy":{"value":"661.50000","value_int":"66150000","display":"$661.50","display_short":"$661.50","currency":"USD"},"sell":{"value":"667.47499","value_int":"66747499","display":"$667.47","display_short":"$667.47","currency":"USD"},"item":"BTC","now":"1387817367194043"}}'
180
+ string: '{"ticker":{"high":577,"low":561.21503,"avg":569.107515,"vol":1379596.28313,"vol_cur":2424.76982,"last":563.988,"buy":564.989,"sell":563.988,"updated":1395623586,"server_time":1395623587}}'
171
181
  http_version:
172
- recorded_at: Mon, 23 Dec 2013 16:49:49 GMT
182
+ recorded_at: Mon, 24 Mar 2014 01:13:07 GMT
173
183
  recorded_with: VCR 2.8.0
data/spec/trader_spec.rb CHANGED
@@ -55,14 +55,14 @@ describe RbtcArbitrage::Trader do
55
55
 
56
56
  describe "#fetch_prices" do
57
57
  it "gets the right price set", :vcr do
58
- stamp_price = CampBX::API.new.xticker["Best Ask"].to_f
59
- mtgox_price = MtGox.ticker.buy
58
+ campbx_price = RbtcArbitrage::Clients::CampbxClient.new.price(:sell)
59
+ btce_price = RbtcArbitrage::Clients::BtceClient.new.price(:buy)
60
60
 
61
61
  trader.fetch_prices
62
62
 
63
63
  #allow for recent price changes
64
- trader.buyer[:price].should be_within(0.02).of(stamp_price)
65
- trader.seller[:price].should be_within(0.02).of(mtgox_price)
64
+ trader.seller[:price].should be_within(0.02).of(campbx_price)
65
+ trader.buyer[:price].should be_within(0.02).of(btce_price)
66
66
  end
67
67
 
68
68
  it "calculates profit and percent accurately" do
@@ -83,8 +83,8 @@ describe RbtcArbitrage::Trader do
83
83
  logger: nil,
84
84
  verbose: false,
85
85
  live: true,
86
- seller: :btce,
87
- buyer: :mtgox,
86
+ seller: :campbx,
87
+ buyer: :btce,
88
88
  notify: true,
89
89
  }
90
90
  }
@@ -100,8 +100,8 @@ describe RbtcArbitrage::Trader do
100
100
  end
101
101
 
102
102
  it "sets the right exchanges" do
103
- trader.buy_client.should be_a(RbtcArbitrage::Clients::MtGoxClient)
104
- trader.sell_client.should be_a(RbtcArbitrage::Clients::BtceClient)
103
+ trader.sell_client.should be_a(RbtcArbitrage::Clients::CampbxClient)
104
+ trader.buy_client.should be_a(RbtcArbitrage::Clients::BtceClient)
105
105
  end
106
106
 
107
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbtc_arbitrage_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hank Stoever
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-04 00:00:00.000000000 Z
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: mtgox
42
+ name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.8.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.8.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: activemodel
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,8 +164,9 @@ files:
164
164
  - lib/rbtc_arbitrage/clients/campbx_client.rb
165
165
  - lib/rbtc_arbitrage/clients/client.rb.example
166
166
  - lib/rbtc_arbitrage/clients/coinbase_client.rb
167
- - lib/rbtc_arbitrage/clients/mtgox_client.rb
168
167
  - lib/rbtc_arbitrage/trader.rb
168
+ - lib/rbtc_arbitrage/trader/logger.rb
169
+ - lib/rbtc_arbitrage/trader/notifier.rb
169
170
  - lib/rbtc_arbitrage/version.rb
170
171
  - rbtc_arbitrage.gemspec
171
172
  - spec/cli_spec.rb
@@ -173,7 +174,6 @@ files:
173
174
  - spec/clients/btce_client_spec.rb
174
175
  - spec/clients/campbx_client_spec.rb
175
176
  - spec/clients/coinbase_client_spec.rb
176
- - spec/clients/mtgox_client_spec.rb
177
177
  - spec/rbtc_arbitrage_spec.rb
178
178
  - spec/spec_helper.rb
179
179
  - spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_balance/fetches_the_balance_correctly.yml
@@ -191,10 +191,6 @@ files:
191
191
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml
192
192
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml
193
193
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml
194
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml
195
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml
196
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml
197
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_prices_correctly.yml
198
194
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/should_raise_SecurityError_if_not_live.yml
199
195
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_BTC.yml
200
196
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_USD.yml
@@ -222,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
218
  version: '0'
223
219
  requirements: []
224
220
  rubyforge_project:
225
- rubygems_version: 2.0.6
221
+ rubygems_version: 2.2.0
226
222
  signing_key:
227
223
  specification_version: 4
228
224
  summary: A gem for conducting arbitrage with Bitcoin.
@@ -232,7 +228,6 @@ test_files:
232
228
  - spec/clients/btce_client_spec.rb
233
229
  - spec/clients/campbx_client_spec.rb
234
230
  - spec/clients/coinbase_client_spec.rb
235
- - spec/clients/mtgox_client_spec.rb
236
231
  - spec/rbtc_arbitrage_spec.rb
237
232
  - spec/spec_helper.rb
238
233
  - spec/support/cassettes/RbtcArbitrage_Clients_BitstampClient/_balance/fetches_the_balance_correctly.yml
@@ -250,10 +245,6 @@ test_files:
250
245
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/calls_coinbase.yml
251
246
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_buy_correctly.yml
252
247
  - spec/support/cassettes/RbtcArbitrage_Clients_CoinbaseClient/_price/fetches_price_for_sell_correctly.yml
253
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_balance/fetches_the_balance_correctly.yml
254
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_buy_correctly.yml
255
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_price_for_sell_correctly.yml
256
- - spec/support/cassettes/RbtcArbitrage_Clients_MtGoxClient/_price/fetches_prices_correctly.yml
257
248
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/should_raise_SecurityError_if_not_live.yml
258
249
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_BTC.yml
259
250
  - spec/support/cassettes/RbtcArbitrage_Trader/_execute_trade/when_live/raises_SecurityError_if_not_enough_USD.yml
@@ -1,56 +0,0 @@
1
- module RbtcArbitrage
2
- module Clients
3
- class MtGoxClient
4
- include RbtcArbitrage::Client
5
-
6
- ##
7
- # Returns an array of Floats.
8
- # The first element is the balance in BTC;
9
- # The second is in USD.
10
- def balance
11
- return @balance if @balance
12
- balances = MtGox.balance
13
- @balance = [balances[0].amount.to_f, balances[1].amount.to_f]
14
- end
15
-
16
- ##
17
- # Configures the MtGox
18
- # client's API keys.
19
- def validate_env
20
- validate_keys :mtgox_key, :mtgox_secret, :mtgox_address
21
- MtGox.configure do |config|
22
- config.key = ENV["MTGOX_KEY"]
23
- config.secret = ENV["MTGOX_SECRET"]
24
- end
25
- end
26
-
27
- def exchange
28
- :mtgox
29
- end
30
-
31
- # `action` is :buy or :sell
32
- # Returns a Numeric type.
33
- def price action
34
- return @price if @price
35
- action = {
36
- buy: :sell,
37
- sell: :buy,
38
- }[action]
39
- @price = MtGox.ticker.send(action)
40
- end
41
-
42
- # `action` is :buy or :sell
43
- def trade action
44
- action = "#{action.to_s}!".to_sym
45
- MtGox.send(action, @options[:volume], :market)
46
- end
47
-
48
- ##
49
- # Transfers BTC to the address of a different
50
- # exchange.
51
- def transfer other_client
52
- MtGox.withdraw! @options[:volume], other_client.address
53
- end
54
- end
55
- end
56
- end
@@ -1,53 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RbtcArbitrage::Clients::MtGoxClient do
4
- let(:client) { RbtcArbitrage::Clients::MtGoxClient.new }
5
- before(:each) { client.validate_env }
6
-
7
- describe "#balance" do
8
- it "fetches the balance correctly", :vcr do
9
- balances = MtGox.balance
10
- balance = client.balance
11
- balance.should == [balances[0].amount.to_f, balances[1].amount.to_f]
12
- end
13
- end
14
-
15
- describe "#price" do
16
- [:buy, :sell].each do |action|
17
- it "fetches price for #{action} correctly", :vcr do
18
- client.price(action).should be_a(BigDecimal)
19
- end
20
- end
21
-
22
- it "calls MtGox" do
23
- hash = Hashie::Mash.new(buy: 10)
24
- hash.should_receive(:buy)
25
- MtGox.should_receive(:ticker) { hash }
26
- client.price(:sell)
27
-
28
- client.instance_variable_set(:@price, nil)
29
- hash = Hashie::Mash.new(sell: 10)
30
- hash.should_receive(:sell)
31
- MtGox.should_receive(:ticker) { hash }
32
- client.price(:buy)
33
- end
34
- end
35
-
36
- describe "#trade" do
37
- it "calls MtGox" do
38
- MtGox.should_receive(:sell!).with(0.01, :market)
39
- client.trade(:sell)
40
-
41
- MtGox.should_receive(:buy!).with(0.01, :market)
42
- client.trade(:buy)
43
- end
44
- end
45
-
46
- describe "#transfer" do
47
- it "calls MtGox correctly" do
48
- sell_client = RbtcArbitrage::Clients::BtceClient.new
49
- MtGox.should_receive(:withdraw!).with(0.01, sell_client.address)
50
- client.transfer sell_client
51
- end
52
- end
53
- end
@@ -1,77 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://data.mtgox.com/api/1/generic/info
6
- body:
7
- encoding: US-ASCII
8
- string: nonce=1387161061259915
9
- response:
10
- status:
11
- code: 200
12
- message: OK
13
- headers:
14
- Server:
15
- - nginx/1.4.4
16
- Content-Type:
17
- - application/json; charset=utf-8
18
- X-Powered-By:
19
- - PHP/5.5.4
20
- Access-Control-Allow-Origin:
21
- - '*'
22
- Content-Length:
23
- - '1731'
24
- Expires:
25
- - Mon, 16 Dec 2013 02:31:02 GMT
26
- Cache-Control:
27
- - max-age=0, no-cache, no-store
28
- Pragma:
29
- - no-cache
30
- Date:
31
- - Mon, 16 Dec 2013 02:31:02 GMT
32
- Connection:
33
- - keep-alive
34
- body:
35
- encoding: UTF-8
36
- string: '{"result":"success","return":{"Login":"heynk","Index":"141119","Id":"84fdd298-4386-4d7c-86c0-af74f2e0d0ec","Link":"M82141119X","Rights":["deposit","get_info","merchant","trade","withdraw"],"Language":"en_US","Created":"2012-04-07
37
- 13:52:16","Last_Login":"2013-10-15 20:52:29","Wallets":{"BTC":{"Balance":{"value":"0.00000133","value_int":"133","display":"0.00000133\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"},"Operations":1,"Daily_Withdraw_Limit":{"value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"},"Monthly_Withdraw_Limit":null,"Max_Withdraw":{"value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"},"Open_Orders":{"value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"}},"USD":{"Balance":{"value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"},"Operations":0,"Daily_Withdraw_Limit":{"value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"},"Monthly_Withdraw_Limit":{"value":"10000.00000","value_int":"1000000000","display":"$10,000.00000","display_short":"$10,000.00","currency":"USD"},"Max_Withdraw":{"value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"},"Open_Orders":{"value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"}}},"Monthly_Volume":{"value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"},"Trade_Fee":0.6}}'
38
- http_version:
39
- recorded_at: Mon, 16 Dec 2013 02:31:02 GMT
40
- - request:
41
- method: post
42
- uri: https://data.mtgox.com/api/1/generic/info
43
- body:
44
- encoding: US-ASCII
45
- string: nonce=1387161062673595
46
- response:
47
- status:
48
- code: 200
49
- message: OK
50
- headers:
51
- Server:
52
- - nginx/1.4.4
53
- Content-Type:
54
- - application/json; charset=utf-8
55
- X-Powered-By:
56
- - PHP/5.5.4
57
- Access-Control-Allow-Origin:
58
- - '*'
59
- Content-Length:
60
- - '1731'
61
- Expires:
62
- - Mon, 16 Dec 2013 02:31:03 GMT
63
- Cache-Control:
64
- - max-age=0, no-cache, no-store
65
- Pragma:
66
- - no-cache
67
- Date:
68
- - Mon, 16 Dec 2013 02:31:03 GMT
69
- Connection:
70
- - keep-alive
71
- body:
72
- encoding: UTF-8
73
- string: '{"result":"success","return":{"Login":"heynk","Index":"141119","Id":"84fdd298-4386-4d7c-86c0-af74f2e0d0ec","Link":"M82141119X","Rights":["deposit","get_info","merchant","trade","withdraw"],"Language":"en_US","Created":"2012-04-07
74
- 13:52:16","Last_Login":"2013-10-15 20:52:29","Wallets":{"BTC":{"Balance":{"value":"0.00000133","value_int":"133","display":"0.00000133\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"},"Operations":1,"Daily_Withdraw_Limit":{"value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"},"Monthly_Withdraw_Limit":null,"Max_Withdraw":{"value":"100.00000000","value_int":"10000000000","display":"100.00000000\u00a0BTC","display_short":"100.00\u00a0BTC","currency":"BTC"},"Open_Orders":{"value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"}},"USD":{"Balance":{"value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"},"Operations":0,"Daily_Withdraw_Limit":{"value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"},"Monthly_Withdraw_Limit":{"value":"10000.00000","value_int":"1000000000","display":"$10,000.00000","display_short":"$10,000.00","currency":"USD"},"Max_Withdraw":{"value":"1000.00000","value_int":"100000000","display":"$1,000.00000","display_short":"$1,000.00","currency":"USD"},"Open_Orders":{"value":"0.00000","value_int":"0","display":"$0.00000","display_short":"$0.00","currency":"USD"}}},"Monthly_Volume":{"value":"0.00000000","value_int":"0","display":"0.00000000\u00a0BTC","display_short":"0.00\u00a0BTC","currency":"BTC"},"Trade_Fee":0.6}}'
75
- http_version:
76
- recorded_at: Mon, 16 Dec 2013 02:31:03 GMT
77
- recorded_with: VCR 2.7.0