tdameritrade

package module
v0.1.30 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 23 Imported by: 0

README

go-tdameritrade

go client for the tdameritrade api, forked from Zachray Rice's library

Documentation

import "github.com/JonCooperWorks/go-tdameritrade"

go-tdameritrade handles all interaction with the TD Ameritrade REST API. See the TD Ameritrade developer site to learn how their APIs work. This is a very thin wrapper and does not perform any validation.

Authentication with TD Ameritrade

There is an example of using OAuth2 to authenticate a user and use the services on the TD Ameritrade API in examples/webauth/webauth.go. Authentication is handled by the Authenticator struct and its methods StartOAuth2Flow and FinishOAuth2Flow. You can get an authenticated tdameritrade.Client from an authenticated request with the AuthenticatedClient method, and use that to interact with the TD API. See auth.go.

// Authenticator is a helper for TD Ameritrade's authentication.
// It authenticates users and validates the state returned from TD Ameritrade to protect users from CSRF attacks.
// It's recommended to use NewAuthenticator instead of creating this struct directly because TD Ameritrade requires Client IDs to be in the form clientid@AMER.OAUTHAP.
// This is not immediately obvious from the documentation.
// See https://developer.tdameritrade.com/content/authentication-faq
type Authenticator struct {
	Store  PersistentStore
	OAuth2 oauth2.Config
}

The library handles state generation and the OAuth2 flow. Users simply implement the PersistentStore interface (see auth.go) and tell it how to store and retrieve OAuth2 state and an oauth2.Token with the logged in user's credentials.

// PersistentStore is meant to persist data from TD Ameritrade that is needed between requests.
// Implementations must return the same value they set for a user in StoreState in GetState, or the login process will fail.
// It is meant to allow credentials to be stored in cookies, JWTs and anything else you can think of.
type PersistentStore interface {
	StoreToken(token *oauth2.Token, w http.ResponseWriter, req *http.Request) error
	GetToken(req *http.Request) (*oauth2.Token, error)
	StoreState(state string, w http.ResponseWriter, req *http.Request) error
	GetState(*http.Request) (string, error)
}

Interacting with the TD Ameritrade API

The library is centered around the tdameritrade.Client. It allows access to all services exposed by the TD Ameritrade REST API. More information about each service can be found on TD Ameritrade's developer website.

// A Client manages communication with the TD-Ameritrade API.
type Client struct {
	client *http.Client // HTTP client used to communicate with the API.

	// Base URL for API requests. Defaults to the public TD-Ameritrade API, but can be
	// set to any endpoint. This allows for more manageable testing.
	BaseURL *url.URL

	// services used for talking to different parts of the tdameritrade api
	PriceHistory       *PriceHistoryService
	Account            *AccountsService
	MarketHours        *MarketHoursService
	Quotes             *QuotesService
	Instrument         *InstrumentService
	Chains             *ChainsService
	Mover              *MoverService
	TransactionHistory *TransactionHistoryService
	User               *UserService
	Watchlist          *WatchlistService
}

You get a tdameritrade.Client from the FinishOAuth2 or AuthenticatedClient method on the tdameritrade.Authenticator struct.

Streaming

TD Ameritrade provides a websockets API that allows for streaming data. go-tdameritrade provides a streaming client for authenticating with TD Ameritrade's socket API. To create an instance of an authenticated tdameritrade.StreamingClient, use the tdameritrade.NewAuthenticatedStreamingClient method. You'll need an authenticated tdameritrade.Client and the account ID you intend to listen on. To manually create an authenticated socket, use tdameritrade.NewUnauthenticatedStreamingClient to create a socket and send a JSON encoded authentication message. A convenience method, tdameritrade.NewStreamAuthCommand, will create one of these given a UserPrincipal and an account ID.

TD's Streaming API accepts commands in a format described in their documentation. go-tdameritrade provides struct wrappers over the command types.

type Command struct {
	Requests []StreamRequest `json:"requests"`
}

type StreamRequest struct {
	Service    string       `json:"service"`
	Requestid  string       `json:"requestid"`
	Command    string       `json:"command"`
	Account    string       `json:"account"`
	Source     string       `json:"source"`
	Parameters StreamParams `json:"parameters"`
}

type StreamParams struct {
	Keys   string `json:"keys"`
	Fields string `json:"fields"`
}

Commands can be sent to TD Ameritrade with the SendCommand convenience method.

streamingClient.SendCommand(tdameritrade.Command{
	Requests: []tdameritrade.StreamRequest{
		{
			Service:   "QUOTE",
			Requestid: "2",
			Command:   "SUBS",
			Account:   userPrincipals.Accounts[0].AccountID,
			Source:    userPrincipals.StreamerInfo.AppID,
			Parameters: tdameritrade.StreamParams{
				Keys:   "AAPL",
				Fields: "0,1,2,3,4,5,6,7,8",
			},
		},
	},
})

Streaming support is very basic. go-tdameritrade can only receive []byte payloads from a TD Ameritrade websocket with the ReceiveText method. You can find an example here.

Examples

More examples are in the examples directory.

Configuring the Authenticator from an environment variable
clientID := os.Getenv("TDAMERITRADE_CLIENT_ID")
if clientID == "" {
	log.Fatal("Unauthorized: No client ID present")
}

authenticator := tdameritrade.NewAuthenticator(
	&HTTPHeaderStore{},
	oauth2.Config{
		ClientID: clientID,
		Endpoint: oauth2.Endpoint{
			TokenURL: "https://api.tdameritrade.com/v1/oauth2/token",
			AuthURL:  "https://auth.tdameritrade.com/auth",
		},
		RedirectURL: "https://localhost:8080/callback",
	},
)
Authenticating a user with OAuth2
type TDHandlers struct {
	authenticator *tdameritrade.Authenticator
}

func (h *TDHandlers) Authenticate(w http.ResponseWriter, req *http.Request) {
	redirectURL, err := h.authenticator.StartOAuth2Flow(w, req)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	http.Redirect(w, req, redirectURL, http.StatusTemporaryRedirect)
}

func (h *TDHandlers) Callback(w http.ResponseWriter, req *http.Request) {
	ctx := context.Background()
	_, err := h.authenticator.FinishOAuth2Flow(ctx, w, req)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	http.Redirect(w, req, "/quote?ticker=SPY", http.StatusTemporaryRedirect)
}
Looking up a stock quote using the API.
type TDHandlers struct {
	authenticator *tdameritrade.Authenticator
}

func (h *TDHandlers) Quote(w http.ResponseWriter, req *http.Request) {
	ctx := context.Background()
	client, err := h.authenticator.AuthenticatedClient(ctx, req)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	ticker, ok := req.URL.Query()["ticker"]
	if !ok || len(ticker) == 0 {
		w.Write([]byte("ticker is required"))
		return
	}

	quote, _, err := client.Quotes.GetQuotes(ctx, ticker[0])
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	body, err := json.Marshal(quote)
	if err != nil {
		w.Write([]byte(err.Error()))
		return
	}

	w.Write(body)

}

Use at your own risk.

Documentation

Overview

Package tdameritrade is a wrapper around the TD Ameritrade REST API. It contains helpers for building apps that interact with TD Ameritrade's API on behalf of traders.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoCode is returned when the TD Ameritrade request is missing a code.
	ErrNoCode = fmt.Errorf("missing code in request from TD Ameritrade")

	// ErrNoState is returned when TD Ameritrade request is missing state, indicating a CSRF attempt.
	ErrNoState = fmt.Errorf("missing state in request from TD Ameritrade")
)
View Source
var (
	ChangeTypes    = []string{"value", "percent"}
	DirectionTypes = []string{"up", "down"}
)

Functions

func ConvertToEpoch

func ConvertToEpoch(t time.Time) int64

func PrintRequest

func PrintRequest(r *http.Request) string

Utility for printing out requests for debugging.

Types

type Account

type Account struct {
	SecuritiesAccount `json:"securitiesAccount"`
}

func (Account) MarshalEasyJSON added in v0.1.29

func (v Account) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Account) MarshalJSON added in v0.1.10

func (v Account) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Account) UnmarshalEasyJSON added in v0.1.29

func (v *Account) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Account) UnmarshalJSON added in v0.1.10

func (v *Account) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AccountOptions

type AccountOptions struct {
	Position bool
	Orders   bool
}

func (AccountOptions) MarshalEasyJSON added in v0.1.29

func (v AccountOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AccountOptions) MarshalJSON added in v0.1.10

func (v AccountOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AccountOptions) UnmarshalEasyJSON added in v0.1.29

func (v *AccountOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AccountOptions) UnmarshalJSON added in v0.1.10

func (v *AccountOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Accounts

type Accounts []*Account

func (Accounts) MarshalEasyJSON added in v0.1.29

func (v Accounts) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Accounts) MarshalJSON added in v0.1.29

func (v Accounts) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Accounts) UnmarshalEasyJSON added in v0.1.29

func (v *Accounts) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Accounts) UnmarshalJSON added in v0.1.29

func (v *Accounts) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type AccountsService

type AccountsService struct {
	// contains filtered or unexported fields
}

func (*AccountsService) CancelOrder

func (s *AccountsService) CancelOrder(ctx context.Context, accountID, orderID string) (*Response, error)

func (*AccountsService) CreateSavedOrder

func (s *AccountsService) CreateSavedOrder(ctx context.Context, accountID string, order *Order) (*Response, error)

func (*AccountsService) DeleteSavedOrder

func (s *AccountsService) DeleteSavedOrder(ctx context.Context, accountID, savedOrderID string) (*Response, error)

func (*AccountsService) GetAccount

func (s *AccountsService) GetAccount(ctx context.Context, accountID string, opts *AccountOptions) (*Account, *Response, error)

func (*AccountsService) GetAccounts

func (s *AccountsService) GetAccounts(ctx context.Context, opts *AccountOptions) (*Accounts, *Response, error)

func (*AccountsService) GetOrder

func (s *AccountsService) GetOrder(ctx context.Context, accountID, orderID string) (*Response, error)

