ally_api

package module
v0.0.0-...-aad3b03 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2017 License: MIT Imports: 12 Imported by: 0

README

ally-api

Go API bindings for Ally Invest (formerly TradeKing).

Ally Invest documentation can be found here: https://www.ally.com/api/invest/documentation/getting-started/

Status

This project is currently under development.

TODO:

  • Define all response types to coincide with the API documentation.

The bindings take advantage of the XML output of the Ally Invest API. I do not plan on supporting anything else. They specifically state in their API documentation that XML is output by default. Furthermore, they only provide sample XML output (not JSON). Therefore, I'm assuming XML is what Ally Invest prefers to support.

CLI Tool

At this stage of development, I recommend you look at the CLI client tool found in the root of the project. It is the primary interface for testing the library.

The CLI tool, for convenience, relies on a configuration file. Simply specify a configuration file. It doesn't have to exist. When you specify a non-existing configuration file, the CLI tool will create one. Then, you can populate it, and use the now-populated file.

jackman@dorito:~/gopath/src/github.com/jackmanlabs/ally-api$ go build cmd/cli

jackman@dorito:~/gopath/src/github.com/jackmanlabs/ally-api$ ./cli 
Usage of ./cli:
  -config string
        The path of the configuration file. Specifying a non-existent file will cause an empty one to be created.
2017/11/14 16:06:08 A config file path must be specified. If the file you specify does not exist, a new one will be created for you which you may populate.

jackman@dorito:~/gopath/src/github.com/jackmanlabs/ally-api$ ./cli -config config.json
2017/11/14 16:21:01 New, empty config file successfully created: config.json

Another execution of ./cli -config config.json will result in a great deal of usage information:

jackman@dorito:~/gopath/src/github.com/jackmanlabs/ally-api$ ./cli -config config.json
2017/11/14 16:23:45 

This application requires at least two arguments, an operation and a
resource.

Valid operations include REST operations, such as GET, PUT, POST, DELETE,
and PATCH. Capitalization is not required.

At the time of this writing, the following operation/resource combinations
are defined:

    ACCOUNT CALLS
    =============
    GET     accounts
    GET     accounts/balances
    GET     accounts/{id}
    GET     accounts/{id}/balances
    GET     accounts/{id}/history
    GET     accounts/{id}/holdings
    
    ORDER/TRADE CALLS
    =================
    GET     accounts/{id}/orders
    POST    accounts/{id}/orders
    POST    accounts/{id}/orders/preview
    
    MARKET CALLS
    ============
    GET     market/clock
    GET     market/ext/quotes
    GET     market/news/search
    GET     market/news/{id}
    GET     market/options/search
    GET     market/options/strikes
    GET     market/options/expirations
    GET     market/timesales
    GET     market/toplists
    GET     market/quotes (streaming)
    
    MEMBER CALLS
    ============
    GET     member/profile
    
    UTILITY CALLS
    =============
    GET     utility/status
    GET     utility/version
    
    WATCHLIST CALLS
    ===============
    GET     watchlists
    POST    watchlists
    GET     watchlists/{id}
    DELETE  watchlists/{id}
    POST    watchlists/{id}/symbols
    DELETE  watchlists/{id}/symbols
    
    DEPRECATED
    ==========
    GET market/chains
    GET market/quotes

Because of the way the library is written, and because the developer hasn't come
up with something better, when you want to make a call with a URL parameter,
append the value of the parameter to the end of the command, like so:

    GET watchlists/{id} 12

If the URL contains multiple parameters, the values you append should be in the
same order as they are found in the URL template.

This tool was written to test the library. Therefore, I don't want to encourage
anyone to think this tool's output will be consistent. At the time of this
writing, the tool does two things. First, it dumps the raw response body to a
file, named after the library function being called. Second, whatever was
successfully parsed is logged to stderr in the form of JSON.

Rehash Tool

The Rehash tool is used to compare raw XML from the server and the data parsed by the library.

Re-Use of Ally Invest Documentation

In the process of creating the various data types to correspond with Ally's API, the comments in those data types are derived from the descriptions in the Ally documentation. This is done simply for convenience. Credit goes to Ally and their API documentation writers.

I do not intend to update this documentation as it would be time-consuming to track.

Furthermore, if Ally Invest is offended by the reuse of technical documentation, I will be happy to make things right.

