honeymaker 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3263fa7b4c91808f48416df3570c42d21948759fb5190b9fe523671da953ce29
4
- data.tar.gz: ffb885474e57533e933cbeb36d81f6c63586e4b84282322757ebfaef3037b046
3
+ metadata.gz: f4a5dc67259d8ff33eba5584ed8fe9cc59e0f7d62c2d6bf6f794fbe24430bf93
4
+ data.tar.gz: 2115566b5168a2b5588e71292292a010a9f3d88673d127a75a2e71427876994b
5
5
  SHA512:
6
- metadata.gz: 4c76739afb0c6239ae6af0e2292646c43aba16a6ef1abf004ad1df65b9a305a6ca47976517ae5ca01ffa3ca6e1b3889882315ae33e15ef695b2f97b711764f51
7
- data.tar.gz: 4c4c7b51f95757f0ef330c54abdc215dd01bc6dc5242de1c2367b5cbe80188207715b7ab6534cd682b86cf27bc7fed62ae4016bcc46ba94fc89c2b7b88df8104
6
+ metadata.gz: 2cd7119999981ce3e901dbeb2b172f037c0a077d5ee13f902f7fabdf320a336461e35c395eb7bbce07f6e2cc3fc3a35f1c06c691013a3904a8c73df40ce2ff38
7
+ data.tar.gz: c0ebe66c0a2ada2c2fe7cb255df67d2d07f22c17e39e54dd50f5a10185bcc67b5bd5c80a4e1d56bc351942473678399dd924a808aa16809acc47809b82c8d667
data/README.md CHANGED
@@ -8,7 +8,7 @@ Ruby clients for cryptocurrency exchange APIs. Originally extracted from [Deltab
8
8
 
9
9
  ## Supported Exchanges
10
10
 
11
- Binance, Binance US, Kraken, Coinbase, Bybit, KuCoin, Bitget, MEXC, Bitvavo, Gemini, Hyperliquid, BingX, Bitrue, BitMart.
11
+ Binance, Binance US, Kraken, Kraken Futures, Coinbase, Bybit, KuCoin, Bitget, MEXC, Bitvavo, Gemini, Hyperliquid, BingX, Bitrue, BitMart.
12
12
 
13
13
  ## Installation
14
14
 
@@ -90,6 +90,50 @@ if result.success?
90
90
  end
91
91
  ```
92
92
 
93
+ ### Account History (Tax Reporting)
94
+
95
+ History endpoints for margin, futures, staking/earn, and other tax-relevant events:
96
+
97
+ ```ruby
98
+ # Margin
99
+ client.margin_borrow_repay_history(type: "BORROW") # Binance
100
+ client.margin_interest_history # Binance, KuCoin, Bitget
101
+ client.margin_force_liquidation # Binance
102
+
103
+ # Futures
104
+ client.futures_income_history(income_type: "REALIZED_PNL") # Binance USDT-M
105
+ client.coin_futures_income_history # Binance Coin-M
106
+ client.futures_account_bills(product_type: "USDT-FUTURES") # Bitget
107
+ client.futures_income # BingX
108
+
109
+ # Staking / Earn
110
+ client.simple_earn_flexible_rewards # Binance
111
+ client.simple_earn_locked_subscriptions # Binance
112
+ client.earn_yield_history # Bybit
113
+ client.staking_rewards # Gemini
114
+ client.staking_rewards_history # Binance US
115
+
116
+ # Other
117
+ client.universal_transfer_history(type: "MAIN_MARGIN") # Binance
118
+ client.dust_log # Binance
119
+ client.asset_dividend # Binance
120
+ ```
121
+
122
+ Coverage varies by exchange. Kraken's `get_ledgers(type:)` covers margin, staking, and trades in a single endpoint. Coinbase's `list_transactions` covers 30+ event types.
123
+
124
+ ### Kraken Futures
125
+
126
+ Kraken Futures uses separate API keys and a different auth scheme — it's a standalone client:
127
+
128
+ ```ruby
129
+ client = Honeymaker.client("kraken_futures", api_key: "...", api_secret: "...")
130
+
131
+ client.get_accounts # wallet balances, margin, PnL
132
+ client.get_fills # trade fills
133
+ client.get_open_positions # open positions
134
+ client.historical_funding_rates(symbol: "PF_XBTUSD") # funding rate history
135
+ ```
136
+
93
137
  ### Credential Validation
94
138
 
95
139
  ```ruby
@@ -168,6 +168,32 @@ module Honeymaker
168
168
  end
169
169
  end
170
170
 
171
+ def test_new_order(symbol:, side:, type:, time_in_force: nil, quantity: nil, quote_order_qty: nil,
172
+ price: nil, new_client_order_id: nil, strategy_id: nil, strategy_type: nil,
173
+ stop_price: nil, trailing_delta: nil, iceberg_qty: nil, new_order_resp_type: nil,
174
+ self_trade_prevention_mode: nil, recv_window: 5000, compute_commission_rates: false)
175
+ with_rescue do
176
+ response = connection.post do |req|
177
+ req.url "/api/v3/order/test"
178
+ req.headers = headers
179
+ req.params = {
180
+ symbol: symbol, side: side, type: type,
181
+ timeInForce: time_in_force, quantity: quantity,
182
+ quoteOrderQty: quote_order_qty, price: price,
183
+ newClientOrderId: new_client_order_id,
184
+ strategyId: strategy_id, strategyType: strategy_type,
185
+ stopPrice: stop_price, trailingDelta: trailing_delta,
186
+ icebergQty: iceberg_qty, newOrderRespType: new_order_resp_type,
187
+ selfTradePreventionMode: self_trade_prevention_mode,
188
+ computeCommissionRates: compute_commission_rates,
189
+ recvWindow: recv_window, timestamp: timestamp_ms
190
+ }.compact
191
+ req.params[:signature] = sign_params(req.params)
192
+ end
193
+ response.body
194
+ end
195
+ end
196
+
171
197
  def cancel_order(symbol:, order_id: nil, orig_client_order_id: nil, new_client_order_id: nil,
172
198
  cancel_restrictions: nil, recv_window: 5000)
173
199
  with_rescue do
@@ -77,6 +77,10 @@ module Honeymaker
77
77
  })
