Skip to content

Commit ecb9bf9

Browse files
Merge pull request #3 from Logarithm-Labs/fix-user-fills-types
Update Info::OrderFill fields
2 parents 7045c3c + 2714458 commit ecb9bf9

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

hyperliquid/info_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ func GetInfoAPI() *InfoAPI {
1111
api.SetDebugActive()
1212
}
1313
TEST_ADDRESS := os.Getenv("TEST_ADDRESS")
14+
if TEST_ADDRESS == "" {
15+
panic("Set TEST_ADDRESS in .env file")
16+
}
1417
api.SetAccountAddress(TEST_ADDRESS)
1518
return api
1619
}
@@ -61,6 +64,17 @@ func TestInfoAPI_GetAccountFills(t *testing.T) {
6164
if len(*res) == 0 {
6265
t.Errorf("GetAccountFills() len = %v, want > %v", res, 0)
6366
}
67+
res0 := (*res)[0]
68+
t.Logf("res0 = %+v", res0)
69+
if res0.Px == 0 {
70+
t.Errorf("res0.Px = %v, want > %v", res0.Px, 0)
71+
}
72+
if res0.Sz == 0 {
73+
t.Errorf("res0.Sz = %v, want > %v", res0.Sz, 0)
74+
}
75+
if res0.Fee == 0 {
76+
t.Errorf("res0.Fee = %v, want > %v", res0.Fee, 0)
77+
}
6478
t.Logf("GetAccountFills() = %v", res)
6579
}
6680

hyperliquid/info_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ type Meta struct {
9191

9292
type OrderFill struct {
9393
Cloid string `json:"cloid"`
94-
ClosedPnl string `json:"closedPnl"`
94+
ClosedPnl float64 `json:"closedPnl,string"`
9595
Coin string `json:"coin"`
9696
Crossed bool `json:"crossed"`
9797
Dir string `json:"dir"`
98-
Fee string `json:"fee"`
98+
Fee float64 `json:"fee,string"`
9999
FeeToken string `json:"feeToken"`
100100
Hash string `json:"hash"`
101101
Oid int `json:"oid"`
102-
Px string `json:"px"`
102+
Px float64 `json:"px,string"`
103103
Side string `json:"side"`
104104
StartPosition string `json:"startPosition"`
105-
Sz string `json:"sz"`
105+
Sz float64 `json:"sz,string"`
106106
Tid int64 `json:"tid"`
107107
Time int64 `json:"time"`
108108
Liquidation *Liquidation `json:"liquidation"`

0 commit comments

Comments
 (0)