allyinvest/types.go

131 lines
4.1 KiB
Go
Raw Normal View History

package main
2019-11-09 03:26:17 +00:00
import "encoding/xml"
/**
2019-11-15 02:24:21 +00:00
Response structure from Ally
*/
type AllyResponse struct {
XMLName xml.Name `xml:"response"`
Error string `xml:"error"`
ResponseId string `xml:"id,attr"`
ElapsedTime int `xml:"elapsedtime"`
Accounts []AccountSummary `xml:"accounts>accountsummary"`
2019-11-09 03:26:17 +00:00
}
2019-11-15 02:24:21 +00:00
/**
TODO: We need to work on AccountHoldings next.
*/
type AccountHoldings struct {
XMLName xml.Name `xml:"accountholdings"`
Holdings []Holding `xml:"holding"`
TotalSecurities float64 `xml:"totalsecurities"`
}
type HoldingDisplayData struct {
XMLName xml.Name `xml:"displaydata"`
}
type InstrumentData struct {
XMLName xml.Name `xml:"instrument"`
Cfi string `xml:"cfi"`
Cusip string `xml:"cusip"`
Desc string `xml:"desc"`
Factor int `xml:"factor"`
Matdt string `xml:"matdt"`
Mult int `xml:"mult"`
PutCall int `xml:"putcall"`
SecType string `xml:"sectyp"`
StrikePrice float64 `xml:"strkpx"`
Symbol string `xml:"sym"`
}
type QuoteData struct {
XMLName xml.Name `xml:"quote"`
Change float64 `xml:"change"`
LastPrice float64 `xml:"lastprice"`
}
type Holding struct {
XMLName xml.Name `xml:"holding"`
AccountType int `xml:"accounttype"`
CostBasis float64 `xml:"costbasis"`
DisplayData HoldingDisplayData `xml:"displaydata"`
GainLoss float64 `xml:"gainloss"`
Instrument InstrumentData `xml:"instrument"`
MarketValue float64 `xml:"marketvalue"`
MarketValueChange float64 `xml:"marketvaluechange"`
Price float64 `xml:"price"`
PurchasePrice float64 `xml:"purchaseprice"`
Quantity int `xml:"qty"`
Quote QuoteData `xml:"quote"`
2019-11-09 03:26:17 +00:00
}
2019-11-15 02:24:21 +00:00
/**
Account summary information
*/
2019-11-09 03:26:17 +00:00
type AccountSummary struct {
XMLName xml.Name `xml:"accountsummary"`
Account int `xml:"account"`
AccountName string `xml:"accountname"`
AccountBalanceInfo AccountBalance `xml:"accountbalance"`
AccountHoldingsInfo AccountHoldings `xml:"accountholdings"`
2019-11-09 03:26:17 +00:00
}
2019-11-15 02:24:21 +00:00
/**
Different securites currently held with an account
*/
type Securities struct {
2019-11-15 02:24:21 +00:00
XMLName xml.Name `xml:"securities"`
LongOptions float64 `xml:"longoptions"`
LongStocks float64 `xml:"longstocks"`
Options float64 `xml:"options"`
ShortOptions float64 `xml:"shortoptions"`
ShortStocks float64 `xml:"shortstocks"`
}
2019-11-15 02:24:21 +00:00
/**
Various values representing account balance
*/
2019-11-09 03:26:17 +00:00
type AccountBalance struct {
XMLName xml.Name `xml:"accountbalance"`
Account int `xml:"account"`
AccountValue float64 `xml:"accountvalue"`
BuyingPower BuyingPower `xml:"buyingpower"`
FedCall int `xml:"fedcall"`
HouseCall int `xml:"housecall"`
Money Money `xml:"money"`
Securities Securities `xml:"securities"`
2019-11-09 03:26:17 +00:00
}
2019-11-15 02:24:21 +00:00
/**
Various values representing buying power of this account
*/
2019-11-09 03:26:17 +00:00
type BuyingPower struct {
XMLName xml.Name `xml:"buyingpower"`
CashAvailableForWithdrawal float64 `xml:"cashavailableforwithdrawal"`
DayTrading int `xml:"daytrading"`
EquityPercentage int `xml:"equitypercentage"`
Options int `xml:"options"`
SodDayTrading int `xml:"soddaytrading"`
SodOptions int `xml:"sodoptions"`
SodStock int `xml:"sodstock"`
Stock int `xml:"stock"`
2019-11-09 03:26:17 +00:00
}
2019-11-15 02:24:21 +00:00
/**
Various values representing money in this account
*/
2019-11-09 03:26:17 +00:00
type Money struct {
XMLName xml.Name `xml:"money"`
AccruedInterest float64 `xml:"accruedinterest"`
Cash float64 `xml:"cash"`
CashAvailable float64 `xml:"cashavailable"`
MarginBalance float64 `xml:"marginbalance"`
Mmf float64 `xml:"mnf"`
Total float64 `xml:"total"`
UnclearedDeposits float64 `xml:"uncleareddeposits"`
UnsettledFunds float64 `xml:"unsettledfunds"`
Yield float64 `xml:"yield"`
}