API discrepencies

/market/ext/quotes

pchg example has a %, but the live API does not. sho example has commas, live API does not. tcond is numeric in live API.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountBalance

type AccountBalance struct {
	Account      int                `xml:"account"`
	AccountValue float64            `xml:"accountvalue"` // Account value
	BuyingPower  AccountBuyingPower `xml:"buyingpower"`  //
	FedCall      float64            `xml:"fedcall"`      // Value of any fed call on account
	HouseCall    float64            `xml:"housecall"`    // Value of any house call
	Money        AccountMoney       `xml:"money"`        //
	Securities   AccountSecurities  `xml:"securities"`   //
}

type AccountBalanceSimple

type AccountBalanceSimple struct {
	Account      int     `xml:"account"`
	AccountName  string  `xml:"accountname"`  // Used in the 'GET accounts/balances' response
	AccountValue float64 `xml:"accountvalue"` // Account value
}

type AccountBalancesResponse

type AccountBalancesResponse struct {
	Response
	AccountBalance AccountBalance `xml:"accountbalance"`
}

type AccountBuyingPower

type AccountBuyingPower struct {
	CashAvailableForWithdrawal float64 `xml:"cashavailableforwithdrawal,omitempty"` // Cash available for withdrawal (cash & margin accounts only, n/a for retirement accounts)
	DayTrading                 float64 `xml:"daytrading,omitempty"`                 //
	EquityPercentage           float64 `xml:"equitypercentage,omitempty"`           // Percentage of equity (margin accounts only)
	Options                    float64 `xml:"options,omitempty"`                    // Options buying power. Path: /response/accounts/accountsummary/accountbalance/buyingpower/
	SodDayTrading              float64 `xml:"soddaytrading,omitempty"`              //
	SodOptions                 float64 `xml:"sodoptions,omitempty"`                 // Start of day options buying power
	SodStock                   float64 `xml:"sodstock,omitempty"`                   // Start of day stock buying power
	Stock                      float64 `xml:"stock,omitempty"`                      // Stock buying power
}

type AccountHistoryResponse

type AccountHistoryResponse struct {
	Response
	Transactions []AccountTransaction `xml:"transactions>transaction"`
}

type AccountHolding

type AccountHolding struct {
	AccountType       int                        `xml:"accounttype"`           // Holdings attribute for where asset as held, "1"= cash, "2"= margin long, "5"=margin short.
	CostBasis         float64                    `xml:"costbasis"`             // Holding cost basis
	DisplayData       *AccountHoldingDisplayData `xml:"displaydata,omitempty"` //
	GainLoss          float64                    `xml:"gainloss"`              // Holding gain/loss overall
	Instrument        AccountHoldingInstrument   `xml:"instrument"`            //
	MarketValue       float64                    `xml:"marketvalue"`           // Holding market value
	MarketValueChange float64                    `xml:"marketvaluechange"`     // Holding market value change
	Price             float64                    `xml:"price"`                 // Instrument price
	PurchasePrice     float64                    `xml:"purchaseprice"`         // Holding purchase price
	Qty               float64                    `xml:"qty"`                   // Holding quantity
	Quote             AccountHoldingQuote        `xml:"quote"`
	Underlying        struct{}                   `xml:"underlying"`
}

type AccountHoldingDisplayData

type AccountHoldingDisplayData struct {
	AccountType       string `xml:"accounttype"`       // Holdings attribute for where asset as held, "1"= cash, "2"= margin long, "5"=margin short.
	AssetClass        string `xml:"assetclass"`        // Holding asset class type
	Change            string `xml:"change"`            // Holding asset change for the day
	CostBasis         string `xml:"costbasis"`         // Holding cost basis
	Desc              string `xml:"desc"`              // Instrument description
	LastPrice         string `xml:"lastprice"`         // Instrument last price
	MarketValue       string `xml:"marketvalue"`       // Holding market value
	MarketValueChange string `xml:"marketvaluechange"` // Holding market value change
	Qty               string `xml:"qty"`               // Holding quantity
	Symbol            string `xml:"symbol"`            // Holding underlying symbol
}

type AccountHoldingInstrument

