Skip to content

Commit

Permalink
Bitstamp: Add minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Beadko committed Mar 30, 2024
1 parent 37ec60a commit b5c530f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions exchanges/bitstamp/bitstamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ func TestGetOpenOrders(t *testing.T) {
assert.Equal(t, 0.50000000, res.AmountAtCreate, "AmountAtCreate should match")
assert.Equal(t, 110.00, res.LimitPrice, "LimitPrice should match")
assert.Equal(t, "1234123412341234", res.ClientOrderID, "ClientOrderID should match")
assert.Equal(t, "BTC/USD", res.Market, "Market should match")
}
}
}
Expand All @@ -385,12 +386,12 @@ func TestGetOrderStatus(t *testing.T) {
assert.Equal(t, 200.00, o.AmountRemaining, "AmountRemaining should match")
assert.Equal(t, 0, o.Type, "Type should match")
assert.Equal(t, "0.50000000", o.ClientOrderID, "ClientOrderID should match")
assert.Equal(t, "BTC/USD", o.Symbol, "Symbol should match")
assert.Equal(t, "BTC/USD", o.Market, "Market should match")
for _, tr := range o.Transactions {
assert.Equal(t, "2022-01-31 14:43:15", tr.DateTime, "DateTime should match")
assert.Equal(t, 50.00, tr.Price, "Price should match")
assert.Equal(t, 101.00, tr.FromCurrency, "FromCurrency should match")
assert.Equal(t, float64(1), tr.ToCurrency, "ToCurrency should match")
assert.Equal(t, 1.0, tr.ToCurrency, "ToCurrency should match")
assert.Equal(t, 0, o.Type, "Type should match")
}
}
Expand Down Expand Up @@ -536,7 +537,7 @@ func TestSubmitOrder(t *testing.T) {
assert.ErrorContains(t, err, "You have only 0 USD available. Check your account balance for details.")
} else {
require.NoError(t, err, "SubmitOrder must not error")
assert.Equal(t, float64(45), o.Amount, "Amount should be correct")
assert.Equal(t, 45.0, o.Amount, "Amount should be correct")
assert.Equal(t, asset.Spot, o.AssetType, "AssetType should be correct")
assert.Equal(t, "123456789", o.ClientOrderID, "ClientOrderID should be correct")
assert.Equal(t, "1234123412341234", o.OrderID, "OrderID should be correct")
Expand Down Expand Up @@ -998,7 +999,7 @@ func TestGetOrderInfo(t *testing.T) {
assert.Equal(t, time.Date(2022, time.January, 31, 14, 43, 15, 0, time.UTC), o.Date, "Date should match")
assert.Equal(t, "1458532827766784", o.OrderID, "OrderID should match")
assert.Equal(t, order.Open, o.Status, "Status should match")
assert.Equal(t, float64(200), o.RemainingAmount, "RemainingAmount should match")
assert.Equal(t, 200.00, o.RemainingAmount, "RemainingAmount should match")
for _, tr := range o.Trades {
assert.Equal(t, 50.00, tr.Price, "Price should match")
}
Expand Down
3 changes: 2 additions & 1 deletion exchanges/bitstamp/bitstamp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Order struct {
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
Expand All @@ -135,7 +136,7 @@ type OrderStatus struct {
DateTime string `json:"datetime"`
Status string
ClientOrderID string `json:"client_order_id"`
Symbol string `json:"market"`
Market string `json:"market"`
Transactions []struct {
TradeID int64 `json:"tid"`
FromCurrency float64 `json:"{from_currency},string"`
Expand Down
2 changes: 1 addition & 1 deletion exchanges/bitstamp/bitstamp_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ func (b *Bitstamp) GetOrderInfo(ctx context.Context, orderID string, _ currency.
}
status, err := order.StringToOrderStatus(o.Status)
if err != nil {
log.Errorf(log.ExchangeSys, "%s %v", b.Name, err)
return nil, err
}
return &order.Detail{
RemainingAmount: o.AmountRemaining,
Expand Down

0 comments on commit b5c530f

Please sign in to comment.