diff --git a/invstmt_test.go b/invstmt_test.go index 50727e6..0fd3583 100644 --- a/invstmt_test.go +++ b/invstmt_test.go @@ -1481,3 +1481,377 @@ func TestUnmarshalPositionList(t *testing.T) { } checkEqual(t, "PositionList", reflect.ValueOf(&expected), reflect.ValueOf(&actual)) } + +func TestUnmarshalOOList(t *testing.T) { + input := ` + + + 76464632 + + 922908645 + CUSIP + + 20170310124445 + 10 + CASH + DAY + NONE + + Y + + + + 76464632 + + 922908645 + CUSIP + + 20170310124445 + 10 + CASH + GOODTILCANCEL + NONE + 168.50 + + BUY + SHARES + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + 19.75 + + BUYTOCLOSE + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + 19.75 + + BUY + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + 19.75 + + CURRENCY + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + SELLSHORT + SHARES + + Y + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + SELLTOOPEN + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + SHARES + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + SELL + + + + 999387423 + + 899422348 + CUSIP + + 20170324031900 + 25 + CASH + GOODTILCANCEL + ALLORNONE + + + 899422389 + CUSIP + + CURRENCY + N + +` + + var oounits1, oolimitprice1, oounits2, oolimitprice2 ofxgo.Amount + oounits1.SetFrac64(10, 1) + oolimitprice1.SetFrac64(16850, 100) + oounits2.SetFrac64(25, 1) + oolimitprice2.SetFrac64(1975, 100) + + expected := ofxgo.OOList{ + ofxgo.OOBuyDebt{ + OO: ofxgo.OO{ + FiTId: "76464632", + SecId: ofxgo.SecurityId{ + UniqueId: "922908645", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 10, 12, 44, 45, 0), + Units: oounits1, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationDay, + Restriction: ofxgo.RestrictionNone, + }, + Auction: true, + }, + ofxgo.OOBuyMF{ + OO: ofxgo.OO{ + FiTId: "76464632", + SecId: ofxgo.SecurityId{ + UniqueId: "922908645", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 10, 12, 44, 45, 0), + Units: oounits1, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionNone, + LimitPrice: oolimitprice1, + }, + BuyType: ofxgo.BuyTypeBuy, + UnitType: ofxgo.UnitTypeShares, + }, + ofxgo.OOBuyOpt{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + LimitPrice: oolimitprice2, + }, + OptBuyType: ofxgo.OptBuyTypeBuyToClose, + }, + ofxgo.OOBuyStock{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + LimitPrice: oolimitprice2, + }, + BuyType: ofxgo.BuyTypeBuy, + }, + ofxgo.OOBuyOther{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + LimitPrice: oolimitprice2, + }, + UnitType: ofxgo.UnitTypeCurrency, + }, + ofxgo.OOSellDebt{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + }, + ofxgo.OOSellMF{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + SellType: ofxgo.SellTypeSellShort, + UnitType: ofxgo.UnitTypeShares, + SellAll: true, + }, + ofxgo.OOSellOpt{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + OptSellType: ofxgo.OptSellTypeSellToOpen, + }, + ofxgo.OOSellOther{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + UnitType: ofxgo.UnitTypeShares, + }, + ofxgo.OOSellStock{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + SellType: ofxgo.SellTypeSell, + }, + ofxgo.OOSwitchMF{ + OO: ofxgo.OO{ + FiTId: "999387423", + SecId: ofxgo.SecurityId{ + UniqueId: "899422348", + UniqueIdType: "CUSIP", + }, + DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0), + Units: oounits2, + SubAcct: ofxgo.SubAcctTypeCash, + Duration: ofxgo.DurationGoodTilCancel, + Restriction: ofxgo.RestrictionAllOrNone, + }, + SecId: ofxgo.SecurityId{ + UniqueId: "899422389", + UniqueIdType: "CUSIP", + }, + UnitType: ofxgo.UnitTypeCurrency, + SwitchAll: false, + }, + } + + var actual ofxgo.OOList + err := xml.Unmarshal([]byte(input), &actual) + if err != nil { + t.Fatalf("Unexpected error unmarshalling OOList: %s\n", err) + } + checkEqual(t, "OOList", reflect.ValueOf(&expected), reflect.ValueOf(&actual)) +}