okex-ruby-api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ec2d0c0ee3a810735420175e6dfa11a25c9b5bf37d9ca9c1f1a06386e22990b
4
- data.tar.gz: 917e0911819a63fe5c42ab6159fb5617164fd024c9e172d854dc84efef77bbd5
3
+ metadata.gz: afa60a5ac3bcd6673a4c8baafe0ad83345e177a257a87daf52f6320efd4dddef
4
+ data.tar.gz: e5b6c80f4fd1f9a9916055f74fcc41b724f030760e893b1fb1575d4da7dfe365
5
5
  SHA512:
6
- metadata.gz: 7d1005119c5a496122e0340dda52abd7f23eb2d059811a82e219fabbcccff8a99c3b8f170d7739ad8baa224e0e800054ce26912d0b8cf3312aa2a544e6e74ec7
7
- data.tar.gz: 5d139dba46035e69bbdcd02c685c2a9a7b4faa29485e5ab5f3131d4b4d961f700c2bf56c9f5e6d86152bbe1fc1556a1b5be87592a57b8c810f14ca4333f5ea94
6
+ metadata.gz: e66a83ee46f8231a5dc18f632a908cd293f173b9ea451f5ad2acc7f0f7c54ae558b212451cdc6aae99a749421238a8a21f6c055fd542687ad2cfe78e34ef5d1d
7
+ data.tar.gz: c7b582ecdc31bd71656d4769a3b95a8228b1fc90c670ea99862318e37718284a88af4b1d5c0782bc2e429720e9e4c89b5f997af1da0d7a124eeaf1cfb9bf6a36
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- okex-ruby-api (0.1.0)
4
+ okex-ruby-api (0.2.0)
5
5
  httparty (~> 0.19)
6
6
  openssl (~> 2.2)
7
7
 
data/README.md CHANGED
@@ -23,28 +23,45 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
- ### Futures
26
+ ### Markets
27
27
 
28
- Initialize a futures session:
28
+ Initialize a markets session:
29
29
  ```ruby
30
- futures = OKEX::API::Futures.new
30
+ markets = OKEX::API::Markets.new
31
31
  ```
32
32
 
33
33
  Query for all current futures specs:
34
34
  ```ruby
35
- futures.list
35
+ markets.list(type: :futures)
36
+ ```
37
+
38
+ Query for all current spot specs:
39
+ ```ruby
40
+ markets.list(type: :spot)
36
41
  ```
37
42
 
38
43
  Query for all current futures prices:
39
44
  ```ruby
40
- futures.tickers
45
+ markets.tickers(type: :futures)
46
+ ```
47
+
48
+ Query for all current spot prices:
49
+ ```ruby
50
+ markets.tickers(type: :spot)
41
51
  ```
42
52
 
43
53
  Fetch a single current futures price:
44
54
  ```ruby
45
- futures.ticker('BTC-USDT-220325')
55
+ markets.ticker('BTC-USDT-220325', type: :futures)
46
56
  ```
47
57
 
58
+ Fetch a single current spot price:
59
+ ```ruby
60
+ markets.ticker('BTC-USDT', type: :spot)
61
+ ```
62
+
63
+ > Note: type is optional and defaults to 'spot'.
64
+
48
65
  ## Development
49
66
 
50
67
  After checking out the repo, run `bin/setup` to install dependencies.
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'public'
4
+
5
+ class OKEX::API::Markets < OKEX::API::Public
6
+
7
+ def list(type: :spot)
8
+ raise ArgumentError, "type must be either 'futures' or 'spot'" unless %w(futures spot).include?(type.to_s)
9
+ send_request(:get, "/#{type.to_s}/v3/instruments", {})
10
+ end
11
+
12
+ def tickers(type: :spot)
13
+ raise ArgumentError, "type must be either 'futures' or 'spot'" unless %w(futures spot).include?(type.to_s)
14
+ send_request(:get, "/#{type.to_s}/v3/instruments/ticker", {})
15
+ end
16
+
17
+ def ticker(futures_name, type: :spot)
18
+ raise ArgumentError, "type must be either 'futures' or 'spot'" unless %w(futures spot).include?(type.to_s)
19
+ send_request(:get, "/#{type.to_s}/v3/instruments/#{futures_name}/ticker", {})
20
+ end
21
+
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OKEX
4
4
  module API
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/okex/api.rb CHANGED
@@ -2,4 +2,4 @@
2
2
  require_relative "../ext/base"
3
3
  require_relative "api/version"
4
4
  require_relative "api/config"
5
- require_relative "api/futures"
5
+ require_relative "api/markets"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okex-ruby-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - benrs44
@@ -61,7 +61,7 @@ files:
61
61
  - lib/okex/api.rb
62
62
  - lib/okex/api/base.rb
63
63
  - lib/okex/api/config.rb
64
- - lib/okex/api/futures.rb
64
+ - lib/okex/api/markets.rb
65
65
  - lib/okex/api/private.rb
66
66
  - lib/okex/api/public.rb
67
67
  - lib/okex/api/version.rb
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'public'
4
-
5
- class OKEX::API::Futures < OKEX::API::Public
6
-
7
- def list
8
- send_request(:get, '/futures/v3/instruments', {})
9
- end
10
-
11
- def tickers
12
- send_request(:get, '/futures/v3/instruments/ticker', {})
13
- end
14
-
15
- def ticker(futures_name)
16
- send_request(:get, "/futures/v3/instruments/#{futures_name}/ticker", {})
17
- end
18
-
19
- end