kraken_ruby 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/kraken_ruby-0.2.1.gem +0 -0
- data/lib/kraken_ruby/client.rb +11 -6
- data/lib/kraken_ruby/version.rb +1 -1
- data/spec/client_spec.rb +13 -6
- 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: 60837e2ad5baa1c1bc95134a33aee85b9e4fecd2
|
4
|
+
data.tar.gz: 8439a69deba784ef9bf3ea2e39f94d836c6fa157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1bd273af83305d4b321a6fa436fe68870ab7b703159d1a799c7069b97c84df4c554eeb51dbc1e1a4734ae1c82ceb2fe4ca793ee0f11094cd910aacc9c58004e
|
7
|
+
data.tar.gz: 894ec8af3e84cb059ff9dd853bb4c4d250af0880b08afe818e0d05b91fdec6d9d985ddc2de768949d6ea2617cd225acf422345ae08433ed1485e2eab882f59d3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -189,4 +189,4 @@ volume = kraken.query_ledgers(asset_pairs)
|
|
189
189
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
190
190
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
191
191
|
4. Push to the branch (`git push origin my-new-feature`)
|
192
|
-
5. Create new Pull Request
|
192
|
+
5. Create new Pull Request
|
data/kraken_ruby-0.2.1.gem
CHANGED
Binary file
|
data/lib/kraken_ruby/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'hashie'
|
3
|
-
require '
|
3
|
+
require 'base64'
|
4
4
|
require 'addressable/uri'
|
5
5
|
|
6
6
|
|
@@ -35,7 +35,7 @@ module Kraken
|
|
35
35
|
opts = { 'pair' => pairs }
|
36
36
|
get_public 'Ticker', opts
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def order_book(pair, opts={})
|
40
40
|
opts['pair'] = pair
|
41
41
|
get_public 'Depth', opts
|
@@ -111,7 +111,7 @@ module Kraken
|
|
111
111
|
def add_order(opts={})
|
112
112
|
required_opts = %w{pair, type, ordertype, volume}
|
113
113
|
opts.keys.each do |key|
|
114
|
-
unless required_opts.include?(1)
|
114
|
+
unless required_opts.include?(1)
|
115
115
|
raise "Required options, not given. Input must include #{required_opts}"
|
116
116
|
end
|
117
117
|
end
|
@@ -131,7 +131,7 @@ module Kraken
|
|
131
131
|
|
132
132
|
headers = {
|
133
133
|
'API-Key' => @api_key,
|
134
|
-
'API-Sign' => generate_signature(method, post_data, opts)
|
134
|
+
'API-Sign' => generate_signature(method, post_data, opts)
|
135
135
|
}
|
136
136
|
|
137
137
|
url = @base_uri + url_path(method)
|
@@ -139,8 +139,14 @@ module Kraken
|
|
139
139
|
r['error'].empty? ? r['result'] : r['error']
|
140
140
|
end
|
141
141
|
|
142
|
+
# Generate a 64-bit nonce where the 32 high bits come directly from the current
|
143
|
+
# timestamp and the low 32 bits are pseudorandom. We can't use a pure [P]RNG here
|
144
|
+
# because the Kraken API requires every request within a given session to use a
|
145
|
+
# monotonically increasing nonce value. This approach splits the difference.
|
142
146
|
def nonce
|
143
|
-
Time.now.to_i
|
147
|
+
high_bits = Time.now.to_i << 32
|
148
|
+
low_bits = SecureRandom.random_number(2 ** 32) & 0xffffffff
|
149
|
+
(high_bits | low_bits).to_s
|
144
150
|
end
|
145
151
|
|
146
152
|
def encode_options(opts)
|
@@ -167,6 +173,5 @@ module Kraken
|
|
167
173
|
def url_path(method)
|
168
174
|
'/' + @api_version + '/private/' + method
|
169
175
|
end
|
170
|
-
|
171
176
|
end
|
172
177
|
end
|
data/lib/kraken_ruby/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -2,11 +2,12 @@ require 'kraken_ruby'
|
|
2
2
|
|
3
3
|
describe Kraken::Client do
|
4
4
|
|
5
|
-
# YOU MUST
|
6
|
-
|
5
|
+
# YOU MUST SET ENVIRONMENT VARIABLES KRAKEN_API_KEY AND
|
6
|
+
# KRAKEN_API_SECRET TO TEST PRIVATE DATA QUERIES. PRIVATE
|
7
|
+
# TESTS WILL FAIL OTHERWISE.
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
API_KEY = ENV['KRAKEN_API_KEY']
|
10
|
+
API_SECRET = ENV['KRAKEN_API_SECRET']
|
10
11
|
|
11
12
|
before :each do
|
12
13
|
sleep 0.3 # to prevent rapidly pinging the Kraken server
|
@@ -52,10 +53,16 @@ describe Kraken::Client do
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
context "private data" do # More tests to come
|
56
|
+
context "private data" do # More tests to come
|
56
57
|
it "gets the user's balance" do
|
57
58
|
expect(kraken.balance).to be_instance_of(Hash)
|
58
59
|
end
|
60
|
+
|
61
|
+
it "uses a 64 bit nonce" do
|
62
|
+
nonce = kraken.send :nonce
|
63
|
+
expect(nonce.to_i.size).to eq(8)
|
64
|
+
expect(nonce.to_i).to be_instance_of(Bignum)
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
|
-
end
|
68
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kraken_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Leishman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|