mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-22 03:30:04 -05:00
Add comments for generated constants
This commit is contained in:
parent
a05882fcda
commit
c6ef8be074
167
constants.go
167
constants.go
@ -15,6 +15,7 @@ import (
|
||||
|
||||
type acctType uint
|
||||
|
||||
// AcctType* constants represent types of bank accounts
|
||||
const (
|
||||
AcctTypeChecking acctType = 1 + iota
|
||||
AcctTypeSavings
|
||||
@ -82,6 +83,7 @@ func NewAcctType(s string) (acctType, error) {
|
||||
|
||||
type trnType uint
|
||||
|
||||
// TrnType* constants represent types of transactions. INT, ATM, and POS depend on the signage of the account.
|
||||
const (
|
||||
TrnTypeCredit trnType = 1 + iota
|
||||
TrnTypeDebit
|
||||
@ -162,6 +164,7 @@ func NewTrnType(s string) (trnType, error) {
|
||||
|
||||
type imageType uint
|
||||
|
||||
// ImageType* constants represent what this image contains
|
||||
const (
|
||||
ImageTypeStatement imageType = 1 + iota
|
||||
ImageTypeTransaction
|
||||
@ -227,6 +230,7 @@ func NewImageType(s string) (imageType, error) {
|
||||
|
||||
type imageRefType uint
|
||||
|
||||
// ImageRefType* constants represent the type of reference to the image
|
||||
const (
|
||||
ImageRefTypeOpaque imageRefType = 1 + iota
|
||||
ImageRefTypeURL
|
||||
@ -292,6 +296,7 @@ func NewImageRefType(s string) (imageRefType, error) {
|
||||
|
||||
type checkSup uint
|
||||
|
||||
// CheckSup* constants represent what portions of the check this image contains
|
||||
const (
|
||||
CheckSupFrontOnly checkSup = 1 + iota
|
||||
CheckSupBackOnly
|
||||
@ -357,6 +362,7 @@ func NewCheckSup(s string) (checkSup, error) {
|
||||
|
||||
type correctAction uint
|
||||
|
||||
// CorrectAction* constants represent whether this transaction correction replaces or deletes the transaction matching its CORRECTFITID
|
||||
const (
|
||||
CorrectActionDelete correctAction = 1 + iota
|
||||
CorrectActionReplace
|
||||
@ -421,6 +427,7 @@ func NewCorrectAction(s string) (correctAction, error) {
|
||||
|
||||
type balType uint
|
||||
|
||||
// BalType* constants represent how this BAL's VALUE field should be interpreted
|
||||
const (
|
||||
BalTypeDollar balType = 1 + iota
|
||||
BalTypePercent
|
||||
@ -486,6 +493,7 @@ func NewBalType(s string) (balType, error) {
|
||||
|
||||
type inv401kSource uint
|
||||
|
||||
// Inv401kSource* constants represent the source of money used for this security in a 401(k) account. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST.
|
||||
const (
|
||||
Inv401kSourcePreTax inv401kSource = 1 + iota
|
||||
Inv401kSourceAfterTax
|
||||
@ -555,6 +563,7 @@ func NewInv401kSource(s string) (inv401kSource, error) {
|
||||
|
||||
type subAcctType uint
|
||||
|
||||
// SubAcctType* constants represent the sub-account type for a source and/or destination of a transaction. Used in fields named SubAcctFrom, SubAcctTo, SubAcctSec, SubAcctFund, HeldInAcct.
|
||||
const (
|
||||
SubAcctTypeCash subAcctType = 1 + iota
|
||||
SubAcctTypeMargin
|
||||
@ -621,6 +630,7 @@ func NewSubAcctType(s string) (subAcctType, error) {
|
||||
|
||||
type buyType uint
|
||||
|
||||
// BuyType* constants represent types of purchases
|
||||
const (
|
||||
BuyTypeBuy buyType = 1 + iota
|
||||
BuyTypeBuyToCover
|
||||
@ -685,6 +695,7 @@ func NewBuyType(s string) (buyType, error) {
|
||||
|
||||
type optAction uint
|
||||
|
||||
// OptAction* constants represent types of actions for options
|
||||
const (
|
||||
OptActionExercise optAction = 1 + iota
|
||||
OptActionAssign
|
||||
@ -750,6 +761,7 @@ func NewOptAction(s string) (optAction, error) {
|
||||
|
||||
type tferAction uint
|
||||
|
||||
// TferAction* constants represent whether the transfer is into or out of this account
|
||||
const (
|
||||
TferActionIn tferAction = 1 + iota
|
||||
TferActionOut
|
||||
@ -814,6 +826,7 @@ func NewTferAction(s string) (tferAction, error) {
|
||||
|
||||
type posType uint
|
||||
|
||||
// PosType* constants represent position type
|
||||
const (
|
||||
PosTypeLong posType = 1 + iota
|
||||
PosTypeShort
|
||||
@ -878,6 +891,7 @@ func NewPosType(s string) (posType, error) {
|
||||
|
||||
type secured uint
|
||||
|
||||
// Secured* constants represent how an option is secured
|
||||
const (
|
||||
SecuredNaked secured = 1 + iota
|
||||
SecuredCovered
|
||||
@ -942,6 +956,7 @@ func NewSecured(s string) (secured, error) {
|
||||
|
||||
type duration uint
|
||||
|
||||
// Duration* constants represent how long the investment order is good for
|
||||
const (
|
||||
DurationDay duration = 1 + iota
|
||||
DurationGoodTilCancel
|
||||
@ -1007,6 +1022,7 @@ func NewDuration(s string) (duration, error) {
|
||||
|
||||
type restriction uint
|
||||
|
||||
// Restriction* constants represent a special restriction on an investment order
|
||||
const (
|
||||
RestrictionAllOrNone restriction = 1 + iota
|
||||
RestrictionMinUnits
|
||||
@ -1072,6 +1088,7 @@ func NewRestriction(s string) (restriction, error) {
|
||||
|
||||
type unitType uint
|
||||
|
||||
// UnitType* constants represent type of the UNITS value
|
||||
const (
|
||||
UnitTypeShares unitType = 1 + iota
|
||||
UnitTypeCurrency
|
||||
@ -1136,6 +1153,7 @@ func NewUnitType(s string) (unitType, error) {
|
||||
|
||||
type optBuyType uint
|
||||
|
||||
// OptBuyType* constants represent types of purchases for options
|
||||
const (
|
||||
OptBuyTypeBuyToOpen optBuyType = 1 + iota
|
||||
OptBuyTypeBuyToClose
|
||||
@ -1200,6 +1218,7 @@ func NewOptBuyType(s string) (optBuyType, error) {
|
||||
|
||||
type sellType uint
|
||||
|
||||
// SellType* constants represent types of sales
|
||||
const (
|
||||
SellTypeSell sellType = 1 + iota
|
||||
SellTypeSellShort
|
||||
@ -1264,6 +1283,7 @@ func NewSellType(s string) (sellType, error) {
|
||||
|
||||
type loanPmtFreq uint
|
||||
|
||||
// LoanPmtFreq* constants represent the frequency of loan payments
|
||||
const (
|
||||
LoanPmtFreqWeekly loanPmtFreq = 1 + iota
|
||||
LoanPmtFreqBiweekly
|
||||
@ -1336,6 +1356,7 @@ func NewLoanPmtFreq(s string) (loanPmtFreq, error) {
|
||||
|
||||
type incomeType uint
|
||||
|
||||
// IncomeType* constants represent types of investment income
|
||||
const (
|
||||
IncomeTypeCGLong incomeType = 1 + iota
|
||||
IncomeTypeCGShort
|
||||
@ -1403,6 +1424,7 @@ func NewIncomeType(s string) (incomeType, error) {
|
||||
|
||||
type sellReason uint
|
||||
|
||||
// SellReason* constants represent the reason the sell of a debt security was generated: CALL (the debt was called), SELL (the debt was sold), MATURITY (the debt reached maturity)
|
||||
const (
|
||||
SellReasonCall sellReason = 1 + iota
|
||||
SellReasonSell
|
||||
@ -1468,6 +1490,7 @@ func NewSellReason(s string) (sellReason, error) {
|
||||
|
||||
type optSellType uint
|
||||
|
||||
// OptSellType* constants represent types of sales for options
|
||||
const (
|
||||
OptSellTypeSellToClose optSellType = 1 + iota
|
||||
OptSellTypeSellToOpen
|
||||
@ -1532,6 +1555,7 @@ func NewOptSellType(s string) (optSellType, error) {
|
||||
|
||||
type relType uint
|
||||
|
||||
// RelType* constants represent related option transaction types
|
||||
const (
|
||||
RelTypeSpread relType = 1 + iota
|
||||
RelTypeStraddle
|
||||
@ -1598,6 +1622,7 @@ func NewRelType(s string) (relType, error) {
|
||||
|
||||
type charType uint
|
||||
|
||||
// CharType* constants represent types of characters allowed in password
|
||||
const (
|
||||
CharTypeAlphaOnly charType = 1 + iota
|
||||
CharTypeNumericOnly
|
||||
@ -1664,6 +1689,7 @@ func NewCharType(s string) (charType, error) {
|
||||
|
||||
type syncMode uint
|
||||
|
||||
// SyncMode* constants represent data synchronization mode supported (see OFX spec for more details)
|
||||
const (
|
||||
SyncModeFull syncMode = 1 + iota
|
||||
SyncModeLite
|
||||
@ -1726,8 +1752,74 @@ func NewSyncMode(s string) (syncMode, error) {
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type ofxSec uint
|
||||
|
||||
// OfxSec* constants represent the type of application-level security required for the message set
|
||||
const (
|
||||
OfxSecNone ofxSec = 1 + iota
|
||||
OfxSecType1
|
||||
)
|
||||
|
||||
var ofxSecs = [...]string{"NONE", "TYPE 1"}
|
||||
|
||||
func (e ofxSec) Valid() bool {
|
||||
// This check is mostly out of paranoia, ensuring e != 0 should be
|
||||
// sufficient
|
||||
return e >= OfxSecNone && e <= OfxSecType1
|
||||
}
|
||||
|
||||
func (e ofxSec) String() string {
|
||||
if e.Valid() {
|
||||
return ofxSecs[e-1]
|
||||
}
|
||||
return fmt.Sprintf("invalid ofxSec (%d)", e)
|
||||
}
|
||||
|
||||
func (e *ofxSec) FromString(in string) error {
|
||||
value := strings.TrimSpace(in)
|
||||
|
||||
for i, s := range ofxSecs {
|
||||
if s == value {
|
||||
*e = ofxSec(i + 1)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
*e = 0
|
||||
return errors.New("Invalid OfxSec: \"" + in + "\"")
|
||||
}
|
||||
|
||||
func (e *ofxSec) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||
var value string
|
||||
err := d.DecodeElement(&value, &start)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return e.FromString(value)
|
||||
}
|
||||
|
||||
func (e *ofxSec) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
|
||||
if !e.Valid() {
|
||||
return nil
|
||||
}
|
||||
enc.EncodeElement(ofxSecs[*e-1], start)
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewOfxSec returns returns an 'enum' value of type ofxSec given its
|
||||
// string representation
|
||||
func NewOfxSec(s string) (ofxSec, error) {
|
||||
var e ofxSec
|
||||
err := e.FromString(s)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type debtType uint
|
||||
|
||||
// DebtType* constants represent debt type
|
||||
const (
|
||||
DebtTypeCoupon debtType = 1 + iota
|
||||
DebtTypeZero
|
||||
@ -1792,6 +1884,7 @@ func NewDebtType(s string) (debtType, error) {
|
||||
|
||||
type debtClass uint
|
||||
|
||||
// DebtClass* constants represent the class of debt
|
||||
const (
|
||||
DebtClassTreasury debtClass = 1 + iota
|
||||
DebtClassMunicipal
|
||||
@ -1858,6 +1951,7 @@ func NewDebtClass(s string) (debtClass, error) {
|
||||
|
||||
type couponFreq uint
|
||||
|
||||
// CouponFreq* constants represent when debt coupons mature
|
||||
const (
|
||||
CouponFreqMonthly couponFreq = 1 + iota
|
||||
CouponFreqQuarterly
|
||||
@ -1925,6 +2019,7 @@ func NewCouponFreq(s string) (couponFreq, error) {
|
||||
|
||||
type callType uint
|
||||
|
||||
// CallType* constants represent type of next call (for a debt)
|
||||
const (
|
||||
CallTypeCall callType = 1 + iota
|
||||
CallTypePut
|
||||
@ -1991,6 +2086,7 @@ func NewCallType(s string) (callType, error) {
|
||||
|
||||
type assetClass uint
|
||||
|
||||
// AssetClass* constants represent type of asset classes
|
||||
const (
|
||||
AssetClassDomesticBond assetClass = 1 + iota
|
||||
AssetClassIntlBond
|
||||
@ -2060,6 +2156,7 @@ func NewAssetClass(s string) (assetClass, error) {
|
||||
|
||||
type mfType uint
|
||||
|
||||
// MfType* constants represent types of mutual funds
|
||||
const (
|
||||
MfTypeOpenEnd mfType = 1 + iota
|
||||
MfTypeCloseEnd
|
||||
@ -2125,6 +2222,7 @@ func NewMfType(s string) (mfType, error) {
|
||||
|
||||
type optType uint
|
||||
|
||||
// OptType* constants represent whether the option is a PUT or a CALL
|
||||
const (
|
||||
OptTypePut optType = 1 + iota
|
||||
OptTypeCall
|
||||
@ -2189,6 +2287,7 @@ func NewOptType(s string) (optType, error) {
|
||||
|
||||
type stockType uint
|
||||
|
||||
// StockType* constants represent types of stock
|
||||
const (
|
||||
StockTypeCommon stockType = 1 + iota
|
||||
StockTypePreferred
|
||||
@ -2253,72 +2352,9 @@ func NewStockType(s string) (stockType, error) {
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type ofxSec uint
|
||||
|
||||
const (
|
||||
OfxSecNone ofxSec = 1 + iota
|
||||
OfxSecType1
|
||||
)
|
||||
|
||||
var ofxSecs = [...]string{"NONE", "TYPE 1"}
|
||||
|
||||
func (e ofxSec) Valid() bool {
|
||||
// This check is mostly out of paranoia, ensuring e != 0 should be
|
||||
// sufficient
|
||||
return e >= OfxSecNone && e <= OfxSecType1
|
||||
}
|
||||
|
||||
func (e ofxSec) String() string {
|
||||
if e.Valid() {
|
||||
return ofxSecs[e-1]
|
||||
}
|
||||
return fmt.Sprintf("invalid ofxSec (%d)", e)
|
||||
}
|
||||
|
||||
func (e *ofxSec) FromString(in string) error {
|
||||
value := strings.TrimSpace(in)
|
||||
|
||||
for i, s := range ofxSecs {
|
||||
if s == value {
|
||||
*e = ofxSec(i + 1)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
*e = 0
|
||||
return errors.New("Invalid OfxSec: \"" + in + "\"")
|
||||
}
|
||||
|
||||
func (e *ofxSec) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||
var value string
|
||||
err := d.DecodeElement(&value, &start)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return e.FromString(value)
|
||||
}
|
||||
|
||||
func (e *ofxSec) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
|
||||
if !e.Valid() {
|
||||
return nil
|
||||
}
|
||||
enc.EncodeElement(ofxSecs[*e-1], start)
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewOfxSec returns returns an 'enum' value of type ofxSec given its
|
||||
// string representation
|
||||
func NewOfxSec(s string) (ofxSec, error) {
|
||||
var e ofxSec
|
||||
err := e.FromString(s)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type holderType uint
|
||||
|
||||
// HolderType* constants represent how the account is held
|
||||
const (
|
||||
HolderTypeIndividual holderType = 1 + iota
|
||||
HolderTypeJoint
|
||||
@ -2386,6 +2422,7 @@ func NewHolderType(s string) (holderType, error) {
|
||||
|
||||
type acctClassification uint
|
||||
|
||||
// AcctClassification* constants represent the type of an account
|
||||
const (
|
||||
AcctClassificationPersonal acctClassification = 1 + iota
|
||||
AcctClassificationBusiness
|
||||
@ -2452,6 +2489,7 @@ func NewAcctClassification(s string) (acctClassification, error) {
|
||||
|
||||
type svcStatus uint
|
||||
|
||||
// SvcStatus* constants represent the status of the account: AVAIL = Available, but not yet requested, PEND = Requested, but not yet available, ACTIVE = In use
|
||||
const (
|
||||
SvcStatusAvail svcStatus = 1 + iota
|
||||
SvcStatusPend
|
||||
@ -2517,6 +2555,7 @@ func NewSvcStatus(s string) (svcStatus, error) {
|
||||
|
||||
type usProductType uint
|
||||
|
||||
// UsProductType* constants represent type of investment account (in the US)
|
||||
const (
|
||||
UsProductType401K usProductType = 1 + iota
|
||||
UsProductType403B
|
||||
|
@ -1183,6 +1183,51 @@ func TestSyncMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOfxSec(t *testing.T) {
|
||||
e, err := ofxgo.NewOfxSec("NONE")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error creating new OfxSec from string \"NONE\"\n")
|
||||
}
|
||||
if !e.Valid() {
|
||||
t.Fatalf("OfxSec unexpectedly invalid\n")
|
||||
}
|
||||
err = e.FromString("TYPE 1")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on OfxSec.FromString(\"TYPE 1\")\n")
|
||||
}
|
||||
if e.String() != "TYPE 1" {
|
||||
t.Fatalf("OfxSec.String() expected to be \"TYPE 1\"\n")
|
||||
}
|
||||
|
||||
marshalHelper(t, "TYPE 1", &e)
|
||||
|
||||
overwritten, err := ofxgo.NewOfxSec("THISWILLNEVERBEAVALIDENUMSTRING")
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error creating new OfxSec from string \"THISWILLNEVERBEAVALIDENUMSTRING\"\n")
|
||||
}
|
||||
if overwritten.Valid() {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not be valid\n")
|
||||
}
|
||||
if !strings.Contains(strings.ToLower(overwritten.String()), "invalid") {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not return valid string from String()\n")
|
||||
}
|
||||
|
||||
b, err := xml.Marshal(&overwritten)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on xml.Marshal(OfxSec): %s\n", err)
|
||||
}
|
||||
if string(b) != "" {
|
||||
t.Fatalf("Expected empty string, got '%s'\n", string(b))
|
||||
}
|
||||
|
||||
unmarshalHelper(t, "TYPE 1", &e, &overwritten)
|
||||
|
||||
err = xml.Unmarshal([]byte("<GARBAGE><!LALDK>"), &overwritten)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error unmarshalling garbage value\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDebtType(t *testing.T) {
|
||||
e, err := ofxgo.NewDebtType("COUPON")
|
||||
if err != nil {
|
||||
@ -1543,51 +1588,6 @@ func TestStockType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOfxSec(t *testing.T) {
|
||||
e, err := ofxgo.NewOfxSec("NONE")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error creating new OfxSec from string \"NONE\"\n")
|
||||
}
|
||||
if !e.Valid() {
|
||||
t.Fatalf("OfxSec unexpectedly invalid\n")
|
||||
}
|
||||
err = e.FromString("TYPE 1")
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on OfxSec.FromString(\"TYPE 1\")\n")
|
||||
}
|
||||
if e.String() != "TYPE 1" {
|
||||
t.Fatalf("OfxSec.String() expected to be \"TYPE 1\"\n")
|
||||
}
|
||||
|
||||
marshalHelper(t, "TYPE 1", &e)
|
||||
|
||||
overwritten, err := ofxgo.NewOfxSec("THISWILLNEVERBEAVALIDENUMSTRING")
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error creating new OfxSec from string \"THISWILLNEVERBEAVALIDENUMSTRING\"\n")
|
||||
}
|
||||
if overwritten.Valid() {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not be valid\n")
|
||||
}
|
||||
if !strings.Contains(strings.ToLower(overwritten.String()), "invalid") {
|
||||
t.Fatalf("OfxSec created with string \"THISWILLNEVERBEAVALIDENUMSTRING\" should not return valid string from String()\n")
|
||||
}
|
||||
|
||||
b, err := xml.Marshal(&overwritten)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error on xml.Marshal(OfxSec): %s\n", err)
|
||||
}
|
||||
if string(b) != "" {
|
||||
t.Fatalf("Expected empty string, got '%s'\n", string(b))
|
||||
}
|
||||
|
||||
unmarshalHelper(t, "TYPE 1", &e, &overwritten)
|
||||
|
||||
err = xml.Unmarshal([]byte("<GARBAGE><!LALDK>"), &overwritten)
|
||||
if err == nil {
|
||||
t.Fatalf("Expected error unmarshalling garbage value\n")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHolderType(t *testing.T) {
|
||||
e, err := ofxgo.NewHolderType("INDIVIDUAL")
|
||||
if err != nil {
|
||||
|
@ -2,53 +2,53 @@
|
||||
|
||||
enums = {
|
||||
# Bank/general
|
||||
"AcctType": ["Checking", "Savings", "MoneyMrkt", "CreditLine", "CD"],
|
||||
"TrnType": ["Credit", "Debit", "Int", "Div", "Fee", "SrvChg", "Dep", "ATM", "POS", "Xfer", "Check", "Payment", "Cash", "DirectDep", "DirectDebit", "RepeatPmt", "Hold", "Other"],
|
||||
"ImageType": ["Statement", "Transaction", "Tax"],
|
||||
"ImageRefType": ["Opaque", "URL", "FormURL"],
|
||||
"CheckSup": ["FrontOnly", "BackOnly", "FrontAndBack"],
|
||||
"CorrectAction": ["Delete", "Replace"],
|
||||
"BalType": ["Dollar", "Percent", "Number"],
|
||||
"AcctType": (["Checking", "Savings", "MoneyMrkt", "CreditLine", "CD"], "types of bank accounts"),
|
||||
"TrnType": (["Credit", "Debit", "Int", "Div", "Fee", "SrvChg", "Dep", "ATM", "POS", "Xfer", "Check", "Payment", "Cash", "DirectDep", "DirectDebit", "RepeatPmt", "Hold", "Other"], "types of transactions. INT, ATM, and POS depend on the signage of the account."),
|
||||
"ImageType": (["Statement", "Transaction", "Tax"], "what this image contains"),
|
||||
"ImageRefType": (["Opaque", "URL", "FormURL"], "the type of reference to the image"),
|
||||
"CheckSup": (["FrontOnly", "BackOnly", "FrontAndBack"], "what portions of the check this image contains"),
|
||||
"CorrectAction": (["Delete", "Replace"], "whether this transaction correction replaces or deletes the transaction matching its CORRECTFITID"),
|
||||
"BalType": (["Dollar", "Percent", "Number"], "how this BAL's VALUE field should be interpreted"),
|
||||
|
||||
# InvStmt
|
||||
"Inv401kSource": ["PreTax", "AfterTax", "Match", "ProfitSharing", "Rollover", "OtherVest", "OtherNonVest"],
|
||||
"SubAcctType": ["Cash", "Margin", "Short", "Other"], # used in fields named: SubAcctSec, HeldInAcct, SubAcctFund
|
||||
"BuyType": ["Buy", "BuyToCover"],
|
||||
"OptAction": ["Exercise", "Assign", "Expire"],
|
||||
"TferAction": ["In", "Out"],
|
||||
"PosType": ["Long", "Short"],
|
||||
"Secured": ["Naked", "Covered"],
|
||||
"Duration": ["Day", "GoodTilCancel", "Immediate"],
|
||||
"Restriction": ["AllOrNone", "MinUnits", "None"],
|
||||
"UnitType": ["Shares", "Currency"],
|
||||
"OptBuyType": ["BuyToOpen", "BuyToClose"],
|
||||
"SellType": ["Sell", "SellShort"],
|
||||
"LoanPmtFreq": ["Weekly", "Biweekly", "TwiceMonthly", "Monthly", "FourWeeks", "BiMonthly", "Quarterly", "Semiannually", "Annually", "Other"],
|
||||
"IncomeType": ["CGLong", "CGShort", "Div", "Interest", "Misc"],
|
||||
"SellReason": ["Call", "Sell", "Maturity"],
|
||||
"OptSellType": ["SellToClose", "SellToOpen"],
|
||||
"RelType": ["Spread", "Straddle", "None", "Other"],
|
||||
"Inv401kSource": (["PreTax", "AfterTax", "Match", "ProfitSharing", "Rollover", "OtherVest", "OtherNonVest"], "the source of money used for this security in a 401(k) account. Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST."),
|
||||
"SubAcctType": (["Cash", "Margin", "Short", "Other"], "the sub-account type for a source and/or destination of a transaction. Used in fields named SubAcctFrom, SubAcctTo, SubAcctSec, SubAcctFund, HeldInAcct."),
|
||||
"BuyType": (["Buy", "BuyToCover"], "types of purchases"),
|
||||
"OptAction": (["Exercise", "Assign", "Expire"], "types of actions for options"),
|
||||
"TferAction": (["In", "Out"], "whether the transfer is into or out of this account"),
|
||||
"PosType": (["Long", "Short"], "position type"),
|
||||
"Secured": (["Naked", "Covered"], "how an option is secured"),
|
||||
"Duration": (["Day", "GoodTilCancel", "Immediate"], "how long the investment order is good for"),
|
||||
"Restriction": (["AllOrNone", "MinUnits", "None"], "a special restriction on an investment order"),
|
||||
"UnitType": (["Shares", "Currency"], "type of the UNITS value"),
|
||||
"OptBuyType": (["BuyToOpen", "BuyToClose"], "types of purchases for options"),
|
||||
"SellType": (["Sell", "SellShort"], "types of sales"),
|
||||
"LoanPmtFreq": (["Weekly", "Biweekly", "TwiceMonthly", "Monthly", "FourWeeks", "BiMonthly", "Quarterly", "Semiannually", "Annually", "Other"], "the frequency of loan payments"),
|
||||
"IncomeType": (["CGLong", "CGShort", "Div", "Interest", "Misc"], "types of investment income"),
|
||||
"SellReason": (["Call", "Sell", "Maturity"], "the reason the sell of a debt security was generated: CALL (the debt was called), SELL (the debt was sold), MATURITY (the debt reached maturity)"),
|
||||
"OptSellType": (["SellToClose", "SellToOpen"], "types of sales for options"),
|
||||
"RelType": (["Spread", "Straddle", "None", "Other"], "related option transaction types"),
|
||||
|
||||
# Prof
|
||||
"CharType": ["AlphaOnly", "NumericOnly", "AlphaOrNumeric", "AlphaAndNumeric"],
|
||||
"SyncMode": ["Full", "Lite"],
|
||||
"CharType": (["AlphaOnly", "NumericOnly", "AlphaOrNumeric", "AlphaAndNumeric"], "types of characters allowed in password"),
|
||||
"SyncMode": (["Full", "Lite"], "data synchronization mode supported (see OFX spec for more details)"),
|
||||
"OfxSec": (["None", "Type 1"], "the type of application-level security required for the message set"),
|
||||
|
||||
# SecList
|
||||
"DebtType": ["Coupon", "Zero"],
|
||||
"DebtClass": ["Treasury", "Municipal", "Corporate", "Other"],
|
||||
"CouponFreq": ["Monthly", "Quarterly", "Semiannual", "Annual", "Other"],
|
||||
"CallType": ["Call", "Put", "Prefund", "Maturity"],
|
||||
"AssetClass": ["DomesticBond", "IntlBond", "LargeStock", "SmallStock", "IntlStock", "MoneyMrkt", "Other"],
|
||||
"MfType": ["OpenEnd", "CloseEnd", "Other"],
|
||||
"OptType": ["Put", "Call"],
|
||||
"StockType": ["Common", "Preferred", "Convertible", "Other"],
|
||||
"OfxSec": ["None", "Type 1"],
|
||||
"DebtType": (["Coupon", "Zero"], "debt type"),
|
||||
"DebtClass": (["Treasury", "Municipal", "Corporate", "Other"], "the class of debt"),
|
||||
"CouponFreq": (["Monthly", "Quarterly", "Semiannual", "Annual", "Other"], "when debt coupons mature"),
|
||||
"CallType": (["Call", "Put", "Prefund", "Maturity"], "type of next call (for a debt)"),
|
||||
"AssetClass": (["DomesticBond", "IntlBond", "LargeStock", "SmallStock", "IntlStock", "MoneyMrkt", "Other"], "type of asset classes"),
|
||||
"MfType": (["OpenEnd", "CloseEnd", "Other"], "types of mutual funds"),
|
||||
"OptType": (["Put", "Call"], "whether the option is a PUT or a CALL"),
|
||||
"StockType": (["Common", "Preferred", "Convertible", "Other"], "types of stock"),
|
||||
|
||||
# Signup
|
||||
"HolderType": ["Individual", "Joint", "Custodial", "Trust", "Other"],
|
||||
"AcctClassification": ["Personal", "Business", "Corporate", "Other"],
|
||||
"SvcStatus": ["Avail", "Pend", "Active"],
|
||||
"UsProductType": ["401K", "403B", "IRA", "KEOGH", "Other", "SARSEP", "Simple", "Normal", "TDA", "Trust", "UGMA"],
|
||||
"HolderType": (["Individual", "Joint", "Custodial", "Trust", "Other"], "how the account is held"),
|
||||
"AcctClassification": (["Personal", "Business", "Corporate", "Other"], "the type of an account"),
|
||||
"SvcStatus": (["Avail", "Pend", "Active"], "the status of the account: AVAIL = Available, but not yet requested, PEND = Requested, but not yet available, ACTIVE = In use"),
|
||||
"UsProductType": (["401K", "403B", "IRA", "KEOGH", "Other", "SARSEP", "Simple", "Normal", "TDA", "Trust", "UGMA"], "type of investment account (in the US)"),
|
||||
}
|
||||
|
||||
header = """package ofxgo
|
||||
@ -70,6 +70,7 @@ import (
|
||||
template = """
|
||||
type {enumLower} uint
|
||||
|
||||
// {enum}* constants represent {comment}
|
||||
const (
|
||||
{constNames})
|
||||
|
||||
@ -136,22 +137,25 @@ with open("constants.go", 'w') as f:
|
||||
|
||||
for enum in enums:
|
||||
enumLower = enum[:1].lower() + enum[1:].replace(" ", "")
|
||||
firstValue = enum+enums[enum][0].replace(" ", "")
|
||||
lastValue = enum+enums[enum][-1].replace(" ", "")
|
||||
firstValue = enum+enums[enum][0][0].replace(" ", "")
|
||||
lastValue = enum+enums[enum][0][-1].replace(" ", "")
|
||||
|
||||
comment = enums[enum][1]
|
||||
|
||||
constNames = "\t{firstValue} {enumLower} = 1 + iota\n".format(
|
||||
enum=enum,
|
||||
firstValue=firstValue,
|
||||
enumLower=enumLower)
|
||||
for value in enums[enum][1:]:
|
||||
for value in enums[enum][0][1:]:
|
||||
constNames += "\t{enum}{value}\n".format(
|
||||
enum=enum,
|
||||
value=value.replace(" ", ""))
|
||||
|
||||
upperValueString = "\", \"".join([s.upper() for s in enums[enum]])
|
||||
upperValueString = "\", \"".join([s.upper() for s in enums[enum][0]])
|
||||
|
||||
f.write(template.format(enum=enum,
|
||||
enumLower=enumLower,
|
||||
comment=comment,
|
||||
firstValue=firstValue,
|
||||
lastValue=lastValue,
|
||||
constNames=constNames,
|
||||
@ -224,8 +228,8 @@ with open("constants_test.go", 'w') as f:
|
||||
f.write(test_header)
|
||||
|
||||
for enum in enums:
|
||||
firstValueUpper = enums[enum][0].upper()
|
||||
lastValueUpper = enums[enum][-1].upper()
|
||||
firstValueUpper = enums[enum][0][0].upper()
|
||||
lastValueUpper = enums[enum][0][-1].upper()
|
||||
f.write(test_template.format(enum=enum,
|
||||
firstValueUpper=firstValueUpper,
|
||||
lastValueUpper=lastValueUpper))
|
||||
|
Loading…
Reference in New Issue
Block a user