Realizing I can use online tools to convert API responses into XML
This commit is contained in:
parent
d824d3c635
commit
a422f62b2b
@ -63,6 +63,7 @@ func (c *AllyApi) Accounts() []AccountSummary {
|
|||||||
var resp AccountResponse
|
var resp AccountResponse
|
||||||
err = xml.Unmarshal(raw, &resp)
|
err = xml.Unmarshal(raw, &resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return resp.Accounts.Accountsummary
|
return resp.Accounts.Accountsummary
|
||||||
|
2
main.go
2
main.go
@ -7,5 +7,5 @@ func main() {
|
|||||||
var api AllyApi
|
var api AllyApi
|
||||||
api.Initialize()
|
api.Initialize()
|
||||||
|
|
||||||
fmt.Printf("%f\n", api.Accounts()[0].Accountbalance.Money.Cash)
|
fmt.Printf("%s\n", api.Accounts()[0].Accountholdings.Displaydata.Totalsecurities)
|
||||||
}
|
}
|
||||||
|
88
types.go
88
types.go
@ -1,49 +1,51 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "encoding/xml"
|
import (
|
||||||
|
"encoding/xml"
|
||||||
|
)
|
||||||
|
|
||||||
type AccountSummary struct {
|
type AccountSummary struct {
|
||||||
XMLName xml.Name `xml:"accountsummary"`
|
XMLName xml.Name `xml:"accountsummary"`
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Account string `xml:"account"`
|
Account string `xml:"account"`
|
||||||
Accountbalance struct {
|
Accountbalance struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Account string `xml:"account"`
|
Account string `xml:"account"`
|
||||||
Accountvalue string `xml:"accountvalue"`
|
Accountvalue float64 `xml:"accountvalue"`
|
||||||
Buyingpower struct {
|
Buyingpower struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Cashavailableforwithdrawal string `xml:"cashavailableforwithdrawal"`
|
Cashavailableforwithdrawal float64 `xml:"cashavailableforwithdrawal"`
|
||||||
Daytrading string `xml:"daytrading"`
|
Daytrading float64 `xml:"daytrading"`
|
||||||
Equitypercentage string `xml:"equitypercentage"`
|
Equitypercentage float64 `xml:"equitypercentage"`
|
||||||
Options string `xml:"options"`
|
Options float64 `xml:"options"`
|
||||||
Soddaytrading string `xml:"soddaytrading"`
|
Soddaytrading float64 `xml:"soddaytrading"`
|
||||||
Sodoptions string `xml:"sodoptions"`
|
Sodoptions float64 `xml:"sodoptions"`
|
||||||
Sodstock string `xml:"sodstock"`
|
Sodstock float64 `xml:"sodstock"`
|
||||||
Stock string `xml:"stock"`
|
Stock float64 `xml:"stock"`
|
||||||
} `xml:"buyingpower"`
|
} `xml:"buyingpower"`
|
||||||
Fedcall string `xml:"fedcall"`
|
Fedcall float64 `xml:"fedcall"`
|
||||||
Housecall string `xml:"housecall"`
|
Housecall float64 `xml:"housecall"`
|
||||||
Money struct {
|
Money struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Accruedinterest string `xml:"accruedinterest"`
|
Accruedinterest float64 `xml:"accruedinterest"`
|
||||||
Cash string `xml:"cash"`
|
Cash float64 `xml:"cash"`
|
||||||
Cashavailable string `xml:"cashavailable"`
|
Cashavailable float64 `xml:"cashavailable"`
|
||||||
Marginbalance string `xml:"marginbalance"`
|
Marginbalance float64 `xml:"marginbalance"`
|
||||||
Mmf string `xml:"mmf"`
|
Mmf float64 `xml:"mmf"`
|
||||||
Total string `xml:"total"`
|
Total float64 `xml:"total"`
|
||||||
Uncleareddeposits string `xml:"uncleareddeposits"`
|
Uncleareddeposits float64 `xml:"uncleareddeposits"`
|
||||||
Unsettledfunds string `xml:"unsettledfunds"`
|
Unsettledfunds float64 `xml:"unsettledfunds"`
|
||||||
Yield string `xml:"yield"`
|
Yield float64 `xml:"yield"`
|
||||||
} `xml:"money"`
|
} `xml:"money"`
|
||||||
Securities struct {
|
Securities struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Longoptions string `xml:"longoptions"`
|
Longoptions float64 `xml:"longoptions"`
|
||||||
Longstocks string `xml:"longstocks"`
|
Longstocks float64 `xml:"longstocks"`
|
||||||
Options string `xml:"options"`
|
Options float64 `xml:"options"`
|
||||||
Shortoptions string `xml:"shortoptions"`
|
Shortoptions float64 `xml:"shortoptions"`
|
||||||
Shortstocks string `xml:"shortstocks"`
|
Shortstocks float64 `xml:"shortstocks"`
|
||||||
Stocks string `xml:"stocks"`
|
Stocks float64 `xml:"stocks"`
|
||||||
Total string `xml:"total"`
|
Total float64 `xml:"total"`
|
||||||
} `xml:"securities"`
|
} `xml:"securities"`
|
||||||
} `xml:"accountbalance"`
|
} `xml:"accountbalance"`
|
||||||
Accountholdings struct {
|
Accountholdings struct {
|
||||||
@ -69,7 +71,7 @@ type AccountSummary struct {
|
|||||||
Qty string `xml:"qty"`
|
Qty string `xml:"qty"`
|
||||||
Symbol string `xml:"symbol"`
|
Symbol string `xml:"symbol"`
|
||||||
} `xml:"displaydata"`
|
} `xml:"displaydata"`
|
||||||
Gainloss string `xml:"gainloss"`
|
Gainloss float64 `xml:"gainloss"`
|
||||||
Instrument struct {
|
Instrument struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Cusip string `xml:"cusip"`
|
Cusip string `xml:"cusip"`
|
||||||
@ -78,19 +80,19 @@ type AccountSummary struct {
|
|||||||
Sectyp string `xml:"sectyp"`
|
Sectyp string `xml:"sectyp"`
|
||||||
Sym string `xml:"sym"`
|
Sym string `xml:"sym"`
|
||||||
} `xml:"instrument"`
|
} `xml:"instrument"`
|
||||||
Marketvalue string `xml:"marketvalue"`
|
Marketvalue float64 `xml:"marketvalue"`
|
||||||
Marketvaluechange string `xml:"marketvaluechange"`
|
Marketvaluechange float64 `xml:"marketvaluechange"`
|
||||||
Price string `xml:"price"`
|
Price float64 `xml:"price"`
|
||||||
Purchaseprice string `xml:"purchaseprice"`
|
Purchaseprice float64 `xml:"purchaseprice"`
|
||||||
Qty string `xml:"qty"`
|
Qty float64 `xml:"qty"`
|
||||||
Quote struct {
|
Quote struct {
|
||||||
Text string `xml:",chardata"`
|
Text string `xml:",chardata"`
|
||||||
Change string `xml:"change"`
|
Change float64 `xml:"change"`
|
||||||
Lastprice string `xml:"lastprice"`
|
Lastprice float64 `xml:"lastprice"`
|
||||||
} `xml:"quote"`
|
} `xml:"quote"`
|
||||||
Underlying string `xml:"underlying"`
|
Underlying string `xml:"underlying"`
|
||||||
} `xml:"holding"`
|
} `xml:"holding"`
|
||||||
Totalsecurities string `xml:"totalsecurities"`
|
Totalsecurities float64 `xml:"totalsecurities"`
|
||||||
} `xml:"accountholdings"`
|
} `xml:"accountholdings"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user