market-api-calls #2

Manually merged
jacob.windle merged 10 commits from market-api-calls into master 2020-01-22 00:15:38 +00:00
3 changed files with 16 additions and 4 deletions
Showing only changes of commit d2861c2df2 - Show all commits

View File

@ -96,3 +96,9 @@ func (c *AllyApi) AccountHoldings(accountId string) AccountDetailHoldingsRespons
_ = xml.Unmarshal(c.getAndRead(fmt.Sprintf("accounts/%s/holdings", accountId)), &resp)
return resp
}
func (c *AllyApi) MarketClock() MarketClockResponse {
var resp MarketClockResponse
_ = xml.Unmarshal(c.getAndRead("market/clock"), &resp)
return resp
}

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"strconv"
)
func main() {
@ -10,7 +9,5 @@ func main() {
var api AllyApi
api.Initialize()
acctId, _ := strconv.Atoi(api.Accounts()[0].Account)
fmt.Printf("AccountDetail: %s\n", api.AccountDetail(acctId).AccountHoldings.Holding[0].Displaydata.Change)
fmt.Printf("Market Clock: %d\n", api.MarketClock().UnixTime)
}

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/xml"
"time"
)
type Accountbalance struct {
@ -138,3 +139,11 @@ type AccountDetailHoldingsResponse struct {
XMLName xml.Name `xml:"response"`
AccountHoldings Accountholdings `xml:"accountholdings"`
}
type MarketClockResponse struct {
XMLName xml.Name `xml:"response"`
Date string `xml:"date"`
CurrentStatus string `xml:"status>current"`
Message string `xml:"message"`
UnixTime time.Time `xml:"unixtime"`
}