Skip to content

Commit

Permalink
implement withdraw endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjmp committed May 16, 2021
1 parent 1f759c3 commit 9af0ce3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ You can find more info on all `kline_candlestick` attributes & available interva
- [`fees!`](https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data): Get withdrawal information (status, minimum amount and fees) for all symbols.
- [`info!`](https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data): Get current account information.
- [`trades!`](https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-trade-list-user_data): Get trades for a specific account and symbol.
- [`withdraw!`](https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi): Submit a withdraw request. _I haven't confirmed this works for binance.us yet. If you find that it does, please submit a PR!_

### Binance::Api::DataStream class methods

Expand Down
2 changes: 1 addition & 1 deletion binance-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ Gem::Specification.new do |spec|
spec.add_dependency 'faye-websocket', '~> 0.11'
spec.add_dependency 'eventmachine', '~> 1.2'

spec.add_runtime_dependency 'activesupport', '~> 5.1', '>= 5.1.0'
spec.add_runtime_dependency 'activesupport', '>= 5.1.0'
end
17 changes: 17 additions & 0 deletions lib/binance/api/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ def trades!(fromId: nil, limit: 500, recvWindow: 5000, symbol: nil, api_key: nil
params: params.delete_if { |key, value| value.nil? },
security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
end

# @note have not tested this for binance.us yet.
def withdraw!(coin: nil, withdrawOrderId: nil, network: nil, address: nil, addressTag: nil, amount: nil,
transactionFeeFlag: false, name: nil, recvWindow: nil, api_key: nil, api_secret_key: nil)
raise Error.new(message: "amount is required") if amount.nil?
raise Error.new(message: "coin is required") if coin.nil?
raise Error.new(message: "address is required") if address.nil?
timestamp = Configuration.timestamp
params = {
coin: coin, withdrawOrderId: withdrawOrderId, network: network, address: address, timestamp: timestamp,
addressTag: addressTag, amount: amount, transactionFeeFlag: transactionFeeFlag,
name: name, recvWindow: recvWindow,
}
Request.send!(api_key_type: :read_info, path: "/sapi/v1/capital/withdraw/apply",
params: params.delete_if { |key, value| value.nil? }, method: :post,
security_type: :user_data, api_key: api_key, api_secret_key: api_secret_key)
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/binance/api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Binance
module Api
VERSION = "1.2.2"
VERSION = "1.2.3"
end
end

0 comments on commit 9af0ce3

Please sign in to comment.