type AccountHoldingInstrument struct {
	Cusip        string  `xml:"cusip"`  // Instrument cusip
	Desc         string  `xml:"desc"`   // Instrument description
	Factor       float64 `xml:"factor"` // Instrument factor
	SecurityType string  `xml:"sectyp"` // Instrument security type (FIXML)
	Symbol       string  `xml:"sym"`    // Instrument underlying symbol (FIXML)
}

type AccountHoldingQuote

type AccountHoldingQuote struct {
	Change    float64 `xml:"change"`    // Holding asset change for the day
	LastPrice float64 `xml:"lastprice"` // Instrument last price
}

type AccountHoldings

type AccountHoldings struct {
	Holdings        []AccountHolding            `xml:"holding"`
	TotalSecurities float64                     `xml:"totalsecurities"` // Total account market value
	DisplayData     *AccountHoldingsDisplayData `xml:"displaydata,omitempty"`
}

type AccountHoldingsDisplayData

type AccountHoldingsDisplayData struct {
	TotalSecurities string `xml:"totalsecurities"` // Total account market value
}

type AccountHoldingsResponse

type AccountHoldingsResponse struct {
	Response
	AccountHoldings AccountHoldings `xml:"accountholdings"`
}

type AccountMoney

type AccountMoney struct {
	AccruedInterest   float64 `xml:"accruedinterest"`   // Amount of any accrued interest on the account
	Cash              float64 `xml:"cash"`              // cash
	CashAvailable     float64 `xml:"cashavailable"`     // cash available
	MarginBalance     float64 `xml:"marginbalance"`     // Margin balance (- indicates debit balance, + indicates credit balance)
	Mmf               float64 `xml:"mmf"`               // Money market fund
	Total             float64 `xml:"total"`             // Total cash balance. Path: /response/accounts/accountsummary/accountbalance/money/
	UnclearedDeposits float64 `xml:"uncleareddeposits"` // uncleared deposits
	UnsettledFunds    float64 `xml:"unsettledfunds"`    // unsettle funds
	Yield             float64 `xml:"yield"`             // Yield
}

type AccountOrdersResponse

type AccountOrdersResponse struct {
	Response
	Orders []Order `xml:"orderstatus>order"`
}

type AccountResponse

type AccountResponse struct {
	AccountBalance  AccountBalance  `xml:"accountbalance"`
	AccountHoldings AccountHoldings `xml:"accountholdings"`
	Response
}

type AccountSecurities

type AccountSecurities struct {
	LongOptions  float64 `xml:"longoptions"`  // Long option market value
	LongStocks   float64 `xml:"longstocks"`   // Long stock market value
	Options      float64 `xml:"options"`      // Total option market value. Path: /response/accounts/accountsummary/accountbalance/securities/
	ShortOptions float64 `xml:"shortoptions"` // Short option market value
	ShortStocks  float64 `xml:"shortstocks"`  // Short stock market value
	Stocks       float64 `xml:"stocks"`       // Total stock market value
	Total        float64 `xml:"total"`        // Total market value (stock & option). Path: /response/accounts/accountsummary/accountbalance/securities/
}

type AccountSummary

type AccountSummary struct {
	Account         int             `xml:"account"` // Account number
	AccountBalance  AccountBalance  `xml:"accountbalance"`
	AccountHoldings AccountHoldings `xml:"accountholdings"`
}

type AccountTransaction

type AccountTransaction struct {
	Activity    string                   `xml:"activity"`
	Amount      float64                  `xml:"amount"`
	Date        time.Time                `xml:"date"`
	Desc        string                   `xml:"desc"`
	Symbol      string                   `xml:"symbol"`
	Transaction AccountTransactionDetail `xml:"transaction"`
}

type AccountTransactionDetail

type AccountTransactionDetail struct {
	Accounttype     int                        `xml:"accounttype"`
	Commission      float64                    `xml:"commission"`
	Description     string                     `xml:"description"`
	Fee             float64                    `xml:"fee"`
	Price           float64                    `xml:"price"`
	Quantity        float64                    `xml:"quantity"`
	Secfee          float64                    `xml:"secfee"`
	Security        AccountTransactionSecurity `xml:"security"`
	Settlementdate  time.Time                  `xml:"settlementdate"`
	Side            int                        `xml:"side"`
	Source          string                     `xml:"source"`
	Tradedate       time.Time                  `xml:"tradedate"`
	Transactionid   int                        `xml:"transactionid"`
	Transactiontype string                     `xml:"transactiontype"`
}

