mexbt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -14
- data/lib/mexbt/client.rb +3 -0
- data/lib/mexbt/version.rb +1 -1
- data/spec/private_api_spec.rb +25 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15732e233077f44d567ce9daae9097843322d1d3
|
4
|
+
data.tar.gz: 5a29f9c01b744e4636864b5a7fcd171be33e1365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39e9ad6cc488e0b18fb9b00cc21862be8af7a4c3ce5be9bcf26915db7ddbf9ba5e9f9546c3a9ab8bbc43cf570f93dd3b79eed7ba0462de623f71a0efb644c37d
|
7
|
+
data.tar.gz: 2d5ed961b26805dce2795e429c2cb4b7f03f7361241344755d576cb833ac321c814de5bf6cbe52f78b58d42802a585c0197f0598e59a59be8bbe12a6a79e4b77
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ returns it as-is.
|
|
7
7
|
|
8
8
|
If using bundler simply this to your Gemfile:
|
9
9
|
|
10
|
-
gem '
|
10
|
+
gem 'mexbt'
|
11
11
|
|
12
12
|
And run `bundle install` of course.
|
13
13
|
|
@@ -39,28 +39,28 @@ Or alternatively you can set it per call:
|
|
39
39
|
|
40
40
|
You need to generate an API key pair at https://mexbt.com/api/keys. However if you want to get started quickly we recommend having a play in the sandbox first, see the 'Sandbox' section below.
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
Mexbt.configure do |c|
|
43
|
+
mexbt.public_key = "xxx"
|
44
44
|
mexbt.private_key = "yyy"
|
45
45
|
mexbt.user_id = "email@test.com" # Your registered email address
|
46
46
|
mexbt.sandbox = true # Set this to true to use the sandbox
|
47
|
-
|
47
|
+
end
|
48
48
|
|
49
49
|
## Order functions
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
Mexbt::Orders.create(amount: 0.1, currency_pair: 'btcmxn') # Create a market buy order for 0.1 BTC for Pesos
|
52
|
+
Mexbt::Orders.create(amount: 2, side: :sell, currency_pair: 'btcusd') # Create a market order to sell 2 BTC for USD
|
53
|
+
Mexbt::Orders.create(amount: 2, price: 1, side: :buy, type: :limit, currency_pair: 'ltcmxn') # Create a limit order to buy 2 LTC for 1 peso
|
54
|
+
Mexbt::Orders.cancel(id: 123, currency_pair: 'btcmxn')
|
55
|
+
Mexbt::Orders.cancel_all() # Cancel all orders for the default currency pair
|
56
56
|
|
57
57
|
## Account functions
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
Mexbt::Account.balance
|
60
|
+
Mexbt::Account.trades
|
61
|
+
Mexbt::Account.orders
|
62
|
+
Mexbt::Account.deposit_addresses
|
63
|
+
Mexbt::Account.withdraw(amount: 1, currency: :btc, address: 'xxx') Mexbt::Account.info # Fetches your user info
|
64
64
|
|
65
65
|
## Sandbox
|
66
66
|
|
data/lib/mexbt/client.rb
CHANGED
@@ -13,6 +13,9 @@ module Mexbt
|
|
13
13
|
if Mexbt.public_key.nil? || Mexbt.private_key.nil?
|
14
14
|
raise "You must configure your API keys!"
|
15
15
|
end
|
16
|
+
if Mexbt.user_id.nil?
|
17
|
+
raise "You must configure your user_id!"
|
18
|
+
end
|
16
19
|
nonce = (Time.now.to_f*10000).to_i
|
17
20
|
{
|
18
21
|
apiKey: Mexbt.public_key,
|
data/lib/mexbt/version.rb
CHANGED
data/spec/private_api_spec.rb
CHANGED
@@ -4,25 +4,43 @@ describe Mexbt::Private do
|
|
4
4
|
|
5
5
|
context "without authentication" do
|
6
6
|
|
7
|
-
|
7
|
+
after do
|
8
|
+
Mexbt.configure do |c|
|
9
|
+
c.public_key = nil
|
10
|
+
c.private_key = nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should raise a friendly error if no keys are configured" do
|
8
15
|
expect { Mexbt::Account.balance }.to raise_error("You must configure your API keys!")
|
9
16
|
end
|
10
17
|
|
18
|
+
it "should raise a friendly error if no user_id is configured" do
|
19
|
+
Mexbt.configure do |c|
|
20
|
+
c.public_key = "foo"
|
21
|
+
c.private_key = "bar"
|
22
|
+
end
|
23
|
+
expect { Mexbt::Account.balance }.to raise_error("You must configure your user_id!")
|
24
|
+
end
|
25
|
+
|
11
26
|
end
|
12
27
|
|
13
28
|
context "with authentication" do
|
14
29
|
|
15
30
|
before do
|
16
|
-
Mexbt.configure do |
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
31
|
+
Mexbt.configure do |c|
|
32
|
+
c.public_key = "8a742b8ecaff21784d8d788119bded0e"
|
33
|
+
c.private_key = "e989fb9c1905a4fbd0a4bfe84230c9bc"
|
34
|
+
c.user_id = "test@mexbt.com"
|
35
|
+
c.sandbox = true
|
21
36
|
end
|
22
37
|
end
|
23
38
|
|
24
39
|
after do
|
25
|
-
Mexbt.configure
|
40
|
+
Mexbt.configure do |c|
|
41
|
+
c.public_key = nil
|
42
|
+
c.user_id = nil
|
43
|
+
end
|
26
44
|
end
|
27
45
|
|
28
46
|
context Mexbt::Account do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mexbt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- williamcoates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|