Bitstamp: Add missing API fields and enhance test coverage (#1510)

* Bitstamp: Add missing fields

* Bitstamp: update assert to require, update tests WIP

* Bitstamp: Update the tests

* Bitstamp: Update GetOrderInfo

* Bitstamp: Add minor updates

* Bitstamp: Update TestGetFee, add Amount to GetOrderInfo

* Bitstamp: Update TestGetFee

* Bitstamp: Update OrderStatus type
This commit is contained in:
Bea
2024-05-06 09:05:49 +08:00
committed by GitHub
parent f1ff951199
commit a46622a9c8
4 changed files with 159 additions and 122 deletions

File diff suppressed because one or more lines are too long

View File

@@ -24,16 +24,18 @@ var errWSPairParsingError = errors.New("unable to parse currency pair from wsRes
// Ticker holds ticker information
type Ticker struct {
Last float64 `json:"last,string"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Vwap float64 `json:"vwap,string"`
Volume float64 `json:"volume,string"`
Bid float64 `json:"bid,string"`
Ask float64 `json:"ask,string"`
Timestamp int64 `json:"timestamp,string"`
Open float64 `json:"open,string"`
Side orderSide `json:"side,string"`
Last float64 `json:"last,string"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Vwap float64 `json:"vwap,string"`
Volume float64 `json:"volume,string"`
Bid float64 `json:"bid,string"`
Ask float64 `json:"ask,string"`
Timestamp int64 `json:"timestamp,string"`
Open float64 `json:"open,string"`
Open24 float64 `json:"open_24,string"`
Side orderSide `json:"side,string"`
PercentChange24 float64 `json:"percent_change_24,string"`
}
// OrderbookBase holds singular price information
@@ -114,28 +116,35 @@ type UserTransactions struct {
// Order holds current open order data
type Order struct {
ID int64 `json:"id,string"`
DateTime string `json:"datetime"`
Type int `json:"type,string"`
Price float64 `json:"price,string"`
Amount float64 `json:"amount,string"`
Currency string `json:"currency_pair"`
ID int64 `json:"id,string"`
DateTime string `json:"datetime"`
Type int `json:"type,string"`
Price float64 `json:"price,string"`
Amount float64 `json:"amount,string"`
AmountAtCreate float64 `json:"amount_at_create,string"`
Currency string `json:"currency_pair"`
LimitPrice float64 `json:"limit_price,string"`
ClientOrderID string `json:"client_order_id"`
Market string `json:"market"`
}
// OrderStatus holds order status information
type OrderStatus struct {
Price float64 `json:"price,string"`
Amount float64 `json:"amount,string"`
Type int `json:"type"`
ID string `json:"id"`
DateTime string `json:"datetime"`
Status string
Transactions []struct {
TradeID int64 `json:"tid"`
USD float64 `json:"usd,string"`
Price float64 `json:"price,string"`
Fee float64 `json:"fee,string"`
BTC float64 `json:"btc,string"`
AmountRemaining float64 `json:"amount_remaining,string"`
Type int `json:"type"`
ID string `json:"id"`
DateTime string `json:"datetime"`
Status string `json:"status"`
ClientOrderID string `json:"client_order_id"`
Market string `json:"market"`
Transactions []struct {
TradeID int64 `json:"tid"`
FromCurrency float64 `json:"{from_currency},string"`
ToCurrency float64 `json:"{to_currency},string"`
Price float64 `json:"price,string"`
Fee float64 `json:"fee,string"`
DateTime string `json:"datetime"`
Type int `json:"type"`
}
}
@@ -163,6 +172,8 @@ type WithdrawalRequests struct {
Currency currency.Code `json:"currency"`
Address string `json:"address"`
TransactionID string `json:"transaction_id"`
Network string `json:"network"`
TxID int64 `json:"txid"`
}
// CryptoWithdrawalResponse response from a crypto withdrawal request
@@ -178,9 +189,9 @@ type FIATWithdrawalResponse struct {
// UnconfirmedBTCTransactions holds address information about unconfirmed
// transactions
type UnconfirmedBTCTransactions struct {
Amount float64 `json:"amount,string"`
Address string `json:"address"`
Confirmations int `json:"confirmations"`
Address string `json:"address"`
DestinationTag int `json:"destination_tag"`
MemoID string `json:"memo_id"`
}
// CaptureError is used to capture unmarshalled errors

View File

@@ -567,20 +567,23 @@ func (b *Bitstamp) GetOrderInfo(ctx context.Context, orderID string, _ currency.
TID: strconv.FormatInt(o.Transactions[i].TradeID, 10),
Price: o.Transactions[i].Price,
Fee: o.Transactions[i].Fee,
Amount: o.Transactions[i].BTC,
Amount: o.Transactions[i].ToCurrency,
}
}
orderDate, err := time.Parse(time.DateTime, o.DateTime)
if err != nil {
return nil, err
}
status, err := order.StringToOrderStatus(o.Status)
if err != nil {
return nil, err
}
return &order.Detail{
Amount: o.Amount,
Price: o.Price,
OrderID: o.ID,
Date: orderDate,
Trades: th,
RemainingAmount: o.AmountRemaining,
OrderID: o.ID,
Date: orderDate,
Trades: th,
Status: status,
}, nil
}

View File

@@ -106,7 +106,8 @@
"type": 0
}
],
"amount": "200.00"
"amount_remaining": "200.00",
"client_order_id": "0.50000000"
},
"queryString": "",
"bodyParams": "id=1458532827766784&key=FUId9Nby1VbZrGgZHfzGbswd4CDcp6Ar&nonce=1700374285822027000&signature=0B7C759A57B10EC315CE3A53480EDC720BE9BCD2CCEA86313808914484483386",