luno 0.2.4 → 0.2.8

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: 66c33cc060c525bafdeb139b9eaf3daedd7feea98d87ba478bde609be1302e2e
4
- data.tar.gz: 2e520a35c126e1984e7472afbf1081f704e3d4b1b47abec433022bad0550f1e9
3
+ metadata.gz: 741cc36b2b40ba8f2113f2fb41654b00a517898c6f79edfe070b279c36246994
4
+ data.tar.gz: 113aaa7447c3320afde4d7c5a0d8a1a1c248efbfe0de7f27d228fe40a13e42f8
5
5
  SHA512:
6
- metadata.gz: c6046d8b1032769839eca0f4c6ef5fcffa9071ce9430530771a52400a9136f97a3c3b3fc541f4cb771f7157a0b264a8e91205e7ebc71e43de07b99a3ff4d5c51
7
- data.tar.gz: f4447d3fbd30f63944a2230e5cb34685b3c364a3b4299c6e03388372184f3a89188a7396bd76b3aa8a1b8fc52f760a45bf27ac3e8544368d26fa486e89298c20
6
+ metadata.gz: 89633b98f67bf14edd4fa9005f740a8cf0d159c32586001cbe338d7c8407bee57b4d2c9211295881eaa6a136b190ad5dde037e79059908ab905f1deeae60cc59
7
+ data.tar.gz: 7d07c10654c48ac214ea9026143dfa55c63e993823a79e0ab8675b72f46f3272cc2cd755eeccd1f98831520e82e56b2ed67ccf94d126a0216b6897bef08f61b1
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- luno (0.2.3)
5
- active_attr (~> 0.15)
6
- httparty (~> 0.18)
7
- nokogiri (~> 1.11.2)
4
+ luno (0.2.7)
5
+ active_attr (~> 0.15.3)
6
+ httparty (~> 0.20.0)
7
+ nokogiri (~> 1.12.5)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -67,7 +67,7 @@ GEM
67
67
  ruby-progressbar
68
68
  mocha (1.11.2)
69
69
  multi_xml (0.6.0)
70
- nokogiri (1.11.7-arm64-darwin)
70
+ nokogiri (1.12.5-arm64-darwin)
71
71
  racc (~> 1.4)
72
72
  pry (0.14.1)
73
73
  coderay (~> 1.1)
data/lib/luno/client.rb CHANGED
@@ -22,7 +22,7 @@ module Luno
22
22
 
23
23
  attr_reader :key, :secret, :base_path, :port
24
24
 
25
- def initialize(key:, secret:, base_path: 'https://api.mybitx.com/api/1', port: 80)
25
+ def initialize(key:, secret:, base_path: 'https://api.luno.com/api/1', port: 80)
26
26
  @key = key
27
27
  @secret = secret
28
28
  @base_path = base_path
@@ -12,6 +12,7 @@ module Luno
12
12
  ZMW: 'Zambian Kwacha'
13
13
  }
14
14
 
