Class: Honeymaker::Clients::Gemini
- Inherits:
-
Honeymaker::Client
- Object
- Honeymaker::Client
- Honeymaker::Clients::Gemini
- Defined in:
- lib/honeymaker/clients/gemini.rb
Constant Summary collapse
- URL =
"https://api.gemini.com"- RATE_LIMITS =
{ default: 200, orders: 200 }.freeze
Constants inherited from Honeymaker::Client
Instance Attribute Summary
Attributes inherited from Honeymaker::Client
Instance Method Summary collapse
- #cancel_order(order_id:) ⇒ Object
- #get_approved_addresses(network:) ⇒ Object
- #get_balances ⇒ Object
- #get_candles(symbol:, time_frame:) ⇒ Object
- #get_my_trades(symbol: nil, limit_trades: nil, timestamp: nil) ⇒ Object
- #get_price_feed ⇒ Object
- #get_raw_balances ⇒ Object
- #get_symbol_details(symbol:) ⇒ Object
- #get_symbols ⇒ Object
- #get_ticker(symbol:) ⇒ Object
- #get_transfers(timestamp: nil, limit_transfers: nil) ⇒ Object
- #new_order(symbol:, amount:, price:, side:, type:, client_order_id: nil, options: []) ⇒ Object
- #order_status(order_id:) ⇒ Object
- #staking_balances ⇒ Object
-
#staking_history ⇒ Object
— Staking —.
- #staking_rewards ⇒ Object
- #withdraw(currency:, address:, amount:) ⇒ Object
Methods inherited from Honeymaker::Client
#initialize, rate_limits, #validate
Constructor Details
This class inherits a constructor from Honeymaker::Client
Instance Method Details
#cancel_order(order_id:) ⇒ Object
75 76 77 |
# File 'lib/honeymaker/clients/gemini.rb', line 75 def cancel_order(order_id:) post_signed("/v1/order/cancel", { order_id: order_id }) end |
#get_approved_addresses(network:) ⇒ Object
29 30 31 |
# File 'lib/honeymaker/clients/gemini.rb', line 29 def get_approved_addresses(network:) post_signed("/v1/approvedAddresses/account/#{network}") end |
#get_balances ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/honeymaker/clients/gemini.rb', line 37 def get_balances result = get_raw_balances return result if result.failure? balances = {} Array(result.data).each do |balance| symbol = balance["currency"]&.upcase next unless symbol available = BigDecimal((balance["available"] || "0").to_s) amount = BigDecimal((balance["amount"] || "0").to_s) locked = amount - available next if available.zero? && locked.zero? balances[symbol] = { free: available, locked: locked } end Result::Success.new(balances) end |
#get_candles(symbol:, time_frame:) ⇒ Object
21 22 23 |
# File 'lib/honeymaker/clients/gemini.rb', line 21 def get_candles(symbol:, time_frame:) get_public("/v2/candles/#{symbol}/#{time_frame}") end |
#get_my_trades(symbol: nil, limit_trades: nil, timestamp: nil) ⇒ Object
79 80 81 |
# File 'lib/honeymaker/clients/gemini.rb', line 79 def get_my_trades(symbol: nil, limit_trades: nil, timestamp: nil) post_signed("/v1/mytrades", { symbol: symbol, limit_trades: limit_trades, timestamp: }) end |
#get_price_feed ⇒ Object
25 26 27 |
# File 'lib/honeymaker/clients/gemini.rb', line 25 def get_price_feed get_public("/v1/pricefeed") end |
#get_raw_balances ⇒ Object
33 34 35 |
# File 'lib/honeymaker/clients/gemini.rb', line 33 def get_raw_balances post_signed("/v1/balances") end |
#get_symbol_details(symbol:) ⇒ Object
13 14 15 |
# File 'lib/honeymaker/clients/gemini.rb', line 13 def get_symbol_details(symbol:) get_public("/v1/symbols/details/#{symbol}") end |
#get_symbols ⇒ Object
9 10 11 |
# File 'lib/honeymaker/clients/gemini.rb', line 9 def get_symbols get_public("/v1/symbols") end |
#get_ticker(symbol:) ⇒ Object
17 18 19 |
# File 'lib/honeymaker/clients/gemini.rb', line 17 def get_ticker(symbol:) get_public("/v1/pubticker/#{symbol}") end |
#get_transfers(timestamp: nil, limit_transfers: nil) ⇒ Object
83 84 85 |
# File 'lib/honeymaker/clients/gemini.rb', line 83 def get_transfers(timestamp: nil, limit_transfers: nil) post_signed("/v1/transfers", { timestamp: , limit_transfers: limit_transfers }) end |
#new_order(symbol:, amount:, price:, side:, type:, client_order_id: nil, options: []) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/honeymaker/clients/gemini.rb', line 55 def new_order(symbol:, amount:, price:, side:, type:, client_order_id: nil, options: []) result = post_signed("/v1/order/new", { symbol: symbol, amount: amount, price: price, side: side, type: type, client_order_id: client_order_id, options: }) return result if result.failure? raw = result.data Result::Success.new({ order_id: raw["order_id"].to_s, raw: raw }) end |
#order_status(order_id:) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/honeymaker/clients/gemini.rb', line 67 def order_status(order_id:) result = post_signed("/v1/order/status", { order_id: order_id }) return result if result.failure? raw = result.data Result::Success.new(normalize_order(raw["order_id"].to_s, raw)) end |
#staking_balances ⇒ Object
101 102 103 |
# File 'lib/honeymaker/clients/gemini.rb', line 101 def staking_balances post_signed("/v1/balances/staking") end |
#staking_history ⇒ Object
— Staking —
93 94 95 |
# File 'lib/honeymaker/clients/gemini.rb', line 93 def staking_history post_signed("/v1/staking/history") end |
#staking_rewards ⇒ Object
97 98 99 |
# File 'lib/honeymaker/clients/gemini.rb', line 97 def staking_rewards post_signed("/v1/staking/rewards") end |
#withdraw(currency:, address:, amount:) ⇒ Object
87 88 89 |
# File 'lib/honeymaker/clients/gemini.rb', line 87 def withdraw(currency:, address:, amount:) post_signed("/v1/withdraw/#{currency}", { address: address, amount: amount }) end |