type AccountTransactionSecurity

type AccountTransactionSecurity struct {
	Cusip  int    `xml:"cusip"`
	Id     int    `xml:"id"`
	Sectyp string `xml:"sectyp"`
	Sym    string `xml:"sym"`
}

type AccountsBalancesResponse

type AccountsBalancesResponse struct {
	AccountBalances []AccountBalanceSimple `xml:"accountbalance"`
	Response
	TotalBalance float64 `xml:"totalbalance>accountvalue"`
}

type AccountsResponse

type AccountsResponse struct {
	AccountSummaries []AccountSummary `xml:"accounts>accountsummary"`
	Response
}

type Client

type Client struct {
	http.Client
}

func NewClient

func NewClient(consumerKey, consumerSecret, oauthToken, oauthTokenSecret string) *Client

func (*Client) DeleteWatchlist

func (client *Client) DeleteWatchlist(id int) (*AccountsBalancesResponse, error)

DELETE watchlists/{id}

func (*Client) DeleteWatchlistSymbols

func (client *Client) DeleteWatchlistSymbols(id int) (*AccountsBalancesResponse, error)

DELETE watchlists/{id}/symbols

func (*Client) GetAccount

func (client *Client) GetAccount(id int) (*AccountResponse, error)

GET accounts/{id}

func (*Client) GetAccountBalances

func (client *Client) GetAccountBalances(id int) (*AccountBalancesResponse, error)

GET accounts/{id}/balances

func (*Client) GetAccountHistory

func (client *Client) GetAccountHistory(id int) (*AccountHistoryResponse, error)

GET accounts/{id}/history

func (*Client) GetAccountHoldings

func (client *Client) GetAccountHoldings(id int) (*AccountHoldingsResponse, error)

GET accounts/{id}/holdings

func (*Client) GetAccountOrders

func (client *Client) GetAccountOrders(id int) (*AccountOrdersResponse, error)

GET accounts/{id}/orders

func (*Client) GetAccounts

func (client *Client) GetAccounts() (*AccountsResponse, error)

GET accounts

func (*Client) GetAccountsBalances

func (client *Client) GetAccountsBalances() (*AccountsBalancesResponse, error)

GET accounts/balances

func (*Client) GetClock

func (client *Client) GetClock() (*ClockResponse, error)

GET market/clock

func (*Client) GetExtQuotes

func (client *Client) GetExtQuotes(symbols []string) (*ExtQuotesResponse, error)

GET market/ext/quotes

func (*Client) GetNews

func (client *Client) GetNews(id int) (*NewsResponse, error)

GET market/news/{id}

func (*Client) GetNewsSearch

func (client *Client) GetNewsSearch() (*NewsSearchResponse, error)

GET market/news/search

func (*Client) GetOptionsExpirations

func (client *Client) GetOptionsExpirations() (*OptionsExpirationsResponse, error)

GET market/options/expirations

func (*Client) GetOptionsSearch

func (client *Client) GetOptionsSearch() (*OptionsSearchResponse, error)

GET market/options/search

func (*Client) GetOptionsStrikes

func (client *Client) GetOptionsStrikes() (*OptionsStrikesResponse, error)

GET market/options/strikes

func (*Client) GetProfile

func (client *Client) GetProfile() (*ProfileResponse, error)

GET member/profile

func (*Client) GetQuotes

func (client *Client) GetQuotes() (*QuotesResponse, error)

GET market/quotes (streaming)

func (*Client) GetStatus

func (client *Client) GetStatus() (*StatusResponse, error)

GET utility/status

func (*Client) GetTimeSales

func (client *Client) GetTimeSales() (*TimeSalesResponse, error)

GET market/timesales

func (*Client) GetTopLists

func (client *Client) GetTopLists() (*TopListsResponse, error)

GET market/toplists

func (*Client) GetVersion

func (client *Client) GetVersion() (*VersionResponse, error)

GET utility/version

func (*Client) GetWatchlist

func (client *Client) GetWatchlist(id int) (*WatchListResponse, error)

GET watchlists/{id}

func (*Client) GetWatchlists

func (client *Client) GetWatchlists() (*WatchListsResponse, error)

GET watchlists

func (*Client) PostAccountOrderPreview

func (client *Client) PostAccountOrderPreview(id int) (*AccountsBalancesResponse, error)

