Documentation ¶
Index ¶
- Constants
- Variables
- func SetBaseUrl(baseUrl string)
- type APIError
- type APIKey
- type Adjustment
- type AuthMethod
- type Bar
- type Client
- func (c *Client) GetMultiBars(symbols []string, params GetBarsParams) (map[string][]Bar, error)
- func (c *Client) GetMultiBarsAsync(symbols []string, params GetBarsParams) <-chan MultiBarItem
- func (c *Client) GetSnapshots(symbols []string) (map[string]*Snapshot, error)
- func (c *Client) ListAssets(status *string) ([]v1.Asset, error)
- type GetBarsParams
- type MultiBarItem
- type Quote
- type Snapshot
- type TimeFrame
- type TimeFrameUnit
- type Trade
Constants ¶
const ( BasicAuth = iota HeaderAuth )
const ( EnvApiKeyID = "APCA_API_KEY_ID" EnvApiSecretKey = "APCA_API_SECRET_KEY" EnvAuthMethod = "APCA_API_AUTH_METHOD" EnvApiOAuth = "APCA_API_OAUTH" EnvPolygonKeyID = "POLY_API_KEY_ID" )
Variables ¶
var ( // DefaultClient is the default Alpaca client using the // environment variable set credentials. DefaultClient = NewClient(Credentials()) )
Functions ¶
func SetBaseUrl ¶
func SetBaseUrl(baseUrl string)
Types ¶
type APIError ¶
APIError wraps the detailed code and message supplied by Alpaca's API for debugging purposes.
type APIKey ¶
type APIKey struct { ID string Secret string OAuth string PolygonKeyID string AuthMethod AuthMethod }
func Credentials ¶
func Credentials() *APIKey
Credentials returns the user's Alpaca API key ID and secret for use through the SDK.
type Adjustment ¶ added in v4.1.16
type Adjustment string
Adjustment specifies the corporate action adjustment(s) for the bars
const ( Raw Adjustment = "raw" Split Adjustment = "split" Dividend Adjustment = "dividend" All Adjustment = "all" )
List of adjustments
type AuthMethod ¶ added in v4.1.21
type AuthMethod int
func AuthMethodFromString ¶ added in v4.1.21
func AuthMethodFromString(s string) AuthMethod
type Bar ¶
type Bar struct { Timestamp time.Time `json:"t"` Open float64 `json:"o"` High float64 `json:"h"` Low float64 `json:"l"` Close float64 `json:"c"` Volume uint64 `json:"v"` TradeCount uint64 `json:"n"` VWAP float64 `json:"vw"` }
Bar is an aggregate of trades
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an Alpaca REST API client.
func (*Client) GetMultiBars ¶ added in v4.1.16
GetMultiBars returns bars for the given symbols.
func (*Client) GetMultiBarsAsync ¶ added in v4.1.16
func (c *Client) GetMultiBarsAsync(symbols []string, params GetBarsParams) <-chan MultiBarItem
GetMultiBarsAsync returns a channel that will be populated with the bars for the requested symbols.
func (*Client) GetSnapshots ¶
GetSnapshots returns the snapshots for multiple symbol.
type GetBarsParams ¶ added in v4.1.16
type GetBarsParams struct { // TimeFrame is the aggregation size of the bars TimeFrame TimeFrame // Adjustment tells if the bars should be adjusted for corporate actions Adjustment Adjustment // Start is the inclusive beginning of the interval Start time.Time // End is the inclusive end of the interval End time.Time // TotalLimit is the limit of the total number of the returned bars. // If missing, all bars between start end end will be returned. TotalLimit int // PageLimit is the pagination size. If empty, the default page size will be used. PageLimit int // Feed is the source of the data: sip or iex. // If provided, it overrides the client's Feed option. Feed string }
GetBarsParams contains optional parameters for getting bars
type MultiBarItem ¶ added in v4.1.16
MultiBarItem contains a single bar for a symbol or an error
type Quote ¶
type Quote struct { BidExchange string `json:"bx"` BidPrice float64 `json:"bp"` BidSize uint32 `json:"bs"` AskExchange string `json:"ax"` AskPrice float64 `json:"ap"` AskSize uint32 `json:"as"` Timestamp time.Time `json:"t"` Conditions []string `json:"c"` Tape string `json:"z"` }
Quote is a stock quote from the market.
type Snapshot ¶
type Snapshot struct { LatestTrade *Trade `json:"latestTrade"` LatestQuote *Quote `json:"latestQuote"` MinuteBar *Bar `json:"minuteBar"` DailyBar *Bar `json:"dailyBar"` PrevDailyBar *Bar `json:"prevDailyBar"` }
Snapshot is a snapshot of a symbol.
type TimeFrame ¶ added in v4.1.16
type TimeFrame struct { N int Unit TimeFrameUnit }
TimeFrame is the resolution of the bars
var ( OneMin TimeFrame = NewTimeFrame(1, Min) OneHour TimeFrame = NewTimeFrame(1, Hour) OneDay TimeFrame = NewTimeFrame(1, Day) )
func NewTimeFrame ¶ added in v4.1.16
func NewTimeFrame(n int, unit TimeFrameUnit) TimeFrame
type TimeFrameUnit ¶ added in v4.1.16
type TimeFrameUnit string
TimeFrameUnite is the base unit of the timeframe.
const ( Min TimeFrameUnit = "Min" Hour TimeFrameUnit = "Hour" Day TimeFrameUnit = "Day" )
List of timeframe units