Documentation ¶
Overview ¶
Client is a simple client for testing out the Alpaca and Polygon APIs.
This client relies on a TOML config file located at ~/.alpaca.toml that looks like this:
alpaca apiKeyID="abc...xyz" apiSecretKey="abc...xyz"
Index ¶
- func GetSymbols(allSymbols string) []string
- type Client
- func (c *Client) CancelAllOrders() error
- func (c *Client) CancelOrder(orderID string) error
- func (c *Client) Close() error
- func (c *Client) CloseAllPositions() error
- func (c *Client) ClosePosition(symbol string) error
- func (c *Client) GetAccount() (*alpaca.Account, error)
- func (c *Client) GetAccountActivities(activityType *string, opts *alpaca.AccountActivitiesRequest) ([]alpaca.AccountActvity, error)
- func (c *Client) GetAccountConfigurations() (*alpaca.AccountConfigurations, error)
- func (c *Client) GetAggregates(symbol, timespan, from, to string) (*alpaca.Aggregates, error)
- func (c *Client) GetAsset(symbol string) (*alpaca.Asset, error)
- func (c *Client) GetCalendar(start, end *string) ([]alpaca.CalendarDay, error)
- func (c *Client) GetClock() (*alpaca.Clock, error)
- func (c *Client) GetHistoricAggregatesV2(symbol string, multiplier int, resolution polygon.AggType, from, to *time.Time, ...) (*polygon.HistoricAggregatesV2, error)
- func (c *Client) GetHistoricQuotesV2(ticker string, date string, opts *polygon.HistoricTicksV2Params) (*polygon.HistoricQuotesV2, error)
- func (c *Client) GetHistoricTradesV2(ticker string, date string, opts *polygon.HistoricTicksV2Params) (*polygon.HistoricTradesV2, error)
- func (c *Client) GetLastQuote(symbol string) (*alpaca.LastQuoteResponse, error)
- func (c *Client) GetLastTrade(symbol string) (*alpaca.LastTradeResponse, error)
- func (c *Client) GetOrder(orderID string) (*alpaca.Order, error)
- func (c *Client) GetPortfolioHistory(period *string, timeframe *alpaca.RangeFreq, dateEnd *time.Time, ...) (*alpaca.PortfolioHistory, error)
- func (c *Client) GetPosition(symbol string) (*alpaca.Position, error)
- func (c *Client) GetPreviousClose(symbol string) (*polygon.PreviousCloseV2, error)
- func (c *Client) GetStockExchanges() ([]polygon.StockExchange, error)
- func (c *Client) GetSymbolBars(symbol string, opts alpaca.ListBarParams) ([]alpaca.Bar, error)
- func (c *Client) ListAssets(status *string) ([]alpaca.Asset, error)
- func (c *Client) ListBars(symbols []string, opts alpaca.ListBarParams) (map[string][]alpaca.Bar, error)
- func (c *Client) ListOrders(opts alpaca.ListOrdersOptions) ([]alpaca.Order, error)
- func (c *Client) ListPositions() ([]alpaca.Position, error)
- func (c *Client) NewAccountHandler(handler api.AccountHandler) error
- func (c *Client) NewMinuteBarHandler(symbol string, handler api.MinuteBarHandler) error
- func (c *Client) NewOrderHandler(handler api.OrderHandler) error
- func (c *Client) NewQuoteHandler(symbol string, handler api.QuoteHandler) error
- func (c *Client) NewSecondBarHandler(symbol string, handler api.SecondBarHandler) error
- func (c *Client) NewTradeHandler(symbol string, handler api.TradeHandler) error
- func (c *Client) PlaceOrder(req alpaca.PlaceOrderRequest) (*alpaca.Order, error)
- func (c *Client) ReplaceOrder(orderID string, req alpaca.ReplaceOrderRequest) (*alpaca.Order, error)
- func (c *Client) StartStreams(symbols []string, handlerGetter api.HandlerGetter) (<-chan struct{}, error)
- func (c *Client) UpdateAccountConfigurations(newConfigs alpaca.AccountConfigurationsRequest) (*alpaca.AccountConfigurations, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSymbols ¶
GetSymbols splits the comma-separated symbol list and upcases the names.
Types ¶
type Client ¶
type Client struct { AClient *alpaca.Client PClient *polygon.Client AStream *alpaca.Stream PStream *polygon.Stream }
Client contains an Alpaca v2 and Polygon v2 API client. Client implements the API interface.
func (*Client) CancelAllOrders ¶
func (*Client) CancelOrder ¶
func (*Client) CloseAllPositions ¶
func (*Client) ClosePosition ¶
func (*Client) GetAccountActivities ¶
func (c *Client) GetAccountActivities(activityType *string, opts *alpaca.AccountActivitiesRequest) ([]alpaca.AccountActvity, error)
func (*Client) GetAccountConfigurations ¶
func (c *Client) GetAccountConfigurations() (*alpaca.AccountConfigurations, error)
func (*Client) GetAggregates ¶
func (c *Client) GetAggregates(symbol, timespan, from, to string) (*alpaca.Aggregates, error)
func (*Client) GetCalendar ¶
func (c *Client) GetCalendar(start, end *string) ([]alpaca.CalendarDay, error)
func (*Client) GetHistoricAggregatesV2 ¶
func (c *Client) GetHistoricAggregatesV2( symbol string, multiplier int, resolution polygon.AggType, from, to *time.Time, unadjusted *bool) (*polygon.HistoricAggregatesV2, error)
Polygon v2
func (*Client) GetHistoricQuotesV2 ¶
func (c *Client) GetHistoricQuotesV2(ticker string, date string, opts *polygon.HistoricTicksV2Params) (*polygon.HistoricQuotesV2, error)
func (*Client) GetHistoricTradesV2 ¶
func (c *Client) GetHistoricTradesV2(ticker string, date string, opts *polygon.HistoricTicksV2Params) (*polygon.HistoricTradesV2, error)
func (*Client) GetLastQuote ¶
func (c *Client) GetLastQuote(symbol string) (*alpaca.LastQuoteResponse, error)
func (*Client) GetLastTrade ¶
func (c *Client) GetLastTrade(symbol string) (*alpaca.LastTradeResponse, error)
func (*Client) GetPortfolioHistory ¶
func (*Client) GetPreviousClose ¶
func (c *Client) GetPreviousClose(symbol string) (*polygon.PreviousCloseV2, error)
func (*Client) GetStockExchanges ¶
func (c *Client) GetStockExchanges() ([]polygon.StockExchange, error)
func (*Client) GetSymbolBars ¶
func (*Client) ListOrders ¶
func (*Client) NewAccountHandler ¶
func (c *Client) NewAccountHandler(handler api.AccountHandler) error
NewAccountHandler creates a new account handler.
func (*Client) NewMinuteBarHandler ¶
func (c *Client) NewMinuteBarHandler(symbol string, handler api.MinuteBarHandler) error
NewMinuteBarHandler creates a new minuteBar handler.
func (*Client) NewOrderHandler ¶
func (c *Client) NewOrderHandler(handler api.OrderHandler) error
NewOrderHandler creates a new order handler.
func (*Client) NewQuoteHandler ¶
func (c *Client) NewQuoteHandler(symbol string, handler api.QuoteHandler) error
NewQuoteHandler creates a new quote handler.
func (*Client) NewSecondBarHandler ¶
func (c *Client) NewSecondBarHandler(symbol string, handler api.SecondBarHandler) error
NewSecondBarHandler creates a new secondBar handler.
func (*Client) NewTradeHandler ¶
func (c *Client) NewTradeHandler(symbol string, handler api.TradeHandler) error
NewTradeHandler creates a new trade handler.
func (*Client) PlaceOrder ¶
func (*Client) ReplaceOrder ¶
func (*Client) StartStreams ¶
func (c *Client) StartStreams(symbols []string, handlerGetter api.HandlerGetter) (<-chan struct{}, error)
StartStreams starts the data streams using the specified source.
symbols is a slice of upper-case symbol names to stream.
handlerGetter gets the handlers for the various streams.
The provided channel is sent an empty struct when the stream ends. For "paper" or "live", the stream ends at 4pm ET. For a filename source, the stream ends at the end of the file.
func (*Client) UpdateAccountConfigurations ¶
func (c *Client) UpdateAccountConfigurations(newConfigs alpaca.AccountConfigurationsRequest) (*alpaca.AccountConfigurations, error)