Kucoin: Update order execution limits (#2124)

* refactor(kucoin): enhance contract and symbol structures, update order execution limits tests

* fix(number): handle null input in UnmarshalJSON and update tests

* Update exchanges/kucoin/kucoin_futures_types.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_futures_types.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_types.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/kucoin/kucoin_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: destroyed this code across all implementations

* glorious: rename

* ai overlord: nit

* Update exchanges/kucoin/kucoin_futures_types.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2025-12-17 12:42:34 +11:00
committed by GitHub
parent b1e4983f49
commit 7f412e2772
7 changed files with 206 additions and 204 deletions

View File

@@ -16,7 +16,10 @@ type Number float64
// UnmarshalJSON implements json.Unmarshaler
func (f *Number) UnmarshalJSON(data []byte) error {
switch c := data[0]; c { // From json.decode literalInterface
case 'n', 't', 'f': // null, true, false
case 'n': // null
*f = Number(0)
return nil
case 't', 'f': // true, false
return fmt.Errorf("%w: %s", errInvalidNumberValue, data)
case '"': // string
if len(data) < 2 || data[len(data)-1] != '"' {
@@ -40,7 +43,6 @@ func (f *Number) UnmarshalJSON(data []byte) error {
}
*f = Number(val)
return nil
}

View File

@@ -22,12 +22,16 @@ func TestNumberUnmarshalJSON(t *testing.T) {
assert.NoError(t, err, "Unmarshal should not error")
assert.Zero(t, n.Float64(), "UnmarshalJSON should parse empty as 0")
err = n.UnmarshalJSON([]byte(`null`))
assert.NoError(t, err, "Unmarshal should not error")
assert.Zero(t, n.Float64(), "UnmarshalJSON should parse empty as 0")
err = n.UnmarshalJSON([]byte(`1337.37`))
assert.NoError(t, err, "Unmarshal should not error on number types")
assert.Equal(t, 1337.37, n.Float64(), "UnmarshalJSON should handle raw numerics")
// Invalid value checking
for _, i := range []string{`"MEOW"`, `null`, `false`, `true`, `"1337.37`} {
for _, i := range []string{`"MEOW"`, `false`, `true`, `"1337.37`} {
err = n.UnmarshalJSON([]byte(i))
assert.ErrorIsf(t, err, errInvalidNumberValue, "UnmarshalJSON should error with invalid Value for %q", i)
}