78
78
  end
79
79
 
80
+ def get_all_coins_info
81
+ get_signed("/openApi/wallets/v1/capital/config/getall")
82
+ end
83
+
80
84
  def get_trade_fills(symbol: nil, order_id: nil, start_time: nil, end_time: nil, from_id: nil, limit: nil)
81
85
  get_signed("/openApi/spot/v1/trade/fills", {
82
86
  symbol: symbol, orderId: order_id,
@@ -17,6 +17,10 @@ module Honeymaker
17
17
  get_public("/spot/v1/symbols/details")
18
18
  end
19
19
 
20
+ def get_currencies
21
+ get_public("/account/v1/currencies")
22
+ end
23
+
20
24
  def get_ticker(symbol: nil)
21
25
  get_public("/spot/quotation/v3/ticker", { symbol: symbol })
22
26
  end
@@ -102,6 +106,10 @@ module Honeymaker
102
106
  })
103
107
  end
104
108
 
109
+ def get_withdraw_addresses
110
+ get_signed("/account/v1/withdraw/address/list")
111
+ end
112
+
105
113
  def withdraw(currency:, amount:, address:, address_memo: nil, destination: nil)
106
114
  post_signed("/account/v1/withdraw/apply", {
107
115
  currency: currency, amount: amount,
@@ -77,6 +77,17 @@ module Honeymaker
77
77
  })
78
78
  end
79
79
 
80
+ def get_all_coins_information(recv_window: 5000)
81
+ get_signed("/api/v1/capital/config/getall", { recvWindow: recv_window })
82
+ end
83
+
84
+ def withdraw(coin:, address:, amount:, network: nil, address_tag: nil, recv_window: 5000)
85
+ post_signed("/api/v1/capital/withdraw/apply", {
86
+ coin: coin, address: address, amount: amount,
87
+ network: network, addressTag: address_tag, recvWindow: recv_window
88
+ })
89
+ end
90
+
80
91
  def account_trade_list(symbol:, start_time: nil, end_time: nil, from_id: nil, limit: 500, recv_window: 5000)
