mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
bithumb: Add missing functionality (#770)
* bithumb: Add missing functionality * glorious: nits
This commit is contained in:
@@ -31,6 +31,7 @@ const (
|
||||
publicOrderBook = "/public/orderbook/"
|
||||
publicTransactionHistory = "/public/transaction_history/"
|
||||
publicCandleStick = "/public/candlestick/"
|
||||
publicAssetStatus = "/public/assetsstatus/"
|
||||
|
||||
privateAccInfo = "/info/account"
|
||||
privateAccBalance = "/info/balance"
|
||||
@@ -48,6 +49,8 @@ const (
|
||||
privateMarketSell = "/trade/market_sell"
|
||||
)
|
||||
|
||||
var errSymbolIsEmpty = errors.New("symbol cannot be empty")
|
||||
|
||||
// Bithumb is the overarching type across the Bithumb package
|
||||
type Bithumb struct {
|
||||
exchange.Base
|
||||
@@ -129,6 +132,24 @@ func (b *Bithumb) GetOrderBook(symbol string) (*Orderbook, error) {
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
// GetAssetStatus returns the withdrawal and deposit status for the symbol
|
||||
func (b *Bithumb) GetAssetStatus(symbol string) (*Status, error) {
|
||||
if symbol == "" {
|
||||
return nil, errSymbolIsEmpty
|
||||
}
|
||||
var response Status
|
||||
err := b.SendHTTPRequest(exchange.RestSpot, publicAssetStatus+strings.ToUpper(symbol), &response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if response.Status != noError {
|
||||
return nil, errors.New(response.Message)
|
||||
}
|
||||
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
// GetTransactionHistory returns recent transactions
|
||||
//
|
||||
// symbol e.g. "btc"
|
||||
@@ -154,7 +175,7 @@ func (b *Bithumb) GetTransactionHistory(symbol string) (TransactionHistory, erro
|
||||
func (b *Bithumb) GetAccountInformation(orderCurrency, paymentCurrency string) (Account, error) {
|
||||
var response Account
|
||||
if orderCurrency == "" {
|
||||
return response, errors.New("order currency must be set")
|
||||
return response, errSymbolIsEmpty
|
||||
}
|
||||
|
||||
val := url.Values{}
|
||||
@@ -270,7 +291,7 @@ func (b *Bithumb) GetOrders(orderID, transactionType, count, after, currency str
|
||||
params := url.Values{}
|
||||
|
||||
if currency == "" {
|
||||
return response, errors.New("order currency is required")
|
||||
return response, errSymbolIsEmpty
|
||||
}
|
||||
|
||||
params.Set("order_currency", strings.ToUpper(currency))
|
||||
|
||||
@@ -229,6 +229,7 @@ func TestMarketSellOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTicker(t *testing.T) {
|
||||
t.Parallel()
|
||||
cp := currency.NewPair(currency.QTUM, currency.KRW)
|
||||
_, err := b.UpdateTicker(cp, asset.Spot)
|
||||
if err != nil {
|
||||
@@ -243,6 +244,7 @@ func TestUpdateTicker(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateTickers(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := b.UpdateTickers(asset.Spot)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -260,6 +262,7 @@ func setFeeBuilder() *exchange.FeeBuilder {
|
||||
|
||||
// TestGetFeeByTypeOfflineTradeFee logic test
|
||||
func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
var feeBuilder = setFeeBuilder()
|
||||
_, err := b.GetFeeByType(feeBuilder)
|
||||
if err != nil {
|
||||
@@ -277,6 +280,7 @@ func TestGetFeeByTypeOfflineTradeFee(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetFee(t *testing.T) {
|
||||
t.Parallel()
|
||||
var feeBuilder = setFeeBuilder()
|
||||
// CryptocurrencyTradeFee Basic
|
||||
if _, err := b.GetFee(feeBuilder); err != nil {
|
||||
@@ -574,6 +578,7 @@ func TestGetDepositAddress(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCandleStick(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetCandleStick("BTC_KRW", "1m")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -581,6 +586,7 @@ func TestGetCandleStick(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetHistoricCandles(t *testing.T) {
|
||||
t.Parallel()
|
||||
currencyPair, err := currency.NewPairFromString("BTCKRW")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -593,6 +599,7 @@ func TestGetHistoricCandles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetHistoricCandlesExtended(t *testing.T) {
|
||||
t.Parallel()
|
||||
currencyPair, err := currency.NewPairFromString("BTCKRW")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -629,6 +636,7 @@ func TestGetHistoricTrades(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := b.UpdateOrderExecutionLimits("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -655,6 +663,7 @@ func TestUpdateOrderExecutionLimits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAmountMinimum(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
name string
|
||||
unitprice float64
|
||||
@@ -706,3 +715,16 @@ func TestGetAmountMinimum(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAssetStatus(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetAssetStatus("")
|
||||
if !errors.Is(err, errSymbolIsEmpty) {
|
||||
t.Fatalf("received: %v but expected: %v", err, errSymbolIsEmpty)
|
||||
}
|
||||
|
||||
_, err = b.GetAssetStatus("sol")
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: %v but expected: %v", err, nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,3 +290,14 @@ type OHLCVResponse struct {
|
||||
Status string `json:"status"`
|
||||
Data [][6]interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// Status defines the current exchange allowance to deposit or withdraw a
|
||||
// currency
|
||||
type Status struct {
|
||||
Status string `json:"status"`
|
||||
Data struct {
|
||||
DepositStatus int64 `json:"deposit_status"`
|
||||
WithdrawalStatus int64 `json:"withdrawal_status"`
|
||||
} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user