mexbt 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mexbt/account.rb +19 -5
- data/lib/mexbt/version.rb +1 -1
- data/spec/private_api_spec.rb +4 -4
- 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: 25fa8e7c779ae07ef6f22b81bfa259eebcc5659e
|
4
|
+
data.tar.gz: 275a2668c6469ade0a0512472ce08dfd767310ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106267fe0660c0fc2e953c30d3fa08af104ab8d932b2e0c83574ed55deef11b783b5d0d63389cf631a5f7e89644e950b7aea28e9498f7455efb21126b8b8f39f
|
7
|
+
data.tar.gz: d65cc9be57cf4706e9091e5bc3a4e7ade89618139dae00e2a5a45598479d7984699ce1fe8a0ac27e42c770c52544eea9273f3f630b864efda5938f2520e81a69
|
data/lib/mexbt/account.rb
CHANGED
@@ -39,14 +39,17 @@ module Mexbt
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def withdraw(amount:, address:, currency: :btc)
|
42
|
-
call("withdraw", { ins: currency, amount: amount, sendToAddress: address })
|
42
|
+
call("withdraw", { ins: currency, amount: format_amount(amount), sendToAddress: address })
|
43
|
+
rescue RuntimeError => e
|
44
|
+
if sandbox
|
45
|
+
puts "Withdrawals do not yet work on the sandbox :( Let's pretend..."
|
46
|
+
else
|
47
|
+
raise e
|
48
|
+
end
|
43
49
|
end
|
44
50
|
|
45
51
|
def create_order(amount:, price: nil, currency_pair: Mexbt.currency_pair, side: :buy, type: :market)
|
46
|
-
|
47
|
-
if Mexbt.sandbox
|
48
|
-
amount = BigDecimal.new(amount, 15).round(6).to_f
|
49
|
-
end
|
52
|
+
amount = format_amount(amount)
|
50
53
|
type =
|
51
54
|
case type
|
52
55
|
when :market, 1
|
@@ -86,5 +89,16 @@ module Mexbt
|
|
86
89
|
end
|
87
90
|
call("orders/modify", { ins: currency_pair, serverOrderId: id, modifyAction: action } )
|
88
91
|
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def format_amount(amount)
|
96
|
+
if sandbox
|
97
|
+
# Horribly hack because sandbox only accepts 6 decimal places thanks to AP
|
98
|
+
BigDecimal.new(amount, 15).round(6).to_f
|
99
|
+
else
|
100
|
+
amount
|
101
|
+
end
|
102
|
+
end
|
89
103
|
end
|
90
104
|
end
|
data/lib/mexbt/version.rb
CHANGED
data/spec/private_api_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe Mexbt::Account do
|
|
29
29
|
|
30
30
|
context "with per-instance authentication" do
|
31
31
|
|
32
|
-
subject(:account) { Mexbt::Account.new(public_key: "
|
32
|
+
subject(:account) { Mexbt::Account.new(public_key: "62e78ef68b20bc1db55e56cd7cb675df", private_key: "b4bf685ab83a0a4017cdf471e4d410e1", user_id: "test@mexbt.com", sandbox: true) }
|
33
33
|
|
34
34
|
it "still works" do
|
35
35
|
expect(account.info[:isAccepted]).to be true
|
@@ -43,8 +43,8 @@ describe Mexbt::Account do
|
|
43
43
|
|
44
44
|
before do
|
45
45
|
Mexbt.configure do |c|
|
46
|
-
c.public_key = "
|
47
|
-
c.private_key = "
|
46
|
+
c.public_key = "62e78ef68b20bc1db55e56cd7cb675df"
|
47
|
+
c.private_key = "b4bf685ab83a0a4017cdf471e4d410e1"
|
48
48
|
c.user_id = "test@mexbt.com"
|
49
49
|
c.sandbox = true
|
50
50
|
end
|
@@ -137,4 +137,4 @@ describe Mexbt::Account do
|
|
137
137
|
|
138
138
|
end
|
139
139
|
|
140
|
-
end
|
140
|
+
end
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- williamcoates
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|