etradeapi

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: MIT Imports: 11 Imported by: 0

README

etradeapi

Library to assist with calling the etrade api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	AccountID       string // user friendly ID shown on UIs example "64983239"
	AccountIDKey    string // internal ID needed for other calls example "Oy0YQdGsas2IN-_pVwGAew"
	AccountMode     string // "MARGIN" or "CASH"
	AccountDesc     string
	AccountName     string
	AccountType     string
	InstitutionType string
	AccountStatus   string
	ClosedDate      int64
}

Account is the array element of the Account fields value

type AccountListResponse

type AccountListResponse struct {
	AccountListResponse Accounts
}

AccountListResponse is the root object returned by "/v1/accounts/list" endpoint

type AccountPortfolio

type AccountPortfolio struct {
	AccountID  string
	Position   []Position
	TotalPages int
}

AccountPortfolio is the array element of the AccountPortfolio fields value

type AccountPortfolios

type AccountPortfolios struct {
	AccountPortfolio []AccountPortfolio
}

AccountPortfolios is the PortfolioResponse fields value

type Accounts

type Accounts struct {
	Accounts AccountsInner
}

Accounts is the AccountListResponse fields value

type AccountsInner

type AccountsInner struct {
	Account []Account
}

AccountsInner is the Accounts fields value

type AllQuoteDetails

type AllQuoteDetails struct {
	AdjustedFlag          bool
	Ask                   float64
	AskSize               int64
	AskTime               string
	Bid                   float64
	BidExchange           string
	BidSize               int64
	BidTime               string
	ChangeClose           float64
	ChangeClosePercentage float64
	CompanyName           string
	DaysToExpiration      int64
	DirLast               string
	Dividend              float64
	Eps                   float64
	EstEarnings           float64
	ExDividendDate        int64
	High                  float64
	High52                float64
	LastTrade             float64
	Low                   float64
	Low52                 float64
	Open                  float64
	OpenInterest          int64
	OptionStyle           string
	PreviousClose         float64
	PreviousDayVolume     int64
	PrimaryExchange       string
	SymbolDescription     string
	TotalVolume           int64
	Upc                   int64
	CashDeliverable       float64
	MarketCap             float64
	SharesOutstanding     float64
	NextEarningDate       string
	Beta                  float64
	Yield                 float64
	DeclaredDividend      float64
	DividendPayableDate   int64
	Pe                    float64
	Week52LowDate         int64
	Week52HiDate          int64
	IntrinsicValue        float64
	TimePremium           float64
	OptionMultiplier      float64
	ContractSize          float64
	ExpirationDate        int64
	TimeOfLastTrade       int64
	AverageVolume         int64

	// in doc but not seen in real response
	AnnualDividend float64
	AskExchange    string
	HighAsk        float64
	HighBid        float64
	LowAsk         float64
	LowBid         float64
	NumberOfTrades int64

	TodayClose  float64
	Volume10Day int64
	//optionDeliverableList []OptionDeliverable
	MarketCloseBidSize int64
	MarketCloseAskSize int64
	MarketCloseVolume  int64
	//EhQuote ExtendedHourQuoteDetail
	OptionPreviousBidPrice float64
	OptionPreviousAskPrice float64
	OsiKey                 string
	// contains filtered or unexported fields
}

AllQuoteDetails is the All fields value

type Brokerage

type Brokerage struct {
	Product            Product
	Quantity           float64
	Price              float64
	SettlementCurrency string
	PaymentCurrency    string
	Fee                float64
	DisplaySymbol      string
	SettlementDate     int64
}

Brokerage is the Brokerage fields value

type Config

type Config interface {
	ConsumerKey() string
	ConsumerSecret() string
	RequestTokenURL() string
	AccessTokenURL() string
	RenewTokenURL() string
	AuthorizeURL() string
	BaseServerURL() string
}

Config must be implemented and provided to New

func NewConfig

func NewConfig(c general.Config) (Config, error)

NewConfig provides a Config implementation based on general.Config

type Etrade

type Etrade interface {
	Status() string
	AccessTokenOK() bool

	AuthURL() (string, error)
	CheckCode(code string) error

	MakeGetRequest(url string, form url.Values, result interface{}) error
	MakePostRequest(url string, form url.Values, body interface{}, result interface{}) error

	EtradeTimeAsGoTime(etradeTime int64) time.Time

	Accounts() ([]Account, error)
	Transactions(accountIDKey string, start time.Time) ([]Transaction, error)
}

Etrade provides access to the etrade API

func New

func New(
	config Config,
	recordLog recordlog.RecordLog,
	dumperFactory general.DumperFactory,
	roundTripper http.RoundTripper,

	persistentState general.PersistentState,
) Etrade

New provides an implementation of the Etrade interface

type ExpirationDate

