client

package
v0.0.0-...-daaccfe Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrETradeAuthFailed = errors.New("authentication failed")

Functions

func IsAuthFailed

func IsAuthFailed(err error) bool

func NewStatusMap

func NewStatusMap(status string, keysAndValues ...string) jsonmap.JsonMap

func NewStatusResponse

func NewStatusResponse(status string, keysAndValues ...string) []byte

Types

type ETradeClient

type ETradeClient interface {
	Authenticate() ([]byte, error)

	Verify(verifyKey string) ([]byte, error)

	GetKeys() (consumerKey string, consumerSecret string, accessToken string, accessSecret string)

	ListAccounts() ([]byte, error)

	GetAccountBalances(accountIdKey string, realTimeNAV bool) ([]byte, error)

	ListTransactions(
		accountIdKey string, startDate *time.Time, endDate *time.Time, sortOrder constants.SortOrder, marker string,
		count int,
	) ([]byte, error)

	ListTransactionDetails(accountIdKey string, transactionId string) ([]byte, error)

	ViewPortfolio(
		accountIdKey string, count int, sortBy constants.PortfolioSortBy, sortOrder constants.SortOrder,
		pageNumber string, marketSession constants.MarketSession, totalsRequired bool, lotsRequired bool,
		view constants.PortfolioView,
	) ([]byte, error)

	ListPositionLotsDetails(accountIdKey string, positionId int64) ([]byte, error)

	ListAlerts(
		count int, category constants.AlertCategory, status constants.AlertStatus, sort constants.SortOrder,
		search string,
	) ([]byte, error)

	ListAlertDetails(alertId string, htmlTags bool) ([]byte, error)

	DeleteAlerts(alertIds []string) ([]byte, error)

	GetQuotes(
		symbols []string, detailFlag constants.QuoteDetailFlag, requireEarningsDate bool, skipMiniOptionsCheck bool,
	) ([]byte, error)

	LookupProduct(search string) ([]byte, error)

	GetOptionChains(
		symbol string, expiryYear int, expiryMonth int, expiryDay int, strikePriceNear int, noOfStrikes int,
		includeWeekly bool, skipAdjusted bool, optionCategory constants.OptionCategory,
		chainType constants.OptionChainType,
		priceType constants.OptionPriceType,
	) ([]byte, error)

	GetOptionExpireDates(symbol string, expiryType constants.OptionExpiryType) ([]byte, error)

	ListOrders(
		accountIdKey string, marker string, count int, status constants.OrderStatus, fromDate *time.Time,
		toDate *time.Time, symbols []string, securityType constants.OrderSecurityType,
		transactionType constants.OrderTransactionType, marketSession constants.MarketSession,
	) ([]byte, error)
}

func CreateETradeClient

func CreateETradeClient(
	logger *slog.Logger, production bool, consumerKey string, consumerSecret string, accessToken string,
	accessSecret string,
) (ETradeClient, error)

type ETradeClientMock

type ETradeClientMock struct {
	mock.Mock
}

func (*ETradeClientMock) Authenticate

func (c *ETradeClientMock) Authenticate() ([]byte, error)

func (*ETradeClientMock) DeleteAlerts

func (c *ETradeClientMock) DeleteAlerts(alertIds []string) ([]byte, error)

func (*ETradeClientMock) GetAccountBalances

func (c *ETradeClientMock) GetAccountBalances(accountIdKey string, realTimeNAV bool) ([]byte, error)

func (*ETradeClientMock) GetKeys

func (c *ETradeClientMock) GetKeys() (
	consumerKey string, consumerSecret string, accessToken string, accessSecret string,
)

func (*ETradeClientMock) GetOptionChains

func (c *ETradeClientMock) GetOptionChains(
	symbol string, expiryYear, expiryMonth, expiryDay, strikePriceNear, noOfStrikes int,
	includeWeekly, skipAdjusted bool, optionCategory constants.OptionCategory, chainType constants.OptionChainType,
	priceType constants.OptionPriceType,
) ([]byte, error)

func (*ETradeClientMock) GetOptionExpireDates

func (c *ETradeClientMock) GetOptionExpireDates(symbol string, expiryType constants.OptionExpiryType) ([]byte, error)

