Withdraw Crypto wrapper mapping (#226)

* Initial commit

* Updates signature for all withdrawal methods to use new withdrawRequest struct type

* Implements crypto withdraw features & tests for Alphapoint, ANX, Binance, Bitfinex, Bitflyer, Bithumb, Bitmex, Bitstamp, Bittrex, BTCC, BTCmarkets, CoinbasePro, Coinut. Updates WithdrawRequest type with more members. Breaking change to update real order testing for increased code coverage

* Updates all realOrder tests to run when no API key is present. Updates exchange functions to handle errors better

* Implements crypto withdrawals for Exmo, GateIO, Gemini, HitBTC, Huobi, HuobiHadax, Kraken, LakeBTC, Liqui, Localbitcoins, OKCoin, OKEX, Poloniex, Wex, Yobit and ZB. Updates real order test formatting for all real order tests

* Update alphapoint. Fixes anx typos. Adds function WithdrawFiatFundsToInternationalBank to exchange wrapper interface. Adds WithdrawFiatFundsToInternationalBank to alphapoint, bitmex, coinbasepro. Updates Kraken to use TradePassword property

* Reverts alphapoint to use ErrNotYetImplemented

* Fixes line spacing and removes unnecessary line
This commit is contained in:
Scott
2019-01-03 13:15:07 +11:00
committed by Adrian Gallagher
parent 9ebcb1a462
commit b1e6534e7c
88 changed files with 2050 additions and 802 deletions

View File

@@ -51,6 +51,17 @@ const (
openOrders = "/api/v3/openOrders"
allOrders = "/api/v3/allOrders"
// Withdraw API endpoints
withdraw = "/wapi/v3/withdraw.html"
depositHistory = "/wapi/v3/depositHistory.html"
withdrawalHistory = "/wapi/v3/withdrawHistory.html"
depositAddress = "/wapi/v3/depositAddress.html"
accountStatus = "/wapi/v3/accountStatus.html"
systemStatus = "/wapi/v3/systemStatus.html"
dustLog = "/wapi/v3/userAssetDribbletLog.html"
tradeFee = "/wapi/v3/tradeFee.html"
assetDetail = "/wapi/v3/assetDetail.html"
// binance authenticated and unauthenticated limit rates
// to-do
binanceAuthRate = 0
@@ -702,3 +713,45 @@ func calculateTradingFee(purchasePrice, amount, multiplier float64) float64 {
func getCryptocurrencyWithdrawalFee(currency string, purchasePrice, amount float64) float64 {
return WithdrawalFees[currency]
}
// WithdrawCrypto sends cryptocurrency to the address of your choosing
func (b *Binance) WithdrawCrypto(asset, address, addressTag, name, amount string) (int64, error) {
var resp WithdrawResponse
path := fmt.Sprintf("%s%s", b.APIUrl, withdraw)
params := url.Values{}
params.Set("asset", asset)
params.Set("address", string(address))
params.Set("amount", string(amount))
if len(name) > 0 {
params.Set("name", string(name))
}
if len(addressTag) > 0 {
params.Set("addressTag", string(addressTag))
}
if err := b.SendAuthHTTPRequest("POST", path, params, &resp); err != nil {
return -1, err
}
if !resp.Success {
return resp.ID, errors.New(resp.Msg)
}
return resp.ID, nil
}
//GetDepositAddressForCurrency retrieves the wallet address for a given currency
func (b *Binance) GetDepositAddressForCurrency(currency string) error {
path := fmt.Sprintf("%s%s", b.APIUrl, depositAddress)
var resp interface{}
params := url.Values{}
params.Set("asset", currency)
if err := b.SendAuthHTTPRequest("GET", path, params, &resp); err != nil {
return err
}
return nil
}