honeymaker 0.12.6-aarch64-linux → 0.12.9-aarch64-linux

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: facaf702a43fc739fe970a71f72017dd240617a8938a53934adb892c968f91cf
4
- data.tar.gz: f7076b3470b45e3250f5794894f8e7e6a93cbcf034c76a67e117eea52649e5d1
3
+ metadata.gz: 901d607f1242d28df9edabb0c220fad7a1baadbacb4fb49a021ead29e3ce53d7
4
+ data.tar.gz: 5ab4a1eccae21eadffe7b7f6bb5816ace139e8516747c473be88668f1a08f260
5
5
  SHA512:
6
- metadata.gz: 8b19a598c52226ea8b503c9b887e0d091cc387937799475af8b65473907c8ce3e5546126cdaa73f1c0610d6c5bcf36f46f181c190a01b14e9c7f8c85d297a637
7
- data.tar.gz: 7363a8ca3f95e42abd6dbb6584db23bcb80c6dc2872067e23a930c75d51ff80f737df96a50ec01547051591a4a2725b137d56b5690c0a9f54fe496070180856a
6
+ metadata.gz: 6d72cf531cd7661ecd4a92f2eb1ee2b9538ba1d4d47692d51ee77c47df07bec45f4b5be44ebed08328f53780efb1593d7b6dccf702df4eec97d576020c03c639
7
+ data.tar.gz: 7164cdfb8945963d1020cd9f45cf78c9ed96e0a0f6750f866f472b95a060cf32794e4dce27866f3de1e7b49a2d4f3d78f1e8ecc3c4605393bd80435f3a2a772c
@@ -79,8 +79,8 @@ jobs:
79
79
  - { os: ubuntu-24.04-arm, platform: aarch64-linux, ruby: "4.0" }
80
80
  - { os: macos-15-intel, platform: x86_64-darwin, ruby: "3.4" }
81
81
  - { os: macos-15-intel, platform: x86_64-darwin, ruby: "4.0" }
82
- - { os: macos-14, platform: arm64-darwin, ruby: "3.4" }
83
- - { os: macos-14, platform: arm64-darwin, ruby: "4.0" }
82
+ - { os: macos-15, platform: arm64-darwin, ruby: "3.4" }
83
+ - { os: macos-15, platform: arm64-darwin, ruby: "4.0" }
84
84
  - { os: windows-latest, platform: x64-mingw-ucrt, ruby: "3.4" }
85
85
  - { os: windows-latest, platform: x64-mingw-ucrt, ruby: "4.0" }
86
86
  runs-on: ${{ matrix.os }}
@@ -14,7 +14,7 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- os: [ubuntu-latest, macos-14]
17
+ os: [ubuntu-latest, macos-15]
18
18
  ruby: ["3.4", "4.0"]
19
19
  runs-on: ${{ matrix.os }}
