Documentation
¶
Index ¶
- func CheckResponse(resp *http.Response) error
- func DecodeJSON(resp *http.Response, target interface{}) error
- func GetAuthToken(store keyring.Store, baseURL string, forceRefresh bool) (string, error)
- type APIError
- type Account
- type AccountsResponse
- type BuyingPower
- type Client
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) GetInstrument(ctx context.Context, symbol, instType string) (*InstrumentResponse, error)
- func (c *Client) GetOptionChain(ctx context.Context, accountID, symbol, expiration string) (*OptionChainResponse, error)
- func (c *Client) GetOptionExpirations(ctx context.Context, accountID, symbol string) (*OptionExpirationsResponse, error)
- func (c *Client) GetOptionGreeks(ctx context.Context, accountID string, osiSymbols []string) (*GreeksResponse, error)
- func (c *Client) GetPortfolio(ctx context.Context, accountID string) (*Portfolio, error)
- func (c *Client) GetQuotes(ctx context.Context, accountID string, instruments []QuoteInstrument) ([]Quote, error)
- func (c *Client) GetWithParams(ctx context.Context, path string, params map[string]string) (*http.Response, error)
- func (c *Client) Post(ctx context.Context, path string, body io.Reader) (*http.Response, error)
- func (c *Client) WithTokenRefresher(refresher TokenRefresher) *Client
- type CostBasis
- type Equity
- type Gain
- type GreeksData
- type GreeksResponse
- type HistoryResponse
- type Instrument
- type InstrumentIdentifier
- type InstrumentResponse
- type InstrumentsResponse
- type MultilegExpiration
- type MultilegInstrument
- type MultilegLeg
- type MultilegOrderRequest
- type MultilegOrderResponse
- type MultilegPreflightLeg
- type MultilegPreflightRequest
- type MultilegPreflightResponse
- type MultilegPriceIncrement
- type MultilegRegulatoryFees
- type OptionChainRequest
- type OptionChainResponse
- type OptionExpirationsRequest
- type OptionExpirationsResponse
- type OptionGreeks
- type OptionInstrument
- type OptionQuote
- type OptionsOrderRequest
- type OptionsPreflightRequest
- type OptionsPreflightResponse
- type OptionsRegulatoryFees
- type Order
- type OrderExpiration
- type OrderInstrument
- type OrderListResponse
- type OrderRequest
- type OrderResponse
- type OrderStatusResponse
- type OrdersResponse
- type Portfolio
- type Position
- type PreflightRequest
- type PreflightResponse
- type Price
- type Quote
- type QuoteInstrument
- type QuoteRequest
- type QuotesResponse
- type RegulatoryFees
- type TokenRefresher
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors. If the response status code indicates an error (>= 400), it parses the error body and returns an APIError. Otherwise, returns nil.
func DecodeJSON ¶
DecodeJSON decodes a JSON response body into the given target.
Types ¶
type APIError ¶
APIError represents an error response from the Public.com API.
func (*APIError) IsForbidden ¶
IsForbidden returns true if the error is a 403 Forbidden.
func (*APIError) IsNotFound ¶
IsNotFound returns true if the error is a 404 Not Found.
func (*APIError) IsUnauthorized ¶
IsUnauthorized returns true if the error is a 401 Unauthorized.
type AccountsResponse ¶
type AccountsResponse = publicapi.AccountsResponse
type BuyingPower ¶
type BuyingPower = publicapi.BuyingPower
type Client ¶
type Client struct {
BaseURL string
AuthToken string
HTTPClient *http.Client
TokenRefresher TokenRefresher // Optional: called on 401 to get fresh token
}
Client handles HTTP requests to the Public.com API.
func NewClientWithAuth ¶
NewClientWithAuth creates a new API client with automatic token retrieval. It fetches the auth token using the provided keyring store and base URL.
func (*Client) GetInstrument ¶
func (c *Client) GetInstrument(ctx context.Context, symbol, instType string) (*InstrumentResponse, error)
GetInstrument retrieves trading details for a single instrument.
func (*Client) GetOptionChain ¶
func (c *Client) GetOptionChain(ctx context.Context, accountID, symbol, expiration string) (*OptionChainResponse, error)
GetOptionChain retrieves the option chain for a symbol and expiration date.
func (*Client) GetOptionExpirations ¶
func (c *Client) GetOptionExpirations(ctx context.Context, accountID, symbol string) (*OptionExpirationsResponse, error)
GetOptionExpirations retrieves available option expiration dates for a symbol.
func (*Client) GetOptionGreeks ¶
func (c *Client) GetOptionGreeks(ctx context.Context, accountID string, osiSymbols []string) (*GreeksResponse, error)
GetOptionGreeks retrieves greeks for the given OSI option symbols.
func (*Client) GetPortfolio ¶
GetPortfolio retrieves the portfolio for the given account ID.
func (*Client) GetQuotes ¶
func (c *Client) GetQuotes(ctx context.Context, accountID string, instruments []QuoteInstrument) ([]Quote, error)
GetQuotes retrieves quotes for the given instruments.
func (*Client) GetWithParams ¶
func (c *Client) GetWithParams(ctx context.Context, path string, params map[string]string) (*http.Response, error)
GetWithParams performs a GET request to the specified path with query parameters.
func (*Client) WithTokenRefresher ¶
func (c *Client) WithTokenRefresher(refresher TokenRefresher) *Client
WithTokenRefresher sets a token refresher function that will be called on 401.
type GreeksData ¶
type GreeksData = publicapi.GreeksData
type GreeksResponse ¶
type GreeksResponse = publicapi.GreeksResponse
type HistoryResponse ¶
type HistoryResponse = publicapi.HistoryResponse
type Instrument ¶
type Instrument = publicapi.Instrument
type InstrumentIdentifier ¶
type InstrumentIdentifier = publicapi.InstrumentIdentifier
type InstrumentResponse ¶
type InstrumentResponse = publicapi.InstrumentResponse
type InstrumentsResponse ¶ added in v0.5.0
type InstrumentsResponse = publicapi.InstrumentsResponse
type MultilegExpiration ¶ added in v0.5.0
type MultilegExpiration = publicapi.MultilegExpiration
type MultilegInstrument ¶ added in v0.5.0
type MultilegInstrument = publicapi.MultilegInstrument
type MultilegLeg ¶ added in v0.5.0
type MultilegLeg = publicapi.MultilegLeg
type MultilegOrderRequest ¶ added in v0.5.0
type MultilegOrderRequest = publicapi.MultilegOrderRequest
type MultilegOrderResponse ¶ added in v0.5.0
type MultilegOrderResponse = publicapi.MultilegOrderResponse
type MultilegPreflightLeg ¶ added in v0.5.0
type MultilegPreflightLeg = publicapi.MultilegPreflightLeg
type MultilegPreflightRequest ¶ added in v0.5.0
type MultilegPreflightRequest = publicapi.MultilegPreflightRequest
type MultilegPreflightResponse ¶ added in v0.5.0
type MultilegPreflightResponse = publicapi.MultilegPreflightResponse
type MultilegPriceIncrement ¶ added in v0.5.0
type MultilegPriceIncrement = publicapi.MultilegPriceIncrement
type MultilegRegulatoryFees ¶ added in v0.5.0
type MultilegRegulatoryFees = publicapi.MultilegRegulatoryFees
type OptionChainRequest ¶
type OptionChainRequest = publicapi.OptionChainRequest
type OptionChainResponse ¶
type OptionChainResponse = publicapi.OptionChainResponse
type OptionExpirationsRequest ¶
type OptionExpirationsRequest = publicapi.OptionExpirationsRequest
type OptionExpirationsResponse ¶
type OptionExpirationsResponse = publicapi.OptionExpirationsResponse
type OptionGreeks ¶
type OptionGreeks = publicapi.OptionGreeks
type OptionInstrument ¶
type OptionInstrument = publicapi.OptionInstrument
type OptionQuote ¶
type OptionQuote = publicapi.OptionQuote
type OptionsOrderRequest ¶ added in v0.4.0
type OptionsOrderRequest = publicapi.OptionsOrderRequest
type OptionsPreflightRequest ¶ added in v0.4.0
type OptionsPreflightRequest = publicapi.OptionsPreflightRequest
type OptionsPreflightResponse ¶ added in v0.4.0
type OptionsPreflightResponse = publicapi.OptionsPreflightResponse
type OptionsRegulatoryFees ¶ added in v0.4.0
type OptionsRegulatoryFees = publicapi.OptionsRegulatoryFees
type OrderExpiration ¶
type OrderExpiration = publicapi.OrderExpiration
type OrderInstrument ¶
type OrderInstrument = publicapi.OrderInstrument
type OrderListResponse ¶
type OrderListResponse = publicapi.OrderListResponse
type OrderRequest ¶
type OrderRequest = publicapi.OrderRequest
type OrderResponse ¶
type OrderResponse = publicapi.OrderResponse
type OrderStatusResponse ¶
type OrderStatusResponse = publicapi.OrderStatusResponse
type OrdersResponse ¶
type OrdersResponse = publicapi.OrdersResponse
type PreflightRequest ¶
type PreflightRequest = publicapi.PreflightRequest
type PreflightResponse ¶
type PreflightResponse = publicapi.PreflightResponse
type QuoteInstrument ¶
type QuoteInstrument = publicapi.QuoteInstrument
type QuoteRequest ¶
type QuoteRequest = publicapi.QuoteRequest
type QuotesResponse ¶
type QuotesResponse = publicapi.QuotesResponse
type RegulatoryFees ¶
type RegulatoryFees = publicapi.RegulatoryFees
type TokenRefresher ¶
TokenRefresher is a function that returns a fresh auth token. It's called when the API returns 401 Unauthorized.
type Transaction ¶
type Transaction = publicapi.Transaction