Class: BinanceAPI::WAPI

Inherits:
Base
  • Object
show all
Defined in:
lib/binance_api/wapi.rb

Constant Summary

Constants inherited from Base

Base::BASE_URL

Instance Method Summary collapse

Instance Method Details

#account_status(options = {}) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/binance_api/wapi.rb', line 113

def (options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/accountStatus.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end

#deposit_address(asset, options = {}) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/binance_api/wapi.rb', line 74

def deposit_address(asset, options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    asset: asset,
    status: options.fetch(:status, nil),
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/depositAddress.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end

#deposit_history(asset, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/binance_api/wapi.rb', line 30

def deposit_history(asset, options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    asset: asset,
    status: options.fetch(:status, nil),
    startTime: options.fetch(:start_time, nil),
    endTime: options.fetch(:end_time, nil),
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/depositHistory.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end

#system_statusObject



131
132
133
134
135
136
# File 'lib/binance_api/wapi.rb', line 131

def system_status
  response = safe { RestClient.get("#{BASE_URL}/wapi/v3/systemStatus.html") }
  
  json = JSON.parse(response.body, symbolize_names: true)
  BinanceAPI::Result.new(json, response.code == 200)
end

#withdraw(asset, address, amount, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/binance_api/wapi.rb', line 7

def withdraw(asset, address, amount, options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    asset: asset,
    address: address,
    addressTag: options.fetch(:address_tag, nil),
    amount: amount,
    name: options.fetch(:name, nil),
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/withdraw.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end

#withdraw_fee(asset, options = {}) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/binance_api/wapi.rb', line 94

def withdraw_fee(asset, options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    asset: asset,
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/withdrawFee.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end

#withdraw_history(asset, options = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/binance_api/wapi.rb', line 52

def withdraw_history(asset, options = {})
  recv_window = options.delete(:recv_window) || BinanceAPI.recv_window
  timestamp = options.delete(:timestamp) || Time.now

  params = {
    asset: asset,
    status: options.fetch(:status, nil),
    startTime: options.fetch(:start_time, nil),
    endTime: options.fetch(:end_time, nil),
    recvWindow: recv_window,
    timestamp: timestamp.to_i * 1000 # to milliseconds
  }

  response = safe do
    RestClient.get "#{BASE_URL}/wapi/v3/withdrawHistory.html",
                   params: params_with_signature(params, api_secret),
                   'X-MBX-APIKEY' => api_key
  end

  build_result response
end