20
20
  steps:
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Honeymaker
4
+ module Exchanges
5
+ class Okx < Exchange
6
+ BASE_URL = "https://openapi.okx.com"
7
+
8
+ def get_tickers_info
9
+ with_rescue do
10
+ response = connection.get("/api/v5/public/instruments") do |req|
11
+ req.params = { instType: "SPOT" }
12
+ end
13
+
14
+ okx_data(response).filter_map do |product|
15
+ lot = step_of(product["lotSz"])
16
+ tick = step_of(product["tickSz"])
17
+ base = product["baseCcy"].to_s
18
+ quote = product["quoteCcy"].to_s
19
+ next if base.empty? || quote.empty?
20
+
21
+ {
22
+ ticker: product["instId"],
23
+ base: base,
24
+ quote: quote,
25
+ # minSz is in base; OKX has no notional floor for spot.
26
+ minimum_base_size: product["minSz"]&.to_s,
27
+ minimum_quote_size: "0",
28
+ maximum_base_size: product["maxLmtSz"]&.to_s,
29
+ maximum_quote_size: nil,
30
+ base_decimals: step_decimals(lot),
31
+ quote_decimals: step_decimals(tick),
32
+ price_decimals: step_decimals(tick),
33
+ available: true,
34
+ trading_enabled: product["state"] == "live" && decimal_step?(lot) && decimal_step?(tick)
35
+ }
36
+ end
37
+ end
38
+ end
39
+
40
+ def get_bid_ask(symbol)
41
+ with_rescue do
42
+ response = connection.get("/api/v5/market/ticker") do |req|
43
+ req.params = { instId: symbol }
44
+ end
45
+
46
+ data = okx_data(response).first or raise "OKX has no ticker for #{symbol}"
47
+ {
48
+ bid: BigDecimal(data["bidPx"]),
49
+ ask: BigDecimal(data["askPx"])
50
+ }
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ # OKX answers some errors with HTTP 200 and a nonzero `code` (50011 rate limit, with empty `data`): a failure, not
57
+ # an empty catalogue.
58
+ def okx_data(response)
59
+ body = response.body
60
+ raise "OKX API error #{body["code"]}: #{body["msg"]}" unless body["code"].to_s == "0"
61
+
62
+ body["data"]
63
+ end
64
+
65
+ # A step as a finite positive number, read in any notation ("0.00000001", "1e-8"); else nil. A row with such a step
66
+ # has no decimals (data-api skips it) and does not trade, and the rest of the catalogue still reads.
67
+ def step_of(raw)
68
+ step = BigDecimal(raw.to_s)
69
+ step if step.finite? && step.positive?
70
+ rescue ArgumentError, TypeError, FloatDomainError
71
+ nil
72
+ end
73
+
74
+ def step_decimals(step)
75
+ step&.scale
76
+ end
77
+
78
+ # Decimal places express only a step of 10^-n (n >= 0): a pair stepping by 0.05 or 10 is listed, not tradable.
79
+ def decimal_step?(step)
80
+ !step.nil? && step == BigDecimal("1e-#{step_decimals(step)}")
81
+ end
82
+
83
+ def connection
84
+ @connection ||= build_connection(BASE_URL, content_type_match: //)
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Honeymaker
4
- VERSION = "0.12.6"
4
+ VERSION = "0.12.9"
5
5
  end
data/lib/honeymaker.rb CHANGED
@@ -38,6 +38,7 @@ require_relative "honeymaker/exchanges/kucoin"
38
38
  require_relative "honeymaker/exchanges/hyperliquid"
39
39
  require_relative "honeymaker/exchanges/bingx"
40
40
  require_relative "honeymaker/exchanges/bitrue"
41
+ require_relative "honeymaker/exchanges/okx"
41
42
 
42
43
  if Honeymaker::Native.enabled?("kraken")
43
44
  Honeymaker::Native.load! # fail at boot, not at the first order
@@ -60,7 +61,8 @@ module Honeymaker
60
61
  "kucoin" => Exchanges::Kucoin,
61
62
  "hyperliquid" => Exchanges::Hyperliquid,
62
63
  "bingx" => Exchanges::BingX,
63
- "bitrue" => Exchanges::Bitrue
64
+ "bitrue" => Exchanges::Bitrue,
65
+ "okx" => Exchanges::Okx
64
66
  }.freeze
65
67
 