15
+ # TODO: Update, see: https://www.luno.com/en/countries
15
16
  CURRENCY_PAIRS = [
16
17
  'XBTEUR',
17
18
  'XBTZAR',
@@ -67,4 +68,4 @@ module Luno
67
68
  API_RATE_LIMIT = 5 # per second per ip
68
69
  API_BURST_RATE_LIMIT = 25 # per second per ip
69
70
  end
70
- end
71
+ end
data/lib/luno/markets.rb CHANGED
@@ -4,5 +4,15 @@ module Luno
4
4
  path = "orderbook_top?pair=#{pair}"
5
5
  unauthorised_and_send(http_method: :get, path: path)
6
6
  end
7
+
8
+ def list_ticker_for_pair(pair:)
9
+ path = 'ticker'
10
+ authorise_and_send(http_method: :get, path: path, params: { pair: pair })
11
+ end
12
+
13
+ def list_tickets_for_all_pairs
14
+ path = 'tickers'
15
+ authorise_and_send(http_method: :get, path: path)
16
+ end
7
17
  end
8
- end
18
+ end
data/lib/luno/orders.rb CHANGED
@@ -1,5 +1,91 @@
1
1
  module Luno
2
2
  module Orders
3
+ def get_fee_information(maker:, taker:)
4
+ path = "fee_info"
5
+ pair = "#{maker}#{taker}".upcase
3
6
 
7
+ # TODO: Validate pair from constants
8
+ authorise_and_send(http_method: :get, path: path, params: { pair: pair })
9
+ end
10
+
11
+ def list_orders
12
+ path = "list_orders"
13
+ authorise_and_send(http_method: :get, path: path)
14
+ end
15
+
16
+ def list_trades
17
+ path = "list_trades"
18
+ authorise_and_send(http_method: :get, path: path)
19
+ end
20
+
21
+ # TYPE = "BUY" "SELL"
22
+ def create_market_order(
23
+ pair:,
24
+ type:,
25
+ counter_volume: nil, # how much currency to use for a BUY order
26
+ base_volume: nil, # how much crypto to use for a SELL order
27
+ base_account_id: ,
28
+ counter_account_id: ,
29
+ ttl: 10000,
30
+ client_order_id: nil)
31
+
32
+ # TODO: Raise exception if counter_volume and base_volume are both nil
33
+ path = 'marketorder'
34
+
35
+ params = {
36
+ pair: pair,
37
+ type: type,
38
+ base_account_id: base_account_id,
39
+ counter_account_id: counter_account_id,
40
+ ttl: ttl
41
+ }
42
+
43
+ params.merge({ counter_volume: counter_volume }) if counter_volume
44
+ params.merge({ base_volume: base_volume }) if base_volume
45
+ params.merge({ client_order_id: client_order_id }) if client_order_id
46
+
47
+ authorise_and_send(http_method: :post, path: path, params: params)
48
+ end
49
+
50
+ # Currency pair trade
51
+ # Type = "BID" or "ASK"
52
+ # stop_direction: "BELOW" "ABOVE" "RELATIVE_LAST_TRADE"
53
+ # TODO: Figure out
54
+ def create_limit_order(
55
+ pair:,
56
+ type:,
57
+ volume:,
58
+ price:,
59
+ post_only: nil,
60
+ stop_price: nil,
61
+ stop_direction: nil,
62
+ base_account_id: nil,
63
+ counter_account_id: nil,
64
+ ttl: 10000,
65
+ client_order_id: nil)
66
+ path = 'postorder'
67
+
68
+ params = {
69
+ pair: pair,
70
+ type: type,
71
+ volume: volume,
72
+ price: price,
73
+ ttl: ttl
74
+ }
75
+
76
+ params.merge({ post_only: post_only }) if post_only
77
+ params.merge({ stop_price: stop_price }) if stop_price
78
+ params.merge({ stop_direction: stop_direction }) if stop_direction
79
+ params.merge({ base_account_id: base_account_id }) if base_account_id
80
+ params.merge({ counter_account_id: counter_account_id }) if counter_account_id
81
+ params.merge({ client_order_id: client_order_id }) if client_order_id
82
+
83
+ authorise_and_send(http_method: :post, path: path, params: params)
84
+ end
85
+
86
+ def cancel_order(order_id:)
87
+ path = 'stoporder'
88
+ authorise_and_send(http_method: :post, path: path, params: { order_id: order_id })
89
+ end
4
90
  end
5
- end
91
+ end
@@ -6,7 +6,7 @@ module Luno
6
6
  COUNTRY_ENDPOINT = 'https://www.luno.com/en/countries'
7
7
  DOCUMENTATION_ENDPOINT = 'https://www.luno.com/en/developers/api'
8
8
 
9
- def ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/'])
9
+ def ping(limit: 4, paths: ['https://www.luno.com/', 'https://api.mybitx.com/api/1/', 'https://api.luno.com/api/1'])
10
10
  endpoint_metrics = paths.map do |path|
11
11
  responses = []
12
12
 
@@ -130,4 +130,4 @@ module Luno
130
130
  false
131
131
  end
132
132
  end
133
- end
133
+ end
data/lib/luno/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Luno
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.8"
3
3
  end
data/luno.gemspec CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "httparty", "~> 0.18"
26
- spec.add_dependency "active_attr", "~> 0.15"
27
- spec.add_dependency "nokogiri", "~> 1.11.2"
25
+ spec.add_dependency "httparty", "~> 0.20.0"
26
+ spec.add_dependency "active_attr", "~> 0.15.3"
27
+ spec.add_dependency "nokogiri", "~> 1.12.5"
28
28
 
29
29
  # Development dependancies
30
30
  spec.add_development_dependency "bundler", "~> 2.2.22"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-09 00:00:00.000000000 Z
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: 0.20.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.18'
26
+ version: 0.20.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active_attr
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.15'
33
+ version: 0.15.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.15'
40
+ version: 0.15.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.11.2
47
+ version: 1.12.5
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.11.2
54
+ version: 1.12.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement