Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct { // AccessToken provided from the endpoint to be used to make subsequent // requests AccessToken string `json:"access_token"` // Scope for what endpoints are allowed, for properly configured apps, this // will be all scopes Scope string `json:"scope"` // Expiry for the access token, all access tokens expire after 1800s (30m) // by default ExpiresIn int `json:"expires_in"` // TokenType is 'Bearer' for the TDA API TokenType string `json:"token_type"` }
AccessTokenResponse is a struct to load the TDAmeritrade Response into, this takes many fields and the user is returned the AccessToken using *Session.GetAccessToken()
type AccessTokenStruct ¶
type AccessTokenStruct struct { // GrantType is the type of grant for the access token, this will always be // 'refresh_token' for this library GrantType string `url:"grant_type"` // RefreshToken provided by the Session intialization struct RefreshToken string `url:"refresh_token"` // ClientID is the CONSUMER_KEY with '@AMER.OAUTHAPP' added ClientID string `url:"client_id"` // RedirectUri of the app from TDAmeritrade's Development Portal RedirectUri string `url:"redirect_uri"` }
AccessTokenStruct is the internal structure used for establishing the request between TDAmeritrade Servers and the library, this is used to create a URLEncoded Form object which is sent to retrieve a user's access token
type InstrumentFundamentals ¶
type InstrumentFundamentals struct { // Fundamental struct containing FA indicators Fundamental struct { // Symbol for the listed security on NYSE (and/or NASDAAQ) Symbol string `json:"symbol"` // 52Week high of the stock High52 json.Number `json:"high52"` // 52Week low of the stock Low52 json.Number `json:"low52"` // DividendAmount is a numerical value (in dollars) that a company will // pay out to its shareholders DividendAmount json.Number `json:"dividendAmount"` // DividendYield is the annualzied dividend amount divided by the price // of the stock, lower share price with a high dividend means a very // high yield DividendYield json.Number `json:"dividendYield"` // DividendDate is the expected ex-dividend date based on TDA's // calendar, this is not always accurate DividendDate string `json:"dividendDate"` // Price to Earnings Ratio PeRatio json.Number `json:"peRatio"` // Price to Earnings-Growth Ratio PegRatio json.Number `json:"pegRatio"` // Price to Book Ratio PbRatio json.Number `json:"pbRatio"` // TODO: What is a PRRatio? PrRatio json.Number `json:"prRatio"` // Price to Cash-Flow Ratio PcfRatio json.Number `json:"pcfRatio"` // Gross Margin (borrowed cash) in the Trailing Twelve Months GrossMarginTTM json.Number `json:"grossMarginTTM"` // Gross Margin (borrowed cash) in the Most Recent Quarter GrossMarginMRQ json.Number `json:"grossMarginMRQ"` // Net Profit Margin (Percantage of Revenue) in Trailing Twelve Months NetProfitMarginTTM json.Number `json:"netProfitMarginTTM"` // Net Profit Margin (Percantage of Revenue) in Most Recent Quarter NetProfitMarginMRQ json.Number `json:"netProfitMarginMRQ"` // Operating Margin Trailing Twelve Months OperatingMarginTTM json.Number `json:"operatingMarginTTM"` // Operating Margin Most Recent Quarter OperatingMarginMRQ json.Number `json:"operatingMarginMRQ"` // Net Income divided by Shareholder Equity ReturnOnEquity json.Number `json:"returnOnEquity"` // Net Income divided by Net Company Assets ReturnOnAssets json.Number `json:"returnOnAssets"` // Net Income divided by Investments ReturnOnInvestment json.Number `json:"returnOnInvestment"` // Ability of a company to use near cash to extinguish long term // maturities QuickRatio json.Number `json:"quickRatio"` // Ability of a company to use near cash to meet short-term obligations CurrentRatio json.Number `json:"currentRatio"` // Ability of a company to pay off interest expenses on outstanding debt InterestCoverage json.Number `json:"interestCoverage"` // Company Debt compared to Current Company Capital TotalDebtToCapital json.Number `json:"totalDebtToCapital"` // Long Term Debts to Equity Ratio LtDebtToEquity json.Number `json:"ltDebtToEquity"` // All Debt to Equity Ratio TotalDebtToEquity json.Number `json:"totalDebtToEquity"` // Earnings-Per-Share Trailing Twelve Months EpsTTM json.Number `json:"epsTTM"` // Earnings-Per-Share Change % (Growth/Decline) Twailing Twelve Months EpsChangePercentTTM json.Number `json:"epsChangePercentTTM"` // Earnings-Per-Share Change over 1-Year (Annual Filing) EpsChangeYear json.Number `json:"epsChangeYear"` // Earnings-Per-Share Change QoQ (Quarterly Filing) EpsChange json.Number `json:"epsChange"` // Revenue Change YoY (Annual Filing) RevChangeYear json.Number `json:"revChangeYear"` // Revenue Change Trailing Twelve Months RevChangeTTM json.Number `json:"revChangeTTM"` // Incoming Revenue Change RevChangeIn json.Number `json:"revChangeIn"` // Number of shares currently availabile in the market // (NumberOfShares * SharePrice = MarketCapitalization) SharesOutstanding json.Number `json:"sharesOutstanding"` // $ Value of Available Shares Traded on Exchanges MarketCapFloat json.Number `json:"marketCapFloat"` // Market Capitalization MarketCap json.Number `json:"marketCap"` // Value of Share based on Books BookValuePerShare json.Number `json:"bookValuePerShare"` // % of Short Interest Compared to Available Shares ShortIntToFloat json.Number `json:"shortIntToFloat"` // # of Days before Company Closes out Shorted Shares ShortIntDayToCover json.Number `json:"shortIntDayToCover"` // Dividend Growth Rate over 3 Years DivGrowthRate3Year json.Number `json:"divGrowthRate3Year"` // Dividend Pay Amount (QoQ or MoM Basis) DividendPayAmount json.Number `json:"dividendPayAmount"` // Pay Date (as opposed to Ex-Div Date) for Dividend DividendPayDate string `json:"dividendPayDate"` // Beta Correlation to SPX (Broad Market) Beta json.Number `json:"beta"` // Average Volume based on 1 Day of Trading Vol1DayAvg json.Number `json:"vol1DayAvg"` // Average Volume based on 10 Days of Trading Vol10DayAvg json.Number `json:"vol10DayAvg"` // Average Volume based on 90 days of Trading Vol3MonthAvg json.Number `json:"vol3MonthAvg"` } `json:"fundamental"` // Committee on Uniform Securities Identification Procedures Cusip string `json:"cusip"` // Symbol for Security Symbol string `json:"symbol"` // Description of Security Description string `json:"description"` // Exchange the Security trades on Exchange string `json:"exchange"` // Type of Asset the Security is AssetType string `json:"assetType"` }
InstrumentFundmanetals is the struct for a valid fundamentals response from TDA
type Quote ¶
type Quote struct { AssetType string `json:"assetType"` AssetMainType string `json:"assetMainType"` Cusip string `json:"cusip"` AssetSubType string `json:"assetSubType"` Symbol string `json:"symbol"` Description string `json:"description"` BidPrice float64 `json:"bidPrice"` BidSize int `json:"bidSize"` BidID string `json:"bidId"` AskPrice float64 `json:"askPrice"` AskSize int `json:"askSize"` AskID string `json:"askId"` LastPrice float64 `json:"lastPrice"` LastSize int `json:"lastSize"` LastID string `json:"lastId"` OpenPrice float64 `json:"openPrice"` HighPrice float64 `json:"highPrice"` LowPrice float64 `json:"lowPrice"` BidTick string `json:"bidTick"` ClosePrice float64 `json:"closePrice"` NetChange float64 `json:"netChange"` TotalVolume int `json:"totalVolume"` QuoteTimeInLong int64 `json:"quoteTimeInLong"` TradeTimeInLong int64 `json:"tradeTimeInLong"` Mark float64 `json:"mark"` Exchange string `json:"exchange"` ExchangeName string `json:"exchangeName"` Marginable bool `json:"marginable"` Shortable bool `json:"shortable"` Volatility float64 `json:"volatility"` Digits int `json:"digits"` Five2WkHigh float64 `json:"52WkHigh"` Five2WkLow float64 `json:"52WkLow"` NAV float64 `json:"nAV"` PeRatio float64 `json:"peRatio"` DivAmount float64 `json:"divAmount"` DivYield float64 `json:"divYield"` DivDate string `json:"divDate"` SecurityStatus string `json:"securityStatus"` RegularMarketLastPrice float64 `json:"regularMarketLastPrice"` RegularMarketLastSize int `json:"regularMarketLastSize"` RegularMarketNetChange float64 `json:"regularMarketNetChange"` RegularMarketTradeTimeInLong int64 `json:"regularMarketTradeTimeInLong"` NetPercentChangeInDouble float64 `json:"netPercentChangeInDouble"` MarkChangeInDouble float64 `json:"markChangeInDouble"` MarkPercentChangeInDouble float64 `json:"markPercentChangeInDouble"` RegularMarketPercentChangeInDouble float64 `json:"regularMarketPercentChangeInDouble"` Delayed bool `json:"delayed"` RealtimeEntitled bool `json:"realtimeEntitled"` }
Quote is the response for a quote.
type QuoteRequest ¶
type QuoteRequest struct {
Symbols string `url:"symbol"`
}
type Session ¶
type Session struct { // RefreshKey of your account given by the TDAmeritrade OAuth2 Workflow Refresh string // ConsumerKey from the TDAmeritrade Developer Application Portal ConsumerKey string // RootUrl for the API, this will usually be https://api.tdameritrade.com/v1 RootUrl string // contains filtered or unexported fields }
Session is the client structure that is used for all relevant parts of this library. The session struct takes in 3 required parameters which is the refresh key, consumer key, and the root url (which is usually the same for all endusers).
func NewSession ¶
func NewSession(refresh, consumerKey, rootUrl string, opts ...SessionOption) *Session
NewSession constructs a new TDA Go Session taking in options.
func (*Session) GetAccessToken ¶
GetAccessToken is the session function to retrieve the access token, this returns a multitude of errors and is only intended for internal library usage but is exposed in case the AccessToken is important to be accessed externally
func (*Session) GetInstrumentFundamentals ¶
func (s *Session) GetInstrumentFundamentals(ticker string) (*InstrumentFundamentals, error)
GetInstrumentFundmamentals accesses the TDAmeritrade API using an existing Session struct to provide fundamental data in the form of the InstrumentFundamentals Struct. If the payload from the TDAmeritrade API is empty, an error is returned (rather than only an empty struct) with the fundamentalsEmpty error. The only input parameter is the relevant ticker, which is not case-sensitive.
type SessionOption ¶
type SessionOption func(*Session)
SessionOption is an option that can be provided to NewSession in order to modify the internal state of the created Session.
func WithHttpClient ¶
func WithHttpClient(client http.Client) SessionOption
WithHttpClient is an option that returns a SessionOption that can be used to change the internal HTTP Client used by the TDA Session.
func WithStatPath ¶
func WithStatPath(path string) SessionOption
WithStatPath is an option that sets the stat path to prevent creating a new access token on every request. This is recommended to be used if server is frequently making requests.