AccountEvent.go 1016 B

123456789101112131415161718192021222324252627282930313233343536
  1. package response
  2. import (
  3. "encoding/xml"
  4. "log"
  5. )
  6. type Wallet struct {
  7. Currency string `xml:"currency"`
  8. Balance float64 `xml:"balance"`
  9. Freeze float64 `xml:"freeze"`
  10. }
  11. type AccountStateEvent struct {
  12. XMLName xml.Name `xml:"accountState"`
  13. AccountId int64 `xml:"accountId"`
  14. Balance float64 `xml:"balance"`
  15. Freeze float64 `xml:"freeze"`
  16. AvailableFunds float64 `xml:"availableFunds"`
  17. AvailableToWithdraw float64 `xml:"availableToWithdraw"`
  18. UnrealisedProfitAndLoss float64 `xml:"unrealisedProfitAndLoss"`
  19. Margin float64 `xml:"margin"`
  20. Wallets []Wallet `xml:"wallets>wallet"`
  21. Active bool `xml:"active"`
  22. Equity float64 `xml:"-"`
  23. }
  24. func NewAccountStateEvent(data string) *AccountStateEvent {
  25. r := AccountStateEvent{}
  26. err := xml.Unmarshal([]byte(data), &r)
  27. if err != nil {
  28. log.Println(err)
  29. return nil
  30. }
  31. return &r
  32. }