honeymaker 0.5.1 → 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: a49e9be8c0e38711e061c2ea61373bbce84dfe3f779c5e6933fdc2c8185b942b
4
- data.tar.gz: c9dda3aa8c109c0db2bdcaf086f4b86fe95214cc7a6690d39b921e1182a08766
3
+ metadata.gz: f4a5dc67259d8ff33eba5584ed8fe9cc59e0f7d62c2d6bf6f794fbe24430bf93
4
+ data.tar.gz: 2115566b5168a2b5588e71292292a010a9f3d88673d127a75a2e71427876994b
5
5
  SHA512:
6
- metadata.gz: 7fe8a3cd0df1bea5355498e117887e854716d8050bdfe12009c9b1f0225771b1a18ad59030dfdd1418629df8db06805d79e38392ab99f3b300f93e4a87a52c3b
7
- data.tar.gz: 49e17edfcc5982629034cc755c315fc772188cc9a232102478eaf984522ed4df261bb55818bb0e62dcbe0b9f3a9a15c20759ef2199015da70d48a1b8098a22b3
6
+ metadata.gz: 2cd7119999981ce3e901dbeb2b172f037c0a077d5ee13f902f7fabdf320a336461e35c395eb7bbce07f6e2cc3fc3a35f1c06c691013a3904a8c73df40ce2ff38
7
+ data.tar.gz: c0ebe66c0a2ada2c2fe7cb255df67d2d07f22c17e39e54dd50f5a10185bcc67b5bd5c80a4e1d56bc351942473678399dd924a808aa16809acc47809b82c8d667
@@ -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.1"
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.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deltabadger