func (*AccountsService) GetOrderByPath

func (s *AccountsService) GetOrderByPath(ctx context.Context, accountID string, orderParams *OrderParams) (*Response, error)

func (*AccountsService) GetOrdersByQuery

func (s *AccountsService) GetOrdersByQuery(ctx context.Context, orderParams *OrderParams) (*Orders, *Response, error)

func (*AccountsService) GetSavedOrder

func (s *AccountsService) GetSavedOrder(ctx context.Context, accountID, savedOrderID string, orderParams *OrderParams) (*Response, error)

func (AccountsService) MarshalEasyJSON added in v0.1.29

func (v AccountsService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (AccountsService) MarshalJSON added in v0.1.10

func (v AccountsService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*AccountsService) PlaceOrder

func (s *AccountsService) PlaceOrder(ctx context.Context, accountID string, order *Order) (*Response, error)

func (*AccountsService) ReplaceOrder

func (s *AccountsService) ReplaceOrder(ctx context.Context, accountID string, orderID string, order *Order) (*Response, error)

func (*AccountsService) ReplaceSavedOrder

func (s *AccountsService) ReplaceSavedOrder(ctx context.Context, accountID, savedOrderID string, order *Order) (*Response, error)

func (*AccountsService) UnmarshalEasyJSON added in v0.1.29

func (v *AccountsService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*AccountsService) UnmarshalJSON added in v0.1.10

func (v *AccountsService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Authenticator

type Authenticator struct {
	Store  PersistentStore
	OAuth2 oauth2.Config
}

Authenticator is a helper for TD Ameritrade's authentication. It authenticates users and validates the state returned from TD Ameritrade to protect users from CSRF attacks. It's recommended to use NewAuthenticator instead of creating this struct directly because TD Ameritrade requires Client IDs to be in the form clientid@AMER.OAUTHAP. This is not immediately obvious from the documentation. See https://developer.tdameritrade.com/content/authentication-faq

func NewAuthenticator

func NewAuthenticator(store PersistentStore, oauth2 oauth2.Config) *Authenticator

NewAuthenticator will automatically append @AMER.OAUTHAP to the client ID to save callers hours of frustration.

func (*Authenticator) AuthenticatedClient

func (a *Authenticator) AuthenticatedClient(ctx context.Context, req *http.Request) (*Client, error)

AuthenticatedClient tries to create an authenticated `Client` from a user's request

func (*Authenticator) FinishOAuth2Flow

func (a *Authenticator) FinishOAuth2Flow(ctx context.Context, w http.ResponseWriter, req *http.Request) (*Client, error)

FinishOAuth2Flow finishes authenticating a user returning from TD Ameritrade. It verifies that TD Ameritrade has returned the expected state to prevent CSRF attacks and returns an authenticated `Client` on success.

func (*Authenticator) StartOAuth2Flow

func (a *Authenticator) StartOAuth2Flow(w http.ResponseWriter, req *http.Request) (string, error)

StartOAuth2Flow returns TD Ameritrade's Auth URL and stores a random state value. Redirect users to the returned URL to begin authentication.

type Authorizations

type Authorizations struct {
	Apex               bool   `json:"apex"`
	LevelTwoQuotes     bool   `json:"levelTwoQuotes"`
	StockTrading       bool   `json:"stockTrading"`
	MarginTrading      bool   `json:"marginTrading"`
	StreamingNews      bool   `json:"streamingNews"`
	OptionTradingLevel string `json:"optionTradingLevel"`
	StreamerAccess     bool   `json:"streamerAccess"`
	AdvancedMargin     bool   `json:"advancedMargin"`
	ScottradeAccount   bool   `json:"scottradeAccount"`
}

func (Authorizations) MarshalEasyJSON added in v0.1.29

func (v Authorizations) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Authorizations) MarshalJSON added in v0.1.10

func (v Authorizations) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Authorizations) UnmarshalEasyJSON added in v0.1.29

func (v *Authorizations) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Authorizations) UnmarshalJSON added in v0.1.10

func (v *Authorizations) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Balance

type Balance struct {
	AccruedInterest              float64 `json:"accruedInterest"`
	CashBalance                  float64 `json:"cashBalance"`
	CashReceipts                 float64 `json:"cashReceipts"`
	LongOptionMarketValue        float64 `json:"longOptionMarketValue"`
	LiquidationValue             float64 `json:"liquidationValue"`
	LongMarketValue              float64 `json:"longMarketValue"`
	MoneyMarketFund              float64 `json:"moneyMarketFund"`
	Savings                      float64 `json:"savings"`
	ShortMarketValue             float64 `json:"shortMarketValue"`
	PendingDeposits              float64 `json:"pendingDeposits"`
	CashAvailableForTrading      float64 `json:"cashAvailableForTrading"`
	CashAvailableForWithdrawal   float64 `json:"cashAvailableForWithdrawal"`
	CashCall                     float64 `json:"cashCall"`
	LongNonMarginableMarketValue float64 `json:"longNonMarginableMarketValue"`
	TotalCash                    float64 `json:"totalCash"`
	ShortOptionMarketValue       float64 `json:"shortOptionMarketValue"`
	MutualFundValue              float64 `json:"mutualFundValue"`
	BondValue                    float64 `json:"bondValue"`
	CashDebitCallValue           float64 `json:"cashDebitCallValue"`
	UnsettledCash                float64 `json:"unsettledCash"`
}

func (Balance) MarshalEasyJSON added in v0.1.29

func (v Balance) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Balance) MarshalJSON added in v0.1.10

func (v Balance) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Balance) UnmarshalEasyJSON added in v0.1.29

func (v *Balance) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Balance) UnmarshalJSON added in v0.1.10

func (v *Balance) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CancelTime

type CancelTime struct {
	Date        string `json:"date,omitempty"`
	ShortFormat bool   `json:"shortFormat,omitempty"`
}

func (CancelTime) MarshalEasyJSON added in v0.1.29

func (v CancelTime) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CancelTime) MarshalJSON added in v0.1.10

func (v CancelTime) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CancelTime) UnmarshalEasyJSON added in v0.1.29

func (v *CancelTime) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CancelTime) UnmarshalJSON added in v0.1.10

func (v *CancelTime) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type CashEquivalent

type CashEquivalent struct {
	Cusip       string `json:"cusip,omitempty"`
	Symbol      string `json:"symbol"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type"` //"'SAVINGS' or 'MONEY_MARKET_FUND'"
}

func (CashEquivalent) MarshalEasyJSON added in v0.1.29

func (v CashEquivalent) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CashEquivalent) MarshalJSON added in v0.1.10

func (v CashEquivalent) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CashEquivalent) UnmarshalEasyJSON added in v0.1.29

func (v *CashEquivalent) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CashEquivalent) UnmarshalJSON added in v0.1.10

func (v *CashEquivalent) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Chains

type Chains struct {
	Symbol            string     `json:"symbol"`
	Status            string     `json:"status"`
	Underlying        Underlying `json:"underlying"`
	Strategy          string     `json:"strategy"`
	Interval          float64    `json:"interval"`
	IsDelayed         bool       `json:"isDelayed"`
	IsIndex           bool       `json:"isIndex"`
	InterestRate      float64    `json:"interestRate"`
	UnderlyingPrice   float64    `json:"underlyingPrice"`
	Volatility        float64    `json:"volatility"`
	DaysToExpiration  float64    `json:"daysToExpiration"`
	NumberOfContracts int        `json:"numberOfContracts"`
	CallExpDateMap    ExpDateMap `json:"callExpDateMap"`
	PutExpDateMap     ExpDateMap `json:"putExpDateMap"`
}

func (Chains) MarshalEasyJSON added in v0.1.29

func (v Chains) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Chains) MarshalJSON added in v0.1.10

func (v Chains) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Chains) UnmarshalEasyJSON added in v0.1.29

func (v *Chains) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Chains) UnmarshalJSON added in v0.1.10

func (v *Chains) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ChainsService

type ChainsService struct {
	// contains filtered or unexported fields
}

func (*ChainsService) GetChains

func (s *ChainsService) GetChains(ctx context.Context, queryValues url.Values) (*Chains, *Response, error)

Users must provide the required URL queryValues for this function to work. TD Ameritrade url values: https://developer.tdameritrade.com/option-chains/apis/get/marketdata/chains Instructions for using url.Values: https://golang.org/pkg/net/url/#Values

func (ChainsService) MarshalEasyJSON added in v0.1.29

func (v ChainsService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ChainsService) MarshalJSON added in v0.1.10

func (v ChainsService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ChainsService) UnmarshalEasyJSON added in v0.1.29

func (v *ChainsService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ChainsService) UnmarshalJSON added in v0.1.10

func (v *ChainsService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Client

type Client struct {

	// Base URL for API requests. Defaults to the public TD-Ameritrade API, but can be
	// set to any endpoint. This allows for more manageable testing.
	BaseURL *url.URL

	// services used for talking to different parts of the tdameritrade api
	PriceHistory       *PriceHistoryService
	Account            *AccountsService
	MarketHours        *MarketHoursService
	Quotes             *QuotesService
	Instrument         *InstrumentService
	Chains             *ChainsService
	Mover              *MoverService
	TransactionHistory *TransactionHistoryService
	User               *UserService
	Watchlist          *WatchlistService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) (*Client, error)

NewClient returns a new TD-Ameritrade API client. If a nil httpClient is provided, a new http.Client will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (Client) MarshalEasyJSON added in v0.1.29

func (Client) MarshalEasyJSON(w *jwriter.Writer)

func (Client) MarshalJSON added in v0.1.25

func (Client) MarshalJSON() ([]byte, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

func (*Client) UnmarshalEasyJSON added in v0.1.29

func (*Client) UnmarshalEasyJSON(l *jlexer.Lexer)

func (*Client) UnmarshalJSON added in v0.1.25

func (*Client) UnmarshalJSON([]byte) error

func (*Client) UpdateBaseURL

func (c *Client) UpdateBaseURL(baseURL string) error

type Command

type Command struct {
	Requests []StreamRequest `json:"requests"`
}

func (Command) MarshalEasyJSON added in v0.1.29

func (v Command) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Command) MarshalJSON added in v0.1.10

func (v Command) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Command) UnmarshalEasyJSON added in v0.1.29

func (v *Command) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Command) UnmarshalJSON added in v0.1.10

func (v *Command) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type EasyJSON_exporter_Client added in v0.1.29

type EasyJSON_exporter_Client *Client

type EasyJSON_exporter_Response added in v0.1.29

type EasyJSON_exporter_Response *Response

type Equity

type Equity struct {
	Cusip       string `json:"cusip,omitempty"`
	Symbol      string `json:"symbol"`
	Description string `json:"description,omitempty"`
}

func (Equity) MarshalEasyJSON added in v0.1.29

func (v Equity) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Equity) MarshalJSON added in v0.1.10

func (v Equity) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Equity) UnmarshalEasyJSON added in v0.1.29

func (v *Equity) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Equity) UnmarshalJSON added in v0.1.10

func (v *Equity) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Execution

type Execution struct {
	ActivityType           string          `json:"activityType"`  //"'EXECUTION' or 'ORDER_ACTION'",
	ExecutionType          string          `json:"executionType"` //"'FILL'",
	Quantity               float64         `json:"quantity"`
	OrderRemainingQuantity float64         `json:"orderRemainingQuantity"`
	ExecutionLegs          []*ExecutionLeg `json:"executionLegs"`
}

func (Execution) MarshalEasyJSON added in v0.1.29

func (v Execution) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Execution) MarshalJSON added in v0.1.10

func (v Execution) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Execution) UnmarshalEasyJSON added in v0.1.29

func (v *Execution) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Execution) UnmarshalJSON added in v0.1.10

func (v *Execution) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ExecutionLeg

type ExecutionLeg struct {
	LegID             int64   `json:"legId"`
	Quantity          float64 `json:"quantity"`
	MismarkedQuantity float64 `json:"mismarkedQuantity"`
	Price             float64 `json:"price"`
	Time              string  `json:"time"`
}

func (ExecutionLeg) MarshalEasyJSON added in v0.1.29

func (v ExecutionLeg) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ExecutionLeg) MarshalJSON added in v0.1.10

func (v ExecutionLeg) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ExecutionLeg) UnmarshalEasyJSON added in v0.1.29

func (v *ExecutionLeg) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ExecutionLeg) UnmarshalJSON added in v0.1.10

func (v *ExecutionLeg) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ExpDateMap

type ExpDateMap map[string]map[string][]ExpDateOption

the first string is the exp date. the second string is the strike price.

func (ExpDateMap) MarshalEasyJSON added in v0.1.29

func (v ExpDateMap) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ExpDateMap) MarshalJSON added in v0.1.29

func (v ExpDateMap) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ExpDateMap) UnmarshalEasyJSON added in v0.1.29

func (v *ExpDateMap) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ExpDateMap) UnmarshalJSON added in v0.1.29

func (v *ExpDateMap) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ExpDateOption

type ExpDateOption struct {
	PutCall                string             `json:"putCall"`
	Symbol                 string             `json:"symbol"`
	Description            string             `json:"description"`
	ExchangeName           string             `json:"exchangeName"`
	Bid                    float64            `json:"bid"`
	Ask                    float64            `json:"ask"`
	Last                   float64            `json:"last"`
	Mark                   float64            `json:"mark"`
	BidSize                int                `json:"bidSize"`
	AskSize                int                `json:"askSize"`
	BidAskSize             string             `json:"bidAskSize"`
	LastSize               float64            `json:"lastSize"`
	HighPrice              float64            `json:"highPrice"`
	LowPrice               float64            `json:"lowPrice"`
	OpenPrice              float64            `json:"openPrice"`
	ClosePrice             float64            `json:"closePrice"`
	TotalVolume            int                `json:"totalVolume"`
	TradeDate              string             `json:"tradeDate"`
	TradeTimeInLong        int                `json:"tradeTimeInLong"`
	QuoteTimeInLong        int                `json:"quoteTimeInLong"`
	NetChange              float64            `json:"netChange"`
	Volatility             Float64WithSpecial `json:"volatility"`
	Delta                  float64            `json:"delta"`
	Gamma                  Float64WithSpecial `json:"gamma"`
	Theta                  Float64WithSpecial `json:"theta"`
	Vega                   Float64WithSpecial `json:"vega"`
	Rho                    Float64WithSpecial `json:"rho"`
	OpenInterest           int                `json:"openInterest"`
	TimeValue              float64            `json:"timeValue"`
	TheoreticalOptionValue Float64WithSpecial `json:"theoreticalOptionValue"`
	TheoreticalVolatility  Float64WithSpecial `json:"theoreticalVolatility"`
	OptionDeliverablesList string             `json:"optionDeliverablesList"`
	StrikePrice            float64            `json:"strikePrice"`
	ExpirationDate         int                `json:"expirationDate"`
	DaysToExpiration       int                `json:"daysToExpiration"`
	ExpirationType         string             `json:"expirationType"`
	LastTradingDate        int                `json:"lastTradingDay"`
	Multiplier             float64            `json:"multiplier"`
	SettlementType         string             `json:"settlementType"`
	DeliverableNote        string             `json:"deliverableNote"`
	IsIndexOption          bool               `json:"isIndexOption"`
	PercentChange          float64            `json:"percentChange"`
	MarkChange             float64            `json:"markChange"`
	MarkPercentChange      float64            `json:"markPercentChange"`
	InTheMoney             bool               `json:"inTheMoney"`
	Mini                   bool               `json:"mini"`
	NonStandard            bool               `json:"nonStandard"`
}

func (ExpDateOption) MarshalEasyJSON added in v0.1.29

func (v ExpDateOption) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ExpDateOption) MarshalJSON added in v0.1.10

func (v ExpDateOption) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ExpDateOption) UnmarshalEasyJSON added in v0.1.29

func (v *ExpDateOption) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ExpDateOption) UnmarshalJSON added in v0.1.10

func (v *ExpDateOption) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type FixedIncome

type FixedIncome struct {
	Cusip        string  `json:"cusip"`
	Symbol       string  `json:"symbol"`
	Description  string  `json:"description"`
	MaturityDate string  `json:"maturityDate"`
	VariableRate float64 `json:"variableRate"`
	Factor       float64 `json:"factor"`
}

func (FixedIncome) MarshalEasyJSON added in v0.1.29

func (v FixedIncome) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (FixedIncome) MarshalJSON added in v0.1.10

func (v FixedIncome) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*FixedIncome) UnmarshalEasyJSON added in v0.1.29

func (v *FixedIncome) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*FixedIncome) UnmarshalJSON added in v0.1.10

func (v *FixedIncome) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Float64WithSpecial

type Float64WithSpecial float64

a float64 whose JSON unmarshaller supports NaN and Inf

func (Float64WithSpecial) MarshalJSON

func (v Float64WithSpecial) MarshalJSON() ([]byte, error)

func (*Float64WithSpecial) UnmarshalJSON

func (v *Float64WithSpecial) UnmarshalJSON(b []byte) error

type Hours

type Hours struct {
	Category     string       `json:"category"`
	Date         string       `json:"date"`
	Exchange     string       `json:"exchange"`
	IsOpen       bool         `json:"isOpen"`
	MarketType   string       `json:"marketType"`
	Product      string       `json:"product"`
	ProductName  string       `json:"productName"`
	SessionHours SessionHours `json:"sessionHours"`
}

func (Hours) MarshalEasyJSON added in v0.1.29

func (v Hours) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Hours) MarshalJSON added in v0.1.25

func (v Hours) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Hours) UnmarshalEasyJSON added in v0.1.29

func (v *Hours) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Hours) UnmarshalJSON added in v0.1.25

func (v *Hours) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Instrument

type Instrument struct {
	AssetType string `json:"assetType"`
	Symbol    string `json:"symbol"`
}

func (Instrument) MarshalEasyJSON added in v0.1.29

func (v Instrument) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Instrument) MarshalJSON

func (v Instrument) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Instrument) UnmarshalEasyJSON added in v0.1.29

func (v *Instrument) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Instrument) UnmarshalJSON

func (v *Instrument) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type InstrumentInfo

type InstrumentInfo struct {
	Cusip       string `json:"cusip,omitempty"`
	Symbol      string `json:"symbol"`
	Description string `json:"description,omitempty"`
	Type        string `json:"assetType"` //"'NOT_APPLICABLE' or 'OPEN_END_NON_TAXABLE' or 'OPEN_END_TAXABLE' or 'NO_LOAD_NON_TAXABLE' or 'NO_LOAD_TAXABLE'"
	Exchange    string `json:"exchange"`
}

func (InstrumentInfo) MarshalEasyJSON added in v0.1.29

func (v InstrumentInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (InstrumentInfo) MarshalJSON added in v0.1.10

func (v InstrumentInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*InstrumentInfo) UnmarshalEasyJSON added in v0.1.29

func (v *InstrumentInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*InstrumentInfo) UnmarshalJSON added in v0.1.10

func (v *InstrumentInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type InstrumentService

type InstrumentService struct {
	// contains filtered or unexported fields
}

InstrumentService handles communication with the marketdata related methods of the TDAmeritrade API.

TDAmeritrade API docs: https://developer.tdameritrade.com/instruments/apis

func (*InstrumentService) GetInstrument

func (s *InstrumentService) GetInstrument(ctx context.Context, cusip string) (*Instruments, *Response, error)

func (*InstrumentService) SearchInstruments

func (s *InstrumentService) SearchInstruments(ctx context.Context, symbol, projection string) (*Instruments, *Response, error)

type Instruments

type Instruments map[string]*InstrumentInfo

func (Instruments) MarshalEasyJSON added in v0.1.29

func (v Instruments) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Instruments) MarshalJSON added in v0.1.29

func (v Instruments) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Instruments) UnmarshalEasyJSON added in v0.1.29