POST accounts/{id}/orders/preview

func (*Client) PostAccountOrders

func (client *Client) PostAccountOrders(id int) (*AccountsBalancesResponse, error)

POST accounts/{id}/orders

func (*Client) PostWatchlistSymbols

func (client *Client) PostWatchlistSymbols(id int) (*AccountsBalancesResponse, error)

POST watchlists/{id}/symbols

func (*Client) PostWatchlists

func (client *Client) PostWatchlists() (*AccountsBalancesResponse, error)

POST watchlists

type ClockResponse

type ClockResponse struct {
	ProfileResponse
}

type ExtQuotesResponse

type ExtQuotesResponse struct {
	Response
	Quotes []Quote `xml:"quotes>quote"`
}

type Fixml

type Fixml struct {
	XMLName xml.Name   `xml:"FIXML"`
	Order   FixmlOrder `xml:"Order"`

	// Only used for closing short positions, "Buy to Cover" orders should
	// include this attribute as AcctTyp = "5".
	AcctTyp string `xml:"AcctTyp"`

	// Abbreviation for "classification of financial instrument", used for
	// options to distinguish "OC" for call option or "OP" for put option.
	CFI string `xml:"CFI"`

	// Used for trailing stop orders. Value of ExecInst = "a" needs to be
	// passed.
	ExecInst string `xml:"ExecInst"`

	// Expiration of the option in the format of YYYYMM.
	MMY string `xml:"MMY"`

	// Represents the expiration date of a option. Needs to be in the format of
	// "YYYY‐MM‐ DDT00:00:00.000‐05:00". For single leg orders, this attribute
	// tag changes from Mat to MatDt.
	Mat string `xml:"Mat"`

	// Represents the expiration date of a option. Needs to be in the format of
	// "YYYY‐MM‐ DDT00:00:00.000‐05:00". For multiple leg orders, this attribute
	// tag changes from MatDt to Mat.
	MatDt string `xml:"MatDt"`

	// Used for trailing stop orders. Value of OfstTyp = "0" needs to be passed.
	// The offset value of "0" denotes a "price" offset from the PegPxTyp field
	// below. The offset value of "1" denotes a "basis point" offset from the
	// PegPxTyp field below (used as a percentage offset).
	OfstTyp string `xml:"OfstTyp"`

	// Used for trailing stop orders. Signed value needs to be passed for amount
	// of offset value combined with the PegPxTyp & OfstTyp fields. Negative
	// values are normally used for sell trailing stops so the trigger trails
	// below current price. Positive values are normally used for buy trailing
	// stops so the trigger trails above the current price. For example,
	// assuming an OfstTyp = "0", a sell order with a OfstVal of ‐.50 will
	// trigger if the current price falls by more than .50 of its last highest
	// value since the order was placed. OfstType = "1" would require the signed
	// value for a percentage. For example, OfstVal = "5" would represent a 5%
	// increase in price before a buy trailing stop is triggered.
	OfstVal string `xml:"OfstVal"`

	// Order ID that needs to be passed for any change or cancel requests. Note:
	// for Multi‐leg orders, use tag OrigClOrdID instead of OrigID.
	OrigID string `xml:"OrigID"`

	// Used for trailing stop orders defining type of peg (price used) for
	// trailing. In this case, PegPxTyp = "1" references "last price" of
	// security.
	PegPxTyp string `xml:"PegPxTyp"`

	// Used for options, option legs require and attribute of "O" for opening or
	// "C" for closing.
	PosEfct string `xml:"PosEfct"`

	// Price for price type if needed. This attribute would be required for
	// limits (Typ = "2") or stop limits (Typ = "4").
	Px string `xml:"Px"`

	// Strike price of option contract. This tag changes from Strk to StrkPx for
	// single leg orders.
	Strk string `xml:"Strk"`

	// Strike price of option contract. This tag changes from StrkPx to Strk for
	// multi‐leg orders.
	StrkPx string `xml:"StrkPx"`
}

type FixmlInstrument

type FixmlInstrument struct {
	XMLName xml.Name `xml:"Instrmt"`

	// Security type attribute is needed."CS" for common stock or "OPT" for
	// option.
	SecTyp string `xml:"SecTyp,attr"`

	// Ticker symbol of underlying security. This is utilized for stock, option,
	// & multi‐leg orders.
	Sym string `xml:"Sym,attr"`
}

