PositionEvent.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package response
  2. import (
  3. "encoding/xml"
  4. )
  5. type PositionEvent struct {
  6. XMLName xml.Name `xml:"position"`
  7. AccountId int64 `xml:"accountId"`
  8. InstrumentId int64 `xml:"instrumentId"`
  9. Valuation float64 `xml:"valuation"`
  10. ShortUnfilledQuantity float64 `xml:"shortUnfilledQuantity"`
  11. LongUnfilledQuantity float64 `xml:"longUnfilledQuantity"`
  12. ShortUnfilledCost float64 `xml:"shortUnfilledCost"`
  13. LongUnfilledCost float64 `xml:"longUnfilledCost"`
  14. OpenQuantity float64 `xml:"openQuantity"`
  15. CumulativeCost float64 `xml:"cumulativeCost"`
  16. OpenCost float64 `xml:"openCost"`
  17. Margin float64 `xml:"-"`
  18. Profit float64 `xml:"-"`
  19. CurPrice float64 `xml:"-"`
  20. OpenPrice float64 `xml:"-"`
  21. Currency string `xml:"-"`
  22. ExchangeRate *ExchangeRateEvent `xml:"-"`
  23. }
  24. type Positions struct {
  25. XMLName xml.Name `xml:"positions"`
  26. Data []*PositionEvent `xml:"page>order"`
  27. HasMoreResults bool `xml:"hasMoreResults"`
  28. CorrelationId int64 `xml:"correlationId"`
  29. }
  30. /*
  31. <position>
  32. <accountId>1334343885</accountId>
  33. <instrumentId>4001</instrumentId>
  34. <valuation>-57.895</valuation>
  35. <shortUnfilledCost>0</shortUnfilledCost>
  36. <longUnfilledCost>0</longUnfilledCost>
  37. <openQuantity>1</openQuantity>
  38. <cumulativeCost>12996.7</cumulativeCost>
  39. <openCost>12996.7</openCost>
  40. </position>
  41. */
  42. func NewPositionEvent(data string) *PositionEvent {
  43. r := PositionEvent{}
  44. err := xml.Unmarshal([]byte(data), &r)
  45. if err != nil {
  46. return nil
  47. }
  48. return &r
  49. }