type ExpirationDate struct {
	Year       int32
	Month      int32
	Day        int32
	ExpiryType string
}

ExpirationDate is the array element of the ExpirationDate fields value

type ExpirationDates

type ExpirationDates struct {
	ExpirationDate []ExpirationDate
}

ExpirationDates is the OptionExpireDateResponse fields value

type Fundamental

type Fundamental struct {
	LastTrade     float32
	LastTradeTime int64
	Change        float32
	ChangePct     float32
	PeRatio       float32
	Eps           float32
	Dividend      float32
	DivYield      float32
	MarketCap     float64
	Week52Range   string
	// contains filtered or unexported fields
}

Fundamental is the Fundamental fields value

type Message

type Message struct {
	Description string
	Code        int32
	Type        string
}

Message is the array element of the Message fields value

type Messages

type Messages struct {
	Message []Message
}

Messages is the Messages fields value

type OptionExpireDateResponse

type OptionExpireDateResponse struct {
	OptionExpireDateResponse ExpirationDates
}

OptionExpireDateResponse is the root object returned by "/v1/market/optionexpiredate" endpoint

type Performance

type Performance struct {
	Change    float32
	ChangePct float32
	LastTrade float32

	// in doc but not seen in real response
	DaysGain      float32
	TotalGain     float32
	TotalGainPct  float32
	MarketValue   float32
	QuoteStatus   string
	LastTradeTime int64
}

Performance is the Performance fields value

type PortfolioResponse

type PortfolioResponse struct {
	PortfolioResponse AccountPortfolios
}

PortfolioResponse is the root object returned by "/v1/accounts/{accountKey}/portfolio" endpoint

type Position

type Position struct {
	PositionID        int64
	SymbolDescription string
	DateAcquired      int64
	PricePaid         float32
	Commissions       float32
	OtherFees         float32
	Quantity          float32
	PositionIndicator string
	PositionType      string
	DaysGain          float32
	DaysGainPct       float32
	MarketValue       float32
	TotalCost         float32
	TotalGain         float32
	TotalGainPct      float32
	PctOfPortfolio    float32
	CostPerShare      float32
	TodayCommissions  float32
	TodayFees         float32
	TodayPricePaid    float32
	TodayQuantity     float32
	LotsDetails       string
	QuoteDetails      string
	Product           Product
	Quick             QuickView
	Performance       Performance
	Fundamental       Fundamental
}

Position is the array element of the Position fields value

type Product

type Product struct {
	Symbol       string
	SecurityType string
	ExpiryYear   int32
	ExpiryMonth  int32
	ExpiryDay    int32
	StrikePrice  float32
	CallPut      string

	// in doc but not seen in real response
	SecuritySubType string
	ExpiryType      string
}

Product represents a specific equity, option, or other instrument

type QuickView

type QuickView struct {
	LastTrade     float32
	LastTradeTime int64
	Change        float32
	ChangePct     float32
	Volume        int64

	// in doc but not seen in real response
	QuoteStatus string

	AnnualTotalReturn       float64
	WeightedAverageMaturity float64
	// contains filtered or unexported fields
}

QuickView is the Quick fields value

type Quote

type Quote struct {
	QuoteData []QuoteData

	// in doc but not seen in real response
	Messages Messages
}

Quote is the QuoteResponse fields value

type QuoteData

type QuoteData struct {
	All         AllQuoteDetails
	Product     Product
	DateTime    string
	DateTimeUTC int64
	QuoteStatus string
	AhFlag      string

	// in doc but not seen in real response
	ErrorMessage   string
	TimeZone       string
	DstFlag        bool
	HasMiniOptions bool
}

QuoteData is the array element of the QuoteData fields value

type QuoteResponse

type QuoteResponse struct {
	QuoteResponse Quote
}

QuoteResponse is the root object returned by "/v1/market/quote" endpoint

type Transaction

type Transaction struct {
	TransactionID   string
	AccountID       string
	TransactionDate int64
	PostDate        int64
	Amount          float64
	Description     string
	Description2    string // not in doc but showed up in a transfer type transaction
	TransactionType string
	Memo            string
	ImageFlag       bool
	InstType        string
	StoreID         int
	Brokerage       Brokerage
	DetailsURI      string
}

Transaction is the array element of the Transaction fields value

type TransactionListResponse

type TransactionListResponse struct {
	TransactionListResponse Transactions
}

TransactionListResponse is the root object returned by "/v1/accounts/{accountKey}/transactions" endpoint

type Transactions

type Transactions struct {
	Next             string
	Marker           string
	PageMarkers      string
	MoreTransactions bool
	TransactionCount int
	TotalCount       int
	Transaction      []Transaction
}

Transactions is the TransactionListResponse fields value

Jump to

Keyboard shortcuts

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