api

package
v4.1.14 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvApiKeyID     = "APCA_API_KEY_ID"
	EnvApiSecretKey = "APCA_API_SECRET_KEY"
	EnvApiOAuth     = "APCA_API_OAUTH"
	EnvPolygonKeyID = "POLY_API_KEY_ID"
)

Variables

View Source
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

type APIError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

APIError wraps the detailed code and message supplied by Alpaca's API for debugging purposes

func (*APIError) Error

func (e *APIError) Error() string

type APIKey

type APIKey struct {
	ID           string
	Secret       string
	OAuth        string
	PolygonKeyID string
}

func Credentials

func Credentials() *APIKey

Credentials returns the user's Alpaca API key ID and secret for use through the SDK.

type Bar

type Bar struct {
	Open      float64   `json:"o"`
	High      float64   `json:"h"`
	Low       float64   `json:"l"`
	Close     float64   `json:"c"`
	Volume    uint64    `json:"v"`
	Timestamp time.Time `json:"t"`
}

Bar is an aggregate of trades

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an Alpaca REST API client

func NewClient

func NewClient(credentials *APIKey) *Client

NewClient creates a new Alpaca client with specified credentials

func (*Client) GetSnapshots

func (c *Client) GetSnapshots(symbols []string) (map[string]*Snapshot, error)

GetSnapshots returns the snapshots for multiple symbol

func (*Client) ListAssets

func (c *Client) ListAssets(status *string) ([]v1.Asset, error)

ListAssets returns the list of assets, filtered by the input parameters.

func (*Client) ListBars

func (c *Client) ListBars(symbols []string, opts v1.ListBarParams) (map[string][]v1.Bar, error)

ListBars returns a list of bar lists corresponding to the provided symbol list, and filtered by the provided parameters.

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 Trade

type Trade struct {
	ID         int64     `json:"i"`
	Exchange   string    `json:"x"`
	Price      float64   `json:"p"`
	Size       uint32    `json:"s"`
	Timestamp  time.Time `json:"t"`
	Conditions []string  `json:"c"`
	Tape       string    `json:"z"`
}

Trade is a stock trade that happened on the market

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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