func (v *Instruments) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Instruments) UnmarshalJSON added in v0.1.29

func (v *Instruments) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type KeyEntry

type KeyEntry struct {
	Key string `json:"key"`
}

func (KeyEntry) MarshalEasyJSON added in v0.1.29

func (v KeyEntry) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (KeyEntry) MarshalJSON added in v0.1.10

func (v KeyEntry) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*KeyEntry) UnmarshalEasyJSON added in v0.1.29

func (v *KeyEntry) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*KeyEntry) UnmarshalJSON added in v0.1.10

func (v *KeyEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MarketHours

type MarketHours map[string]map[string]*Hours

func (MarketHours) MarshalEasyJSON added in v0.1.29

func (v MarketHours) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MarketHours) MarshalJSON added in v0.1.29

func (v MarketHours) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MarketHours) UnmarshalEasyJSON added in v0.1.29

func (v *MarketHours) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MarketHours) UnmarshalJSON added in v0.1.29

func (v *MarketHours) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MarketHoursService

type MarketHoursService struct {
	// contains filtered or unexported fields
}

func (*MarketHoursService) GetMarketHours

func (s *MarketHoursService) GetMarketHours(ctx context.Context, market string, date time.Time) (*MarketHours, *Response, error)

func (*MarketHoursService) GetMarketHoursMulti

func (s *MarketHoursService) GetMarketHoursMulti(ctx context.Context, markets string, date time.Time) (*MarketHours, *Response, error)

func (MarketHoursService) MarshalEasyJSON added in v0.1.29

func (v MarketHoursService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MarketHoursService) MarshalJSON added in v0.1.29

func (v MarketHoursService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MarketHoursService) UnmarshalEasyJSON added in v0.1.29

func (v *MarketHoursService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MarketHoursService) UnmarshalJSON added in v0.1.29

func (v *MarketHoursService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Mover

type Mover struct {
	Change      float64 `json:"change"`
	Description string  `json:"description"`
	Direction   string  `json:"direction"`
	Last        float64 `json:"last"`
	TotalVolume float64 `json:"totalVolume"`
	Symbol      string  `json:"symbol"`
}

func (Mover) MarshalEasyJSON added in v0.1.29

func (v Mover) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Mover) MarshalJSON added in v0.1.10

func (v Mover) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Mover) UnmarshalEasyJSON added in v0.1.29

func (v *Mover) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Mover) UnmarshalJSON added in v0.1.10

func (v *Mover) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MoverOptions

type MoverOptions struct {
	Direction  string `url:"direction"`
	ChangeType string `url:"change"`
}

func (MoverOptions) MarshalEasyJSON added in v0.1.29

func (v MoverOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MoverOptions) MarshalJSON added in v0.1.10

func (v MoverOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MoverOptions) UnmarshalEasyJSON added in v0.1.29

func (v *MoverOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MoverOptions) UnmarshalJSON added in v0.1.10

func (v *MoverOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MoverService

type MoverService struct {
	// contains filtered or unexported fields
}

func (MoverService) MarshalEasyJSON added in v0.1.29

func (v MoverService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MoverService) MarshalJSON added in v0.1.29

func (v MoverService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MoverService) Mover

func (s *MoverService) Mover(ctx context.Context, symbol string, opts *MoverOptions) (*[]Mover, *Response, error)

func (*MoverService) UnmarshalEasyJSON added in v0.1.29

func (v *MoverService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MoverService) UnmarshalJSON added in v0.1.29

func (v *MoverService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type MutualFund

type MutualFund struct {
	Cusip       string `json:"cusip,omitempty"`
	Symbol      string `json:"symbol"`
	Description string `json:"description,omitempty"`
	Type        string `json:"type"` //"'NOT_APPLICABLE' or 'OPEN_END_NON_TAXABLE' or 'OPEN_END_TAXABLE' or 'NO_LOAD_NON_TAXABLE' or 'NO_LOAD_TAXABLE'"
}

func (MutualFund) MarshalEasyJSON added in v0.1.29

func (v MutualFund) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (MutualFund) MarshalJSON added in v0.1.10

func (v MutualFund) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*MutualFund) UnmarshalEasyJSON added in v0.1.29

func (v *MutualFund) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*MutualFund) UnmarshalJSON added in v0.1.10

func (v *MutualFund) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type NewWatchlist

type NewWatchlist struct {
	Name           string          `json:"name"`
	WatchlistItems []WatchlistItem `json:"watchlistItems"`
}

func (NewWatchlist) MarshalEasyJSON added in v0.1.29

func (v NewWatchlist) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (NewWatchlist) MarshalJSON added in v0.1.10

func (v NewWatchlist) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*NewWatchlist) UnmarshalEasyJSON added in v0.1.29

func (v *NewWatchlist) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*NewWatchlist) UnmarshalJSON added in v0.1.10

func (v *NewWatchlist) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OptionA

type OptionA struct {
	Cusip              string               `json:"cusip,omitempty"`
	Symbol             string               `json:"symbol"`
	Description        string               `json:"description,omitempty"`
	Type               string               `json:"type"`
	PutCall            string               `json:"putCall"`
	UnderlyingSymbol   string               `json:"underlyingSymbol"`
	OptionMultiplier   float64              `json:"optionMultiplier"`
	OptionDeliverables []*OptionDeliverable `json:"optionDeliverables"`
}

func (OptionA) MarshalEasyJSON added in v0.1.29

func (v OptionA) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OptionA) MarshalJSON added in v0.1.10

func (v OptionA) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OptionA) UnmarshalEasyJSON added in v0.1.29

func (v *OptionA) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OptionA) UnmarshalJSON added in v0.1.10

func (v *OptionA) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OptionDeliverable

type OptionDeliverable struct {
	Symbol           string  `json:"symbol"`
	DeliverableUnits float64 `json:"deliverableUnits"`
	CurrencyType     string  `json:"currencyType"`
	AssetType        string  `json:"assetType"`
}

func (OptionDeliverable) MarshalEasyJSON added in v0.1.29

func (v OptionDeliverable) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OptionDeliverable) MarshalJSON added in v0.1.10

func (v OptionDeliverable) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OptionDeliverable) UnmarshalEasyJSON added in v0.1.29

func (v *OptionDeliverable) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OptionDeliverable) UnmarshalJSON added in v0.1.10

func (v *OptionDeliverable) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Order

type Order struct {
	Session                  string                `json:"session"`
	Duration                 string                `json:"duration"`
	OrderType                string                `json:"orderType"`
	CancelTime               string                `json:"cancelTime,omitempty"`
	ComplexOrderStrategyType string                `json:"complexOrderStrategyType,omitempty"`
	Quantity                 float64               `json:"quantity,omitempty"`
	FilledQuantity           float64               `json:"filledQuantity,omitempty"`
	RemainingQuantity        float64               `json:"remainingQuantity,omitempty"`
	RequestedDestination     string                `json:"requestedDestination,omitempty"`
	DestinationLinkName      string                `json:"destinationLinkName,omitempty"`
	ReleaseTime              string                `json:"releaseTime,omitempty"`
	StopPrice                float64               `json:"stopPrice,omitempty"`
	StopPriceLinkBasis       string                `json:"stopPriceLinkBasis,omitempty"`
	StopPriceLinkType        string                `json:"stopPriceLinkType,omitempty"`
	StopPriceOffset          float64               `json:"stopPriceOffset,omitempty"`
	StopType                 string                `json:"stopType,omitempty"`
	PriceLinkBasis           string                `json:"priceLinkBasis,omitempty"`
	PriceLinkType            string                `json:"priceLinkType,omitempty"`
	Price                    float64               `json:"price,omitempty"`
	TaxLotMethod             string                `json:"taxLotMethod,omitempty"`
	OrderLegCollection       []*OrderLegCollection `json:"orderLegCollection,omitempty"`
	ActivationPrice          float64               `json:"activationPrice,omitempty"`
	SpecialInstruction       string                `json:"specialInstruction,omitempty"`
	OrderStrategyType        string                `json:"orderStrategyType"`
	OrderID                  int64                 `json:"orderId,omitempty"`
	Cancelable               bool                  `json:"cancelable,omitempty"`
	Editable                 bool                  `json:"editable,omitempty"`
	Status                   string                `json:"status,omitempty"`
	EnteredTime              string                `json:"enteredTime,omitempty"`
	CloseTime                string                `json:"closeTime,omitempty"`
	Tag                      string                `json:"tag,omitempty"`
	AccountID                float64               `json:"accountId,omitempty"`
	OrderActivityCollection  []*Execution          `json:"orderActivityCollection,omitempty"`
	ReplacingOrderCollection []*Order              `json:"replacingOrderCollection,omitempty"`
	ChildOrderStrategies     []*Order              `json:"childOrderStrategies,omitempty"`
	StatusDescription        string                `json:"statusDescription,omitempty"`
}

func (Order) MarshalEasyJSON added in v0.1.29

func (v Order) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Order) MarshalJSON added in v0.1.10

func (v Order) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Order) UnmarshalEasyJSON added in v0.1.29

func (v *Order) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Order) UnmarshalJSON added in v0.1.10

func (v *Order) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderInstrument added in v0.1.23

type OrderInstrument struct {
	AssetType        string `json:"assetType"`
	Cusip            string `json:"cusip"`
	Symbol           string `json:"symbol"`
	Description      string `json:"description"`
	PutCall          string `json:"putCall"`
	UnderlyingSymbol string `json:"underlyingSymbol"`
	Instruction      string `json:"instruction"`
	PositionEffect   string `json:"positionEffect"`
	Quantity         int    `json:"quantity"`
}

func (OrderInstrument) MarshalEasyJSON added in v0.1.29

func (v OrderInstrument) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderInstrument) MarshalJSON added in v0.1.24

func (v OrderInstrument) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderInstrument) UnmarshalEasyJSON added in v0.1.29

func (v *OrderInstrument) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderInstrument) UnmarshalJSON added in v0.1.24

func (v *OrderInstrument) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderLegCollection

type OrderLegCollection struct {
	OrderLegType   string     `json:"orderLegType,omitempty"`
	LegID          int        `json:"legId,omitempty"`
	Instrument     Instrument `json:"instrument"`
	Instruction    string     `json:"instruction"`
	PositionEffect string     `json:"positionEffect,omitempty"`
	Quantity       float64    `json:"quantity"`
	QuantityType   string     `json:"quantityType,omitempty"`
}

func (OrderLegCollection) MarshalEasyJSON added in v0.1.29

func (v OrderLegCollection) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderLegCollection) MarshalJSON added in v0.1.10

func (v OrderLegCollection) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderLegCollection) UnmarshalEasyJSON added in v0.1.29

func (v *OrderLegCollection) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderLegCollection) UnmarshalJSON added in v0.1.10

func (v *OrderLegCollection) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderParams

type OrderParams struct {
	AccountId  string `url:"accountId"`
	MaxResults int    `url:"maxResults,omitempty"`
	From       string `url:"fromEnteredTime,omitempty"`
	To         string `url:"toEnteredTime,omitempty"`
	Status     string `url:"status,omitempty"`
}

func (OrderParams) MarshalEasyJSON added in v0.1.29

func (v OrderParams) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderParams) MarshalJSON added in v0.1.10

func (v OrderParams) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderParams) UnmarshalEasyJSON added in v0.1.29

func (v *OrderParams) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderParams) UnmarshalJSON added in v0.1.10

func (v *OrderParams) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderStrategies added in v0.1.23

type OrderStrategies struct {
	Session                  string               `json:"session"`
	Duration                 string               `json:"duration"`
	OrderType                string               `json:"orderType"`
	ComplexOrderStrategyType string               `json:"complexOrderStrategyType"`
	Quantity                 float64              `json:"quantity"`
	FilledQuantity           float64              `json:"filledQuantity"`
	RemainingQuantity        float64              `json:"remainingQuantity"`
	RequestedDestination     string               `json:"requestedDestination"`
	DestinationLinkName      string               `json:"destinationLinkName"`
	Price                    float64              `json:"price"`
	OrderStrategyType        string               `json:"orderStrategyType"`
	OrderID                  int64                `json:"orderId"`
	Cancelable               bool                 `json:"cancelable"`
	Editable                 bool                 `json:"editable"`
	Status                   string               `json:"status"`
	EnteredTime              string               `json:"enteredTime"`
	CloseTime                string               `json:"closeTime"`
	Tag                      string               `json:"tag"`
	AccountID                int                  `json:"accountId"`
	OrderLegCollection       []OrderLegCollection `json:"orderLegCollection"`
}

func (OrderStrategies) MarshalEasyJSON added in v0.1.29

func (v OrderStrategies) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderStrategies) MarshalJSON added in v0.1.24

func (v OrderStrategies) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderStrategies) UnmarshalEasyJSON added in v0.1.29

func (v *OrderStrategies) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderStrategies) UnmarshalJSON added in v0.1.24

func (v *OrderStrategies) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Orders

type Orders []*Order

func (Orders) MarshalEasyJSON added in v0.1.29

func (v Orders) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Orders) MarshalJSON added in v0.1.29

func (v Orders) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Orders) UnmarshalEasyJSON added in v0.1.29

func (v *Orders) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Orders) UnmarshalJSON added in v0.1.29

func (v *Orders) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Period

type Period struct {
	Start string `json:"start"`
	End   string `json:"end"`
}

func (Period) MarshalEasyJSON added in v0.1.29

func (v Period) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Period) MarshalJSON added in v0.1.25

func (v Period) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Period) UnmarshalEasyJSON added in v0.1.29

func (v *Period) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Period) UnmarshalJSON added in v0.1.25

func (v *Period) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PersistentStore

type PersistentStore interface {
	StoreToken(token *oauth2.Token, w http.ResponseWriter, req *http.Request) error
	GetToken(req *http.Request) (*oauth2.Token, error)
	StoreState(state string, w http.ResponseWriter, req *http.Request) error
	GetState(*http.Request) (string, error)
}

PersistentStore is meant to persist data from TD Ameritrade that is needed between requests. Implementations must return the same value they set for a user in StoreState in GetState, or the login process will fail. It is meant to allow credentials to be stored in cookies, JWTs and anything else you can think of.

type Position added in v0.1.16

type Position struct {
	ShortQuantity                  float64    `json:"shortQuantity"`
	AveragePrice                   float64    `json:"averagePrice"`
	CurrentDayProfitLoss           float64    `json:"currentDayProfitLoss"`
	CurrentDayProfitLossPercentage float64    `json:"currentDayProfitLossPercentage"`
	LongQuantity                   float64    `json:"longQuantity"`
	SettledLongQuantity            float64    `json:"settledLongQuantity"`
	SettledShortQuantity           float64    `json:"settledShortQuantity"`
	AgedQuantity                   float64    `json:"agedQuantity"`
	Instrument                     Instrument `json:"instrument"`
	MarketValue                    float64    `json:"marketValue"`
}

func (Position) MarshalEasyJSON added in v0.1.29

func (v Position) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Position) MarshalJSON added in v0.1.16

func (v Position) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Position) UnmarshalEasyJSON added in v0.1.29

func (v *Position) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Position) UnmarshalJSON added in v0.1.16

func (v *Position) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Preferences

type Preferences struct {
	ExpressTrading                   bool   `json:"expressTrading"`
	DirectOptionsRouting             bool   `json:"directOptionsRouting"`
	DirectEquityRouting              bool   `json:"directEquityRouting"`
	DefaultEquityOrderLegInstruction string `json:"defaultEquityOrderLegInstruction"`
	DefaultEquityOrderType           string `json:"defaultEquityOrderType"`
	DefaultEquityOrderPriceLinkType  string `json:"defaultEquityOrderPriceLinkType"`
	DefaultEquityOrderDuration       string `json:"defaultEquityOrderDuration"`
	DefaultEquityOrderMarketSession  string `json:"defaultEquityOrderMarketSession"`
	DefaultEquityQuantity            int    `json:"defaultEquityQuantity"`
	MutualFundTaxLotMethod           string `json:"mutualFundTaxLotMethod"`
	OptionTaxLotMethod               string `json:"optionTaxLotMethod"`
	EquityTaxLotMethod               string `json:"equityTaxLotMethod"`
	DefaultAdvancedToolLaunch        string `json:"defaultAdvancedToolLaunch"`
	AuthTokenTimeout                 string `json:"authTokenTimeout"`
}

func (Preferences) MarshalEasyJSON added in v0.1.29

func (v Preferences) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Preferences) MarshalJSON added in v0.1.10

func (v Preferences) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Preferences) UnmarshalEasyJSON added in v0.1.29

func (v *Preferences) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Preferences) UnmarshalJSON added in v0.1.10

func (v *Preferences) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PriceHistory

type PriceHistory struct {
	Candles []struct {
		Close    float64 `json:"close"`
		Datetime int     `json:"datetime"`
		High     float64 `json:"high"`
		Low      float64 `json:"low"`
		Open     float64 `json:"open"`
		Volume   float64 `json:"volume"`
	} `json:"candles"`
	Empty  bool   `json:"empty"`
	Symbol string `json:"symbol"`
}

func (PriceHistory) MarshalEasyJSON added in v0.1.29

func (v PriceHistory) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PriceHistory) MarshalJSON added in v0.1.10

func (v PriceHistory) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PriceHistory) UnmarshalEasyJSON added in v0.1.29

func (v *PriceHistory) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PriceHistory) UnmarshalJSON added in v0.1.10

func (v *PriceHistory) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PriceHistoryOptions

type PriceHistoryOptions struct {
	PeriodType            string `url:"periodType,omitempty"`
	Period                int    `url:"period,omitempty"`
	FrequencyType         string `url:"frequencyType,omitempty"`
	Frequency             int    `url:"frequency,omitempty"`
	EndDate               int64  `url:"endDate,omitempty"`
	StartDate             int64  `url:"startDate,omitempty"`
	NeedExtendedHoursData *bool  `url:"needExtendedHoursData"`
}

func (PriceHistoryOptions) MarshalEasyJSON added in v0.1.29

func (v PriceHistoryOptions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PriceHistoryOptions) MarshalJSON added in v0.1.10

func (v PriceHistoryOptions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PriceHistoryOptions) UnmarshalEasyJSON added in v0.1.29

func (v *PriceHistoryOptions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PriceHistoryOptions) UnmarshalJSON added in v0.1.10

func (v *PriceHistoryOptions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type PriceHistoryService

type PriceHistoryService struct {
	// contains filtered or unexported fields
}

func (PriceHistoryService) MarshalEasyJSON added in v0.1.29

func (v PriceHistoryService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PriceHistoryService) MarshalJSON added in v0.1.29

func (v PriceHistoryService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PriceHistoryService) PriceHistory

func (s *PriceHistoryService) PriceHistory(ctx context.Context, symbol string, opts *PriceHistoryOptions) (*PriceHistory, *Response, error)

PriceHistory get the price history for a symbol TDAmeritrade API Docs: https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory

func (*PriceHistoryService) UnmarshalEasyJSON added in v0.1.29

func (v *PriceHistoryService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PriceHistoryService) UnmarshalJSON added in v0.1.29

func (v *PriceHistoryService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ProjectedBalances added in v0.1.23

type ProjectedBalances struct {
	CashAvailableForTrading    float64 `json:"cashAvailableForTrading"`
	CashAvailableForWithdrawal float64 `json:"cashAvailableForWithdrawal"`
}

func (ProjectedBalances) MarshalEasyJSON added in v0.1.29

func (v ProjectedBalances) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ProjectedBalances) MarshalJSON added in v0.1.24

func (v ProjectedBalances) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ProjectedBalances) UnmarshalEasyJSON added in v0.1.29

func (v *ProjectedBalances) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ProjectedBalances) UnmarshalJSON added in v0.1.24

func (v *ProjectedBalances) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

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                            float64 `json:"bidSize"`
	BidID                              string  `json:"bidId"`
	AskPrice                           float64 `json:"askPrice"`
	AskSize                            float64 `json:"askSize"`
	AskID                              string  `json:"askId"`
	LastPrice                          float64 `json:"lastPrice"`
	LastSize                           float64 `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                        float64 `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"`
}

func (Quote) MarshalEasyJSON added in v0.1.29

func (v Quote) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Quote) MarshalJSON added in v0.1.10

func (v Quote) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Quote) UnmarshalEasyJSON added in v0.1.29

func (v *Quote) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Quote) UnmarshalJSON added in v0.1.10

func (v *Quote) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type QuoteDelays

type QuoteDelays struct {
	IsNyseDelayed   bool `json:"isNyseDelayed"`
	IsNasdaqDelayed bool `json:"isNasdaqDelayed"`
	IsOpraDelayed   bool `json:"isOpraDelayed"`
	IsAmexDelayed   bool `json:"isAmexDelayed"`
	IsCmeDelayed    bool `json:"isCmeDelayed"`
	IsIceDelayed    bool `json:"isIceDelayed"`
	IsForexDelayed  bool `json:"isForexDelayed"`
}

func (QuoteDelays) MarshalEasyJSON added in v0.1.29

func (v QuoteDelays) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (QuoteDelays) MarshalJSON added in v0.1.10

func (v QuoteDelays) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*QuoteDelays) UnmarshalEasyJSON added in v0.1.29

func (v *QuoteDelays) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*QuoteDelays) UnmarshalJSON added in v0.1.10

func (v *QuoteDelays) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Quotes

type Quotes map[string]*Quote

func (Quotes) MarshalEasyJSON added in v0.1.29

func (v Quotes) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Quotes) MarshalJSON added in v0.1.29

func (v Quotes) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Quotes) UnmarshalEasyJSON added in v0.1.29

func (v *Quotes) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Quotes) UnmarshalJSON added in v0.1.29

func (v *Quotes) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type QuotesService

type QuotesService struct {
	// contains filtered or unexported fields
}

func (*QuotesService) GetQuotes

func (s *QuotesService) GetQuotes(ctx context.Context, symbols string) (*Quotes, *Response, error)

func (QuotesService) MarshalEasyJSON added in v0.1.29

func (v QuotesService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (QuotesService) MarshalJSON added in v0.1.29

func (v QuotesService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*QuotesService) UnmarshalEasyJSON added in v0.1.29

func (v *QuotesService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*QuotesService) UnmarshalJSON added in v0.1.29

func (v *QuotesService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Response

type Response struct {
	*http.Response
}

func (Response) MarshalEasyJSON added in v0.1.29

func (Response) MarshalEasyJSON(w *jwriter.Writer)

func (Response) MarshalJSON added in v0.1.25

func (Response) MarshalJSON() ([]byte, error)

func (*Response) UnmarshalEasyJSON added in v0.1.29

func (*Response) UnmarshalEasyJSON(l *jlexer.Lexer)

func (*Response) UnmarshalJSON added in v0.1.25

func (*Response) UnmarshalJSON([]byte) error

type SecuritiesAccount

type SecuritiesAccount struct {
	Type                    string            `json:"type"`
	AccountID               string            `json:"accountId"`
	RoundTrips              float64           `json:"roundTrips"`
	IsDayTrader             bool              `json:"isDayTrader"`
	IsClosingOnlyRestricted bool              `json:"isClosingOnlyRestricted"`
	Positions               []Position        `json:"positions"`
	OrderStrategies         []OrderStrategies `json:"orderStrategies"`
	InitialBalances         Balance           `json:"initialBalances"`
	CurrentBalances         Balance           `json:"currentBalances"`
	ProjectedBalances       ProjectedBalances `json:"projectedBalances"`
}

func (SecuritiesAccount) MarshalEasyJSON added in v0.1.29

func (v SecuritiesAccount) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SecuritiesAccount) MarshalJSON added in v0.1.10

func (v SecuritiesAccount) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SecuritiesAccount) UnmarshalEasyJSON added in v0.1.29

func (v *SecuritiesAccount) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SecuritiesAccount) UnmarshalJSON added in v0.1.10

func (v *SecuritiesAccount) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SessionHours

type SessionHours struct {
	PreMarket     []Period `json:"preMarket"`
	RegularMarket []Period `json:"regularMarket"`
	PostMarket    []Period `json:"postMarket"`
}

func (SessionHours) MarshalEasyJSON added in v0.1.29

func (v SessionHours) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SessionHours) MarshalJSON added in v0.1.25

func (v SessionHours) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SessionHours) UnmarshalEasyJSON added in v0.1.29

func (v *SessionHours) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SessionHours) UnmarshalJSON added in v0.1.25

func (v *SessionHours) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StoredWatchlist

type StoredWatchlist []struct {
	Name           string                `json:"name"`
	WatchlistID    string                `json:"watchlistId"`
	AccountID      string                `json:"accountId"`
	Status         string                `json:"status"`
	WatchlistItems []StoredWatchlistItem `json:"watchlistItems"`
}

func (StoredWatchlist) MarshalEasyJSON added in v0.1.29

func (v StoredWatchlist) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StoredWatchlist) MarshalJSON added in v0.1.29

func (v StoredWatchlist) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StoredWatchlist) UnmarshalEasyJSON added in v0.1.29

func (v *StoredWatchlist) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StoredWatchlist) UnmarshalJSON added in v0.1.29

func (v *StoredWatchlist) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StoredWatchlistInstrument

type StoredWatchlistInstrument struct {
	Symbol      string `json:"symbol"`
	Description string `json:"description"`
	AssetType   string `json:"assetType"`
}

func (StoredWatchlistInstrument) MarshalEasyJSON added in v0.1.29

func (v StoredWatchlistInstrument) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StoredWatchlistInstrument) MarshalJSON added in v0.1.10

func (v StoredWatchlistInstrument) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StoredWatchlistInstrument) UnmarshalEasyJSON added in v0.1.29

func (v *StoredWatchlistInstrument) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StoredWatchlistInstrument) UnmarshalJSON added in v0.1.10

func (v *StoredWatchlistInstrument) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StoredWatchlistItem

type StoredWatchlistItem struct {
	SequenceID    int                       `json:"sequenceId"`
	Quantity      int                       `json:"quantity"`
	AveragePrice  int                       `json:"averagePrice"`
	Commission    int                       `json:"commission"`
	PurchasedDate string                    `json:"purchasedDate"`
	Instrument    StoredWatchlistInstrument `json:"instrument"`
	Status        string                    `json:"status"`
}

func (StoredWatchlistItem) MarshalEasyJSON added in v0.1.29

func (v StoredWatchlistItem) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StoredWatchlistItem) MarshalJSON added in v0.1.10

func (v StoredWatchlistItem) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StoredWatchlistItem) UnmarshalEasyJSON added in v0.1.29

func (v *StoredWatchlistItem) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StoredWatchlistItem) UnmarshalJSON added in v0.1.10

func (v *StoredWatchlistItem) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthCommand

type StreamAuthCommand struct {
	Requests []StreamAuthRequest `json:"requests"`
}

func NewStreamAuthCommand

func NewStreamAuthCommand(userPrincipal *UserPrincipal, accountID string) (*StreamAuthCommand, error)

NewStreamAuthCommand creates a StreamAuthCommand from a TD Ameritrade UserPrincipal. It validates the account ID against the accounts in the UserPrincipal to avoid creating invalid messages unneccesarily.

func (StreamAuthCommand) MarshalEasyJSON added in v0.1.29

func (v StreamAuthCommand) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthCommand) MarshalJSON added in v0.1.10

func (v StreamAuthCommand) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthCommand) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthCommand) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthCommand) UnmarshalJSON added in v0.1.10

func (v *StreamAuthCommand) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthParams

type StreamAuthParams struct {
	Credential string `json:"credential"`
	Token      string `json:"token"`
	Version    string `json:"version"`
}

func (StreamAuthParams) MarshalEasyJSON added in v0.1.29

func (v StreamAuthParams) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthParams) MarshalJSON added in v0.1.10

func (v StreamAuthParams) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthParams) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthParams) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthParams) UnmarshalJSON added in v0.1.10

func (v *StreamAuthParams) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthRequest

type StreamAuthRequest struct {
	Service    string           `json:"service"`
	Command    string           `json:"command"`
	Requestid  int              `json:"requestid"`
	Account    string           `json:"account"`
	Source     string           `json:"source"`
	Parameters StreamAuthParams `json:"parameters"`
}

func (StreamAuthRequest) MarshalEasyJSON added in v0.1.29

func (v StreamAuthRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthRequest) MarshalJSON added in v0.1.10

func (v StreamAuthRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthRequest) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthRequest) UnmarshalJSON added in v0.1.10

func (v *StreamAuthRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthResponse

type StreamAuthResponse struct {
	Response []StreamAuthResponseBody `json:"response"`
}

func (StreamAuthResponse) MarshalEasyJSON added in v0.1.29

func (v StreamAuthResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthResponse) MarshalJSON added in v0.1.10

func (v StreamAuthResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthResponse) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthResponse) UnmarshalJSON added in v0.1.10

func (v *StreamAuthResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthResponseBody

type StreamAuthResponseBody struct {
	Service   string                    `json:"service"`
	Requestid string                    `json:"requestid"`
	Command   string                    `json:"command"`
	Timestamp int64                     `json:"timestamp"`
	Content   StreamAuthResponseContent `json:"content"`
}

func (StreamAuthResponseBody) MarshalEasyJSON added in v0.1.29

func (v StreamAuthResponseBody) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthResponseBody) MarshalJSON added in v0.1.10

func (v StreamAuthResponseBody) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthResponseBody) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthResponseBody) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthResponseBody) UnmarshalJSON added in v0.1.10

func (v *StreamAuthResponseBody) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamAuthResponseContent

type StreamAuthResponseContent struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func (StreamAuthResponseContent) MarshalEasyJSON added in v0.1.29

