tdapi

package
v0.0.0-...-48f5d39 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: GPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package tdapi supports an interface to the TDAmeritrade API.

Package tdapi supports an interface to the TDAmeritrade API.

Index

Constants

This section is empty.

Variables

View Source
var ErrOrderValidation = errors.New("Validating order failed")

ErrOrderValidation represents an error when validation of order structure fails brokerage rules.

Functions

This section is empty.

Types

type Session

type Session struct {
	sync.RWMutex //RW mutex on the whole structure for next 3 sets of data. Any API call will need to lock and unlock at this level
	// contains filtered or unexported fields
}

Session represents a TD Ameritrade session, which keeps track of various internal state information and caches. Current Spec: User can only stream 1 optionchain at a time, and stream the *tracked* options (from various underlyings)

func New

func New() *Session

New returns a pointer to the a new broker session

func (*Session) AddOptionToStrategy

func (s *Session) AddOptionToStrategy(opt *option.Option, strategy eventFactory.StrategyType) ([]string, error)

AddOptionToStrategy adds a strategy to an option

func (*Session) AddStockOptionsToStream

func (s *Session) AddStockOptionsToStream(stock *asset.Stock) error

AddStockOptionsToStream streams the stockSymbol and it's corresponding options. Currently only supporting OTM option only, FUTURE to make that configurable

func (*Session) CancelOrder

func (s *Session) CancelOrder(orderids []string) error

CancelOrder cancels an order that has been accepted by the broker. Note currently it only cancels the first order in orderids

func (*Session) DeregisterOptionUpdateChan

func (s *Session) DeregisterOptionUpdateChan(id string)

func (*Session) DeregisterOrderUpdateChan

func (s *Session) DeregisterOrderUpdateChan(id string)

func (*Session) DeregisterPortfolioUpdateChan

func (s *Session) DeregisterPortfolioUpdateChan(id string)

func (*Session) Login

func (s *Session) Login(loginid string, pass string) error

Login logs the user into the broker Post condition: Sets source id for the session, which is used as a param for other method calls

func (*Session) Logout

func (s *Session) Logout() error

Logout logs the user out from the broker

func (*Session) RegisterOptionUpdateChan

func (s *Session) RegisterOptionUpdateChan(id string) chan *option.Option

func (*Session) RegisterOrderUpdateChan

func (s *Session) RegisterOrderUpdateChan(id string) chan *ordermessage.Message

func (*Session) RegisterPortfolioUpdateChan

func (s *Session) RegisterPortfolioUpdateChan(id string) chan *portfolio.Portfolio

func (*Session) RemoveOptionFromStrategy

func (s *Session) RemoveOptionFromStrategy(opt *option.Option, strategy eventFactory.StrategyType) ([]string, error)

RemoveOptionFromStrategy sets the strategy back to null

func (*Session) RemoveStockOptionsFromStream

func (s *Session) RemoveStockOptionsFromStream(stock *asset.Stock) error

RemoveStockOptionsFromStream streams the stockSymbol and it's corresponding options. Currently only supporting OTM option only, FUTURE to make that configurable

func (*Session) RetrieveImpliedVolatilityHistory

func (s *Session) RetrieveImpliedVolatilityHistory(stockSymbol string, stock *asset.Stock) error

func (*Session) RetrieveOrderBook

func (s *Session) RetrieveOrderBook(accountid string, ob *orderbook.OrderBook) error

RetrieveOrderBook retrieves the orders from the brokerage firm in an asynchronous method (even though the function call is syncronous)

func (*Session) RetrievePortfolio

func (s *Session) RetrievePortfolio(portfolioParam *portfolio.Portfolio) error

RetrievePortfolio requests the broker for the Portfolio information

func (*Session) RetrievePriceHistory

func (s *Session) RetrievePriceHistory(stockSymbol string, stock *asset.Stock) error

func (*Session) RetrieveSnapshot

func (s *Session) RetrieveSnapshot(symbol string, assetType asset.AssetType, security interface{}) error

RetrieveSnapshot requests the broker for symbol, and is only a single value (for now... in future if needed, expand to mulitple)

func (*Session) RetrieveWatchlists

func (s *Session) RetrieveWatchlists(wls *watchlists.Watchlists) error

RetrieveWatchlists retrieves a watchlist from td

func (*Session) SendSingleLegOptionTrade

func (s *Session) SendSingleLegOptionTrade(order *order.Order) error

SendSingleLegOptionTrade sends the order to TD. It always validates the order before sending request.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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