type FixmlMessage

type FixmlMessage struct {
	//XMLName xml.Name `xml:"fixmlmessage"`
	Text string `xml:",cdata"`
}

type FixmlOrder

type FixmlOrder struct {
	OrderQuantity FixmlOrderQuantity `xml:"OrdQty"`
	Instrument    FixmlInstrument    `xml:"Instrmt"`

	// Account number needs to be passed with all order requests.
	Acct int `xml:"Acct,attr"`

	// Time in force, possible values include "0" ‐ Day Order, "1" ‐ GTC Order,
	// "7" ‐ Market on Close. Not applicable when Typ = "1" (market order).
	TmInForce int `xml:"TmInForce,attr"`

	// Price Type as "1" ‐ Market, "2" ‐ Limit", "3" ‐ Stop, "4" Stop Limit, or
	// "P" for trailing stop.
	Typ string `xml:"Typ,attr"`

	// Side of market as "1" ‐ Buy, "2" ‐ Sell, "5" ‐ Sell Short. Buy to cover
	// orders are attributed as buy orders with Side = "1".
	Side int `xml:"Side,attr"`
}

type FixmlOrderQuantity

type FixmlOrderQuantity struct {
	XMLName xml.Name `xml:"OrdQty"`
	Qty     int      `xml:"Qty,attr"`
}

type NewsResponse

type NewsResponse struct{ Response }

type NewsSearchResponse

type NewsSearchResponse struct{ Response }

type OptionsExpirationsResponse

type OptionsExpirationsResponse struct{ Response }

type OptionsSearchResponse

type OptionsSearchResponse struct{ Response }

type OptionsStrikesResponse

type OptionsStrikesResponse struct{ Response }

type Order

type Order struct {
	XMLName xml.Name `xml:"order"`
	Fixml
	FixmlMessage FixmlMessage `xml:"fixmlmessage"`
}

type ProfileResponse

type ProfileResponse struct {
	Response
	Date     string  `xml:"date"`
	Status   Status  `xml:"status"`
	Message  string  `xml:"message"`
	UnixTime float64 `xml:"unixtime"`
}

type Quote