func (v StreamAuthResponseContent) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamAuthResponseContent) MarshalJSON added in v0.1.10

func (v StreamAuthResponseContent) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamAuthResponseContent) UnmarshalEasyJSON added in v0.1.29

func (v *StreamAuthResponseContent) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamAuthResponseContent) UnmarshalJSON added in v0.1.10

func (v *StreamAuthResponseContent) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamParams

type StreamParams struct {
	Keys   string `json:"keys"`
	Fields string `json:"fields"`
}

func (StreamParams) MarshalEasyJSON added in v0.1.29

func (v StreamParams) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamParams) MarshalJSON added in v0.1.10

func (v StreamParams) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamParams) UnmarshalEasyJSON added in v0.1.29

func (v *StreamParams) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamParams) UnmarshalJSON added in v0.1.10

func (v *StreamParams) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamRequest

type StreamRequest struct {
	Service    string       `json:"service"`
	Requestid  string       `json:"requestid"`
	Command    string       `json:"command"`
	Account    string       `json:"account"`
	Source     string       `json:"source"`
	Parameters StreamParams `json:"parameters"`
}

func (StreamRequest) MarshalEasyJSON added in v0.1.29

func (v StreamRequest) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamRequest) MarshalJSON added in v0.1.10

func (v StreamRequest) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamRequest) UnmarshalEasyJSON added in v0.1.29

func (v *StreamRequest) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamRequest) UnmarshalJSON added in v0.1.10

func (v *StreamRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamerInfo

type StreamerInfo struct {
	StreamerBinaryURL string `json:"streamerBinaryUrl"`
	StreamerSocketURL string `json:"streamerSocketUrl"`
	Token             string `json:"token"`
	TokenTimestamp    string `json:"tokenTimestamp"`
	UserGroup         string `json:"userGroup"`
	AccessLevel       string `json:"accessLevel"`
	ACL               string `json:"acl"`
	AppID             string `json:"appId"`
}

func (StreamerInfo) MarshalEasyJSON added in v0.1.29

func (v StreamerInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamerInfo) MarshalJSON added in v0.1.10

func (v StreamerInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamerInfo) UnmarshalEasyJSON added in v0.1.29

func (v *StreamerInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamerInfo) UnmarshalJSON added in v0.1.10

func (v *StreamerInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamerSubscriptionKeys

type StreamerSubscriptionKeys struct {
	Keys []KeyEntry `json:"keys"`
}

func (StreamerSubscriptionKeys) MarshalEasyJSON added in v0.1.29

func (v StreamerSubscriptionKeys) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamerSubscriptionKeys) MarshalJSON added in v0.1.10

func (v StreamerSubscriptionKeys) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamerSubscriptionKeys) UnmarshalEasyJSON added in v0.1.29

func (v *StreamerSubscriptionKeys) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamerSubscriptionKeys) UnmarshalJSON added in v0.1.10

func (v *StreamerSubscriptionKeys) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type StreamingClient

type StreamingClient struct {
	// contains filtered or unexported fields
}

func NewAuthenticatedStreamingClient

func NewAuthenticatedStreamingClient(userPrincipal *UserPrincipal, accountID string) (*StreamingClient, error)

NewAuthenticatedStreamingClient returns a client that will pull live updates for a TD Ameritrade account. It sends an initial authentication message to TD Ameritrade and waits for a response before returning. Use NewUnauthenticatedStreamingClient if you want to handle authentication yourself. You'll need to Close a StreamingClient to free up the underlying resources.

func NewUnauthenticatedStreamingClient

func NewUnauthenticatedStreamingClient(userPrincipal *UserPrincipal) (*StreamingClient, error)

NewUnauthenticatedStreamingClient returns an unauthenticated streaming client that has a connection to the TD Ameritrade websocket. You can get an authenticated streaming client with NewAuthenticatedStreamingClient. To authenticate manually, send a JSON serialized StreamAuthCommand message with the StreamingClient's Authenticate method. You'll need to Close a streaming client to free up the underlying resources.

func (*StreamingClient) Authenticate

func (s *StreamingClient) Authenticate(authCmd *StreamAuthCommand) error

func (*StreamingClient) Close

func (s *StreamingClient) Close() error

Close closes the underlying websocket connection.

func (StreamingClient) MarshalEasyJSON added in v0.1.29

func (v StreamingClient) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (StreamingClient) MarshalJSON added in v0.1.29

func (v StreamingClient) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*StreamingClient) ReceiveText

func (s *StreamingClient) ReceiveText() (<-chan []byte, <-chan error)

ReceiveText returns read-only channels with the raw byte responses from TD Ameritrade and errors generated while streaming. Callers should select over both of these channels to avoid blocking one. Callers are able to handle errors how thes see fit. All errors will be from Gorilla's websocket library and implement the net.Error interface.

func (*StreamingClient) SendCommand

func (s *StreamingClient) SendCommand(command Command) error

SendCommand serializes and sends a Command struct to TD Ameritrade. It is a wrapper around SendText.

func (*StreamingClient) SendText

func (s *StreamingClient) SendText(payload []byte) error

SendText sends a byte payload to TD Ameritrade's websocket. TD Ameritrade commands are JSON encoded payloads. You should generally be using SendCommand to send commands to TD Ameritrade.

func (*StreamingClient) UnmarshalEasyJSON added in v0.1.29

func (v *StreamingClient) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*StreamingClient) UnmarshalJSON added in v0.1.29

func (v *StreamingClient) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Transaction

type Transaction struct {
	Type                          string          `json:"type"`
	ClearingReferenceNumber       string          `json:"clearingReferenceNumber"`
	SubAccount                    string          `json:"subAccount"`
	SettlementDate                string          `json:"settlementDate"`
	OrderID                       string          `json:"orderId"`
	SMA                           float64         `json:"sma"`
	RequirementReallocationAmount float64         `json:"requirementReallocationAmount"`
	DayTradeBuyingPowerEffect     float64         `json:"dayTradeBuyingPowerEffect"`
	NetAmount                     float64         `json:"netAmount"`
	TransactionDate               string          `json:"transactionDate"`
	OrderDate                     string          `json:"orderDate"`
	TransactionSubType            string          `json:"transactionSubType"`
	TransactionID                 int64           `json:"transactionId"`
	CashBalanceEffectFlag         bool            `json:"cashBalanceEffectFlag"`
	Description                   string          `json:"description"`
	ACHStatus                     string          `json:"achStatus"`
	AccruedInterest               float64         `json:"accruedInterest"`
	Fees                          TransactionFees `json:"fees"`
	TransactionItem               TransactionItem `json:"transactionItem"`
}

Transaction represents a single transaction

type TransactionFees

type TransactionFees struct {
	AdditionalFee float64 `json:"additionalFee"`
	CdscFee       float64 `json:"cdscFee"`
	Commission    float64 `json:"commission"`
	OptRegFee     float64 `json:"optRegFee"`
	OtherCharges  float64 `json:"otherCharges"`
	RFee          float64 `json:"rFee"`
	RegFee        float64 `json:"regFee"`
	SecFee        float64 `json:"secFee"`
}

TransactionFees contains fees related to the transaction

type TransactionHistoryOptions

type TransactionHistoryOptions struct {
	Type   string `url:"type,omitempty"`
	Symbol string `url:"symbol,omitempty"`
	// ISO8601 format, day granularity yyyy-MM-dd
	StartDate string `url:"startDate,omitempty"`
	// ISO8601 format, day granularity yyyy-MM-dd
	EndDate string `url:"endDate,omitempty"`
}

TransactionHistoryOptions is parsed and translated to query options in the https request

type TransactionHistoryService

type TransactionHistoryService struct {
	// contains filtered or unexported fields
}

TransactionHistoryService handles communication with the transaction history related methods of the TDAmeritrade API.

TDAmeritrade API docs: https://developer.tdameritrade.com/transaction-history/apis

func (*TransactionHistoryService) GetTransaction

func (s *TransactionHistoryService) GetTransaction(ctx context.Context, accountID string, transactionID string) (*Transaction, *Response, error)

GetTransaction gets a specific transaction by account TDAmeritrade API Docs: https://developer.tdameritrade.com/transaction-history/apis/get/accounts/%7BaccountId%7D/transactions/%7BtransactionId%7D-0

func (*TransactionHistoryService) GetTransactions

func (s *TransactionHistoryService) GetTransactions(ctx context.Context, accountID string, opts *TransactionHistoryOptions) (*Transactions, *Response, error)

GetTransactions gets all transaction by account TDAmeritrade API Docs: https://developer.tdameritrade.com/transaction-history/apis/get/accounts/%7BaccountId%7D/transactions-0

type TransactionInstrument

type TransactionInstrument struct {
	Symbol               string  `json:"symbol"`
	UnderlyingSymbol     string  `json:"underlyingSymbol"`
	OptionExpirationDate string  `json:"optionExpirationDate"`
	OptionStrikePrice    float64 `json:"optionStrikePrice"`
	PutCall              string  `json:"putCall"`
	CUSIP                string  `json:"cusip"`
	Description          string  `json:"description"`
	AssetType            string  `json:"assetType"`
	BondMaturityDate     string  `json:"bondMaturityDate"`
	BondInterestRate     float64 `json:"bondInterestRate"`
}

TransactionInstrument is the instrumnet traded within a transaction

type TransactionItem

type TransactionItem struct {
	AccountID            int32                 `json:"accountId"`
	Amount               float64               `json:"amount"`
	Price                float64               `json:"price"`
	Cost                 float64               `json:"cost"`
	ParentOrderKey       int32                 `json:"parentOrderKey"`
	ParentChildIndicator string                `json:"parentChildIndicator"`
	Instruction          string                `json:"instruction"`
	PositionEffect       string                `json:"positionEffect"`
	Instrument           TransactionInstrument `json:"instrument"`
}

TransactionItem is an item within a transaction response

type Transactions

type Transactions []*Transaction

Transactions is a slice of transactions

type Underlying

