forked from aclindsa/ofxgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invstmt.go
1414 lines (1302 loc) · 67 KB
/
invstmt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package ofxgo
import (
"errors"
"github.com/aclindsa/xml"
)
// InvStatementRequest allows a customer to request transactions, positions,
// open orders, and balances. It specifies what types of information to include
// in hte InvStatementResponse and which account to include it for.
type InvStatementRequest struct {
XMLName xml.Name `xml:"INVSTMTTRNRQ"`
TrnUID UID `xml:"TRNUID"`
CltCookie String `xml:"CLTCOOKIE,omitempty"`
TAN String `xml:"TAN,omitempty"` // Transaction authorization number
// TODO `xml:"OFXEXTENSION,omitempty"`
InvAcctFrom InvAcct `xml:"INVSTMTRQ>INVACCTFROM"`
DtStart *Date `xml:"INVSTMTRQ>INCTRAN>DTSTART,omitempty"`
DtEnd *Date `xml:"INVSTMTRQ>INCTRAN>DTEND,omitempty"`
Include Boolean `xml:"INVSTMTRQ>INCTRAN>INCLUDE"` // Include transactions (instead of just balance)
IncludeOO Boolean `xml:"INVSTMTRQ>INCOO"` // Include open orders
PosDtAsOf *Date `xml:"INVSTMTRQ>INCPOS>DTASOF,omitempty"` // Date that positions should be sent down for, if present
IncludePos Boolean `xml:"INVSTMTRQ>INCPOS>INCLUDE"` // Include position data in response
IncludeBalance Boolean `xml:"INVSTMTRQ>INCBAL"` // Include investment balance in response
Include401K Boolean `xml:"INVSTMTRQ>INC401K,omitempty"` // Include 401k information
Include401KBal Boolean `xml:"INVSTMTRQ>INC401KBAL,omitempty"` // Include 401k balance information
IncludeTranImage Boolean `xml:"INVSTMTRQ>INCTRANIMAGE,omitempty"` // Include transaction images
}
// Name returns the name of the top-level transaction XML/SGML element
func (r *InvStatementRequest) Name() string {
return "INVSTMTTRNRQ"
}
// Valid returns (true, nil) if this struct would be valid OFX if marshalled
// into XML/SGML
func (r *InvStatementRequest) Valid(version ofxVersion) (bool, error) {
if ok, err := r.TrnUID.Valid(); !ok {
return false, err
}
// TODO implement
return true, nil
}
// Type returns which message set this message belongs to (which Request
// element of type []Message it should appended to)
func (r *InvStatementRequest) Type() messageType {
return InvStmtRq
}
// InvTran represents generic investment transaction. It is included in both
// InvBuy and InvSell as well as many of the more specific transaction
// aggregates.
type InvTran struct {
XMLName xml.Name `xml:"INVTRAN"`
FiTID String `xml:"FITID"` // Unique FI-assigned transaction ID. This ID is used to detect duplicate downloads
SrvrTID String `xml:"SRVRTID,omitempty"` // Server assigned transaction ID
DtTrade Date `xml:"DTTRADE"` // trade date; for stock splits, day of record
DtSettle *Date `xml:"DTSETTLE,omitempty"` // settlement date; for stock splits, execution date
ReversalFiTID String `xml:"REVERSALFITID,omitempty"` // For a reversal transaction, the FITID of the transaction that is being reversed.
Memo String `xml:"MEMO,omitempty"`
}
// InvBuy represents generic investment purchase transaction. It is included
// in many of the more specific transaction Buy* aggregates below.
type InvBuy struct {
XMLName xml.Name `xml:"INVBUY"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
UnitPrice Amount `xml:"UNITPRICE"` // For stocks, MFs, other, price per share. Bonds = percentage of par. Option = premium per share of underlying security
Markup Amount `xml:"MARKUP,omitempty"` // Portion of UNITPRICE that is attributed to the dealer markup
Commission Amount `xml:"COMMISSION,omitempty"`
Taxes Amount `xml:"TAXES,omitempty"`
Fees Amount `xml:"FEES,omitempty"`
Load Amount `xml:"LOAD,omitempty"`
Total Amount `xml:"TOTAL"` // Transaction total. Buys, sells, etc.:((quan. * (price +/- markup/markdown)) +/-(commission + fees + load + taxes + penalty + withholding + statewithholding)). Distributions, interest, margin interest, misc. expense, etc.: amount. Return of cap: cost basis
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
// The next three elements must either all be provided, or none of them
LoanID String `xml:"LOANID,omitempty"` // For 401(k) accounts only. Indicates that the transaction was due to a loan or a loan repayment, and which loan it was
LoanPrincipal Amount `xml:"LOANPRINCIPAL,omitempty"` // For 401(k) accounts only. Indicates how much of the loan repayment was principal
LoanInterest Amount `xml:"LOANINTEREST,omitempty"` // For 401(k) accounts only. Indicates how much of the loan repayment was interest
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
DtPayroll *Date `xml:"DTPAYROLL,omitempty"` // For 401(k)accounts, date the funds for this transaction was obtained via payroll deduction
PriorYearContrib Boolean `xml:"PRIORYEARCONTRIB,omitempty"` // For 401(k) accounts, indicates that this Buy was made with a prior year contribution
}
// InvSell represents generic investment sale transaction. It is included in
// many of the more specific transaction Sell* aggregates below.
type InvSell struct {
XMLName xml.Name `xml:"INVSELL"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
UnitPrice Amount `xml:"UNITPRICE"` // For stocks, MFs, other, price per share. Bonds = percentage of par. Option = premium per share of underlying security
Markdown Amount `xml:"MARKDOWN,omitempty"` // Portion of UNITPRICE that is attributed to the dealer markdown
Commission Amount `xml:"COMMISSION,omitempty"`
Taxes Amount `xml:"TAXES,omitempty"`
Fees Amount `xml:"FEES,omitempty"`
Load Amount `xml:"LOAD,omitempty"`
Withholding Amount `xml:"WITHHOLDING,omitempty"` // Federal tax withholdings
TaxExempt Boolean `xml:"TAXEXEMPT,omitempty"` // Tax-exempt transaction
Total Amount `xml:"TOTAL"` // Transaction total. Buys, sells, etc.:((quan. * (price +/- markup/markdown)) +/-(commission + fees + load + taxes + penalty + withholding + statewithholding)). Distributions, interest, margin interest, misc. expense, etc.: amount. Return of cap: cost basis
Gain Amount `xml:"GAIN,omitempty"` // Total gain
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
LoanID String `xml:"LOANID,omitempty"` // For 401(k) accounts only. Indicates that the transaction was due to a loan or a loan repayment, and which loan it was
StateWithholding Amount `xml:"STATEWITHHOLDING,omitempty"` // State tax withholdings
Penalty Amount `xml:"PENALTY,omitempty"` // Amount withheld due to penalty
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// BuyDebt represents a transaction purchasing a debt security
type BuyDebt struct {
XMLName xml.Name `xml:"BUYDEBT"`
InvBuy InvBuy `xml:"INVBUY"`
AccrdInt Amount `xml:"ACCRDINT,omitempty"` // Accrued interest. This amount is not reflected in the <TOTAL> field of a containing aggregate.
}
// TransactionType returns a string representation of this transaction's type
func (t BuyDebt) TransactionType() string {
return "BUYDEBT"
}
// BuyMF represents a transaction purchasing a mutual fund
type BuyMF struct {
XMLName xml.Name `xml:"BUYMF"`
InvBuy InvBuy `xml:"INVBUY"`
BuyType buyType `xml:"BUYTYPE"` // One of BUY, BUYTOCOVER (BUYTOCOVER used to close short sales.)
RelFiTID String `xml:"RELFITID,omitempty"` // used to relate transactions associated with mutual fund exchanges
}
// TransactionType returns a string representation of this transaction's type
func (t BuyMF) TransactionType() string {
return "BUYMF"
}
// BuyOpt represents a transaction purchasing an option
type BuyOpt struct {
XMLName xml.Name `xml:"BUYOPT"`
InvBuy InvBuy `xml:"INVBUY"`
OptBuyType optBuyType `xml:"OPTBUYTYPE"` // type of purchase: BUYTOOPEN, BUYTOCLOSE (The BUYTOOPEN buy type is like “ordinary” buying of option and works like stocks.)
ShPerCtrct Int `xml:"SHPERCTRCT"` // Shares per contract
}
// TransactionType returns a string representation of this transaction's type
func (t BuyOpt) TransactionType() string {
return "BUYOPT"
}
// BuyOther represents a transaction purchasing a type of security not covered
// by the other Buy* structs
type BuyOther struct {
XMLName xml.Name `xml:"BUYOTHER"`
InvBuy InvBuy `xml:"INVBUY"`
}
// TransactionType returns a string representation of this transaction's type
func (t BuyOther) TransactionType() string {
return "BUYOTHER"
}
// BuyStock represents a transaction purchasing stock
type BuyStock struct {
XMLName xml.Name `xml:"BUYSTOCK"`
InvBuy InvBuy `xml:"INVBUY"`
BuyType buyType `xml:"BUYTYPE"` // One of BUY, BUYTOCOVER (BUYTOCOVER used to close short sales.)
}
// TransactionType returns a string representation of this transaction's type
func (t BuyStock) TransactionType() string {
return "BUYSTOCK"
}
// ClosureOpt represents a transaction closing a position for an option
type ClosureOpt struct {
XMLName xml.Name `xml:"CLOSUREOPT"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
OptAction optAction `xml:"OPTACTION"` // One of EXERCISE, ASSIGN, EXPIRE. The EXERCISE action is used to close out an option that is exercised. The ASSIGN action is used when an option writer is assigned. The EXPIRE action is used when the option’s expired date is reached
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
ShPerCtrct Int `xml:"SHPERCTRCT"` // Shares per contract
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
RelFiTID String `xml:"RELFITID,omitempty"` // used to relate transactions associated with mutual fund exchanges
Gain Amount `xml:"GAIN,omitempty"` // Total gain
}
// TransactionType returns a string representation of this transaction's type
func (t ClosureOpt) TransactionType() string {
return "CLOSUREOPT"
}
// Income represents a transaction where investment income is being realized as
// cash into the investment account
type Income struct {
XMLName xml.Name `xml:"INCOME"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
IncomeType incomeType `xml:"INCOMETYPE"` // Type of investment income: CGLONG (capital gains-long term), CGSHORT (capital gains-short term), DIV (dividend), INTEREST, MISC
Total Amount `xml:"TOTAL"`
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
TaxExempt Boolean `xml:"TAXEXEMPT,omitempty"` // Tax-exempt transaction
Withholding Amount `xml:"WITHHOLDING,omitempty"` // Federal tax withholdings
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t Income) TransactionType() string {
return "INCOME"
}
// InvExpense represents a transaction realizing an expense associated with an
// investment
type InvExpense struct {
XMLName xml.Name `xml:"INVEXPENSE"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
Total Amount `xml:"TOTAL"`
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t InvExpense) TransactionType() string {
return "INVEXPENSE"
}
// JrnlFund represents a transaction journaling cash holdings between
// sub-accounts within the same investment account
type JrnlFund struct {
XMLName xml.Name `xml:"JRNLFUND"`
InvTran InvTran `xml:"INVTRAN"`
Total Amount `xml:"TOTAL"`
SubAcctFrom subAcctType `xml:"SUBACCTFROM"` // Sub-account cash is being transferred from: CASH, MARGIN, SHORT, OTHER
SubAcctTo subAcctType `xml:"SUBACCTTO"` // Sub-account cash is being transferred to: CASH, MARGIN, SHORT, OTHER
}
// TransactionType returns a string representation of this transaction's type
func (t JrnlFund) TransactionType() string {
return "JRNLFUND"
}
// JrnlSec represents a transaction journaling security holdings between
// sub-accounts within the same investment account
type JrnlSec struct {
XMLName xml.Name `xml:"JRNLSEC"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
SubAcctFrom subAcctType `xml:"SUBACCTFROM"` // Sub-account cash is being transferred from: CASH, MARGIN, SHORT, OTHER
SubAcctTo subAcctType `xml:"SUBACCTTO"` // Sub-account cash is being transferred to: CASH, MARGIN, SHORT, OTHER
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
}
// TransactionType returns a string representation of this transaction's type
func (t JrnlSec) TransactionType() string {
return "JRNLSEC"
}
// MarginInterest represents a transaction realizing a margin interest expense
type MarginInterest struct {
XMLName xml.Name `xml:"MARGININTEREST"`
InvTran InvTran `xml:"INVTRAN"`
Total Amount `xml:"TOTAL"`
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
}
// TransactionType returns a string representation of this transaction's type
func (t MarginInterest) TransactionType() string {
return "MARGININTEREST"
}
// Reinvest is a single transaction that contains both income and an investment
// transaction. If servers can’t track this as a single transaction they should
// return an Income transaction and an InvTran.
type Reinvest struct {
XMLName xml.Name `xml:"REINVEST"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
IncomeType incomeType `xml:"INCOMETYPE"` // Type of investment income: CGLONG (capital gains-long term), CGSHORT (capital gains-short term), DIV (dividend), INTEREST, MISC
Total Amount `xml:"TOTAL"` // Transaction total. Buys, sells, etc.:((quan. * (price +/- markup/markdown)) +/-(commission + fees + load + taxes + penalty + withholding + statewithholding)). Distributions, interest, margin interest, misc. expense, etc.: amount. Return of cap: cost basis
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
UnitPrice Amount `xml:"UNITPRICE"` // For stocks, MFs, other, price per share. Bonds = percentage of par. Option = premium per share of underlying security
Commission Amount `xml:"COMMISSION,omitempty"`
Taxes Amount `xml:"TAXES,omitempty"`
Fees Amount `xml:"FEES,omitempty"`
Load Amount `xml:"LOAD,omitempty"`
TaxExempt Boolean `xml:"TAXEXEMPT,omitempty"` // Tax-exempt transaction
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t Reinvest) TransactionType() string {
return "REINVEST"
}
// RetOfCap represents a transaction where capital is being returned to the
// account holder
type RetOfCap struct {
XMLName xml.Name `xml:"RETOFCAP"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
Total Amount `xml:"TOTAL"`
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t RetOfCap) TransactionType() string {
return "RETOFCAP"
}
// SellDebt represents the sale of a debt security. Used when debt is sold,
// called, or reaches maturity.
type SellDebt struct {
XMLName xml.Name `xml:"SELLDEBT"`
InvSell InvSell `xml:"INVSELL"`
SellReason sellReason `xml:"SELLREASON"` // CALL (the debt was called), SELL (the debt was sold), MATURITY (the debt reached maturity)
AccrdInt Amount `xml:"ACCRDINT,omitempty"` // Accrued interest
}
// TransactionType returns a string representation of this transaction's type
func (t SellDebt) TransactionType() string {
return "SELLDEBT"
}
// SellMF represents a transaction selling a mutual fund
type SellMF struct {
XMLName xml.Name `xml:"SELLMF"`
InvSell InvSell `xml:"INVSELL"`
SellType sellType `xml:"SELLTYPE"` // Type of sell. SELL, SELLSHORT
AvgCostBasis Amount `xml:"AVGCOSTBASIS"`
RelFiTID String `xml:"RELFITID,omitempty"` // used to relate transactions associated with mutual fund exchanges
}
// TransactionType returns a string representation of this transaction's type
func (t SellMF) TransactionType() string {
return "SELLMF"
}
// SellOpt represents a transaction selling an option. Depending on the value
// of OptSellType, can be used to sell a previously bought option or write a
// new option.
type SellOpt struct {
XMLName xml.Name `xml:"SELLOPT"`
InvSell InvSell `xml:"INVSELL"`
OptSellType optSellType `xml:"OPTSELLTYPE"` // For options, type of sell: SELLTOCLOSE, SELLTOOPEN. The SELLTOCLOSE action is selling a previously bought option. The SELLTOOPEN action is writing an option
ShPerCtrct Int `xml:"SHPERCTRCT"` // Shares per contract
RelFiTID String `xml:"RELFITID,omitempty"` // used to relate transactions associated with mutual fund exchanges
RelType relType `xml:"RELTYPE,omitempty"` // Related option transaction type: SPREAD, STRADDLE, NONE, OTHER
Secured secured `xml:"SECURED,omitempty"` // NAKED, COVERED
}
// TransactionType returns a string representation of this transaction's type
func (t SellOpt) TransactionType() string {
return "SELLOPT"
}
// SellOther represents a transaction selling a security type not covered by
// the other Sell* structs
type SellOther struct {
XMLName xml.Name `xml:"SELLOTHER"`
InvSell InvSell `xml:"INVSELL"`
}
// TransactionType returns a string representation of this transaction's type
func (t SellOther) TransactionType() string {
return "SELLOTHER"
}
// SellStock represents a transaction selling stock
type SellStock struct {
XMLName xml.Name `xml:"SELLSTOCK"`
InvSell InvSell `xml:"INVSELL"`
SellType sellType `xml:"SELLTYPE"` // Type of sell. SELL, SELLSHORT
}
// TransactionType returns a string representation of this transaction's type
func (t SellStock) TransactionType() string {
return "SELLSTOCK"
}
// Split represents a stock or mutual fund split
type Split struct {
XMLName xml.Name `xml:"SPLIT"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
OldUnits Amount `xml:"OLDUNITS"` // number of shares before the split
NewUnits Amount `xml:"NEWUNITS"` // number of shares after the split
Numerator Int `xml:"NUMERATOR"` // split ratio numerator
Denominator Int `xml:"DENOMINATOR"` // split ratio denominator
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency this transaction is in (instead of CURDEF in INVSTMTRS) if Valid()
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency this transaction was converted to INVSTMTRS' CURDEF from if Valid
FracCash Amount `xml:"FRACCASH,omitempty"` // cash for fractional units
SubAcctFund subAcctType `xml:"SUBACCTFUND,omitempty"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t Split) TransactionType() string {
return "SPLIT"
}
// Transfer represents the transfer of securities into or out of an account
type Transfer struct {
XMLName xml.Name `xml:"TRANSFER"`
InvTran InvTran `xml:"INVTRAN"`
SecID SecurityID `xml:"SECID"`
SubAcctSec subAcctType `xml:"SUBACCTSEC"` // Sub-account type for this security. One of CASH, MARGIN, SHORT, OTHER
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
TferAction tferAction `xml:"TFERACTION"` // One of IN, OUT
PosType posType `xml:"POSTYPE"` // Position type. One of LONG, SHORT
InvAcctFrom InvAcct `xml:"INVACCTFROM,omitempty"`
AvgCostBasis Amount `xml:"AVGCOSTBASIS,omitempty"`
UnitPrice Amount `xml:"UNITPRICE,omitempty"` // For stocks, MFs, other, price per share. Bonds = percentage of par. Option = premium per share of underlying security
DtPurchase *Date `xml:"DTPURCHASE,omitempty"`
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // Source of money for this transaction. One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// TransactionType returns a string representation of this transaction's type
func (t Transfer) TransactionType() string {
return "TRANSFER"
}
// InvTransaction is a generic interface met by all investment transactions
// (Buy*, Sell*, & co.)
type InvTransaction interface {
TransactionType() string
}
// InvBankTransaction is a banking transaction performed in an investment
// account. This represents all transactions not related to securities - for
// instance, funding the account using cash from another bank.
type InvBankTransaction struct {
XMLName xml.Name `xml:"INVBANKTRAN"`
Transactions []Transaction `xml:"STMTTRN,omitempty"`
SubAcctFund subAcctType `xml:"SUBACCTFUND"` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
}
// InvTranList represents a list of investment account transactions. It
// includes the date range its transactions cover, as well as the bank- and
// security-related transactions themselves. It must be unmarshalled manually
// due to the structure (don't know what kind of InvTransaction is coming next)
type InvTranList struct {
XMLName xml.Name `xml:"INVTRANLIST"`
DtStart Date
DtEnd Date // This is the value that should be sent as <DTSTART> in the next InvStatementRequest to ensure that no transactions are missed
InvTransactions []InvTransaction
BankTransactions []InvBankTransaction
}
// UnmarshalXML handles unmarshalling an InvTranList element from an SGML/XML
// string
func (l *InvTranList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
for {
tok, err := nextNonWhitespaceToken(d)
if err != nil {
return err
} else if end, ok := tok.(xml.EndElement); ok && end.Name.Local == start.Name.Local {
// If we found the end of our starting element, we're done parsing
return nil
} else if startElement, ok := tok.(xml.StartElement); ok {
switch startElement.Name.Local {
case "DTSTART":
var dtstart Date
if err := d.DecodeElement(&dtstart, &startElement); err != nil {
return err
}
l.DtStart = dtstart
case "DTEND":
var dtend Date
if err := d.DecodeElement(&dtend, &startElement); err != nil {
return err
}
l.DtEnd = dtend
case "BUYDEBT":
var tran BuyDebt
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "BUYMF":
var tran BuyMF
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "BUYOPT":
var tran BuyOpt
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "BUYOTHER":
var tran BuyOther
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "BUYSTOCK":
var tran BuyStock
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "CLOSUREOPT":
var tran ClosureOpt
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "INCOME":
var tran Income
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "INVEXPENSE":
var tran InvExpense
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "JRNLFUND":
var tran JrnlFund
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "JRNLSEC":
var tran JrnlSec
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "MARGININTEREST":
var tran MarginInterest
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "REINVEST":
var tran Reinvest
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "RETOFCAP":
var tran RetOfCap
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SELLDEBT":
var tran SellDebt
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SELLMF":
var tran SellMF
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SELLOPT":
var tran SellOpt
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SELLOTHER":
var tran SellOther
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SELLSTOCK":
var tran SellStock
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "SPLIT":
var tran Split
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "TRANSFER":
var tran Transfer
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.InvTransactions = append(l.InvTransactions, InvTransaction(tran))
case "INVBANKTRAN":
var tran InvBankTransaction
if err := d.DecodeElement(&tran, &startElement); err != nil {
return err
}
l.BankTransactions = append(l.BankTransactions, tran)
default:
return errors.New("Invalid INVTRANLIST child tag: " + startElement.Name.Local)
}
} else {
return errors.New("Didn't find an opening element")
}
}
}
// MarshalXML handles marshalling an InvTranList element to an SGML/XML string
func (l *InvTranList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
invTranListElement := xml.StartElement{Name: xml.Name{Local: "INVTRANLIST"}}
if err := e.EncodeToken(invTranListElement); err != nil {
return err
}
err := e.EncodeElement(&l.DtStart, xml.StartElement{Name: xml.Name{Local: "DTSTART"}})
if err != nil {
return err
}
err = e.EncodeElement(&l.DtEnd, xml.StartElement{Name: xml.Name{Local: "DTEND"}})
if err != nil {
return err
}
for _, t := range l.InvTransactions {
start := xml.StartElement{Name: xml.Name{Local: t.TransactionType()}}
switch tran := t.(type) {
case BuyDebt:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case BuyMF:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case BuyOpt:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case BuyOther:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case BuyStock:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case ClosureOpt:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case Income:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case InvExpense:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case JrnlFund:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case JrnlSec:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case MarginInterest:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case Reinvest:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case RetOfCap:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case SellDebt:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case SellMF:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case SellOpt:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case SellOther:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case SellStock:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case Split:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
case Transfer:
if err := e.EncodeElement(&tran, start); err != nil {
return err
}
default:
return errors.New("Invalid INVTRANLIST child type: " + tran.TransactionType())
}
}
for _, tran := range l.BankTransactions {
err = e.EncodeElement(&tran, xml.StartElement{Name: xml.Name{Local: "INVBANKTRAN"}})
if err != nil {
return err
}
}
if err := e.EncodeToken(invTranListElement.End()); err != nil {
return err
}
return nil
}
// InvPosition contains generic position information included in each of the
// other *Position types
type InvPosition struct {
XMLName xml.Name `xml:"INVPOS"`
SecID SecurityID `xml:"SECID"`
HeldInAcct subAcctType `xml:"HELDINACCT"` // Sub-account type, one of CASH, MARGIN, SHORT, OTHER
PosType posType `xml:"POSTYPE"` // SHORT = Writer for options, Short for all others; LONG = Holder for options, Long for all others.
Units Amount `xml:"UNITS"` // For stocks, MFs, other, number of shares held. Bonds = face value. Options = number of contracts
UnitPrice Amount `xml:"UNITPRICE"` // For stocks, MFs, other, price per share. Bonds = percentage of par. Option = premium per share of underlying security
MktVal Amount `xml:"MKTVAL"` // Market value of this position
AvgCostBasis Amount `xml:"AVGCOSTBASIS,omitempty"` //
DtPriceAsOf Date `xml:"DTPRICEASOF"` // Date and time of unit price and market value, and cost basis. If this date is unknown, use 19900101 as the placeholder; do not use 0,
Currency *Currency `xml:"CURRENCY,omitempty"` // Overriding currency for UNITPRICE
Memo String `xml:"MEMO,omitempty"`
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// Position is an interface satisfied by all the other *Position types
type Position interface {
PositionType() string
}
// DebtPosition represents a position held in a debt security
type DebtPosition struct {
XMLName xml.Name `xml:"POSDEBT"`
InvPos InvPosition `xml:"INVPOS"`
}
// PositionType returns a string representation of this position's type
func (p DebtPosition) PositionType() string {
return "POSDEBT"
}
// MFPosition represents a position held in a mutual fund
type MFPosition struct {
XMLName xml.Name `xml:"POSMF"`
InvPos InvPosition `xml:"INVPOS"`
UnitsStreet Amount `xml:"UNITSSTREET,omitempty"` // Units in the FI’s street name
UnitsUser Amount `xml:"UNITSUSER,omitempty"` // Units in the user's name directly
ReinvDiv Boolean `xml:"REINVDIV,omitempty"` // Reinvest dividends
ReinvCG Boolean `xml:"REINVCG,omitempty"` // Reinvest capital gains
}
// PositionType returns a string representation of this position's type
func (p MFPosition) PositionType() string {
return "POSMF"
}
// OptPosition represents a position held in an option
type OptPosition struct {
XMLName xml.Name `xml:"POSOPT"`
InvPos InvPosition `xml:"INVPOS"`
Secured secured `xml:"SECURED,omitempty"` // One of NAKED, COVERED
}
// PositionType returns a string representation of this position's type
func (p OptPosition) PositionType() string {
return "POSOPT"
}
// OtherPosition represents a position held in a security type not covered by
// the other *Position elements
type OtherPosition struct {
XMLName xml.Name `xml:"POSOTHER"`
InvPos InvPosition `xml:"INVPOS"`
}
// PositionType returns a string representation of this position's type
func (p OtherPosition) PositionType() string {
return "POSOTHER"
}
// StockPosition represents a position held in a stock
type StockPosition struct {
XMLName xml.Name `xml:"POSSTOCK"`
InvPos InvPosition `xml:"INVPOS"`
UnitsStreet Amount `xml:"UNITSSTREET,omitempty"` // Units in the FI’s street name
UnitsUser Amount `xml:"UNITSUSER,omitempty"` // Units in the user's name directly
ReinvDiv Boolean `xml:"REINVDIV,omitempty"` // Reinvest dividends
}
// PositionType returns a string representation of this position's type
func (p StockPosition) PositionType() string {
return "POSSTOCK"
}
// PositionList represents a list of positions held in securities in an
// investment account
type PositionList []Position
// UnmarshalXML handles unmarshalling a PositionList from an XML string
func (p *PositionList) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
for {
tok, err := nextNonWhitespaceToken(d)
if err != nil {
return err
} else if end, ok := tok.(xml.EndElement); ok && end.Name.Local == start.Name.Local {
// If we found the end of our starting element, we're done parsing
return nil
} else if startElement, ok := tok.(xml.StartElement); ok {
switch startElement.Name.Local {
case "POSDEBT":
var position DebtPosition
if err := d.DecodeElement(&position, &startElement); err != nil {
return err
}
*p = append(*p, Position(position))
case "POSMF":
var position MFPosition
if err := d.DecodeElement(&position, &startElement); err != nil {
return err
}
*p = append(*p, Position(position))
case "POSOPT":
var position OptPosition
if err := d.DecodeElement(&position, &startElement); err != nil {
return err
}
*p = append(*p, Position(position))
case "POSOTHER":
var position OtherPosition
if err := d.DecodeElement(&position, &startElement); err != nil {
return err
}
*p = append(*p, Position(position))
case "POSSTOCK":
var position StockPosition
if err := d.DecodeElement(&position, &startElement); err != nil {
return err
}
*p = append(*p, Position(position))
default:
return errors.New("Invalid INVPOSLIST child tag: " + startElement.Name.Local)
}
} else {
return errors.New("Didn't find an opening element")
}
}
}
// MarshalXML handles marshalling a PositionList to an XML string
func (p *PositionList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
invPosListElement := xml.StartElement{Name: xml.Name{Local: "INVPOSLIST"}}
if err := e.EncodeToken(invPosListElement); err != nil {
return err
}
for _, position := range *p {
start := xml.StartElement{Name: xml.Name{Local: position.PositionType()}}
switch pos := position.(type) {
case DebtPosition:
if err := e.EncodeElement(&pos, start); err != nil {
return err
}
case MFPosition:
if err := e.EncodeElement(&pos, start); err != nil {
return err
}
case OptPosition:
if err := e.EncodeElement(&pos, start); err != nil {
return err
}
case OtherPosition:
if err := e.EncodeElement(&pos, start); err != nil {
return err
}
case StockPosition:
if err := e.EncodeElement(&pos, start); err != nil {
return err
}
default:
return errors.New("Invalid INVPOSLIST child type: " + pos.PositionType())
}
}
if err := e.EncodeToken(invPosListElement.End()); err != nil {
return err
}
return nil
}
// InvBalance contains three (or optionally four) specified balances as well as
// a free-form list of generic balance information which may be provided by an
// FI.
type InvBalance struct {
XMLName xml.Name `xml:"INVBAL"`
AvailCash Amount `xml:"AVAILCASH"` // Available cash across all sub-accounts, including sweep funds
MarginBalance Amount `xml:"MARGINBALANCE"` // Negative means customer has borrowed funds
ShortBalance Amount `xml:"SHORTBALANCE"` // Always positive, market value of all short positions
BuyPower Amount `xml:"BUYPOWER, omitempty"`
BalList []Balance `xml:"BALLIST>BAL,omitempty"`
}
// OO represents a generic open investment order. It is included in the other
// OO* elements.
type OO struct {
XMLName xml.Name `xml:"OO"`
FiTID String `xml:"FITID"`
SrvrTID String `xml:"SRVRTID,omitempty"`
SecID SecurityID `xml:"SECID"`
DtPlaced Date `xml:"DTPLACED"` // Date the order was placed
Units Amount `xml:"UNITS"` // Quantity of the security the open order is for
SubAcct subAcctType `xml:"SUBACCT"` // One of CASH, MARGIN, SHORT, OTHER
Duration duration `xml:"DURATION"` // How long the order is good for. One of DAY, GOODTILCANCEL, IMMEDIATE
Restriction restriction `xml:"RESTRICTION"` // Special restriction on the order: One of ALLORNONE, MINUNITS, NONE
MinUnits Amount `xml:"MINUNITS,omitempty"` // Minimum number of units that must be filled for the order
LimitPrice Amount `xml:"LIMITPRICE,omitempty"`
StopPrice Amount `xml:"STOPPRICE,omitempty"`
Memo String `xml:"MEMO,omitempty"`
Currency *Currency `xml:"CURRENCY,omitempty"` // Overriding currency for UNITPRICE
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST for 401(k) accounts. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST
}
// OpenOrder is an interface satisfied by all the OO* elements.
type OpenOrder interface {
OrderType() string
}
// OOBuyDebt represents an open order to purchase a debt security
type OOBuyDebt struct {
XMLName xml.Name `xml:"OOBUYDEBT"`
OO OO `xml:"OO"`
Auction Boolean `xml:"AUCTION"` // whether the debt should be purchased at the auction
DtAuction *Date `xml:"DTAUCTION,omitempty"`
}
// OrderType returns a string representation of this order's type
func (o OOBuyDebt) OrderType() string {
return "OOBUYDEBT"
}
// OOBuyMF represents an open order to purchase a mutual fund
type OOBuyMF struct {
XMLName xml.Name `xml:"OOBUYMF"`
OO OO `xml:"OO"`
BuyType buyType `xml:"BUYTYPE"` // One of BUY, BUYTOCOVER
UnitType unitType `xml:"UNITTYPE"` // What the units represent: one of SHARES, CURRENCY
}
// OrderType returns a string representation of this order's type
func (o OOBuyMF) OrderType() string {
return "OOBUYMF"
}
// OOBuyOpt represents an open order to purchase an option
type OOBuyOpt struct {
XMLName xml.Name `xml:"OOBUYOPT"`
OO OO `xml:"OO"`
OptBuyType optBuyType `xml:"OPTBUYTYPE"` // One of BUYTOOPEN, BUYTOCLOSE
}
// OrderType returns a string representation of this order's type
func (o OOBuyOpt) OrderType() string {
return "OOBUYOPT"
}