Documentation ¶
Index ¶
- type Account
- type AccountOptions
- type Accounts
- type AccountsService
- func (s *AccountsService) CancelOrder(ctx context.Context, accountID, orderID string) (*Response, error)
- func (s *AccountsService) CreateSavedOrder(ctx context.Context, accountID string, order *Order) (*Response, error)
- func (s *AccountsService) DeleteSavedOrder(ctx context.Context, accountID, savedOrderID string) (*Response, error)
- func (s *AccountsService) GetAccount(ctx context.Context, accountID string, opts *AccountOptions) (*Account, *Response, error)
- func (s *AccountsService) GetAccounts(ctx context.Context, opts *AccountOptions) (*Accounts, *Response, error)
- func (s *AccountsService) GetOrder(ctx context.Context, accountID, orderID string) (*Response, error)
- func (s *AccountsService) GetOrderByPath(ctx context.Context, accountID string, orderParams *OrderParams) (*Response, error)
- func (s *AccountsService) GetOrderByQuery(ctx context.Context, accountID string, orderParams *OrderParams) (*Response, error)
- func (s *AccountsService) GetSavedOrder(ctx context.Context, accountID, savedOrderID string, orderParams *OrderParams) (*Response, error)
- func (s *AccountsService) PlaceOrder(ctx context.Context, accountID string, order *Order) (*Response, error)
- func (s *AccountsService) ReplaceOrder(ctx context.Context, accountID string, orderID string, order *Order) (*Response, error)
- func (s *AccountsService) ReplaceSavedOrder(ctx context.Context, accountID, savedOrderID string, order *Order) (*Response, error)
- type Balance
- type CancelTime
- type CashEquivalent
- type Chains
- type ChainsService
- type Client
- type Equity
- type Execution
- type ExecutionLeg
- type ExpDateMap
- type ExpDateOption
- type FixedIncome
- type Hours
- type Instrument
- type InstrumentInfo
- type InstrumentService
- type Instruments
- type MarketHours
- type MarketHoursService
- type MutualFund
- type OptionA
- type OptionDeliverable
- type Order
- type OrderLegCollection
- type OrderParams
- type Period
- type PriceHistory
- type PriceHistoryOptions
- type PriceHistoryService
- type Quote
- type Quotes
- type QuotesService
- type Response
- type SecuritiesAccount
- type SessionHours
- type Underlying
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
SecuritiesAccount `json:"securitiesAccount"`
}
type AccountOptions ¶
type AccountsService ¶
type AccountsService struct {
// contains filtered or unexported fields
}
AccountsService handles communication with the account related methods of the TDAmeritrade API.
TDAmeritrade API docs: https://developer.tdameritrade.com/account-access/apis
func (*AccountsService) CancelOrder ¶
func (*AccountsService) CreateSavedOrder ¶
func (*AccountsService) DeleteSavedOrder ¶
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) GetOrderByPath ¶
func (s *AccountsService) GetOrderByPath(ctx context.Context, accountID string, orderParams *OrderParams) (*Response, error)
func (*AccountsService) GetOrderByQuery ¶
func (s *AccountsService) GetOrderByQuery(ctx context.Context, accountID string, orderParams *OrderParams) (*Response, error)
func (*AccountsService) GetSavedOrder ¶
func (s *AccountsService) GetSavedOrder(ctx context.Context, accountID, savedOrderID string, orderParams *OrderParams) (*Response, error)
func (*AccountsService) PlaceOrder ¶
func (*AccountsService) ReplaceOrder ¶
func (*AccountsService) ReplaceSavedOrder ¶
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"` }
type CancelTime ¶
type CashEquivalent ¶
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"` }
type ChainsService ¶
type ChainsService struct {
// contains filtered or unexported fields
}
ChainsService handles communication with the marketdata related methods of the TDAmeritrade API.
TDAmeritrade API docs: https://developer.tdameritrade.com/option-chains/apis
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
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 // contains filtered or unexported fields }
A Client manages communication with the TD-Ameritrade API.
func NewClient ¶
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) NewRequest ¶
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) UpdateBaseURL ¶
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"` }
type ExecutionLeg ¶
type ExpDateMap ¶
type ExpDateMap map[string]map[string][]ExpDateOption
the first string is the exp date. the second string is the strike price.
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 float64 `json:"volatility"` Delta float64 `json:"delta"` Gamma float64 `json:"gamma"` Theta float64 `json:"theta"` Vega float64 `json:"vega"` Rho float64 `json:"rho"` OpenInterest int `json:"openInterest"` TimeValue float64 `json:"timeValue"` TheoreticalOptionValue float64 `json:"theoreticalOptionValue"` TheoreticalVolatility float64 `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"` }
type FixedIncome ¶
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"` }
type Instrument ¶
type Instrument struct { AssetType string `json:"assetType"` Data interface{} }
func (*Instrument) MarshalJSON ¶
func (i *Instrument) MarshalJSON() ([]byte, error)
func (*Instrument) UnmarshalJSON ¶
func (i *Instrument) UnmarshalJSON(bs []byte) (err error)
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"` }
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
type MarketHours ¶
type MarketHoursService ¶
type MarketHoursService struct {
// contains filtered or unexported fields
}
MarketHoursService handles communication with the marketdata related methods of the TDAmeritrade API.
TDAmeritrade API docs: https://developer.tdameritrade.com/market-hours/apis
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)
type MutualFund ¶
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"` }
type OptionDeliverable ¶
type Order ¶
type Order struct { Session string `json:"session"` Duration string `json:"duration"` OrderType string `json:"orderType"` CancelTime *CancelTime `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"` 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"` }
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 int `json:"quantity"` QuantityType string `json:"quantityType,omitempty"` }
type OrderParams ¶
type PriceHistory ¶
type PriceHistoryOptions ¶
type PriceHistoryOptions struct { PeriodType string `url:"periodType"` Period int `url:"period"` FrequencyType string `url:"frequencyType"` Frequency int `url:"frequency"` EndDate time.Time `url:"endDate"` StartDate time.Time `url:"startDate"` NeedExtendedHoursData *bool `url:"needExtendedHoursData"` }
PriceHistoryOptions is parsed and translated to query options in the https request
type PriceHistoryService ¶
type PriceHistoryService struct {
// contains filtered or unexported fields
}
PriceHistoryService handles communication with the marketdata related methods of the TDAmeritrade API.
TDAmeritrade API docs: https://developer.tdameritrade.com/price-history/apis
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
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"` }
type QuotesService ¶
type QuotesService struct {
// contains filtered or unexported fields
}
QuotesService handles communication with the marketdata related methods of the TDAmeritrade API.
TDAmeritrade API docs: https://developer.tdameritrade.com/quotes/apis
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 []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"` } `json:"positions"` OrderStrategies []struct { Session string `json:"session"` Duration string `json:"duration"` OrderType string `json:"orderType"` CancelTime struct { Date string `json:"date"` ShortFormat bool `json:"shortFormat"` } `json:"cancelTime"` ComplexOrderStrategyType string `json:"complexOrderStrategyType"` Quantity float64 `json:"quantity"` FilledQuantity float64 `json:"filledQuantity"` RemainingQuantity float64 `json:"remainingQuantity"` RequestedDestination string `json:"requestedDestination"` DestinationLinkName string `json:"destinationLinkName"` ReleaseTime string `json:"releaseTime"` StopPrice float64 `json:"stopPrice"` StopPriceLinkBasis string `json:"stopPriceLinkBasis"` StopPriceLinkType string `json:"stopPriceLinkType"` StopPriceOffset float64 `json:"stopPriceOffset"` StopType string `json:"stopType"` PriceLinkBasis string `json:"priceLinkBasis"` PriceLinkType string `json:"priceLinkType"` Price float64 `json:"price"` TaxLotMethod string `json:"taxLotMethod"` OrderLegCollection []struct { OrderLegType string `json:"orderLegType"` LegID int64 `json:"legId"` Instrument string `json:"instrument"` Instruction string `json:"instruction"` PositionEffect string `json:"positionEffect"` Quantity float64 `json:"quantity"` QuantityType string `json:"quantityType"` } `json:"orderLegCollection"` ActivationPrice float64 `json:"activationPrice"` SpecialInstruction string `json:"specialInstruction"` 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 int64 `json:"accountId, string"` OrderActivityCollection []string `json:"orderActivityCollection"` ReplacingOrderCollection []struct { } `json:"replacingOrderCollection"` ChildOrderStrategies []struct { } `json:"childOrderStrategies"` StatusDescription string `json:"statusDescription"` } `json:"orderStrategies"` InitialBalances Balance `json:"initialBalances"` CurrentBalances Balance `json:"currentBalances"` ProjectedBalances Balance `json:"projectedBalances"` }
type SessionHours ¶
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"` }