func (*ETradeClientMock) GetQuotes

func (c *ETradeClientMock) GetQuotes(
	symbols []string, detailFlag constants.QuoteDetailFlag, requireEarningsDate bool, skipMiniOptionsCheck bool,
) ([]byte, error)

func (*ETradeClientMock) ListAccounts

func (c *ETradeClientMock) ListAccounts() ([]byte, error)

func (*ETradeClientMock) ListAlertDetails

func (c *ETradeClientMock) ListAlertDetails(alertId string, htmlTags bool) ([]byte, error)

func (*ETradeClientMock) ListAlerts

func (c *ETradeClientMock) ListAlerts(
	count int, category constants.AlertCategory, status constants.AlertStatus, sort constants.SortOrder, search string,
) ([]byte, error)

func (*ETradeClientMock) ListOrders

func (c *ETradeClientMock) ListOrders(
	accountIdKey string, marker string, count int, status constants.OrderStatus, fromDate *time.Time, toDate *time.Time,
	symbols []string, securityType constants.OrderSecurityType, transactionType constants.OrderTransactionType,
	marketSession constants.MarketSession,
) ([]byte, error)

func (*ETradeClientMock) ListPositionLotsDetails

func (c *ETradeClientMock) ListPositionLotsDetails(accountIdKey string, positionId int64) ([]byte, error)

func (*ETradeClientMock) ListTransactionDetails

func (c *ETradeClientMock) ListTransactionDetails(accountIdKey string, transactionId string) ([]byte, error)

func (*ETradeClientMock) ListTransactions

func (c *ETradeClientMock) ListTransactions(
	accountIdKey string, startDate *time.Time, endDate *time.Time, sortOrder constants.SortOrder, marker string,
	count int,
) ([]byte, error)

func (*ETradeClientMock) LookupProduct

func (c *ETradeClientMock) LookupProduct(search string) ([]byte, error)

func (*ETradeClientMock) Verify

func (c *ETradeClientMock) Verify(verifyKey string) ([]byte, error)

func (*ETradeClientMock) ViewPortfolio

func (c *ETradeClientMock) ViewPortfolio(
	accountIdKey string, count int, sortBy constants.PortfolioSortBy, sortOrder constants.SortOrder, pageNumber string,
	marketSession constants.MarketSession, totalsRequired bool, lotsRequired bool, view constants.PortfolioView,
) ([]byte, error)

type EndpointUrls

type EndpointUrls interface {
	GetRequestTokenUrl() string
	AuthorizeApplicationUrl() string
	GetAccessTokenUrl() string
	RenewAccessTokenUrl() string
	RevokeAccessTokenUrl() string
	ListAccountsUrl() string
	GetAccountBalancesUrl(accountIdKey string) string
	ListTransactionsUrl(accountIdKey string) string
	ListTransactionDetailsUrl(accountIdKey string, transactionId string) string
	ViewPortfolioUrl(accountIdKey string) string
	ListPositionLotsDetailsUrl(accountIdKey string, positionId int64) string
	ListAlertsUrl() string
	ListAlertDetailsUrl(alertId string) string
	DeleteAlertUrl(alertIdList string) string
	GetQuotesUrl(symbols string) string
	LookUpProductUrl(search string) string
	GetOptionChainsUrl() string
	GetOptionExpireDatesUrl() string
	ListOrdersUrl(accountIdKey string) string
	PreviewOrderUrl(accountIdKey string) string
	PlaceOrderUrl(accountIdKey string) string
	CancelOrderUrl(accountIdKey string) string
	ChangePreviewedOrderUrl(accountIdKey string, orderId string) string
	PlaceChangedOrderUrl(accountIdKey string, orderId string) string
}

func GetEndpointUrls

func GetEndpointUrls(production bool) EndpointUrls

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type OAuthConfig

type OAuthConfig interface {
	Client(ctx context.Context, t *oauth1.Token) *http.Client
	RequestToken() (requestToken, requestSecret string, err error)
	AuthorizationURL(requestToken string) (*url.URL, error)
	AccessToken(requestToken, requestSecret, verifier string) (accessToken, accessSecret string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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