type Underlying struct {
	Symbol            string  `json:"symbol"`
	Description       string  `json:"description"`
	Change            float64 `json:"change"`
	PercentChange     float64 `json:"percentChange"`
	Close             float64 `json:"close"`
	QuoteTime         int     `json:"quoteTime"`
	TradeTime         int     `json:"tradeTime"`
	Bid               float64 `json:"bid"`
	Ask               float64 `json:"ask"`
	Last              float64 `json:"last"`
	Mark              float64 `json:"mark"`
	MarkChange        float64 `json:"markChange"`
	MarkPercentChange float64 `json:"markPercentChange"`
	BidSize           int     `json:"bidSize"`
	AskSize           int     `json:"askSize"`
	HighPrice         float64 `json:"highPrice"`
	LowPrice          float64 `json:"lowPrice"`
	OpenPrice         float64 `json:"openPrice"`
	TotalVolume       int     `json:"totalVolume"`
	ExchangeName      string  `json:"exchangeName"`
	FiftyTwoWeekHigh  float64 `json:"fiftyTwoWeekHigh"`
	FiftyTwoWeekLow   float64 `json:"fiftyTwoWeekLow"`
	Delayed           bool    `json:"delayed"`
}

func (Underlying) MarshalEasyJSON added in v0.1.29

func (v Underlying) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Underlying) MarshalJSON added in v0.1.10

func (v Underlying) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Underlying) UnmarshalEasyJSON added in v0.1.29

func (v *Underlying) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Underlying) UnmarshalJSON added in v0.1.10

func (v *Underlying) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserAccountInfo

type UserAccountInfo struct {
	AccountID         string         `json:"accountId"`
	Description       string         `json:"description"`
	DisplayName       string         `json:"displayName"`
	AccountCdDomainID string         `json:"accountCdDomainId"`
	Company           string         `json:"company"`
	Segment           string         `json:"segment"`
	SurrogateIds      string         `json:"surrogateIds"`
	Preferences       Preferences    `json:"preferences"`
	ACL               string         `json:"acl"`
	Authorizations    Authorizations `json:"authorizations"`
}

func (UserAccountInfo) MarshalEasyJSON added in v0.1.29

func (v UserAccountInfo) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserAccountInfo) MarshalJSON added in v0.1.10

func (v UserAccountInfo) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserAccountInfo) UnmarshalEasyJSON added in v0.1.29

func (v *UserAccountInfo) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserAccountInfo) UnmarshalJSON added in v0.1.10

func (v *UserAccountInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserPrincipal

type UserPrincipal struct {
	AuthToken                string                   `json:"authToken"`
	UserID                   string                   `json:"userId"`
	UserCdDomainID           string                   `json:"userCdDomainId"`
	PrimaryAccountID         string                   `json:"primaryAccountId"`
	LastLoginTime            string                   `json:"lastLoginTime"`
	TokenExpirationTime      string                   `json:"tokenExpirationTime"`
	LoginTime                string                   `json:"loginTime"`
	AccessLevel              string                   `json:"accessLevel"`
	StalePassword            bool                     `json:"stalePassword"`
	StreamerInfo             StreamerInfo             `json:"streamerInfo"`
	ProfessionalStatus       string                   `json:"professionalStatus"`
	Quotes                   QuoteDelays              `json:"quotes"`
	StreamerSubscriptionKeys StreamerSubscriptionKeys `json:"streamerSubscriptionKeys"`
	Accounts                 []UserAccountInfo        `json:"accounts"`
}

func (UserPrincipal) MarshalEasyJSON added in v0.1.29

func (v UserPrincipal) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserPrincipal) MarshalJSON added in v0.1.10

func (v UserPrincipal) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserPrincipal) UnmarshalEasyJSON added in v0.1.29

func (v *UserPrincipal) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserPrincipal) UnmarshalJSON added in v0.1.10

func (v *UserPrincipal) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func (*UserService) GetPreferences

func (s *UserService) GetPreferences(ctx context.Context, accountID string) (*Preferences, *Response, error)

GetPreferences returns Preferences for a specific account. See https://developer.tdameritrade.com/user-principal/apis/get/accounts/%7BaccountId%7D/preferences-0

func (*UserService) GetStreamerSubscriptionKeys

func (s *UserService) GetStreamerSubscriptionKeys(ctx context.Context, accountIDs ...string) (*StreamerSubscriptionKeys, *Response, error)

GetStreamerSubscriptionKeys returns Subscription Keys for provided accounts or default accounts. See https://developer.tdameritrade.com/user-principal/apis/get/userprincipals/streamersubscriptionkeys-0

func (*UserService) GetUserPrincipals

func (s *UserService) GetUserPrincipals(ctx context.Context, fields ...string) (*UserPrincipal, *Response, error)

GetUserPrincipals returns User Principal details. Valid values for `fields` are "streamerSubscriptionKeys", "streamerConnectionInfo", "preferences" and "surrogateIds" See https://developer.tdameritrade.com/user-principal/apis/get/userprincipals-0

func (UserService) MarshalEasyJSON added in v0.1.29

func (v UserService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UserService) MarshalJSON added in v0.1.29

func (v UserService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UserService) UnmarshalEasyJSON added in v0.1.29

func (v *UserService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UserService) UnmarshalJSON added in v0.1.29

func (v *UserService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*UserService) UpdatePreferences

func (s *UserService) UpdatePreferences(ctx context.Context, accountID string, newPreferences *Preferences) (*Response, error)

UpdatePreferences updates Preferences for a specific account. Please note that the directOptionsRouting and directEquityRouting values cannot be modified via this operation, even though they are in the request body. See https://developer.tdameritrade.com/user-principal/apis/put/accounts/%7BaccountId%7D/preferences-0

type WatchlistInstrument

type WatchlistInstrument struct {
	Symbol    string `json:"symbol"`
	AssetType string `json:"assetType"`
}

func (WatchlistInstrument) MarshalEasyJSON added in v0.1.29

func (v WatchlistInstrument) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WatchlistInstrument) MarshalJSON added in v0.1.10

func (v WatchlistInstrument) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WatchlistInstrument) UnmarshalEasyJSON added in v0.1.29

func (v *WatchlistInstrument) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WatchlistInstrument) UnmarshalJSON added in v0.1.10

func (v *WatchlistInstrument) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WatchlistItem

type WatchlistItem struct {
	Quantity      int                 `json:"quantity"`
	AveragePrice  int                 `json:"averagePrice"`
	Commission    int                 `json:"commission"`
	PurchasedDate string              `json:"purchasedDate"`
	Instrument    WatchlistInstrument `json:"instrument"`
}

func (WatchlistItem) MarshalEasyJSON added in v0.1.29

func (v WatchlistItem) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WatchlistItem) MarshalJSON added in v0.1.10

func (v WatchlistItem) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WatchlistItem) UnmarshalEasyJSON added in v0.1.29

func (v *WatchlistItem) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WatchlistItem) UnmarshalJSON added in v0.1.10

func (v *WatchlistItem) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type WatchlistService

type WatchlistService struct {
	// contains filtered or unexported fields
}

func (*WatchlistService) CreateWatchlist

func (s *WatchlistService) CreateWatchlist(ctx context.Context, accountID string, newWatchlist *NewWatchlist) (*Response, error)

CreateWatchlist adds a new watchlist to a user's account See https://developer.tdameritrade.com/watchlist/apis/post/accounts/%7BaccountId%7D/watchlists-0

func (*WatchlistService) DeleteWatchlist

func (s *WatchlistService) DeleteWatchlist(ctx context.Context, accountID, watchlistID string) (*Response, error)

DeleteWatchlist removes a watchlist from a user's account See https://developer.tdameritrade.com/watchlist/apis/delete/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

func (*WatchlistService) GetAllWatchlists

func (s *WatchlistService) GetAllWatchlists(ctx context.Context) (*[]StoredWatchlist, *Response, error)

GetAllWatchlists returns all watchlists for all of a user's linked accounts. See https://developer.tdameritrade.com/watchlist/apis/get/accounts/watchlists-0

func (*WatchlistService) GetAllWatchlistsForAccount

func (s *WatchlistService) GetAllWatchlistsForAccount(ctx context.Context, accountID string) (*[]StoredWatchlist, *Response, error)

GetAllWatchlistsForAccount returns all watchlists for a single user account. See https://developer.tdameritrade.com/watchlist/apis/get/accounts/%7BaccountId%7D/watchlists-0

func (*WatchlistService) GetWatchlist

func (s *WatchlistService) GetWatchlist(ctx context.Context, accountID, watchlistID string) (*StoredWatchlist, *Response, error)

GetWatchlist returns a single watchlist in a user's account See https://developer.tdameritrade.com/watchlist/apis/get/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

func (WatchlistService) MarshalEasyJSON added in v0.1.29

func (v WatchlistService) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (WatchlistService) MarshalJSON added in v0.1.29

func (v WatchlistService) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*WatchlistService) ReplaceWatchlist

func (s *WatchlistService) ReplaceWatchlist(ctx context.Context, accountID, watchlistID string, newWatchlist *NewWatchlist) (*Response, error)

ReplaceWatchlist replaces a watchlist in an account with a new watchlist. It does not verify that symbols are valid. See https://developer.tdameritrade.com/watchlist/apis/put/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

func (*WatchlistService) UnmarshalEasyJSON added in v0.1.29

func (v *WatchlistService) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*WatchlistService) UnmarshalJSON added in v0.1.29

func (v *WatchlistService) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*WatchlistService) UpdateWatchlist

func (s *WatchlistService) UpdateWatchlist(ctx context.Context, accountID, watchlistID string, newWatchlist *NewWatchlist) (*Response, error)

UpdateWatchlist partially updates watchlist for a specific account. Callers can:

  • change the watchlist's name
  • add to the beginning/end of a watchlist
  • update or delete items in a watchlist

This method does not verify that the symbol or asset type are valid. See https://developer.tdameritrade.com/watchlist/apis/patch/accounts/%7BaccountId%7D/watchlists/%7BwatchlistId%7D-0

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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