From c5ea5c4460e0557364d7c39b42d5c61da9139682 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Tue, 11 Jun 2024 15:42:36 +0400 Subject: [PATCH] Fix FilledStatus types. --- hyperliquid/exchange_test.go | 9 +++++++++ hyperliquid/exchange_types.go | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hyperliquid/exchange_test.go b/hyperliquid/exchange_test.go index 610a8ef..4cdb47b 100644 --- a/hyperliquid/exchange_test.go +++ b/hyperliquid/exchange_test.go @@ -1,6 +1,7 @@ package hyperliquid import ( + "math" "os" "testing" "time" @@ -71,6 +72,14 @@ func TestExchangeAPI_MarketOpen(testing *testing.T) { testing.Errorf("MakeOpen() error = %v", err) } testing.Logf("MakeOpen() = %v", res) + avgPrice := res.Response.Data.Statuses[0].Filled.AvgPx + if avgPrice == 0 { + testing.Errorf("res.Response.Data.Statuses[0].Filled.AvgPx = %v", avgPrice) + } + totalSize := res.Response.Data.Statuses[0].Filled.TotalSz + if totalSize != math.Abs(size) { + testing.Errorf("res.Response.Data.Statuses[0].Filled.TotalSz = %v", totalSize) + } accountState, err := exchangeAPI.infoAPI.GetUserState(exchangeAPI.AccountAddress()) if err != nil { testing.Errorf("GetAccountState() error = %v", err) diff --git a/hyperliquid/exchange_types.go b/hyperliquid/exchange_types.go index 485a041..a9af9e9 100644 --- a/hyperliquid/exchange_types.go +++ b/hyperliquid/exchange_types.go @@ -147,9 +147,9 @@ type CloseRequest struct { } type FilledStatus struct { - OrderId int `json:"oid"` - AvgPx string `json:"avgPx"` - TotalSz string `json:"totalSz"` + OrderId int `json:"oid"` + AvgPx float64 `json:"avgPx,string"` + TotalSz float64 `json:"totalSz,string"` } type Liquidation struct {