honeymaker 0.11.3 → 0.11.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a33b3f43a40a17e8f8655683b4349901db4222a6ec5db4d4a8f82585f0dacdd1
4
- data.tar.gz: dde27e04419cb12327dfee7c3ecf69c61f36ddf28c1e9b7e2872c785a726106b
3
+ metadata.gz: 2367ab9c6994586eb565f383f4b897d7a7bdcfb5cf68c0593da80f6b4d4b0497
4
+ data.tar.gz: 585589c4bc524266bed905b142913b6072e5ff8824602cdf5691e6ac2046bf39
5
5
  SHA512:
6
- metadata.gz: f6b7a44553dbc9a413c6df817f4ffbff0f263c077f163e10bce5389d7aba60c108d956c68f9f713ac2b7fef69c699540e3759a1fb5470162146d746ace18a624
7
- data.tar.gz: e53261fd199b590b1d23318d5b2689a59a5b6dc2a402e09b6fb3d63010b1bbb79281e4b3cafd8401964315e51f8a7fbe39e45aa250217e0ed9851c35bc7c494d
6
+ metadata.gz: b4d5824b776181fff4494c1f4fe76e8ff46e21faf198cb23a894ea836fcfb4bc4f3eb8c0eec2315cc072a065ce9de5b4fd9e34d50f52390368069c5fbd091b13
7
+ data.tar.gz: f63b8235706bc5257bc1710939fc68f315316650966476a55ff4a25c1de35bb3035f42f54a94105fd1e446bcb4c6e684b65b2418bb16db68f7310c5bdb17dd16
@@ -65,9 +65,13 @@ module Honeymaker
65
65
  post_private("/0/private/CancelOrder", { nonce: nonce, txid: txid, cl_ord_id: cl_ord_id })
66
66
  end
67
67
 
68
- def get_tradable_asset_pairs(pairs: nil, info: nil, country_code: nil)
68
+ # aclass_base: "all" also returns tokenized equities (xStocks); omitted, Kraken serves only the
69
+ # "currency" class. Note the asset-class parameter is spelled differently per endpoint —
70
+ # aclass_base here, asset_class on Ticker/OHLC/Depth/AddOrder.
71
+ def get_tradable_asset_pairs(pairs: nil, info: nil, country_code: nil, aclass_base: nil)
69
72
  get_public("/0/public/AssetPairs", {
70
- pair: pairs ? pairs.join(",") : nil, info: info, country_code: country_code
73
+ pair: pairs ? pairs.join(",") : nil, info: info, country_code: country_code,
74
+ aclass_base: aclass_base
71
75
  })
72
76
  end
73
77
 
@@ -48,15 +48,25 @@ module Honeymaker
48
48
 
49
49
  def get_tickers_info
50
50
  with_rescue do
51
- response = connection.get("/0/public/AssetPairs")
51
+ # aclass_base=all, not a bare call: the default response carries only the "currency" class,
52
+ # so Kraken tokenized equities (xStocks) are invisible without it. One request returns both
53
+ # classes and they are disjoint.
54
+ response = connection.get("/0/public/AssetPairs", { aclass_base: "all" })
52
55
 
53
56
  error = response.body["error"]
54
57
  return Result::Failure.new(*error) if error.is_a?(Array) && error.any?
55
58
 
56
- response.body["result"].filter_map do |_, info|
59
+ # Every tokenized pair is returned TWICE - once under an SPV key (NVDASPVUSD), once under
60
+ # the x key (NVDAxUSD) - sharing one wsname and altname. Currency pairs are never
61
+ # duplicated, so keying by wsname collapses exactly the aliases and nothing else.
62
+ deduped = response.body["result"].each_with_object({}) do |(_, info), acc|
57
63
  wsname = info["wsname"]
58
- next unless wsname && !wsname.empty?
64
+ next if wsname.nil? || wsname.empty?
59
65
 
66
+ acc[wsname] ||= info
67
+ end
68
+
69
+ deduped.filter_map do |wsname, info|
60
70
  base, quote = wsname.split("/")
61
71
 
62
72
  {
@@ -71,7 +81,15 @@ module Honeymaker
71
81
  quote_decimals: info["cost_decimals"],
72
82
  price_decimals: info["pair_decimals"],
73
83
  available: true,
74
- trading_enabled: info.key?("status") ? info["status"] == "online" : true
84
+ # Tokenized equities are listed but never tradable through this client: AddOrder needs
85
+ # an asset_class parameter it does not send, and Kraken closes the tokenized order
86
+ # books to EEA clients over the API regardless of that. Listing them anyway is what
87
+ # lets a holding be resolved and valued.
88
+ trading_enabled: if info["aclass_base"] == "tokenized_asset"
89
+ false
90
+ else
91
+ info.key?("status") ? info["status"] == "online" : true
92
+ end
75
93
  }
76
94
  end
77
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Honeymaker
4
- VERSION = "0.11.3"
4
+ VERSION = "0.11.4"
5
5
  end
@@ -10,7 +10,34 @@
10
10
  "cost_decimals": 5,
11
11
  "pair_decimals": 1,
12
12
  "ordermin": "0.00010000",
