2017-03-19 21:08:58 -04:00
package ofxgo
import (
"errors"
2017-10-02 09:21:56 -04:00
"github.com/aclindsa/xml"
2017-03-19 21:08:58 -04:00
)
2017-04-13 06:16:23 -04:00
// 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.
2017-03-19 21:08:58 -04:00
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" `
2017-03-29 05:31:01 -04:00
DtStart * Date ` xml:"INVSTMTRQ>INCTRAN>DTSTART,omitempty" `
DtEnd * Date ` xml:"INVSTMTRQ>INCTRAN>DTEND,omitempty" `
2017-03-19 21:08:58 -04:00
Include Boolean ` xml:"INVSTMTRQ>INCTRAN>INCLUDE" ` // Include transactions (instead of just balance)
IncludeOO Boolean ` xml:"INVSTMTRQ>INCOO" ` // Include open orders
2017-03-29 05:31:01 -04:00
PosDtAsOf * Date ` xml:"INVSTMTRQ>INCPOS>DTASOF,omitempty" ` // Date that positions should be sent down for, if present
2017-03-19 21:08:58 -04:00
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
}
2017-04-13 06:16:23 -04:00
// Name returns the name of the top-level transaction XML/SGML element
2017-03-19 21:08:58 -04:00
func ( r * InvStatementRequest ) Name ( ) string {
return "INVSTMTTRNRQ"
}
2017-04-13 06:16:23 -04:00
// Valid returns (true, nil) if this struct would be valid OFX if marshalled
// into XML/SGML
2017-04-17 11:11:46 -04:00
func ( r * InvStatementRequest ) Valid ( version ofxVersion ) ( bool , error ) {
2017-04-18 20:22:07 -04:00
if ok , err := r . TrnUID . Valid ( ) ; ! ok {
return false , err
}
2017-03-29 05:41:28 -04:00
// TODO implement
2017-03-19 21:08:58 -04:00
return true , nil
}
2017-04-13 06:16:23 -04:00
// Type returns which message set this message belongs to (which Request
// element of type []Message it should appended to)
2017-03-31 09:25:07 -04:00
func ( r * InvStatementRequest ) Type ( ) messageType {
return InvStmtRq
}
2017-04-13 06:16:23 -04:00
// InvTran represents generic investment transaction. It is included in both
// InvBuy and InvSell as well as many of the more specific transaction
// aggregates.
2017-03-21 11:20:24 -04:00
type InvTran struct {
XMLName xml . Name ` xml:"INVTRAN" `
2017-04-13 06:16:23 -04:00
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
2017-03-21 11:20:24 -04:00
DtTrade Date ` xml:"DTTRADE" ` // trade date; for stock splits, day of record
2017-03-29 05:31:01 -04:00
DtSettle * Date ` xml:"DTSETTLE,omitempty" ` // settlement date; for stock splits, execution date
2017-04-12 21:40:42 -04:00
ReversalFiTID String ` xml:"REVERSALFITID,omitempty" ` // For a reversal transaction, the FITID of the transaction that is being reversed.
2017-03-21 11:20:24 -04:00
Memo String ` xml:"MEMO,omitempty" `
}
2017-04-13 06:16:23 -04:00
// InvBuy represents generic investment purchase transaction. It is included
// in many of the more specific transaction Buy* aggregates below.
2017-03-21 11:20:24 -04:00
type InvBuy struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"INVBUY" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-04-12 21:40:42 -04:00
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
2017-03-21 11:20:24 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// InvSell represents generic investment sale transaction. It is included in
// many of the more specific transaction Sell* aggregates below.
2017-03-21 11:20:24 -04:00
type InvSell struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"INVSELL" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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" `
Witholding Amount ` xml:"WITHHOLDING,omitempty" ` // Federal tax witholdings
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
2017-04-12 21:40:42 -04:00
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
2017-03-21 11:20:24 -04:00
StateWitholding Amount ` xml:"STATEWITHHOLDING,omitempty" ` // State tax witholdings
2017-04-06 19:17:52 -04:00
Penalty Amount ` xml:"PENALTY,omitempty" ` // Amount withheld due to penalty
2017-03-21 11:20:24 -04:00
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// BuyDebt represents a transaction purchasing a debt security
2017-03-21 11:20:24 -04:00
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.
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t BuyDebt ) TransactionType ( ) string {
return "BUYDEBT"
}
2017-04-13 06:16:23 -04:00
// BuyMF represents a transaction purchasing a mutual fund
2017-03-21 11:20:24 -04:00
type BuyMF struct {
XMLName xml . Name ` xml:"BUYMF" `
InvBuy InvBuy ` xml:"INVBUY" `
2017-04-06 05:58:22 -04:00
BuyType buyType ` xml:"BUYTYPE" ` // One of BUY, BUYTOCOVER (BUYTOCOVER used to close short sales.)
2017-04-12 21:40:42 -04:00
RelFiTID String ` xml:"RELFITID,omitempty" ` // used to relate transactions associated with mutual fund exchanges
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t BuyMF ) TransactionType ( ) string {
return "BUYMF"
}
2017-04-13 06:16:23 -04:00
// BuyOpt represents a transaction purchasing an option
2017-03-21 11:20:24 -04:00
type BuyOpt struct {
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t BuyOpt ) TransactionType ( ) string {
return "BUYOPT"
}
2017-04-13 06:16:23 -04:00
// BuyOther represents a transaction purchasing a type of security not covered
// by the other Buy* structs
2017-03-21 11:20:24 -04:00
type BuyOther struct {
XMLName xml . Name ` xml:"BUYOTHER" `
InvBuy InvBuy ` xml:"INVBUY" `
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t BuyOther ) TransactionType ( ) string {
return "BUYOTHER"
}
2017-04-13 06:16:23 -04:00
// BuyStock represents a transaction purchasing stock
2017-03-21 11:20:24 -04:00
type BuyStock struct {
XMLName xml . Name ` xml:"BUYSTOCK" `
InvBuy InvBuy ` xml:"INVBUY" `
2017-04-06 05:58:22 -04:00
BuyType buyType ` xml:"BUYTYPE" ` // One of BUY, BUYTOCOVER (BUYTOCOVER used to close short sales.)
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t BuyStock ) TransactionType ( ) string {
return "BUYSTOCK"
}
2017-04-13 06:16:23 -04:00
// ClosureOpt represents a transaction closing a position for an option
2017-03-21 11:20:24 -04:00
type ClosureOpt struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"CLOSUREOPT" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-12 21:40:42 -04:00
RelFiTID String ` xml:"RELFITID,omitempty" ` // used to relate transactions associated with mutual fund exchanges
2017-04-06 05:58:22 -04:00
Gain Amount ` xml:"GAIN,omitempty" ` // Total gain
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t ClosureOpt ) TransactionType ( ) string {
return "CLOSUREOPT"
}
2017-04-13 06:16:23 -04:00
// Income represents a transaction where investment income is being realized as
// cash into the investment account
2017-03-21 11:20:24 -04:00
type Income struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"INCOME" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
Witholding Amount ` xml:"WITHHOLDING,omitempty" ` // Federal tax witholdings
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t Income ) TransactionType ( ) string {
return "INCOME"
}
2017-04-13 06:16:23 -04:00
// InvExpense represents a transaction realizing an expense associated with an
// investment
2017-03-21 11:20:24 -04:00
type InvExpense struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"INVEXPENSE" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t InvExpense ) TransactionType ( ) string {
return "INVEXPENSE"
}
2017-04-13 06:16:23 -04:00
// JrnlFund represents a transaction journaling cash holdings between
// sub-accounts within the same investment account
2017-03-21 11:20:24 -04:00
type JrnlFund struct {
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t JrnlFund ) TransactionType ( ) string {
return "JRNLFUND"
}
2017-04-13 06:16:23 -04:00
// JrnlSec represents a transaction journaling security holdings between
// sub-accounts within the same investment account
2017-03-21 11:20:24 -04:00
type JrnlSec struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"JRNLSEC" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t JrnlSec ) TransactionType ( ) string {
return "JRNLSEC"
}
2017-04-13 06:16:23 -04:00
// MarginInterest represents a transaction realizing a margin interest expense
2017-03-21 11:20:24 -04:00
type MarginInterest struct {
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t MarginInterest ) TransactionType ( ) string {
return "MARGININTEREST"
}
2017-04-13 06:16:23 -04:00
// 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.
2017-03-21 11:20:24 -04:00
type Reinvest struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"REINVEST" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t Reinvest ) TransactionType ( ) string {
return "REINVEST"
}
2017-04-13 06:16:23 -04:00
// RetOfCap represents a transaction where capital is being returned to the
// account holder
2017-03-21 11:20:24 -04:00
type RetOfCap struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"RETOFCAP" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t RetOfCap ) TransactionType ( ) string {
return "RETOFCAP"
}
2017-04-13 06:16:23 -04:00
// SellDebt represents the sale of a debt security. Used when debt is sold,
// called, or reaches maturity.
2017-03-21 11:20:24 -04:00
type SellDebt struct {
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t SellDebt ) TransactionType ( ) string {
return "SELLDEBT"
}
2017-04-13 06:16:23 -04:00
// SellMF represents a transaction selling a mutual fund
2017-03-21 11:20:24 -04:00
type SellMF struct {
XMLName xml . Name ` xml:"SELLMF" `
InvSell InvSell ` xml:"INVSELL" `
2017-04-06 05:58:22 -04:00
SellType sellType ` xml:"SELLTYPE" ` // Type of sell. SELL, SELLSHORT
2017-03-21 11:20:24 -04:00
AvgCostBasis Amount ` xml:"AVGCOSTBASIS" `
2017-04-12 21:40:42 -04:00
RelFiTID String ` xml:"RELFITID,omitempty" ` // used to relate transactions associated with mutual fund exchanges
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t SellMF ) TransactionType ( ) string {
return "SELLMF"
}
2017-04-13 06:16:23 -04:00
// 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.
2017-03-21 11:20:24 -04:00
type SellOpt struct {
2017-04-06 05:58:22 -04:00
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
2017-04-12 21:40:42 -04:00
RelFiTID String ` xml:"RELFITID,omitempty" ` // used to relate transactions associated with mutual fund exchanges
2017-04-06 05:58:22 -04:00
RelType relType ` xml:"RELTYPE,omitempty" ` // Related option transaction type: SPREAD, STRADDLE, NONE, OTHER
Secured secured ` xml:"SECURED,omitempty" ` // NAKED, COVERED
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t SellOpt ) TransactionType ( ) string {
return "SELLOPT"
}
2017-04-13 06:16:23 -04:00
// SellOther represents a transaction selling a security type not covered by
// the other Sell* structs
2017-03-21 11:20:24 -04:00
type SellOther struct {
XMLName xml . Name ` xml:"SELLOTHER" `
InvSell InvSell ` xml:"INVSELL" `
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t SellOther ) TransactionType ( ) string {
return "SELLOTHER"
}
2017-04-13 06:16:23 -04:00
// SellStock represents a transaction selling stock
2017-03-21 11:20:24 -04:00
type SellStock struct {
XMLName xml . Name ` xml:"SELLSTOCK" `
InvSell InvSell ` xml:"INVSELL" `
2017-04-06 05:58:22 -04:00
SellType sellType ` xml:"SELLTYPE" ` // Type of sell. SELL, SELLSHORT
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t SellStock ) TransactionType ( ) string {
return "SELLSTOCK"
}
2017-04-13 06:16:23 -04:00
// Split represents a stock or mutual fund split
2017-03-21 11:20:24 -04:00
type Split struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"SPLIT" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-19 21:23:37 -04:00
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
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t Split ) TransactionType ( ) string {
return "SPLIT"
}
2017-04-13 06:16:23 -04:00
// Transfer represents the transfer of securities into or out of an account
2017-03-21 11:20:24 -04:00
type Transfer struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"TRANSFER" `
InvTran InvTran ` xml:"INVTRAN" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-03-21 11:20:24 -04:00
}
2017-04-13 06:16:23 -04:00
// TransactionType returns a string representation of this transaction's type
2017-03-21 11:20:24 -04:00
func ( t Transfer ) TransactionType ( ) string {
return "TRANSFER"
}
2017-04-13 06:16:23 -04:00
// InvTransaction is a generic interface met by all investment transactions
// (Buy*, Sell*, & co.)
2017-03-21 11:20:24 -04:00
type InvTransaction interface {
TransactionType ( ) string
}
2017-04-13 06:16:23 -04:00
// 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.
2017-03-19 21:08:58 -04:00
type InvBankTransaction struct {
XMLName xml . Name ` xml:"INVBANKTRAN" `
Transactions [ ] Transaction ` xml:"STMTTRN,omitempty" `
2017-04-06 05:58:22 -04:00
SubAcctFund subAcctType ` xml:"SUBACCTFUND" ` // Where did the money for the transaction come from or go to? CASH, MARGIN, SHORT, OTHER
2017-03-19 21:08:58 -04:00
}
2017-04-13 06:16:23 -04:00
// InvTranList represents a list of investment account transactions. It
// includes the date range its transactions cover, as well as the bank- and
2017-04-16 20:46:32 -04:00
// security-related transactions themselves. It must be unmarshalled manually
2017-04-13 06:16:23 -04:00
// due to the structure (don't know what kind of InvTransaction is coming next)
2017-03-21 11:20:24 -04:00
type InvTranList struct {
DtStart Date
2017-04-13 06:16:23 -04:00
DtEnd Date // This is the value that should be sent as <DTSTART> in the next InvStatementRequest to ensure that no transactions are missed
2017-03-21 11:20:24 -04:00
InvTransactions [ ] InvTransaction
BankTransactions [ ] InvBankTransaction
}
2017-04-13 10:18:07 -04:00
// UnmarshalXML handles unmarshalling an InvTranList element from an SGML/XML
// string
2017-03-21 11:20:24 -04:00
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" )
}
}
2017-03-20 21:09:08 -04:00
}
2017-04-13 06:16:23 -04:00
// InvPosition contains generic position information included in each of the
// other *Position types
2017-03-20 21:09:08 -04:00
type InvPosition struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"INVPOS" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-03-20 21:09:08 -04:00
}
2017-04-13 06:16:23 -04:00
// Position is an interface satisfied by all the other *Position types
2017-03-20 21:09:08 -04:00
type Position interface {
PositionType ( ) string
}
2017-04-13 06:16:23 -04:00
// DebtPosition represents a position held in a debt security
2017-03-20 21:09:08 -04:00
type DebtPosition struct {
XMLName xml . Name ` xml:"POSDEBT" `
InvPos InvPosition ` xml:"INVPOS" `
}
2017-04-13 06:16:23 -04:00
// PositionType returns a string representation of this position's type
2017-03-20 21:09:08 -04:00
func ( p DebtPosition ) PositionType ( ) string {
return "POSDEBT"
}
2017-04-13 06:16:23 -04:00
// MFPosition represents a position held in a mutual fund
2017-03-20 21:09:08 -04:00
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
2017-04-10 05:27:47 -04:00
ReinvCG Boolean ` xml:"REINVCG,omitempty" ` // Reinvest capital gains
2017-03-20 21:09:08 -04:00
}
2017-04-13 06:16:23 -04:00
// PositionType returns a string representation of this position's type
2017-03-20 21:09:08 -04:00
func ( p MFPosition ) PositionType ( ) string {
return "POSMF"
}
2017-04-13 06:16:23 -04:00
// OptPosition represents a position held in an option
2017-03-20 21:09:08 -04:00
type OptPosition struct {
XMLName xml . Name ` xml:"POSOPT" `
InvPos InvPosition ` xml:"INVPOS" `
2017-04-06 05:58:22 -04:00
Secured secured ` xml:"SECURED,omitempty" ` // One of NAKED, COVERED
2017-03-20 21:09:08 -04:00
}
2017-04-13 06:16:23 -04:00
// PositionType returns a string representation of this position's type
2017-03-20 21:09:08 -04:00
func ( p OptPosition ) PositionType ( ) string {
return "POSOPT"
}
2017-04-13 06:16:23 -04:00
// OtherPosition represents a position held in a security type not covered by
// the other *Position elements
2017-03-20 21:09:08 -04:00
type OtherPosition struct {
XMLName xml . Name ` xml:"POSOTHER" `
InvPos InvPosition ` xml:"INVPOS" `
}
2017-04-13 06:16:23 -04:00
// PositionType returns a string representation of this position's type
2017-03-20 21:09:08 -04:00
func ( p OtherPosition ) PositionType ( ) string {
return "POSOTHER"
}
2017-04-13 06:16:23 -04:00
// StockPosition represents a position held in a stock
2017-03-20 21:09:08 -04:00
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
}
2017-04-13 06:16:23 -04:00
// PositionType returns a string representation of this position's type
2017-03-20 21:09:08 -04:00
func ( p StockPosition ) PositionType ( ) string {
return "POSSTOCK"
}
2017-04-13 06:16:23 -04:00
// PositionList represents a list of positions held in securities in an
// investment account
2017-03-20 21:09:08 -04:00
type PositionList [ ] Position
2017-04-13 06:16:23 -04:00
// UnmarshalXML handles unmarshalling a PositionList from an XML string
2017-03-21 11:20:24 -04:00
func ( p * PositionList ) UnmarshalXML ( d * xml . Decoder , start xml . StartElement ) error {
2017-03-20 21:09:08 -04:00
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
}
2017-03-21 11:20:24 -04:00
* p = append ( * p , Position ( position ) )
2017-03-20 21:09:08 -04:00
case "POSMF" :
var position MFPosition
if err := d . DecodeElement ( & position , & startElement ) ; err != nil {
return err
}
2017-03-21 11:20:24 -04:00
* p = append ( * p , Position ( position ) )
2017-03-20 21:09:08 -04:00
case "POSOPT" :
var position OptPosition
if err := d . DecodeElement ( & position , & startElement ) ; err != nil {
return err
}
2017-03-21 11:20:24 -04:00
* p = append ( * p , Position ( position ) )
2017-03-20 21:09:08 -04:00
case "POSOTHER" :
var position OtherPosition
if err := d . DecodeElement ( & position , & startElement ) ; err != nil {
return err
}
2017-03-21 11:20:24 -04:00
* p = append ( * p , Position ( position ) )
2017-03-20 21:09:08 -04:00
case "POSSTOCK" :
var position StockPosition
if err := d . DecodeElement ( & position , & startElement ) ; err != nil {
return err
}
2017-03-21 11:20:24 -04:00
* p = append ( * p , Position ( position ) )
2017-03-20 21:09:08 -04:00
default :
return errors . New ( "Invalid INVPOSLIST child tag: " + startElement . Name . Local )
}
} else {
return errors . New ( "Didn't find an opening element" )
}
}
2017-03-19 21:08:58 -04:00
}
2017-04-13 06:16:23 -04:00
// 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.
2017-03-19 21:08:58 -04:00
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
2017-04-13 06:16:23 -04:00
BuyPower Amount ` xml:"BUYPOWER, omitempty" `
2017-03-19 21:08:58 -04:00
BalList [ ] Balance ` xml:"BALLIST>BAL,omitempty" `
}
2017-04-13 06:16:23 -04:00
// OO represents a generic open investment order. It is included in the other
// OO* elements.
2017-04-01 11:05:40 -04:00
type OO struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"OO" `
2017-04-12 21:40:42 -04:00
FiTID String ` xml:"FITID" `
SrvrTID String ` xml:"SRVRTID,omitempty" `
SecID SecurityID ` xml:"SECID" `
2017-04-06 05:58:22 -04:00
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
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OpenOrder is an interface satisfied by all the OO* elements.
2017-04-01 11:05:40 -04:00
type OpenOrder interface {
OrderType ( ) string
}
2017-04-13 06:16:23 -04:00
// OOBuyDebt represents an open order to purchase a debt security
2017-04-01 11:05:40 -04:00
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" `
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOBuyDebt ) OrderType ( ) string {
return "OOBUYDEBT"
}
2017-04-13 06:16:23 -04:00
// OOBuyMF represents an open order to purchase a mutual fund
2017-04-01 11:05:40 -04:00
type OOBuyMF struct {
XMLName xml . Name ` xml:"OOBUYMF" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
BuyType buyType ` xml:"BUYTYPE" ` // One of BUY, BUYTOCOVER
UnitType unitType ` xml:"UNITTYPE" ` // What the units represent: one of SHARES, CURRENCY
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOBuyMF ) OrderType ( ) string {
return "OOBUYMF"
}
2017-04-13 06:16:23 -04:00
// OOBuyOpt represents an open order to purchase an option
2017-04-01 11:05:40 -04:00
type OOBuyOpt struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"OOBUYOPT" `
OO OO ` xml:"OO" `
OptBuyType optBuyType ` xml:"OPTBUYTYPE" ` // One of BUYTOOPEN, BUYTOCLOSE
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOBuyOpt ) OrderType ( ) string {
return "OOBUYOPT"
}
2017-04-13 06:16:23 -04:00
// OOBuyOther represents an open order to purchase a security type not covered
// by the other OOBuy* elements
2017-04-01 11:05:40 -04:00
type OOBuyOther struct {
XMLName xml . Name ` xml:"OOBUYOTHER" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
UnitType unitType ` xml:"UNITTYPE" ` // What the units represent: one of SHARES, CURRENCY
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOBuyOther ) OrderType ( ) string {
return "OOBUYOTHER"
}
2017-04-13 06:16:23 -04:00
// OOBuyStock represents an open order to purchase stock
2017-04-01 11:05:40 -04:00
type OOBuyStock struct {
XMLName xml . Name ` xml:"OOBUYSTOCK" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
BuyType buyType ` xml:"BUYTYPE" ` // One of BUY, BUYTOCOVER
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOBuyStock ) OrderType ( ) string {
return "OOBUYSTOCK"
}
2017-04-13 06:16:23 -04:00
// OOSellDebt represents an open order to sell a debt security
2017-04-01 11:05:40 -04:00
type OOSellDebt struct {
XMLName xml . Name ` xml:"OOSELLDEBT" `
OO OO ` xml:"OO" `
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSellDebt ) OrderType ( ) string {
return "OOSELLDEBT"
}
2017-04-13 06:16:23 -04:00
// OOSellMF represents an open order to sell a mutual fund
2017-04-01 11:05:40 -04:00
type OOSellMF struct {
XMLName xml . Name ` xml:"OOSELLMF" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
SellType sellType ` xml:"SELLTYPE" ` // One of SELL, SELLSHORT
UnitType unitType ` xml:"UNITTYPE" ` // What the units represent: one of SHARES, CURRENCY
2017-04-01 11:05:40 -04:00
SellAll Boolean ` xml:"SELLALL" ` // Sell entire holding
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSellMF ) OrderType ( ) string {
return "OOSELLMF"
}
2017-04-13 06:16:23 -04:00
// OOSellOpt represents an open order to sell an option
2017-04-01 11:05:40 -04:00
type OOSellOpt struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"OOSELLOPT" `
OO OO ` xml:"OO" `
OptSellType optSellType ` xml:"OPTSELLTYPE" ` // One of SELLTOOPEN, SELLTOCLOSE
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSellOpt ) OrderType ( ) string {
return "OOSELLOPT"
}
2017-04-13 06:16:23 -04:00
// OOSellOther represents an open order to sell a security type not covered by
// the other OOSell* elements
2017-04-01 11:05:40 -04:00
type OOSellOther struct {
XMLName xml . Name ` xml:"OOSELLOTHER" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
UnitType unitType ` xml:"UNITTYPE" ` // What the units represent: one of SHARES, CURRENCY
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSellOther ) OrderType ( ) string {
return "OOSELLOTHER"
}
2017-04-13 06:16:23 -04:00
// OOSellStock represents an open order to sell stock
2017-04-01 11:05:40 -04:00
type OOSellStock struct {
XMLName xml . Name ` xml:"OOSELLSTOCK" `
OO OO ` xml:"OO" `
2017-04-06 05:58:22 -04:00
SellType sellType ` xml:"SELLTYPE" ` // One of SELL, SELLSHORT
2017-04-01 11:05:40 -04:00
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSellStock ) OrderType ( ) string {
return "OOSELLSTOCK"
}
2017-04-13 06:16:23 -04:00
// OOSwitchMF represents an open order to switch to or purchase a different
// mutual fund
2017-04-01 11:05:40 -04:00
type OOSwitchMF struct {
XMLName xml . Name ` xml:"SWITCHMF" `
OO OO ` xml:"OO" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" ` // Security ID of the fund to switch to or purchase
2017-04-06 05:58:22 -04:00
UnitType unitType ` xml:"UNITTYPE" ` // What the units represent: one of SHARES, CURRENCY
2017-04-01 11:05:40 -04:00
SwitchAll Boolean ` xml:"SWITCHALL" ` // Switch entire holding
}
2017-04-13 06:16:23 -04:00
// OrderType returns a string representation of this order's type
2017-04-01 11:05:40 -04:00
func ( o OOSwitchMF ) OrderType ( ) string {
return "SWITCHMF"
}
2017-04-13 06:16:23 -04:00
// OOList represents a list of open orders (OO* elements)
2017-04-01 11:05:40 -04:00
type OOList [ ] OpenOrder
2017-04-13 06:16:23 -04:00
// UnmarshalXML handles unmarshalling an OOList element from an XML string
2017-04-01 11:05:40 -04:00
func ( o * OOList ) 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 "OOBUYDEBT" :
var oo OOBuyDebt
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOBUYMF" :
var oo OOBuyMF
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOBUYOPT" :
var oo OOBuyOpt
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOBUYOTHER" :
var oo OOBuyOther
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOBUYSTOCK" :
var oo OOBuyStock
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOSELLDEBT" :
var oo OOSellDebt
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOSELLMF" :
var oo OOSellMF
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOSELLOPT" :
var oo OOSellOpt
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOSELLOTHER" :
var oo OOSellOther
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "OOSELLSTOCK" :
var oo OOSellStock
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
case "SWITCHMF" :
var oo OOSwitchMF
if err := d . DecodeElement ( & oo , & startElement ) ; err != nil {
return err
}
* o = append ( * o , OpenOrder ( oo ) )
default :
return errors . New ( "Invalid OOList child tag: " + startElement . Name . Local )
}
} else {
return errors . New ( "Didn't find an opening element" )
}
}
}
2017-04-13 06:16:23 -04:00
// ContribSecurity identifies current contribution allocation for a security in
// a 401(k) account
2017-03-27 20:13:32 -04:00
type ContribSecurity struct {
XMLName xml . Name ` xml:"CONTRIBSECURITY" `
2017-04-12 21:40:42 -04:00
SecID SecurityID ` xml:"SECID" `
2017-03-27 20:13:32 -04:00
PreTaxContribPct Amount ` xml:"PRETAXCONTRIBPCT,omitempty" ` // Percentage of each new employee pretax contribution allocated to this security, rate.
PreTaxContribAmt Amount ` xml:"PRETAXCONTRIBAMT,omitempty" ` // Fixed amount of each new employee pretax contribution allocated to this security, amount
AfterTaxContribPct Amount ` xml:"AFTERTAXCONTRIBPCT,omitempty" ` // Percentage of each new employee after tax contribution allocated to this security, rate.
AfterTaxContribAmt Amount ` xml:"AFTERTAXCONTRIBAMT,omitempty" ` // Fixed amount of each new employee pretax contribution allocated to this security, amount.
MatchContribPct Amount ` xml:"MATCHCONTRIBPCT,omitempty" ` // Percentage of each new employer match contribution allocated to this security, rate.
MatchContribAmt Amount ` xml:"MATCHCONTRIBAMT,omitempty" ` // Fixed amount of each new employer match contribution allocated to this security, amount.
ProfitSharingContribPct Amount ` xml:"PROFITSHARINGCONTRIBPCT,omitempty" ` // Percentage of each new employer profit sharing contribution allocated to this security, rate.
ProfitSharingContribAmt Amount ` xml:"PROFITSHARINGCONTRIBAMT,omitempty" ` // Fixed amount of each new employer profit sharing contribution allocated to this security, amount.
RolloverContribPct Amount ` xml:"ROLLOVERCONTRIBPCT,omitempty" ` // Percentage of new rollover contributions allocated to this security, rate.
RolloverContribAmt Amount ` xml:"ROLLOVERCONTRIBAMT,omitempty" ` // Fixed amount of new rollover contributions allocated to this security, amount.
OtherVestPct Amount ` xml:"OTHERVESTPCT,omitempty" ` // Percentage of each new other employer contribution allocated to this security, rate.
OtherVestAmt Amount ` xml:"OTHERVESTAMT,omitempty" ` // Fixed amount of each new other employer contribution allocated to this security, amount.
OtherNonVestPct Amount ` xml:"OTHERNONVESTPCT,omitempty" ` // Percentage of each new other employee contribution allocated to this security, rate.
OtherNonVestAmt Amount ` xml:"OTHERNONVESTAMT,omitempty" ` // Fixed amount of each new other employee contribution allocated to this security, amount
}
2017-04-13 06:16:23 -04:00
// VestInfo provides the vesting percentage of a 401(k) account as of a
// particular date (past, present, or future)
2017-03-27 20:13:32 -04:00
type VestInfo struct {
XMLName xml . Name ` xml:"VESTINFO" `
2017-03-29 05:31:01 -04:00
VestDate * Date ` xml:"VESTDATE,omitempty" ` // Date at which vesting percentage changes. Default (if empty) is that the vesting percentage below applies to the current date
2017-03-27 20:13:32 -04:00
VestPct Amount ` xml:"VESTPCT" `
}
2017-04-13 06:16:23 -04:00
// LoanInfo represents a loan outstanding against this 401(k) account
2017-03-27 20:13:32 -04:00
type LoanInfo struct {
2017-04-06 05:58:22 -04:00
XMLName xml . Name ` xml:"VESTINFO" `
LoanID String ` xml:"LOANID" ` // Identifier of this loan
LoanDesc String ` xml:"LOANDESC,omitempty" ` // Loan description
InitialLoanBal Amount ` xml:"INITIALLOANBAL,omitempty" ` // Initial loan balance
LoanStartDate * Date ` xml:"LOANSTARTDATE,omitempty" ` // Start date of loan
CurrentLoanBal Amount ` xml:"CURRENTLOANBAL" ` // Current loan principal balance
DtAsOf * Date ` xml:"DTASOF" ` // Date and time of the current loan balance
LoanRate Amount ` xml:"LOANRATE,omitempty" ` // Loan annual interest rate
LoanPmtAmt Amount ` xml:"LOANPMTAMT,omitempty" ` // Loan payment amount
LoanPmtFreq loanPmtFreq ` xml:"LOANPMTFREQ,omitempty" ` // Frequency of loan repayments: WEEKLY, BIWEEKLY, TWICEMONTHLY, MONTHLY, FOURWEEKS, BIMONTHLY, QUARTERLY, SEMIANNUALLY, ANNUALLY, OTHER. See section 10.2.1 for calculation rules.
LoanPmtsInitial Int ` xml:"LOANPMTSINITIAL,omitempty" ` // Initial number of loan payments.
LoanPmtsRemaining Int ` xml:"LOANPMTSREMAINING,omitempty" ` // Remaining number of loan payments
LoanMaturityDate * Date ` xml:"LOANMATURITYDATE,omitempty" ` // Expected loan end date
LoanTotalProjInterest Amount ` xml:"LOANTOTALPROJINTEREST,omitempty" ` // Total projected interest to be paid on this loan
LoanInterestToDate Amount ` xml:"LOANINTERESTTODATE,omitempty" ` // Total interested paid to date on this loan
LoanExtPmtDate * Date ` xml:"LOANNEXTPMTDATE,omitempty" ` // Next payment due date
2017-03-27 20:13:32 -04:00
}
2017-04-13 06:16:23 -04:00
// Inv401KSummaryAggregate represents the total of either contributions,
// withdrawals, or earnings made in each contribution type in a given period
// (dates specified in a containing Inv401KSummaryPeriod)
2017-03-27 20:13:32 -04:00
type Inv401KSummaryAggregate struct {
XMLName xml . Name // One of CONTRIBUTIONS, WITHDRAWALS, EARNINGS
2017-04-13 06:16:23 -04:00
PreTax Amount ` xml:"PRETAX,omitempty" ` // Pretax contributions, withdrawals, or earlings.
AfterTax Amount ` xml:"AFTERTAX,omitempty" ` // After tax contributions, withdrawals, or earlings.
Match Amount ` xml:"MATCH,omitempty" ` // Employer matching contributions, withdrawals, or earlings.
ProfitSharing Amount ` xml:"PROFITSHARING,omitempty" ` // Profit sharing contributions, withdrawals, or earlings.
Rollover Amount ` xml:"ROLLOVER,omitempty" ` // Rollover contributions, withdrawals, or earlings.
OtherVest Amount ` xml:"OTHERVEST,omitempty" ` // Other vesting contributions, withdrawals, or earlings.
OtherNonVest Amount ` xml:"OTHERNONVEST,omitempty" ` // Other non-vesting contributions, withdrawals, or earlings.
Total Amount ` xml:"TOTAL" ` // Sum of contributions, withdrawals, or earlings from all fund sources.
}
// Inv401KSummaryPeriod contains the total contributions, withdrawals, and
// earnings made in the given date range
2017-03-27 20:13:32 -04:00
type Inv401KSummaryPeriod struct {
2017-03-29 05:31:01 -04:00
XMLName xml . Name // One of YEARTODATE, INCEPTODATE, or PERIODTODATE
DtStart Date ` xml:"DTSTART" `
DtEnd Date ` xml:"DTEND" `
Contributions * Inv401KSummaryAggregate ` xml:"CONTRIBUTIONS,omitempty" ` // 401(k) contribution aggregate. Note: this includes loan payments.
Withdrawls * Inv401KSummaryAggregate ` xml:"WITHDRAWLS,omitempty" ` // 401(k) withdrawals aggregate. Note: this includes loan withdrawals.
Earnings * Inv401KSummaryAggregate ` xml:"EARNINGS,omitempty" ` // 401(k) earnings aggregate. This is the market value change. It includes dividends/interest, and capital gains - realized and unrealized.
2017-03-27 20:13:32 -04:00
}
2017-04-13 06:16:23 -04:00
// Inv401K is included in InvStatementResponse for 401(k) accounts and provides
// a summary of the 401(k) specific information about the user's account.
2017-03-27 20:13:32 -04:00
type Inv401K struct {
XMLName xml . Name ` xml:"INV401K" `
EmployerName String ` xml:"EMPLOYERNAME" `
PlanID String ` xml:"PLANID,omitempty" ` // Plan number
2017-03-29 05:31:01 -04:00
PlanJoinDate * Date ` xml:"PLANJOINDATE,omitempty" ` // Date the employee joined the plan
2017-03-27 20:13:32 -04:00
EmployerContactInfo String ` xml:"EMPLOYERCONTACTINFO,omitempty" ` // Name of contact person at employer, plus any available contact information, such as phone number
BrokerContactInfo String ` xml:"BROKERCONTACTINFO,omitempty" ` // Name of contact person at broker, plus any available contact information, such as phone number
DeferPctPreTax Amount ` xml:"DEFERPCTPRETAX,omitempty" ` // Percent of employee salary deferred before tax
DeferPctAfterTax Amount ` xml:"DEFERPCTAFTERTAX,omitempty" ` // Percent of employee salary deferred after tax
//<MATCHINFO> Aggregate containing employer match information. Absent if employer does not contribute matching funds.
2017-03-29 05:31:01 -04:00
MatchPct Amount ` xml:"MATCHINFO>MATCHPCT,omitempty" ` // Percent of employee contribution matched, e.g., 75% if contribution rate is $0.75/$1.00
MaxMatchAmt Amount ` xml:"MATCHINFO>MAXMATCHAMT,omitempty" ` // Maximum employer contribution amount in any year
MaxMatchPct Amount ` xml:"MATCHINFO>MAXMATCHPCT,omitempty" ` // Current maximum employer contribution percentage. Maximum match in a year is MAXMATCHPCT up to the MAXMATCHAMT, if provided
StartOfYear * Date ` xml:"MATCHINFO>STARTOFYEAR,omitempty" ` // Specifies when the employer contribution max is reset. Some plans have a maximum based on the company fiscal year rather than calendar year. Assume calendar year if omitted. Only the month and day (MMDD) are used; year (YYYY) and time are ignored
BaseMatchAmt Amount ` xml:"MATCHINFO>BASEMATCHAMT" ` // Specifies a fixed dollar amount contributed by the employer if the employee participates in the plan at all. This may be present in addition to the <MATCHPCT>. $0 if omitted
BaseMatchPct Amount ` xml:"MATCHINFO>BASEMATCHPCT" ` // Specifies a fixed percent of employee salary matched if the employee participates in the plan at all. This may be present in addition to the MATCHPCT>. 0% if omitted. Base match in a year is BASEMATCHPCT up to the BASEMATCHAMT,if provided
ContribInfo [ ] ContribSecurity ` xml:"CONTRIBINTO>CONTRIBSECURITY" ` // Aggregate to describe how new contributions are distributed among the available securities.
CurrentVestPct Amount ` xml:"CURRENTVESTPCT,omitempty" ` // Estimated percentage of employer contributions vested as of the current date. If omitted, assume 100%
VestInfo [ ] VestInfo ` xml:"VESTINFO,omitempty" ` // Vest change dates. Provides the vesting percentage as of any particular past, current, or future date. 0 or more.
LoanInfo [ ] LoanInfo ` xml:"LOANINFO,omitempty" ` // List of any loans outstanding against this account
YearToDateSummary Inv401KSummaryPeriod ` xml:"INV401KSUMMARY>YEARTODATE" ` // Contributions to date for this calendar year.
InceptToDateSummary * Inv401KSummaryPeriod ` xml:"INV401KSUMMARY>INCEPTODATE,omitempty" ` // Total contributions to date (since inception)
PeriodToDate * Inv401KSummaryPeriod ` xml:"INV401KSUMMARY>PERIODTODATE,omitempty" ` // Total contributions this contribution period
2017-03-27 20:13:32 -04:00
}
2017-04-13 06:16:23 -04:00
// Inv401KBal provides the balances for different 401(k) subaccount types, as
// well as the total cash value of the securities held
2017-03-27 20:13:32 -04:00
type Inv401KBal struct {
XMLName xml . Name ` xml:"INV401KBAL" `
CashBal Amount ` xml:"CASHBAL,omitempty" ` // Available cash balance
PreTax Amount ` xml:"PRETAX,omitempty" ` // Current value of all securities purchased with Before Tax Employee contributions
AfterTax Amount ` xml:"AFTERTAX,omitempty" ` // Current value of all securities purchased with After Tax Employee contributions
Match Amount ` xml:"MATCH,omitempty" ` // Current value of all securities purchased with Employer Match contributions
ProfitSharing Amount ` xml:"PROFITSHARING,omitempty" ` // Current value of all securities purchased with Employer Profit Sharing contributions
Rollover Amount ` xml:"ROLLOVER,omitempty" ` // Current value of all securities purchased with Rollover contributions
OtherVest Amount ` xml:"OTHERVEST,omitempty" ` // Current value of all securities purchased with Other (vesting) Employer contributions
OtherNonVest Amount ` xml:"OTHERNONVEST,omitempty" ` // Current value of all securities purchased with Other (non-vesting) Employer contributions
Total Amount ` xml:"TOTAL" ` // Current value of all securities purchased with all contributions
BalList [ ] Balance ` xml:"BALLIST>BAL,omitempty" `
}
2017-04-13 06:16:23 -04:00
// InvStatementResponse includes requested transaction, position, open order,
// and balance information for an investment account. It is in response to an
// InvStatementRequest or sometimes provided as part of an OFX file downloaded
// manually from an FI.
2017-03-19 21:08:58 -04:00
type InvStatementResponse struct {
XMLName xml . Name ` xml:"INVSTMTTRNRS" `
TrnUID UID ` xml:"TRNUID" `
Status Status ` xml:"STATUS" `
CltCookie String ` xml:"CLTCOOKIE,omitempty" `
2017-03-30 10:24:26 -04:00
// TODO `xml:"OFXEXTENSION,omitempty"`
2017-03-21 11:20:24 -04:00
DtAsOf Date ` xml:"INVSTMTRS>DTASOF" `
2017-04-17 20:20:22 -04:00
CurDef CurrSymbol ` xml:"INVSTMTRS>CURDEF" `
2017-03-21 11:20:24 -04:00
InvAcctFrom InvAcct ` xml:"INVSTMTRS>INVACCTFROM" `
2017-03-29 05:31:01 -04:00
InvTranList * InvTranList ` xml:"INVSTMTRS>INVTRANLIST,omitempty" `
2017-03-21 11:20:24 -04:00
InvPosList PositionList ` xml:"INVSTMTRS>INVPOSLIST,omitempty" `
2017-03-29 05:31:01 -04:00
InvBal * InvBalance ` xml:"INVSTMTRS>INVBAL,omitempty" `
2017-04-01 11:05:40 -04:00
InvOOList OOList ` xml:"INVSTMTRS>INVOOLIST,omitempty" `
MktgInfo String ` xml:"INVSTMTRS>MKTGINFO,omitempty" ` // Marketing information
Inv401K * Inv401K ` xml:"INVSTMTRS>INV401K,omitempty" `
Inv401KBal * Inv401KBal ` xml:"INVSTMTRS>INV401KBAL,omitempty" `
2017-03-19 21:08:58 -04:00
}
2017-04-13 06:16:23 -04:00
// Name returns the name of the top-level transaction XML/SGML element
2017-03-31 11:54:43 -04:00
func ( sr * InvStatementResponse ) Name ( ) string {
2017-03-19 21:08:58 -04:00
return "INVSTMTTRNRS"
}
2017-04-13 06:16:23 -04:00
// Valid returns (true, nil) if this struct was valid OFX when unmarshalled
2017-04-17 11:11:46 -04:00
func ( sr * InvStatementResponse ) Valid ( version ofxVersion ) ( bool , error ) {
2017-04-18 20:22:07 -04:00
if ok , err := sr . TrnUID . Valid ( ) ; ! ok {
return false , err
}
2017-03-19 21:08:58 -04:00
//TODO implement
return true , nil
}
2017-04-13 06:16:23 -04:00
// Type returns which message set this message belongs to (which Response
// element of type []Message it belongs to)
2017-03-31 11:54:43 -04:00
func ( sr * InvStatementResponse ) Type ( ) messageType {
2017-03-31 09:25:07 -04:00
return InvStmtRs
}