bitex 0.1.10 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/lib/bitex/market.rb +1 -8
- data/lib/bitex/version.rb +1 -1
- data/spec/fixtures/profile.json +1 -1
- data/spec/market_spec.rb +33 -40
- data/spec/profile_spec.rb +0 -4
- data/spec/specie_withdrawal_spec.rb +4 -4
- data/spec/support/order_shared_examples.rb +0 -8
- metadata +2 -2
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Use Public Market Data
|
22
22
|
|
23
|
-
Bitex::BitcoinMarketData
|
23
|
+
Bitex::BitcoinMarketData has methods for
|
24
24
|
fetching all public market data available.
|
25
25
|
|
26
26
|
### Ticker
|
@@ -61,7 +61,7 @@ on that page. Once done you can start using it as follows:
|
|
61
61
|
|
62
62
|
### Place an Ask
|
63
63
|
|
64
|
-
ruby > Bitex::Ask.create!(:
|
64
|
+
ruby > Bitex::Ask.create!(:btc, 2, 500) # Try to sell 2 Btc at $500 each.
|
65
65
|
|
66
66
|
### List your pending or recently active orders
|
67
67
|
|
data/lib/bitex/market.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Bitex
|
2
2
|
# Public market data for a specie, do not use directly, use
|
3
|
-
# {BitcoinMarketData}
|
3
|
+
# {BitcoinMarketData} instead.
|
4
4
|
class MarketData
|
5
5
|
|
6
6
|
# The species currency ticker conveniently formatted as a ruby Hash with
|
@@ -57,11 +57,4 @@ module Bitex
|
|
57
57
|
'btc'
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
# A {MarketData} for Litecoin.
|
62
|
-
class LitecoinMarketData < MarketData
|
63
|
-
def self.specie
|
64
|
-
'ltc'
|
65
|
-
end
|
66
|
-
end
|
67
60
|
end
|
data/lib/bitex/version.rb
CHANGED
data/spec/fixtures/profile.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"usd_balance":10000.00,"usd_reserved":2000.00,"usd_available":8000.00,"btc_balance":20.00000000,"btc_reserved":5.00000000,"btc_available":15.00000000,"
|
1
|
+
{"usd_balance":10000.00,"usd_reserved":2000.00,"usd_available":8000.00,"btc_balance":20.00000000,"btc_reserved":5.00000000,"btc_available":15.00000000,"fee":0.5,"btc_deposit_address":"1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
|
data/spec/market_spec.rb
CHANGED
@@ -1,46 +1,39 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bitex::MarketData do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
[1403668800, 570.0, 574.0, 570.0, 574.0, 1.06771929, 571.0, 570.917848641659],
|
38
|
-
[1403683200, 560.0, 570.0, 560.0, 570.0, 1.14175147, 565.0, 565.753596095655],
|
39
|
-
[1403697600, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0],
|
40
|
-
[1403712000, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0]
|
41
|
-
]
|
42
|
-
end
|
43
|
-
end
|
4
|
+
it "gets the ticker" do
|
5
|
+
stub_get("/btc/market/ticker", 'market_ticker')
|
6
|
+
Bitex::BitcoinMarketData.ticker.should == {
|
7
|
+
last: 639.0, high: 659.0, low: 639.0, vwap: 647.195852839369,
|
8
|
+
volume: 4.80579022, bid: 637.0, ask: 638.5
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
it "gets the order book" do
|
13
|
+
stub_get("/btc/market/order_book", 'order_book')
|
14
|
+
Bitex::BitcoinMarketData.order_book.should == {
|
15
|
+
bids: [[639.21,1.95],[637.0,0.47],[630.0,1.58]],
|
16
|
+
asks: [[642.4,0.4],[643.3,0.95],[644.3,0.25]]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
it "gets the transactions" do
|
21
|
+
stub_get("/btc/market/transactions", 'transactions')
|
22
|
+
Bitex::BitcoinMarketData.transactions.should == [
|
23
|
+
[1404259180, 1272, 650.0, 0.5],
|
24
|
+
[1404259179, 1271, 639.0, 0.46948356]
|
25
|
+
]
|
26
|
+
end
|
27
|
+
|
28
|
+
%w(last_24_hours last_7_days last_30_days).each do |method|
|
29
|
+
it "gets aggregated data for #{method}" do
|
30
|
+
stub_get("/btc/market/#{method}", 'aggregated_data')
|
31
|
+
Bitex::BitcoinMarketData.send(method).should == [
|
32
|
+
[1403668800, 570.0, 574.0, 570.0, 574.0, 1.06771929, 571.0, 570.917848641659],
|
33
|
+
[1403683200, 560.0, 570.0, 560.0, 570.0, 1.14175147, 565.0, 565.753596095655],
|
34
|
+
[1403697600, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0],
|
35
|
+
[1403712000, 560.0, 560.0, 560.0, 560.0, 0.0, 565.0, 0.0]
|
36
|
+
]
|
44
37
|
end
|
45
38
|
end
|
46
39
|
end
|
data/spec/profile_spec.rb
CHANGED
@@ -12,12 +12,8 @@ describe Bitex::Profile do
|
|
12
12
|
btc_balance: 20.0,
|
13
13
|
btc_reserved: 5.0,
|
14
14
|
btc_available: 15.0,
|
15
|
-
ltc_balance: 250.0,
|
16
|
-
ltc_reserved: 100.0,
|
17
|
-
ltc_available: 150.0,
|
18
15
|
fee: 0.5,
|
19
16
|
btc_deposit_address: "1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
20
|
-
ltc_deposit_address: "LXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
21
17
|
}
|
22
18
|
end
|
23
19
|
end
|
@@ -59,14 +59,14 @@ describe Bitex::SpecieWithdrawal do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'creates a new withdrawal' do
|
62
|
-
stub_private(:post, "/private/
|
62
|
+
stub_private(:post, "/private/btc/withdrawals", 'specie_withdrawal', {
|
63
63
|
address: '1ADDR',
|
64
64
|
amount: 110,
|
65
65
|
label: 'thelabel',
|
66
66
|
})
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
withdrawal = Bitex::SpecieWithdrawal.create!(:btc, '1ADDR', 110, 'thelabel')
|
68
|
+
withdrawal.should be_a Bitex::SpecieWithdrawal
|
69
|
+
withdrawal.status.should == :received
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'finds a single usd deposit' do
|
@@ -21,14 +21,6 @@ shared_examples_for 'Order' do |api_path|
|
|
21
21
|
order.status.should == :received
|
22
22
|
end
|
23
23
|
|
24
|
-
it 'places for ltc' do
|
25
|
-
stub_private(:post, "/private/#{api_path}", "#{api_path}_create",
|
26
|
-
{amount: 100.50, price: 1000.00, specie: 2})
|
27
|
-
order = subject.class.create!(:ltc, 100.50, 1000.00)
|
28
|
-
order.should be_a subject.class
|
29
|
-
order.status.should == :received
|
30
|
-
end
|
31
|
-
|
32
24
|
it 'places for btc and waits until processed by our matching engine' do
|
33
25
|
stub_private(:post, "/private/#{api_path}", "#{api_path}_create",
|
34
26
|
{amount: 100.50, price: 1000.00, specie: 1})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|