mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-07-01 11:48:38 -04:00
Use named constants instead of strings for enum-like OFX fields
This adds a python script to generate constants.go when `go generate` is called, and updates the structs, tests, and command-line client to all use the new named constants.
This commit is contained in:
68
seclist.go
68
seclist.go
@ -81,22 +81,22 @@ type SecInfo struct {
|
||||
}
|
||||
|
||||
type DebtInfo struct {
|
||||
XMLName xml.Name `xml:"DEBTINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
ParValue Amount `xml:"PARVALUE"`
|
||||
DebtType String `xml:"DEBTTYPE"` // One of COUPON, ZERO (zero coupon)
|
||||
DebtClass String `xml:"DEBTCLASS,omitempty"` // One of TREASURY, MUNICIPAL, CORPORATE, OTHER
|
||||
CouponRate Amount `xml:"COUPONRT,omitempty"` // Bond coupon rate for next closest call date
|
||||
DtCoupon *Date `xml:"DTCOUPON,omitempty"` // Maturity date for next coupon
|
||||
CouponFreq String `xml:"COUPONFREQ,omitempty"` // When coupons mature - one of MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL, or OTHER
|
||||
CallPrice Amount `xml:"CALLPRICE,omitempty"` // Bond call price
|
||||
YieldToCall Amount `xml:"YIELDTOCALL,omitempty"` // Yield to next call
|
||||
DtCall *Date `xml:"DTCALL,omitempty"` // Next call date
|
||||
CallType String `xml:"CALLTYPE,omitempt"` // Type of next call. One of CALL, PUT, PREFUND, MATURITY
|
||||
YieldToMat Amount `xml:"YIELDTOMAT,omitempty"` // Yield to maturity
|
||||
DtMat *Date `xml:"DTMAT,omitempty"` // Debt maturity date
|
||||
AssetClass String `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
XMLName xml.Name `xml:"DEBTINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
ParValue Amount `xml:"PARVALUE"`
|
||||
DebtType debtType `xml:"DEBTTYPE"` // One of COUPON, ZERO (zero coupon)
|
||||
DebtClass debtClass `xml:"DEBTCLASS,omitempty"` // One of TREASURY, MUNICIPAL, CORPORATE, OTHER
|
||||
CouponRate Amount `xml:"COUPONRT,omitempty"` // Bond coupon rate for next closest call date
|
||||
DtCoupon *Date `xml:"DTCOUPON,omitempty"` // Maturity date for next coupon
|
||||
CouponFreq couponFreq `xml:"COUPONFREQ,omitempty"` // When coupons mature - one of MONTHLY, QUARTERLY, SEMIANNUAL, ANNUAL, or OTHER
|
||||
CallPrice Amount `xml:"CALLPRICE,omitempty"` // Bond call price
|
||||
YieldToCall Amount `xml:"YIELDTOCALL,omitempty"` // Yield to next call
|
||||
DtCall *Date `xml:"DTCALL,omitempty"` // Next call date
|
||||
CallType callType `xml:"CALLTYPE,omitempt"` // Type of next call. One of CALL, PUT, PREFUND, MATURITY
|
||||
YieldToMat Amount `xml:"YIELDTOMAT,omitempty"` // Yield to maturity
|
||||
DtMat *Date `xml:"DTMAT,omitempty"` // Debt maturity date
|
||||
AssetClass assetClass `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
}
|
||||
|
||||
func (i DebtInfo) SecurityType() string {
|
||||
@ -104,9 +104,9 @@ func (i DebtInfo) SecurityType() string {
|
||||
}
|
||||
|
||||
type AssetPortion struct {
|
||||
XMLName xml.Name `xml:"PORTION"`
|
||||
AssetClass String `xml:"ASSETCLASS"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
Percent Amount `xml:"PERCENT"` // Percentage of the fund that falls under this asset class
|
||||
XMLName xml.Name `xml:"PORTION"`
|
||||
AssetClass assetClass `xml:"ASSETCLASS"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
Percent Amount `xml:"PERCENT"` // Percentage of the fund that falls under this asset class
|
||||
}
|
||||
|
||||
type FiAssetPortion struct {
|
||||
@ -118,7 +118,7 @@ type FiAssetPortion struct {
|
||||
type MFInfo struct {
|
||||
XMLName xml.Name `xml:"MFINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
MfType String `xml:"MFTYPE"` // One of OPEN, END, CLOSEEND, OTHER
|
||||
MfType mfType `xml:"MFTYPE"` // One of OPEN, END, CLOSEEND, OTHER
|
||||
Yield Amount `xml:"YIELD,omitempty"` // Current yield reported as the dividend expressed as a portion of the current stock price
|
||||
DtYieldAsOf *Date `xml:"DTYIELDASOF,omitempty"` // Date YIELD is valid for
|
||||
AssetClasses []AssetPortion `xml:"MFASSETCLASS>PORTION"`
|
||||
@ -132,12 +132,12 @@ func (i MFInfo) SecurityType() string {
|
||||
type OptInfo struct {
|
||||
XMLName xml.Name `xml:"OPTINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
OptType String `xml:"OPTTYPE"` // One of PUT, CALL
|
||||
OptType optType `xml:"OPTTYPE"` // One of PUT, CALL
|
||||
StrikePrice Amount `xml:"STRIKEPRICE"`
|
||||
DtExpire Date `xml:"DTEXPIRE"` // Expiration date
|
||||
ShPerCtrct Int `xml:"SHPERCTRCT"` // Shares per contract
|
||||
SecId *SecurityId `xml:"SECID,omitempty"` // Security ID of the underlying security
|
||||
AssetClass String `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
AssetClass assetClass `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
}
|
||||
|
||||
@ -146,11 +146,11 @@ func (i OptInfo) SecurityType() string {
|
||||
}
|
||||
|
||||
type OtherInfo struct {
|
||||
XMLName xml.Name `xml:"OTHERINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
TypeDesc String `xml:"TYPEDESC,omitempty"` // Description of security type
|
||||
AssetClass String `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
XMLName xml.Name `xml:"OTHERINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
TypeDesc String `xml:"TYPEDESC,omitempty"` // Description of security type
|
||||
AssetClass assetClass `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
}
|
||||
|
||||
func (i OtherInfo) SecurityType() string {
|
||||
@ -158,13 +158,13 @@ func (i OtherInfo) SecurityType() string {
|
||||
}
|
||||
|
||||
type StockInfo struct {
|
||||
XMLName xml.Name `xml:"STOCKINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
StockType String `xml:"STOCKTYPE,omitempty"` // One of COMMON, PREFERRED, CONVERTIBLE, OTHER
|
||||
Yield Amount `xml:"YIELD,omitempty"` // Current yield reported as the dividend expressed as a portion of the current stock price
|
||||
DtYieldAsOf *Date `xml:"DTYIELDASOF,omitempty"` // Date YIELD is valid for
|
||||
AssetClass String `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
XMLName xml.Name `xml:"STOCKINFO"`
|
||||
SecInfo SecInfo `xml:"SECINFO"`
|
||||
StockType stockType `xml:"STOCKTYPE,omitempty"` // One of COMMON, PREFERRED, CONVERTIBLE, OTHER
|
||||
Yield Amount `xml:"YIELD,omitempty"` // Current yield reported as the dividend expressed as a portion of the current stock price
|
||||
DtYieldAsOf *Date `xml:"DTYIELDASOF,omitempty"` // Date YIELD is valid for
|
||||
AssetClass assetClass `xml:"ASSETCLASS,omitempty"` // One of DOMESTICBOND, INTLBOND, LARGESTOCK, SMALLSTOCK, INTLSTOCK, MONEYMRKT, OTHER
|
||||
FiAssetClass String `xml:"FIASSETCLASS,omitempty"` // FI-defined asset class
|
||||
}
|
||||
|
||||
func (i StockInfo) SecurityType() string {
|
||||
|
Reference in New Issue
Block a user