1
0
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:
2017-04-06 05:58:22 -04:00
parent ea700b33a9
commit 4521bb377a
16 changed files with 3030 additions and 382 deletions

View File

@ -331,17 +331,17 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
UnitPrice: unitprice1,
Commission: commission1,
Total: total1,
SubAcctSec: "CASH",
SubAcctFund: "CASH",
SubAcctSec: ofxgo.SubAcctTypeCash,
SubAcctFund: ofxgo.SubAcctTypeCash,
},
BuyType: "BUY",
BuyType: ofxgo.BuyTypeBuy,
},
},
BankTransactions: []ofxgo.InvBankTransaction{
ofxgo.InvBankTransaction{
Transactions: []ofxgo.Transaction{
ofxgo.Transaction{
TrnType: "CREDIT",
TrnType: ofxgo.TrnTypeCredit,
DtPosted: *ofxgo.NewDateGMT(2017, 1, 20, 0, 0, 0, 0),
DtUser: ofxgo.NewDateGMT(2017, 1, 18, 0, 0, 0, 0),
DtAvail: ofxgo.NewDateGMT(2017, 1, 23, 0, 0, 0, 0),
@ -352,7 +352,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
Memo: "CHECK 19980",
},
},
SubAcctFund: "CASH",
SubAcctFund: ofxgo.SubAcctTypeCash,
},
},
}
@ -371,7 +371,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
ofxgo.Balance{
Name: "Sweep Int Rate",
Desc: "Current interest rate for sweep account balances",
BalType: "PERCENT",
BalType: ofxgo.BalTypePercent,
Value: balvalue,
DtAsOf: ofxgo.NewDateGMT(2017, 4, 1, 0, 0, 0, 0),
},
@ -412,8 +412,8 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
UniqueId: "78462F103",
UniqueIdType: "CUSIP",
},
HeldInAcct: "CASH",
PosType: "LONG",
HeldInAcct: ofxgo.SubAcctTypeCash,
PosType: ofxgo.PosTypeLong,
Units: posunits1,
UnitPrice: posunitprice1,
MktVal: posmktval1,
@ -427,8 +427,8 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
UniqueId: "129887339",
UniqueIdType: "CUSIP",
},
HeldInAcct: "CASH",
PosType: "LONG",
HeldInAcct: ofxgo.SubAcctTypeCash,
PosType: ofxgo.PosTypeLong,
Units: posunits2,
UnitPrice: posunitprice2,
MktVal: posmktval2,
@ -447,13 +447,13 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
},
DtPlaced: *ofxgo.NewDateGMT(2017, 3, 10, 12, 44, 45, 0),
Units: oounits1,
SubAcct: "CASH",
Duration: "GOODTILCANCEL",
Restriction: "NONE",
SubAcct: ofxgo.SubAcctTypeCash,
Duration: ofxgo.DurationGoodTilCancel,
Restriction: ofxgo.RestrictionNone,
LimitPrice: oolimitprice1,
},
BuyType: "BUY",
UnitType: "SHARES",
BuyType: ofxgo.BuyTypeBuy,
UnitType: ofxgo.UnitTypeShares,
},
ofxgo.OOBuyStock{
OO: ofxgo.OO{
@ -464,12 +464,12 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
},
DtPlaced: *ofxgo.NewDateGMT(2017, 3, 24, 3, 19, 0, 0),
Units: oounits2,
SubAcct: "CASH",
Duration: "GOODTILCANCEL",
Restriction: "ALLORNONE",
SubAcct: ofxgo.SubAcctTypeCash,
Duration: ofxgo.DurationGoodTilCancel,
Restriction: ofxgo.RestrictionAllOrNone,
LimitPrice: oolimitprice2,
},
BuyType: "BUY",
BuyType: ofxgo.BuyTypeBuy,
},
},
}
@ -493,7 +493,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
FiId: "99184",
},
Yield: yield1,
AssetClass: "OTHER",
AssetClass: ofxgo.AssetClassOther,
},
ofxgo.OptInfo{
SecInfo: ofxgo.SecInfo{
@ -505,7 +505,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
Ticker: "FERTP",
FiId: "882919",
},
OptType: "PUT",
OptType: ofxgo.OptTypePut,
StrikePrice: strikeprice,
DtExpire: *ofxgo.NewDateGMT(2017, 9, 1, 0, 0, 0, 0),
ShPerCtrct: 100,
@ -513,7 +513,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
UniqueId: "983322180",
UniqueIdType: "CUSIP",
},
AssetClass: "LARGESTOCK",
AssetClass: ofxgo.AssetClassLargeStock,
},
ofxgo.StockInfo{
SecInfo: ofxgo.SecInfo{
@ -526,7 +526,7 @@ func TestUnmarshalInvStatementResponse(t *testing.T) {
FiId: "883897",
},
Yield: yield2,
AssetClass: "SMALLSTOCK",
AssetClass: ofxgo.AssetClassSmallStock,
},
ofxgo.MFInfo{
SecInfo: ofxgo.SecInfo{
@ -754,10 +754,10 @@ NEWFILEUID: NONE
Commission: commission1,
Fees: fees1,
Total: total1,
SubAcctSec: "CASH",
SubAcctFund: "CASH",
SubAcctSec: ofxgo.SubAcctTypeCash,
SubAcctFund: ofxgo.SubAcctTypeCash,
},
OptSellType: "SELLTOOPEN",
OptSellType: ofxgo.OptSellTypeSellToOpen,
ShPerCtrct: 100,
},
ofxgo.ClosureOpt{
@ -770,10 +770,10 @@ NEWFILEUID: NONE
UniqueId: "78462F10",
UniqueIdType: "CUSIP",
},
OptAction: "ASSIGN",
OptAction: ofxgo.OptActionAssign,
Units: units2,
ShPerCtrct: 100,
SubAcctSec: "CASH",
SubAcctSec: ofxgo.SubAcctTypeCash,
},
ofxgo.ClosureOpt{
InvTran: ofxgo.InvTran{
@ -785,10 +785,10 @@ NEWFILEUID: NONE
UniqueId: "SPY161216C00226000",
UniqueIdType: "CUSIP",
},
OptAction: "ASSIGN",
OptAction: ofxgo.OptActionAssign,
Units: units3,
ShPerCtrct: 100,
SubAcctSec: "CASH",
SubAcctSec: ofxgo.SubAcctTypeCash,
},
},
}
@ -832,8 +832,8 @@ NEWFILEUID: NONE
UniqueId: "04956010",
UniqueIdType: "CUSIP",
},
HeldInAcct: "CASH",
PosType: "LONG",
HeldInAcct: ofxgo.SubAcctTypeCash,
PosType: ofxgo.PosTypeLong,
Units: posunits1,
UnitPrice: posunitprice1,
MktVal: posmktval1,
@ -846,8 +846,8 @@ NEWFILEUID: NONE
UniqueId: "36960410",
UniqueIdType: "CUSIP",
},
HeldInAcct: "CASH",
PosType: "LONG",
HeldInAcct: ofxgo.SubAcctTypeCash,
PosType: ofxgo.PosTypeLong,
Units: posunits2,
UnitPrice: posunitprice2,
MktVal: posmktval2,
@ -883,7 +883,7 @@ NEWFILEUID: NONE
SecName: "SPY Dec 16 2016 226.00 Call",
Ticker: "SPY 161216C00226000",
},
OptType: "CALL",
OptType: ofxgo.OptTypeCall,
StrikePrice: strikeprice,
DtExpire: *ofxgo.NewDateGMT(2016, 12, 16, 12, 0, 0, 0),
ShPerCtrct: 100,