Class: Binance::SDK::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/binance/sdk/account.rb

Class Method Summary collapse

Class Method Details

.balance!(recvWindow: 5000, currency: 'USDT') ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/binance/sdk/account.rb', line 19

def balance!(recvWindow: 5000, currency: 'USDT')
  timestamp = Configuration.timestamp

  params = { recvWindow: recvWindow, timestamp: timestamp }

  balance = Request.send!(
    api_key_type: :read_info, path: Endpoints.fetch(:account_balance),
    params: params.delete_if { |key, value| value.nil? },
    security_type: :user_data, api_key: Configuration.api_key, api_secret_key: Configuration.secret_key
  )

  if futures?
    balance.find { |i| i[:asset] == currency }[:balance].to_f
  else
    balance[:balances].find { |i| i[:asset] == currency }[:free]
  end
end

.info!(recvWindow: 5000) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/binance/sdk/account.rb', line 5

def info!(recvWindow: 5000)
  timestamp = Configuration.timestamp

  params = { recvWindow: recvWindow, timestamp: timestamp }

  response = Request.send!(
    api_key_type: :read_info, path: "/sapi/v1/account/status",
    params: params.delete_if { |key, value| value.nil? },
    security_type: :user_data, api_key: Configuration.api_key, api_secret_key: Configuration.secret_key
  )

  puts response
end

.positionsObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/binance/sdk/account.rb', line 37

def positions
  params = {
    recvWindow: 60000,
    timestamp: Configuration.timestamp
  }

  Request.send!(
    api_key_type: :read_info, path: Endpoints.fetch(:account_position_risk),
    params: params.delete_if { |key, value| value.nil? },
    security_type: :user_data, api_key: Configuration.api_key, api_secret_key: Configuration.secret_key
  )
end