Class: Bitmex::User
- Inherits:
-
Object
- Object
- Bitmex::User
- Defined in:
- lib/bitmex/user.rb
Overview
Account Operations
All read-only operations to load user’s data are implemented and work as described in docs. Multiple PUT/POST endpoints return ‘Access Denied’ and are not implemented. It seems that they are meant to be used internally by BitMEX only.
Instance Attribute Summary collapse
-
#rest ⇒ Object
readonly
Returns the value of attribute rest.
-
#websocket ⇒ Object
readonly
Returns the value of attribute websocket.
Instance Method Summary collapse
-
#affiliate_status ⇒ Hash
Get your current affiliate/referral status.
-
#check_referral_code(code) ⇒ Decimal?
Check if a referral code is valid.
-
#commission ⇒ Hash
Get your account’s commission status.
-
#deposit_address(currency = 'XBt') ⇒ String
Get a deposit address.
-
#events(count: 150, startId: nil) ⇒ Array
Get your user events.
-
#execution_history(symbol = 'XBTUSD', timestamp = Date.today) ⇒ Array
Get the execution history by day.
-
#executions(filters = {}) {|Hash| ... } ⇒ Array
Get all raw executions for your account.
-
#initialize(rest, websocket) ⇒ User
constructor
A new instance of User.
-
#margin(currency = 'XBt') ⇒ Hash
Get your account’s margin status.
-
#min_withdrawal_fee(currency = 'XBt') ⇒ Hash
Get the minimum withdrawal fee for a currency This is changed based on network conditions to ensure timely withdrawals.
-
#nickname ⇒ String
Get your alias on the leaderboard.
-
#wallet ⇒ Hash
Get your current wallet information.
-
#wallet_history ⇒ Array
Get a history of all of your wallet transactions (deposits, withdrawals, PNL).
-
#wallet_summary ⇒ Array
Get a summary of all of your wallet transactions (deposits, withdrawals, PNL).
Constructor Details
#initialize(rest, websocket) ⇒ User
Returns a new instance of User.
13 14 15 16 |
# File 'lib/bitmex/user.rb', line 13 def initialize(rest, websocket) @rest = rest @websocket = websocket end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_args, &_ablock) ⇒ Object (private)
132 133 134 135 |
# File 'lib/bitmex/user.rb', line 132 def method_missing(name, *_args, &_ablock) @data = get '' if @data.nil? @data.send name end |
Instance Attribute Details
#rest ⇒ Object (readonly)
Returns the value of attribute rest.
9 10 11 |
# File 'lib/bitmex/user.rb', line 9 def rest @rest end |
#websocket ⇒ Object (readonly)
Returns the value of attribute websocket.
9 10 11 |
# File 'lib/bitmex/user.rb', line 9 def websocket @websocket end |
Instance Method Details
#affiliate_status ⇒ Hash
Get your current affiliate/referral status.
20 21 22 |
# File 'lib/bitmex/user.rb', line 20 def affiliate_status get 'affiliateStatus' end |
#check_referral_code(code) ⇒ Decimal?
Check if a referral code is valid. If the code is valid, responds with the referral code’s discount (e.g. 0.1 for 10%) and false otherwise
27 28 29 30 31 32 33 |
# File 'lib/bitmex/user.rb', line 27 def check_referral_code(code) get 'checkReferralCode', referralCode: code do |response| return nil if !response.success? && [404, 451].include?(response.code) response.to_f end end |
#commission ⇒ Hash
Get your account’s commission status
37 38 39 |
# File 'lib/bitmex/user.rb', line 37 def commission get 'commission' end |
#deposit_address(currency = 'XBt') ⇒ String
Get a deposit address
44 45 46 47 48 49 50 |
# File 'lib/bitmex/user.rb', line 44 def deposit_address(currency = 'XBt') get 'depositAddress', currency: currency do |response| raise response.body unless response.success? response.to_s end end |
#events(count: 150, startId: nil) ⇒ Array
Get your user events
97 98 99 100 |
# File 'lib/bitmex/user.rb', line 97 def events(count: 150, startId: nil) data = get '', resource: 'userEvent', count: count, startId: startId data.userEvents end |
#execution_history(symbol = 'XBTUSD', timestamp = Date.today) ⇒ Array
Get the execution history by day
56 57 58 |
# File 'lib/bitmex/user.rb', line 56 def execution_history(symbol = 'XBTUSD', = Date.today) get 'executionHistory', symbol: symbol, timestamp: end |
#executions(filters = {}) {|Hash| ... } ⇒ Array
Get all raw executions for your account
122 123 124 125 126 127 128 |
# File 'lib/bitmex/user.rb', line 122 def executions(filters = {}, &ablock) if block_given? websocket.listen execution: filters[:symbol], &ablock else get '', filters.merge(resource: :execution) end end |
#margin(currency = 'XBt') ⇒ Hash
Get your account’s margin status
63 64 65 |
# File 'lib/bitmex/user.rb', line 63 def margin(currency = 'XBt') get 'margin', currency: currency end |
#min_withdrawal_fee(currency = 'XBt') ⇒ Hash
Get the minimum withdrawal fee for a currency This is changed based on network conditions to ensure timely withdrawals. During network congestion, this may be high. The fee is returned in the same currency.
71 72 73 |
# File 'lib/bitmex/user.rb', line 71 def min_withdrawal_fee(currency = 'XBt') get 'minWithdrawalFee', currency: currency end |
#nickname ⇒ String
Get your alias on the leaderboard
104 105 106 107 |
# File 'lib/bitmex/user.rb', line 104 def nickname data = get 'name', resource: 'leaderboard' data.name end |
#wallet ⇒ Hash
Get your current wallet information
77 78 79 |
# File 'lib/bitmex/user.rb', line 77 def wallet get 'wallet' end |
#wallet_history ⇒ Array
Get a history of all of your wallet transactions (deposits, withdrawals, PNL)
83 84 85 |
# File 'lib/bitmex/user.rb', line 83 def wallet_history get 'walletHistory' end |
#wallet_summary ⇒ Array
Get a summary of all of your wallet transactions (deposits, withdrawals, PNL)
89 90 91 |
# File 'lib/bitmex/user.rb', line 89 def wallet_summary get 'walletSummary' end |