exchanges/margin: Fix marshalling issue (#1812)

* Fixes issue with marshalling margin types

* Update exchanges/order/order_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/margin/margin.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/order/order_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update test name

---------

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
This commit is contained in:
Scott
2025-03-06 15:17:05 +11:00
committed by GitHub
parent 7a6d6cc002
commit 6ee26a7da1
3 changed files with 53 additions and 3 deletions

View File

@@ -23,6 +23,11 @@ func (t *Type) UnmarshalJSON(d []byte) error {
return err
}
// MarshalJSON conforms type to the json.Marshaler interface
func (t Type) MarshalJSON() ([]byte, error) {
return json.Marshal(t.String())
}
// String returns the string representation of the margin type in lowercase
// the absence of a lower func should hopefully highlight that String is lower
func (t Type) String() string {
@@ -37,10 +42,9 @@ func (t Type) String() string {
return spotIsolatedStr
case NoMargin:
return cashStr
case Unknown:
default:
return unknownStr
}
return ""
}
// Upper returns the upper case string representation of the margin type