81
92
  get_signed("/api/v1/myTrades", {
82
93
  symbol: symbol, startTime: start_time, endTime: end_time,
@@ -22,6 +22,14 @@ module Honeymaker
22
22
  get_public("/v2/candles/#{symbol}/#{time_frame}")
23
23
  end
24
24
 
25
+ def get_price_feed
26
+ get_public("/v1/pricefeed")
27
+ end
28
+
29
+ def get_approved_addresses(network:)
30
+ post_signed("/v1/approvedAddresses/account/#{network}")
31
+ end
32
+
25
33
  def get_raw_balances
26
34
  post_signed("/v1/balances")
27
35
  end
@@ -6,6 +6,10 @@ module Honeymaker
6
6
  URL = "https://api.hyperliquid.xyz"
7
7
  RATE_LIMITS = { default: 200, orders: 200 }.freeze
8
8
 
9
+ def initialize(api_key: nil, api_secret: nil, proxy: nil, logger: nil)
10
+ super
11
+ end
12
+
9
13
  def spot_meta
10
14
  post_info({ type: "spotMeta" })
11
15
  end
@@ -18,6 +22,23 @@ module Honeymaker
18
22
  post_info({ type: "spotClearinghouseState", user: user })
19
23
  end
20
24
 
25
+ def all_mids
26
+ post_info({ type: "allMids" })
27
+ end
28
+
29
+ def spot_balances(user: nil)
30
+ user ||= @api_key
31
+ spot_clearinghouse_state(user: user)
32
+ end
33
+
34
+ def l2_book(coin:)
35
+ post_info({ type: "l2Book", coin: coin })
36
+ end
37
+
38
+ def candles_snapshot(coin:, interval:, start_time:, end_time:)
39
+ post_info({ type: "candleSnapshot", req: { coin: coin, interval: interval, startTime: start_time, endTime: end_time } })
40
+ end
41
+
21
42
  def get_balances(user: nil)
22
43
  user ||= @api_key
23
44
  result = spot_clearinghouse_state(user: user)
@@ -82,6 +103,20 @@ module Honeymaker
82
103
  post_info(body)
83
104
  end
84
105
 
106
+ # --- Trading (requires hyperliquid gem) ---
107
+
108
+ def order(coin:, is_buy:, size:, limit_px:, order_type: { limit: { tif: "Gtc" } })
109
+ with_rescue do
110
+ exchange_client.order(coin: coin, is_buy: is_buy, size: size, limit_px: limit_px, order_type: order_type)
111
+ end
112
+ end
113
+
114
+ def cancel(coin:, oid:)
115
+ with_rescue do
116
+ exchange_client.cancel(coin: coin, oid: oid)
117
+ end
118
+ end
119
+
85
120
  # --- Futures ---
86
121
 
87
122
  def user_funding(user:, start_time:, end_time: nil)
@@ -118,6 +153,17 @@ module Honeymaker
118
153
  validate_trading_credentials
119
154
  end
120
155
 
156
+ def exchange_client
157
+ raise Error, "Trading requires api_secret (agent key)" unless @api_secret && !@api_secret.empty?
158
+ @exchange ||= begin
159
+ require "hyperliquid"
160
+ sdk = ::Hyperliquid.new(private_key: @api_secret)
161
+ sdk.exchange
162
+ rescue LoadError
163
+ raise Error, "Add 'hyperliquid' to your Gemfile to use Hyperliquid trading"
164
+ end
165
+ end
166
+
121
167
  def post_info(body)
122
168
  with_rescue do
123
169
  response = connection.post do |req|
@@ -82,6 +82,10 @@ module Honeymaker
82
82
  delete_signed("/api/v1/orders/#{order_id}")
83
83
  end
84
84
 
85
+ def get_orderbook(symbol:, limit: 20)
86
+ get_public("/api/v1/market/orderbook/level2_#{limit}", { symbol: symbol })
87
+ end
88
+
85
89
  def get_currencies
86
90
  get_public("/api/v3/currencies")
87
91
  end
@@ -17,6 +17,18 @@ module Honeymaker
17
17
  !success?
18
18
  end
19
19
 
20
+ def or(other)
21
+ return data if success?
22
+
23
+ other
24
+ end
25
+
26
+ def ==(other)
27
+ return false unless other.is_a?(Result)
28
+
29
+ data == other.data && errors == other.errors
30
+ end
31
+
20
32
  class Success < Result
21
33
  def initialize(data = nil)
22
34
  @data = data
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Honeymaker
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deltabadger