13
- "costmin": "0.50000"
13
+ "costmin": "0.50000",
14
+ "aclass_base": "currency"
15
+ },
16
+ "NVDAxUSD": {
17
+ "altname": "NVDAxUSD",
18
+ "wsname": "NVDAx/USD",
19
+ "aclass_base": "tokenized_asset",
20
+ "base": "NVDAx",
21
+ "quote": "ZUSD",
22
+ "lot_decimals": 8,
23
+ "cost_decimals": 5,
24
+ "pair_decimals": 2,
25
+ "ordermin": "0.00000001",
26
+ "costmin": "0.5",
27
+ "status": "online"
28
+ },
29
+ "NVDASPVUSD": {
30
+ "altname": "NVDAxUSD",
31
+ "wsname": "NVDAx/USD",
32
+ "aclass_base": "tokenized_asset",
33
+ "base": "NVDAx",
34
+ "quote": "ZUSD",
35
+ "lot_decimals": 8,
36
+ "cost_decimals": 5,
37
+ "pair_decimals": 2,
38
+ "ordermin": "0.00000001",
39
+ "costmin": "0.5",
40
+ "status": "online"
14
41
  }
15
42
  }
16
43
  }
@@ -22,6 +22,36 @@ class Honeymaker::Clients::KrakenTest < Minitest::Test
22
22
  assert result.data["result"].key?("XBTUSDT")
23
23
  end
24
24
 
25
+ # Without aclass_base Kraken serves only the "currency" class, so tokenized equities are invisible.
26
+ def test_get_tradable_asset_pairs_forwards_aclass_base
27
+ captured = nil
28
+ req = stub("req")
29
+ req.stubs(:url)
30
+ req.stubs(:headers=)
31
+ req.stubs(:params=).with { |p| captured = p; true }
32
+ connection = stub
33
+ connection.stubs(:get).yields(req).returns(stub(body: { "error" => [], "result" => {} }))
34
+ @client.instance_variable_set(:@connection, connection)
35
+
36
+ assert @client.get_tradable_asset_pairs(aclass_base: "all").success?
37
+ assert_equal "all", captured[:aclass_base]
38
+ end
39
+
40
+ def test_get_tradable_asset_pairs_omits_aclass_base_when_not_asked
41
+ captured = nil
42
+ req = stub("req")
43
+ req.stubs(:url)
44
+ req.stubs(:headers=)
45
+ req.stubs(:params=).with { |p| captured = p; true }
46
+ connection = stub
47
+ connection.stubs(:get).yields(req).returns(stub(body: { "error" => [], "result" => {} }))
48
+ @client.instance_variable_set(:@connection, connection)
49
+
50
+ @client.get_tradable_asset_pairs
51
+
52
+ refute captured.key?(:aclass_base), "params are compacted, so nil must not be sent"
53
+ end
54
+
25
55
  def test_get_ticker_information
26
56
  stub_connection(:get, { "error" => [], "result" => { "XBTUSDT" => { "a" => ["50000"] } } })
27
57
  result = @client.get_ticker_information(pair: "XBTUSDT")
@@ -9,6 +9,45 @@ class Honeymaker::Exchanges::KrakenTest < Minitest::Test
9
9
  @exchange = Honeymaker::Exchanges::Kraken.new
10
10
  end
11
11
 
12
+ # Tokenized equities (xStocks) live behind aclass_base and are invisible to a bare AssetPairs call.
13
+ # aclass_base=all returns currency + tokenized in one request; the two sets are disjoint.
14
+ def test_get_tickers_info_requests_every_asset_class
15
+ response = stub(body: load_fixture("kraken_asset_pairs.json"))
16
+ connection = stub
17
+ connection.expects(:get).with("/0/public/AssetPairs", { aclass_base: "all" }).returns(response)
18
+ @exchange.instance_variable_set(:@connection, connection)
19
+
20
+ assert @exchange.get_tickers_info.success?
21
+ end
22
+
23
+ # Kraken returns every tokenized pair TWICE - once under an SPV key, once under the x key - with
24
+ # one shared wsname and altname. Only tokenized pairs are double-keyed; currency pairs never are.
25
+ # Mapping the raw response would ingest each of them twice.
26
+ def test_get_tickers_info_deduplicates_the_spv_alias
27
+ body = load_fixture("kraken_asset_pairs.json")
28
+ stub_request(body)
29
+
30
+ result = @exchange.get_tickers_info
31
+
32
+ nvda = result.data.select { |t| t[:base] == "NVDAx" }
33
+ assert_equal 1, nvda.size, "NVDAxUSD and NVDASPVUSD are one pair"
34
+ assert_equal "NVDAxUSD", nvda.first[:ticker]
35
+ end
36
+
37
+ # Listed, so a holding can be resolved and valued; not tradable, because AddOrder needs an
38
+ # asset_class parameter this client does not send, and Kraken closes the tokenized order books to
39
+ # EEA clients over the API regardless.
40
+ def test_tokenized_pairs_are_listed_but_not_trading_enabled
41
+ body = load_fixture("kraken_asset_pairs.json")
42
+ stub_request(body)
43
+
44
+ nvda = @exchange.get_tickers_info.data.find { |t| t[:base] == "NVDAx" }
45
+
46
+ assert_equal "online", body["result"]["NVDAxUSD"]["status"]
47
+ assert nvda[:available], "listed, so balances resolve"
48
+ refute nvda[:trading_enabled], "we cannot place these orders"
49
+ end
50
+
12
51
  def test_get_tickers_info_parses_response
13
52
  body = load_fixture("kraken_asset_pairs.json")
14
53
  stub_request(body)
@@ -68,7 +107,9 @@ class Honeymaker::Exchanges::KrakenTest < Minitest::Test
68
107
  result = @exchange.get_tickers_info
69
108
 
70
109
  assert result.success?
71
- assert_empty result.data
110
+ # Asserts the wsname-less pair is dropped, not that the whole response is - the fixture now
111
+ # carries a tokenized pair too.
112
+ refute result.data.any? { |t| t[:ticker] == "XBTUSDT" }
72
113
  end
73
114
 
74
115
  def test_get_tickers_info_uses_real_costmin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeymaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deltabadger