type Quote struct {
	Adp100           *float64  `xml:"adp_100"`            // Stock,	Average Daily Price - 100 day
	Adp200           *float64  `xml:"adp_200"`            // Stock,	Average Daily Price - 200 day
	Adp50            *float64  `xml:"adp_50"`             // Stock,	Average Daily Price - 50 day
	Adv21            *int      `xml:"adv_21"`             // Stock,	Average Daily Volume - 21 day
	Adv30            *int      `xml:"adv_30"`             // Stock,	Average Daily Volume - 30 day
	Adv90            *int      `xml:"adv_90"`             // Stock,	Average Daily Volume - 90 day
	Ask              *float64  `xml:"ask"`                // Stock, Option	Ask price
	AskTime          *string   `xml:"ask_time"`           // Stock, Option	Time of latest ask
	Asksz            *int      `xml:"asksz"`              // Stock, Option	Size of latest ask (in 100's)
	Basis            *int      `xml:"basis"`              // Stock, Option	Reported precision (quotation decimal places)
	Beta             *float64  `xml:"beta"`               // Stock,	Beta volatility measure
	Bid              *float64  `xml:"bid"`                // Stock, Option	Bid price
	BidTime          *string   `xml:"bid_time"`           // Stock, Option	Time of latest bid
	Bidsz            *int      `xml:"bidsz"`              // Stock, Option	Size of latest bid (in 100's)
	Bidtick          *string   `xml:"bidtick"`            // Stock,	Tick direction since last bid
	Chg              *float64  `xml:"chg"`                // Stock, Option	Change since prior day close (cl)
	ChgSign          *string   `xml:"chg_sign"`           // Stock, Option	Change sign (e, u, d) as even, up, down
	ChgT             *float64  `xml:"chg_t"`              // Stock, Option	change in text format
	Cl               *float64  `xml:"cl"`                 // Stock, Option	previous close
	ContractSize     *int      `xml:"contract_size"`      // Option,	contract size for option
	Cusip            *int      `xml:"cusip"`              // Stock,	Cusip
	Date             *string   `xml:"date"`               // Stock, Option	Trade date of last trade
	Datetime         time.Time `xml:"datetime"`           // Stock, Option	Date and time
	DaysToExpiration *int      `xml:"days_to_expiration"` // Option,	Days until option expiration date
	Div              *float64  `xml:"div"`                // Stock,	Latest announced cash dividend
	Divexdate        *string   `xml:"divexdate"`          // Stock,	Ex-dividend date of div(YYYYMMDD)
	Divfreq          *string   `xml:"divfreq"`            // Stock,	Dividend frequency, A - Annual Dividend, S - Semi Annual Dividend, Q - Quarterly Dividend, M - Monthly Dividend, N - Not applicable or No Set Dividend Frequency.
	Divpaydt         *string   `xml:"divpaydt"`           // Stock,	Dividend pay date of last announced div
	DollarValue      *float64  `xml:"dollar_value"`       // Stock, Option	Total dollar value of shares traded today
	Eps              *float64  `xml:"eps"`                // Stock,	Earnings per share
	Exch             *string   `xml:"exch"`               // Stock, Option	exchange code
	ExchDesc         *string   `xml:"exch_desc"`          // Stock, Option	exchange description
	Hi               *float64  `xml:"hi"`                 // Stock, Option	High Trade Price for the trading day
	Iad              *float64  `xml:"iad"`                // Stock,	Indicated annual dividend
	Idelta           *int      `xml:"idelta"`             // Option,	Option risk measure of delta using implied volatility
	Igamma           *int      `xml:"igamma"`             // Option,	Option risk measure of gamma using implied volatility
	ImpVolatility    *int      `xml:"imp_volatility"`     // Option,	Implied volatility of option price based current stock price
	IncrVl           *int      `xml:"incr_vl"`            // Stock, Option	Volume of last trade
	Irho             *int      `xml:"irho"`               // Option,	Option risk measure of rho using implied volatility
	IssueDesc        *int      `xml:"issue_desc"`         // Option,	Issue description
	Itheta           *int      `xml:"itheta"`             // Option,	Option risk measure of theta using implied volatility
	Ivega            *int      `xml:"ivega"`              // Option,	Option risk measure of vega using implied volatility
	Last             *float64  `xml:"last"`               // Stock, Option	Last trade price
	Lo               *float64  `xml:"lo"`                 // Stock, Option	Low Trade Price for the trading day
	Name             *string   `xml:"name"`               // Stock, Option	Company name
	OpDelivery       *int      `xml:"op_delivery"`        // Option,	Option Settlement Designation – S Std N – Non Std X - NA
	OpFlag           *int      `xml:"op_flag"`            // Stock,	Security has options (1=Yes, 0=No).
	OpStyle          *int      `xml:"op_style"`           // Option,	Option Style – values are “A” American and “E” European
	OpSubclass       *int      `xml:"op_subclass"`        // Option,	Option class (0=Standard, 1=Leap, 3=Short Term)
	Openinterest     *int      `xml:"openinterest"`       // Option,	Open interest of option contract
	Opn              *float64  `xml:"opn"`                // Stock, Option	Open trade price
	OptVal           *int      `xml:"opt_val"`            // Option,	Estimated Option Value – via Ju/Zhong or Black-Scholes
	Pchg             *float64  `xml:"pchg"`               // Stock, Option	percentage change from prior day close
	PchgSign         *string   `xml:"pchg_sign"`          // Stock, Option	prchg sign (e, u, d) as even, up, down
	Pcls             *float64  `xml:"pcls"`               // Stock, Option	Prior day close
	Pe               *float64  `xml:"pe"`                 // Stock,	Price earnings ratio
	Phi              *float64  `xml:"phi"`                // Stock, Option	Prior day high value
	Plo              *float64  `xml:"plo"`                // Stock, Option	Prior day low value
	Popn             *float64  `xml:"popn"`               // Stock, Option	Prior day open
	PrAdp100         *float64  `xml:"pr_adp_100"`         // Stock,	Prior Average Daily Price "100"trade days
	PrAdp200         *float64  `xml:"pr_adp_200"`         // Stock,	Prior Average Daily Price "200"trade days
	PrAdp50          *float64  `xml:"pr_adp_50"`          // Stock,	Prior Average Daily Price "50"trade days
	PrDate           *string   `xml:"pr_date"`            // Stock, Option	Trade Date of Prior Last
	PrOpeninterest   *int      `xml:"pr_openinterest"`    // Option,	Prior day's open interest
	Prbook           *float64  `xml:"prbook"`             // Stock,	Book Value Price
	Prchg            *float64  `xml:"prchg"`              // Stock, Option	Prior day change
	PremMult         *int      `xml:"prem_mult"`          // Option,	Option premium multiplier
	PutCall          *int      `xml:"put_call"`           // Option,	Option type (Put or Call)
	Pvol             *int      `xml:"pvol"`               // Stock, Option	Prior day total volume
	Qcond            *int      `xml:"qcond"`              // Option,	Condition code of quote
	Rootsymbol       *int      `xml:"rootsymbol"`         // Option,	Option root symbol
	Secclass         *int      `xml:"secclass"`           // Stock, Option	Security class (0=stock, 1=option)
	Sesn             *string   `xml:"sesn"`               // Stock, Option	Trading session as (pre, regular, &amp, post)
	Sho              *int      `xml:"sho"`                // Stock,	Shares Outstanding
	Strikeprice      *int      `xml:"strikeprice"`        // Option,	Option strike price (not extended by multiplier)
	Symbol           *string   `xml:"symbol"`             // Stock, Option	Symbol from data provider
	Tcond            *string   `xml:"tcond"`              // Stock, Option	Trade condition code – (H) halted or (R) resumed
	Timestamp        *int      `xml:"timestamp"`          // Stock, Option	Timestamp
	TrNum            *int      `xml:"tr_num"`             // Stock, Option	Number of trades since market open
	Tradetick        *string   `xml:"tradetick"`          // Stock, Option	Tick direction from prior trade – (e,u,d) even, up, down)
	Trend            *string   `xml:"trend"`              // Stock, Option	Trend based on 10 prior ticks (e,u,d) even, up, down
	UnderCusip       *int      `xml:"under_cusip"`        // Option,	An option's underlying cusip
	Undersymbol      *int      `xml:"undersymbol"`        // Option,	An option's underlying symbol
	Vl               *int      `xml:"vl"`                 // Stock, Option	Cumulative volume
	Volatility12     *float64  `xml:"volatility12"`       // Stock,	one year volatility measure
	Vwap             *float64  `xml:"vwap"`               // Stock, Option	Volume weighted average price
	Wk52Hi           *float64  `xml:"wk52hi"`             // Stock, Option	52 week high
	Wk52Hidate       *string   `xml:"wk52hidate"`         // Stock, Option	52 week high date
	Wk52Lo           *float64  `xml:"wk52lo"`             // Stock, Option	52 week low
	Wk52Lodate       *string   `xml:"wk52lodate"`         // Stock, Option	52 week low date
	Xdate            *int      `xml:"xdate"`              // Option,	Expiration date of option in the format of (YYYYMMDD)
	Xday             *int      `xml:"xday"`               // Option,	Expiration day of option
	Xmonth           *int      `xml:"xmonth"`             // Option,	Expiration month of option
	Xyear            *int      `xml:"xyear"`              // Option,	Expiration year of option
	Yield            *float64  `xml:"yield"`              // Stock,	Dividend yield as %
}

func (*Quote) UnmarshalXML

func (this *Quote) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

I know this is ugly, BUT this is a real PITA situation. I don't want to hassle the consumers of this API with the issue of nested values and what-have-you. This solution is messy, but it makes it easy for the consumer.

type QuotesResponse

type QuotesResponse struct{ Response }

type Response

type Response struct {
	XMLName     xml.Name `xml:"response"`
	ResponseId  string   `xml:"id,attr"`
	ElapsedTime float64  `xml:"elapsedtime"`
	Error       string   `xml:"error"`
}

type Status

type Status struct {
	Current  string `xml:"current"`
	Next     string `xml:"next"`
	ChangeAt string `xml:"change_at"`
}

type StatusResponse

type StatusResponse struct {
	Response
	Time string `xml:"time"`
}

type TimeSalesResponse

type TimeSalesResponse struct{ Response }

type TopListsResponse

type TopListsResponse struct{ Response }

type VersionResponse

type VersionResponse struct {
	Response
	Version string `xml:"version"`
}

type WatchListResponse

type WatchListResponse struct{ Response }

type WatchListsResponse

type WatchListsResponse struct{ Response }

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL