123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package response
- import (
- "encoding/xml"
- )
- type PositionEvent struct {
- XMLName xml.Name `xml:"position"`
- AccountId int64 `xml:"accountId"`
- InstrumentId int64 `xml:"instrumentId"`
- Valuation float64 `xml:"valuation"`
- ShortUnfilledQuantity float64 `xml:"shortUnfilledQuantity"`
- LongUnfilledQuantity float64 `xml:"longUnfilledQuantity"`
- ShortUnfilledCost float64 `xml:"shortUnfilledCost"`
- LongUnfilledCost float64 `xml:"longUnfilledCost"`
- OpenQuantity float64 `xml:"openQuantity"`
- CumulativeCost float64 `xml:"cumulativeCost"`
- OpenCost float64 `xml:"openCost"`
- Margin float64 `xml:"-"`
- Profit float64 `xml:"-"`
- CurPrice float64 `xml:"-"`
- OpenPrice float64 `xml:"-"`
- Currency string `xml:"-"`
- ExchangeRate *ExchangeRateEvent `xml:"-"`
- }
- type Positions struct {
- XMLName xml.Name `xml:"positions"`
- Data []*PositionEvent `xml:"page>order"`
- HasMoreResults bool `xml:"hasMoreResults"`
- CorrelationId int64 `xml:"correlationId"`
- }
- /*
- <position>
- <accountId>1334343885</accountId>
- <instrumentId>4001</instrumentId>
- <valuation>-57.895</valuation>
- <shortUnfilledCost>0</shortUnfilledCost>
- <longUnfilledCost>0</longUnfilledCost>
- <openQuantity>1</openQuantity>
- <cumulativeCost>12996.7</cumulativeCost>
- <openCost>12996.7</openCost>
- </position>
- */
- func NewPositionEvent(data string) *PositionEvent {
- r := PositionEvent{}
- err := xml.Unmarshal([]byte(data), &r)
- if err != nil {
- return nil
- }
- return &r
- }
|