66
68
  CLIENTS = {
@@ -0,0 +1,16 @@
1
+ {
2
+ "code": "0",
3
+ "msg": "",
4
+ "data": [
5
+ {"instType": "SPOT", "instId": "BTC-USDT", "baseCcy": "BTC", "quoteCcy": "USDT", "state": "live",
6
+ "lotSz": "0.00000001", "minSz": "0.00001", "tickSz": "0.1", "maxLmtSz": "9999999999", "maxMktSz": "1000000"},
7
+ {"instType": "SPOT", "instId": "ETH-EUR", "baseCcy": "ETH", "quoteCcy": "EUR", "state": "suspend",
8
+ "lotSz": "0.000001", "minSz": "0.0001", "tickSz": "0.01", "maxLmtSz": "1000000", "maxMktSz": "1000000"},
9
+ {"instType": "SPOT", "instId": "XYZ-USDT", "baseCcy": "XYZ", "quoteCcy": "USDT", "state": "live",
10
+ "lotSz": "1", "minSz": "10", "tickSz": "0.05", "maxLmtSz": "1000000", "maxMktSz": "1000000"},
11
+ {"instType": "SPOT", "instId": "BROKEN", "baseCcy": "", "quoteCcy": "", "state": "live",
12
+ "lotSz": "1", "minSz": "1", "tickSz": "1", "maxLmtSz": "1", "maxMktSz": "1"},
13
+ {"instType": "SPOT", "instId": "TEN-USDT", "baseCcy": "TEN", "quoteCcy": "USDT", "state": "live",
14
+ "lotSz": "10", "minSz": "10", "tickSz": "0.0010", "maxLmtSz": "1000000", "maxMktSz": "1000000"}
15
+ ]
16
+ }
@@ -0,0 +1 @@
1
+ {"code": "0", "msg": "", "data": [{"instId": "BTC-USDT", "last": "67124", "askPx": "67125.6", "bidPx": "67123.4"}]}
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ # Fixtures follow the shapes in OKX's v5 docs (public instruments, market ticker).
6
+ class Honeymaker::Exchanges::OkxTest < Minitest::Test
7
+ include FixtureHelper
8
+
9
+ def setup
10
+ @exchange = Honeymaker::Exchanges::Okx.new
11
+ end
12
+
13
+ def test_get_tickers_info_parses_response
14
+ stub_connection(load_fixture("okx_instruments.json"))
15
+
16
+ result = @exchange.get_tickers_info
17
+
18
+ assert result.success?
19
+ assert_equal %w[BTC-USDT ETH-EUR XYZ-USDT TEN-USDT], result.data.map { |t| t[:ticker] }
20
+
21
+ btc = result.data.first
22
+ assert_equal "BTC", btc[:base]
23
+ assert_equal "USDT", btc[:quote]
24
+ assert_equal "0.00001", btc[:minimum_base_size]
25
+ assert_equal "0", btc[:minimum_quote_size]
26
+ assert_equal "9999999999", btc[:maximum_base_size]
27
+ assert_equal 8, btc[:base_decimals]
28
+ assert_equal 1, btc[:quote_decimals]
29
+ assert_equal 1, btc[:price_decimals]
30
+ assert btc[:available]
31
+ assert btc[:trading_enabled]
32
+ end
33
+
34
+ def test_only_live_instruments_trade
35
+ stub_connection(load_fixture("okx_instruments.json"))
36
+
37
+ refute @exchange.get_tickers_info.data.find { |t| t[:ticker] == "ETH-EUR" }[:trading_enabled]
38
+ end
39
+
40
+ def test_a_step_decimals_cannot_express_does_not_trade
41
+ stub_connection(load_fixture("okx_instruments.json"))
42
+
43
+ xyz = @exchange.get_tickers_info.data.find { |t| t[:ticker] == "XYZ-USDT" }
44
+ refute xyz[:trading_enabled]
45
+ assert_equal 0, xyz[:base_decimals]
46
+
47
+ # A lot of 10 is a power of ten, but zero decimal places would still allow 11.
48
+ ten = @exchange.get_tickers_info.data.find { |t| t[:ticker] == "TEN-USDT" }
49
+ refute ten[:trading_enabled]
50
+ end
51
+
52
+ def test_trailing_zeros_still_read_as_a_decimal_step
53
+ stub_connection({ "code" => "0", "data" => [{ "instId" => "A-B", "baseCcy" => "A", "quoteCcy" => "B", "state" => "live",
54
+ "lotSz" => "0.0100", "tickSz" => "1.0", "minSz" => "1" }] })
55
+
56
+ a = @exchange.get_tickers_info.data.first
57
+ assert a[:trading_enabled]
58
+ assert_equal 2, a[:base_decimals]
59
+ assert_equal 0, a[:price_decimals]
60
+ end
61
+
62
+ def test_get_bid_ask_parses_response
63
+ stub_connection(load_fixture("okx_ticker.json"))
64
+
65
+ result = @exchange.get_bid_ask("BTC-USDT")
66
+
67
+ assert result.success?
68
+ assert_equal BigDecimal("67123.4"), result.data[:bid]
69
+ assert_equal BigDecimal("67125.6"), result.data[:ask]
70
+ end
71
+
72
+ def test_an_error_envelope_fails_instead_of_reading_as_an_empty_catalogue
73
+ stub_connection({ "code" => "50011", "msg" => "Too Many Requests", "data" => [] })
74
+
75
+ result = @exchange.get_tickers_info
76
+ assert result.failure?
77
+ assert_equal ["OKX API error 50011: Too Many Requests"], result.errors
78
+
79
+ assert_equal ["OKX API error 50011: Too Many Requests"], @exchange.get_bid_ask("BTC-USDT").errors
80
+ end
81
+
82
+ def test_an_unknown_instrument_has_no_bid_ask
83
+ stub_connection({ "code" => "0", "msg" => "", "data" => [] })
84
+
85
+ assert_equal ["OKX has no ticker for NOPE-USDT"], @exchange.get_bid_ask("NOPE-USDT").errors
86
+ end
87
+
88
+ def test_an_unreadable_step_disables_its_row_only
89
+ row = ->(id, lot) { { "instId" => id, "baseCcy" => id, "quoteCcy" => "USDT", "state" => "live", "lotSz" => lot, "tickSz" => "0.1", "minSz" => "1" } }
90
+ stub_connection({ "code" => "0", "data" => [row.("BLANK", ""), row.("DOT", "."), row.("NAN", "NaN"), row.("INF", "Infinity"), row.("EXP", "1e-8")] })
91
+
92
+ result = @exchange.get_tickers_info
93
+ assert result.success?
94
+ by = result.data.to_h { |t| [t[:ticker], t] }
95
+ %w[BLANK DOT NAN INF].each do |id|
96
+ assert_nil by[id][:base_decimals], id
97
+ refute by[id][:trading_enabled], id
98
+ end
99
+ assert by["EXP"][:trading_enabled]
100
+ assert_equal 8, by["EXP"][:base_decimals]
101
+ end
102
+
103
+ private
104
+
105
+ def stub_connection(body)
106
+ response = stub(body: body)
107
+ connection = stub
108
+ connection.stubs(:get).returns(response)
109
+ @exchange.instance_variable_set(:@connection, connection)
110
+ end
111
+ end
@@ -22,6 +22,6 @@ class HoneymakerTest < Minitest::Test
22
22
  end
23
23
 
24
24
  def test_all_exchanges_registered
25
- assert_equal 13, Honeymaker::EXCHANGES.size
25
+ assert_equal 14, Honeymaker::EXCHANGES.size
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeymaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.6
4
+ version: 0.12.9
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Deltabadger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-23 00:00:00.000000000 Z
11
+ date: 2026-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -131,6 +131,7 @@ files:
131
131
  - lib/honeymaker/exchanges/kraken.rb
132
132
  - lib/honeymaker/exchanges/kucoin.rb
133
133
  - lib/honeymaker/exchanges/mexc.rb
134
+ - lib/honeymaker/exchanges/okx.rb
134
135
  - lib/honeymaker/floors.rb
135
136
  - lib/honeymaker/native.rb
136
137
  - lib/honeymaker/native/kraken.rb
@@ -172,6 +173,8 @@ files:
172
173
  - test/fixtures/kucoin_symbols.json
173
174
  - test/fixtures/mexc_book_ticker.json
174
175
  - test/fixtures/mexc_exchange_info.json
176
+ - test/fixtures/okx_instruments.json
177
+ - test/fixtures/okx_ticker.json
175
178
  - test/honeymaker/client_test.rb
176
179
  - test/honeymaker/clients/binance_client_test.rb
177
180
  - test/honeymaker/clients/binance_us_client_test.rb
@@ -205,6 +208,7 @@ files:
205
208
  - test/honeymaker/exchanges/kraken_test.rb
206
209
  - test/honeymaker/exchanges/kucoin_test.rb
207
210
  - test/honeymaker/exchanges/mexc_test.rb
211
+ - test/honeymaker/exchanges/okx_test.rb
208
212
  - test/honeymaker/floors_test.rb
209
213
  - test/honeymaker/honeymaker_test.rb
210
214
  - test/honeymaker/result_test.rb