marketdata

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 13 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OneMin   = NewTimeFrame(1, Min)
	OneHour  = NewTimeFrame(1, Hour)
	OneDay   = NewTimeFrame(1, Day)
	OneWeek  = NewTimeFrame(1, Week)
	OneMonth = NewTimeFrame(1, Month)
)
View Source
var DefaultClient = NewClient(ClientOpts{})

DefaultClient uses options from environment variables, or the defaults.

Functions

func GetAuctionsAsync added in v2.8.0

func GetAuctionsAsync(symbol string, params GetAuctionsParams) <-chan DailyAuctionsItem

GetAuctionsAsync returns a channel that will be populated with the auctions for the given symbol.

func GetBarsAsync

func GetBarsAsync(symbol string, params GetBarsParams) <-chan BarItem

GetBarsAsync returns a channel that will be populated with the bars for the given symbol.

func GetCryptoBarsAsync

func GetCryptoBarsAsync(symbol string, params GetCryptoBarsParams) <-chan CryptoBarItem

GetCryptoBarsAsync returns a channel that will be populated with the bars for the given crypto symbol.

func GetCryptoMultiBars

func GetCryptoMultiBars(symbols []string, params GetCryptoBarsParams) (map[string][]CryptoBar, error)

GetCryptoMultiBars returns the bars for the given crypto symbols. It blocks until all the bars are collected. If you want to process the incoming bars instantly, use GetCryptoMultiBarsAsync instead!

func GetCryptoMultiBarsAsync

func GetCryptoMultiBarsAsync(symbols []string, params GetCryptoBarsParams) <-chan CryptoMultiBarItem

GetCryptoMultiBarsAsync returns a channel that will be populated with the bars for the given crypto symbols.

func GetCryptoQuotesAsync

func GetCryptoQuotesAsync(symbol string, params GetCryptoQuotesParams) <-chan CryptoQuoteItem

GetCryptoQuotesAsync returns a channel that will be populated with the quotes for the given crypto symbol that happened between the given start and end times, limited to the given limit.

func GetCryptoSnapshots added in v2.3.0

func GetCryptoSnapshots(symbols []string, exchange string) (map[string]CryptoSnapshot, error)

GetCryptoSnapshots returns the snapshots for the given crypto symbols on the given exchange

func GetCryptoTradesAsync

func GetCryptoTradesAsync(symbol string, params GetCryptoTradesParams) <-chan CryptoTradeItem

GetCryptoQuotesAsync returns a channel that will be populated with the trades for the given crypto symbol that happened between the given start and end times, limited to the given limit.

func GetLatestBars added in v2.0.3

func GetLatestBars(symbols []string) (map[string]Bar, error)

GetLatestBars returns the latest minute bars for the given symbols.

func GetLatestCryptoBars added in v2.3.0

func GetLatestCryptoBars(symbols []string, exchange string) (map[string]CryptoBar, error)

GetLatestCryptoBars returns the latest bars for the given crypto symbols on the given exchange

func GetLatestCryptoQuotes added in v2.3.0

func GetLatestCryptoQuotes(symbols []string, exchange string) (map[string]CryptoQuote, error)

GetLatestCryptoQuotes returns the latest quotes for the given crypto symbols on the given exchange

func GetLatestCryptoTrades added in v2.3.0

func GetLatestCryptoTrades(symbols []string, exchange string) (map[string]CryptoTrade, error)

GetLatestCryptoTrades returns the latest trades for the given crypto symbols on the given exchange

func GetLatestCryptoXBBOs added in v2.3.0

func GetLatestCryptoXBBOs(symbols []string, exchanges []string) (map[string]CryptoXBBO, error)

GetLatestCryptoXBBOs returns the latest cross exchange BBOs for the given crypto symbols on the given exchanges

func GetLatestQuotes added in v2.0.3

func GetLatestQuotes(symbols []string) (map[string]Quote, error)

GetLatestQuotes returns the latest quotes for the given symbols.

func GetLatestTrades added in v2.0.3

func GetLatestTrades(symbols []string) (map[string]Trade, error)

GetLatestTrades returns the latest trades for the given symbols.

func GetMultiAuctions added in v2.8.0

func GetMultiAuctions(symbols []string, params GetAuctionsParams) (map[string][]DailyAuctions, error)

GetMultiAuctions returns the auctions for the given symbols. It blocks until all the auctions are collected. If you want to process the incoming auctions instantly, use GetMultiAuctionsAsync instead!

func GetMultiAuctionsAsync added in v2.8.0

func GetMultiAuctionsAsync(symbols []string, params GetAuctionsParams) <-chan MultiDailyAuctionsItem

GetMultiAuctionsAsync returns a channel that will be populated with the auctions for the given symbols.

func GetMultiBars

func GetMultiBars(symbols []string, params GetBarsParams) (map[string][]Bar, error)

GetMultiBars returns the bars for the given symbols. It blocks until all the bars are collected. If you want to process the incoming bars instantly, use GetMultiBarsAsync instead!

func GetMultiBarsAsync

func GetMultiBarsAsync(symbols []string, params GetBarsParams) <-chan MultiBarItem

GetMultiBarsAsync returns a channel that will be populated with the bars for the given symbols.

func GetMultiQuotes

func GetMultiQuotes(symbols []string, params GetQuotesParams) (map[string][]Quote, error)

GetMultiQuotes returns the quotes for the given symbols. It blocks until all the quotes are collected. If you want to process the incoming quotes instantly, use GetMultiQuotesAsync instead!

func GetMultiQuotesAsync

func GetMultiQuotesAsync(symbols []string, params GetQuotesParams) <-chan MultiQuoteItem

GetMultiQuotesAsync returns a channel that will be populated with the quotes for the given symbols.

func GetMultiTrades

func GetMultiTrades(symbols []string, params GetTradesParams) (map[string][]Trade, error)

GetMultiTrades returns the trades for the given symbols. It blocks until all the trades are collected. If you want to process the incoming trades instantly, use GetMultiTradesAsync instead!

func GetMultiTradesAsync

func GetMultiTradesAsync(symbols []string, params GetTradesParams) <-chan MultiTradeItem

GetMultiTradesAsync returns a channel that will be populated with the trades for the given symbols.

func GetQuotesAsync

func GetQuotesAsync(symbol string, params GetQuotesParams) <-chan QuoteItem

GetQuotesAsync returns a channel that will be populated with the quotes for the given symbol that happened between the given start and end times, limited to the given limit.

func GetSnapshots

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

GetSnapshots returns the snapshots for a multiple symbols

func GetTradesAsync

func GetTradesAsync(symbol string, params GetTradesParams) <-chan TradeItem

GetTradesAsync returns a channel that will be populated with the trades for the given symbol that happened between the given start and end times, limited to the given limit.

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 Adjustment

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 Auction added in v2.8.0

type Auction struct {
	Timestamp time.Time `json:"t"`
	Price     float64   `json:"p"`
	Size      uint32    `json:"s"`
	Exchange  string    `json:"x"`
	Condition string    `json:"c"`
}

Auction is a special trade that represents a stock auction

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

func GetBars

func GetBars(symbol string, params GetBarsParams) ([]Bar, error)

GetBars returns the bars for the given symbol. It blocks until all the bars are collected. If you want to process the incoming bars instantly, use GetBarsAsync instead!

func GetLatestBar added in v2.0.3

func GetLatestBar(symbol string) (*Bar, error)

GetLatestBar returns the latest minute bar for a given symbol.

type BarItem

type BarItem struct {
	Bar   Bar
	Error error
}

BarItem contains a single bar or an error

type Client

type Client interface {
	GetTrades(symbol string, params GetTradesParams) ([]Trade, error)
	GetTradesAsync(symbol string, params GetTradesParams) <-chan TradeItem
	GetMultiTrades(symbols []string, params GetTradesParams) (map[string][]Trade, error)
	GetMultiTradesAsync(symbols []string, params GetTradesParams) <-chan MultiTradeItem
	GetQuotes(symbol string, params GetQuotesParams) ([]Quote, error)
	GetQuotesAsync(symbol string, params GetQuotesParams) <-chan QuoteItem
	GetMultiQuotes(symbols []string, params GetQuotesParams) (map[string][]Quote, error)
	GetMultiQuotesAsync(symbols []string, params GetQuotesParams) <-chan MultiQuoteItem
	GetBars(symbol string, params GetBarsParams) ([]Bar, error)
	GetBarsAsync(symbol string, params GetBarsParams) <-chan BarItem
	GetMultiBars(symbols []string, params GetBarsParams) (map[string][]Bar, error)
	GetMultiBarsAsync(symbols []string, params GetBarsParams) <-chan MultiBarItem
	GetAuctions(symbol string, params GetAuctionsParams) ([]DailyAuctions, error)
	GetAuctionsAsync(symbol string, params GetAuctionsParams) <-chan DailyAuctionsItem
	GetMultiAuctions(symbols []string, params GetAuctionsParams) (map[string][]DailyAuctions, error)
	GetMultiAuctionsAsync(symbols []string, params GetAuctionsParams) <-chan MultiDailyAuctionsItem
	GetLatestBar(symbol string) (*Bar, error)
	GetLatestBars(symbols []string) (map[string]Bar, error)
	GetLatestTrade(symbol string) (*Trade, error)
	GetLatestTrades(symbols []string) (map[string]Trade, error)
	GetLatestQuote(symbol string) (*Quote, error)
	GetLatestQuotes(symbols []string) (map[string]Quote, error)
	GetSnapshot(symbol string) (*Snapshot, error)
	GetSnapshots(symbols []string) (map[string]*Snapshot, error)
	GetCryptoTrades(symbol string, params GetCryptoTradesParams) ([]CryptoTrade, error)
	GetCryptoTradesAsync(symbol string, params GetCryptoTradesParams) <-chan CryptoTradeItem
	GetCryptoQuotes(symbol string, params GetCryptoQuotesParams) ([]CryptoQuote, error)
	GetCryptoQuotesAsync(symbol string, params GetCryptoQuotesParams) <-chan CryptoQuoteItem
	GetCryptoBars(symbol string, params GetCryptoBarsParams) ([]CryptoBar, error)
	GetCryptoBarsAsync(symbol string, params GetCryptoBarsParams) <-chan CryptoBarItem
	GetCryptoMultiBars(symbols []string, params GetCryptoBarsParams) (map[string][]CryptoBar, error)
	GetCryptoMultiBarsAsync(symbols []string, params GetCryptoBarsParams) <-chan CryptoMultiBarItem
	GetLatestCryptoBar(symbol, exchange string) (*CryptoBar, error)
	GetLatestCryptoBars(symbols []string, exchange string) (map[string]CryptoBar, error)
	GetLatestCryptoTrade(symbol, exchange string) (*CryptoTrade, error)
	GetLatestCryptoTrades(symbols []string, exchange string) (map[string]CryptoTrade, error)
	GetLatestCryptoQuote(symbol, exchange string) (*CryptoQuote, error)
	GetLatestCryptoQuotes(symbols []string, exchange string) (map[string]CryptoQuote, error)
	GetLatestCryptoXBBO(symbol string, exchanges []string) (*CryptoXBBO, error)
	GetLatestCryptoXBBOs(symbols []string, exchanges []string) (map[string]CryptoXBBO, error)
	GetCryptoSnapshot(symbol string, exchange string) (*CryptoSnapshot, error)
	GetCryptoSnapshots(symbols []string, exchange string) (map[string]CryptoSnapshot, error)
	GetNews(params GetNewsParams) ([]News, error)
}

Client is the alpaca marketdata client.

func NewClient

func NewClient(opts ClientOpts) Client

NewClient creates a new marketdata client using the given opts.

type ClientOpts

type ClientOpts struct {
	ApiKey    string
	ApiSecret string
	OAuth     string
	BaseURL   string
	// Timeout sets the HTTP timeout for each request.
	//
	// Deprecated: use HttpClient with its Timeout set instead.
	// If both are set, HttpClient has precedence.
	Timeout    time.Duration
	RetryLimit int
	RetryDelay time.Duration
	// Feed is the default feed to be used by all requests. Can be overridden per request.
	// For the latest endpoints this is the only way to set this parameter.
	Feed string
	// Currency is the default currency to be used by all requests. Can be overridden per request.
	// For the latest endpoints this is the only way to set this parameter.
	Currency string
	// HttpClient to be used for each http request.
	HttpClient *http.Client
}

ClientOpts contains options for the alpaca marketdata client.

Currently it contains the exact same options as the trading alpaca client, but there is no guarantee that this will remain the case.

type CryptoBar

type CryptoBar struct {
	Timestamp  time.Time `json:"t"`
	Exchange   string    `json:"x"`
	Open       float64   `json:"o"`
	High       float64   `json:"h"`
	Low        float64   `json:"l"`
	Close      float64   `json:"c"`
	Volume     float64   `json:"v"`
	TradeCount uint64    `json:"n"`
	VWAP       float64   `json:"vw"`
}

CryptoBar is an aggregate of crypto trades

func GetCryptoBars

func GetCryptoBars(symbol string, params GetCryptoBarsParams) ([]CryptoBar, error)

GetCryptoBars returns the bars for the given crypto symbol. It blocks until all the bars are collected. If you want to process the incoming bars instantly, use GetCryptoBarsAsync instead!

func GetLatestCryptoBar added in v2.3.0

func GetLatestCryptoBar(symbol, exchange string) (*CryptoBar, error)

GetLatestCryptoBar returns the latest bar for a given crypto symbol on the given exchange

type CryptoBarItem

type CryptoBarItem struct {
	Bar   CryptoBar
	Error error
}

CryptoBarItem contains a single crypto bar or an error

type CryptoMultiBarItem

type CryptoMultiBarItem struct {
	Symbol string
	Bar    CryptoBar
	Error  error
}

CryptoMultiBarItem contains a single crypto bar for a symbol or an error

type CryptoQuote

type CryptoQuote struct {
	Timestamp time.Time `json:"t"`
	Exchange  string    `json:"x"`
	BidPrice  float64   `json:"bp"`
	BidSize   float64   `json:"bs"`
	AskPrice  float64   `json:"ap"`
	AskSize   float64   `json:"as"`
}

CryptoQuote is crypto quote

func GetCryptoQuotes

func GetCryptoQuotes(symbol string, params GetCryptoQuotesParams) ([]CryptoQuote, error)

GetCryptoQuotes returns the quotes for the given crypto symbol. It blocks until all the quotes are collected. If you want to process the incoming quotes instantly, use GetCryptoQuotesAsync instead!

func GetLatestCryptoQuote

func GetLatestCryptoQuote(symbol, exchange string) (*CryptoQuote, error)

GetLatestCryptoQuote returns the latest quote for a given crypto symbol on the given exchange

type CryptoQuoteItem

type CryptoQuoteItem struct {
	Quote CryptoQuote
	Error error
}

CryptoQuoteItem contains a single crypto quote or an error

type CryptoSnapshot added in v2.1.0

type CryptoSnapshot struct {
	LatestTrade  *CryptoTrade `json:"latestTrade"`
	LatestQuote  *CryptoQuote `json:"latestQuote"`
	MinuteBar    *CryptoBar   `json:"minuteBar"`
	DailyBar     *CryptoBar   `json:"dailyBar"`
	PrevDailyBar *CryptoBar   `json:"prevDailyBar"`
}

CryptoSnapshot is a snapshot of a crypto symbol

func GetCryptoSnapshot added in v2.1.0

func GetCryptoSnapshot(symbol string, exchange string) (*CryptoSnapshot, error)

GetCryptoSnapshot returns the snapshot for a given crypto symbol on the given exchange

type CryptoSnapshots added in v2.3.0

type CryptoSnapshots struct {
	Snapshots map[string]CryptoSnapshot `json:"snapshots"`
}

CryptoSnapshots is the snapshots for multiple crypto symbols

type CryptoTrade

type CryptoTrade struct {
	Timestamp time.Time `json:"t"`
	Price     float64   `json:"p"`
	Size      float64   `json:"s"`
	Exchange  string    `json:"x"`
	ID        int64     `json:"i"`
	// TakerSide is the side of the taker of the trade. It is either "B" (buy), "S" (sell) or "-" (unspecified)
	TakerSide string `json:"tks"`
}

CryptoTrade is a crypto trade

func GetCryptoTrades

func GetCryptoTrades(symbol string, params GetCryptoTradesParams) ([]CryptoTrade, error)

GetCryptoTrades returns the trades for the given crypto symbol. It blocks until all the trades are collected. If you want to process the incoming trades instantly, use GetCryptoTradesAsync instead!

func GetLatestCryptoTrade

func GetLatestCryptoTrade(symbol, exchange string) (*CryptoTrade, error)

GetLatestCryptoTrade returns the latest trade for a given crypto symbol on the given exchange

type CryptoTradeItem

type CryptoTradeItem struct {
	Trade CryptoTrade
	Error error
}

type CryptoXBBO

type CryptoXBBO struct {
	Timestamp   time.Time `json:"t"`
	BidExchange string    `json:"bx"`
	BidPrice    float64   `json:"bp"`
	BidSize     float64   `json:"bs"`
	AskExchange string    `json:"ax"`
	AskPrice    float64   `json:"ap"`
	AskSize     float64   `json:"as"`
}

CryptoXBBO is a cross exchange crypto BBO

func GetLatestCryptoXBBO

func GetLatestCryptoXBBO(symbol string, exchanges []string) (*CryptoXBBO, error)

GetLatestCryptoXBBO returns the latest cross exchange BBO for a given crypto symbol on the given exchanges

type DailyAuctions added in v2.8.0

type DailyAuctions struct {
	Date    civil.Date `json:"d"`
	Opening []Auction  `json:"o"`
	Closing []Auction  `json:"c"`
}

DailyAuctions contains all the opening and closing auctions for a symbol in a single day

func GetAuctions added in v2.8.0

func GetAuctions(symbol string, params GetAuctionsParams) ([]DailyAuctions, error)

GetAuctions returns the auctions for the given symbol. It blocks until all the auctions are collected. If you want to process the incoming auctions instantly, use GetAuctionsAsync instead!

type DailyAuctionsItem added in v2.8.0

type DailyAuctionsItem struct {
	DailyAuctions DailyAuctions
	Error         error
}

DailyAuctionsItem contains the daily auctions in a single day or an error

type GetAuctionsParams added in v2.8.0

type GetAuctionsParams struct {
	// 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 auctions.
	// If missing, all auctions 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
	// AsOf defines the date when the symbols are mapped. "-" means no mapping.
	AsOf string
	// Currency is the currency of the displayed prices
	Currency string
}

GetAuctionsParams contains optional parameters for getting auctions

type GetBarsParams

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
	// AsOf defines the date when the symbols are mapped. "-" means no mapping.
	AsOf string
	// Currency is the currency of the displayed prices
	Currency string
}

GetBarsParams contains optional parameters for getting bars

type GetCryptoBarsParams

type GetCryptoBarsParams struct {
	// TimeFrame is the aggregation size of the bars
	TimeFrame TimeFrame
	// 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
	// Exchanges is the list of exchanges to query. If empty, the default exchanges will be used.
	Exchanges []string
}

GetCryptoBarsParams contains optional parameters for getting crypto bars

type GetCryptoQuotesParams

type GetCryptoQuotesParams struct {
	// 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 quotes.
	// If missing, all quotes 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
	// Exchanges is the list of exchanges to query. If empty, the default exchanges will be used.
	Exchanges []string
}

GetCryptoQuotesParams contains optional parameters for getting crypto quotes

type GetCryptoTradesParams

type GetCryptoTradesParams struct {
	// 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 trades.
	// If missing, all trades 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
	// Exchanges is the list of exchanges to query. If empty, the default exchanges will be used.
	Exchanges []string
}

GetCryptoTradesParams contains optional parameters for getting crypto trades

type GetNewsParams added in v2.2.0

type GetNewsParams struct {
	// Symbols filters the news to the related symbols.
	// If empty or nil, all articles will be returned.
	Symbols []string
	// Start is the inclusive beginning of the interval
	Start time.Time
	// End is the inclusive end of the interval
	End time.Time
	// Sort sets the sort order of the results. Sorting will be done by the UpdatedAt field.
	Sort Sort
	// IncludeContent tells the server to include the article content in the response.
	IncludeContent bool
	// ExcludeContentless tells the server to exclude articles that have no content.
	ExcludeContentless bool
	// TotalLimit is the limit of the total number of the returned news.
	//
	// If it's non-zero, NoTotalLimit must be false, otherwise an error well be returned.
	// If it's zero then the NoTotalLimit parameter is considered: if NoTotalLimit is true,
	// then all the articles in the given start-end interval are returned.
	// If NoTotalLimit is false, then 50 articles will be returned.
	//
	// The reason for this complication is that the default (empty GetNewsParams) would
	// not return all the news articles.
	TotalLimit int
	// NoTotalLimit means all news articles will be returned from the given start-end interval.
	//
	// TotalLimit must be set to 0 if NoTotalLimit is true, otherwise an error well be returned.
	NoTotalLimit bool
	// PageLimit is the pagination size. If empty, the default page size will be used.
	PageLimit int
}

GetNewsParams contains optional parameters for getting news articles.

type GetQuotesParams

type GetQuotesParams struct {
	// 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 quotes.
	// If missing, all quotes 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.
	Feed string
	// AsOf defines the date when the symbols are mapped. "-" means no mapping.
	AsOf string
	// Currency is the currency of the displayed prices
	Currency string
}

GetQuotesParams contains optional parameters for getting quotes

type GetTradesParams

type GetTradesParams struct {
	// 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 trades.
	// If missing, all trades 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.
	Feed string
	// AsOf defines the date when the symbols are mapped. "-" means no mapping.
	AsOf string
	// Currency is the currency of the displayed prices
	Currency string
}

GetTradesParams contains optional parameters for getting trades.

type MultiBarItem

type MultiBarItem struct {
	Symbol string
	Bar    Bar
	Error  error
}

MultiBarItem contains a single bar for a symbol or an error

type MultiDailyAuctionsItem added in v2.8.0

type MultiDailyAuctionsItem struct {
	Symbol        string
	DailyAuctions DailyAuctions
	Error         error
}

MultiDailyAuctionsItem contains the daily auctions for a symbol in a single day or an error

type MultiQuoteItem

type MultiQuoteItem struct {
	Symbol string
	Quote  Quote
	Error  error
}

MultiQuoteItem contains a single quote for a symbol or an error

type MultiTradeItem

type MultiTradeItem struct {
	Symbol string
	Trade  Trade
	Error  error
}

MultiTradeItem contains a single trade for a symbol or an error

type News added in v2.2.0

type News struct {
	ID        int         `json:"id"`
	Author    string      `json:"author"`
	CreatedAt time.Time   `json:"created_at"`
	UpdatedAt time.Time   `json:"updated_at"`
	Headline  string      `json:"headline"`
	Summary   string      `json:"summary"`
	Content   string      `json:"content"`
	Images    []NewsImage `json:"images"`
	URL       string      `json:"url"`
	Symbols   []string    `json:"symbols"`
}

News is a single news article.

func GetNews added in v2.2.0

func GetNews(params GetNewsParams) ([]News, error)

GetNews returns the news articles based on the given params.

type NewsImage added in v2.2.0

type NewsImage struct {
	Size string `json:"size"`
	URL  string `json:"url"`
}

NewsImage is a single image for a news article.

type Quote

type Quote struct {
	Timestamp   time.Time `json:"t"`
	BidPrice    float64   `json:"bp"`
	BidSize     uint32    `json:"bs"`
	BidExchange string    `json:"bx"`
	AskPrice    float64   `json:"ap"`
	AskSize     uint32    `json:"as"`
	AskExchange string    `json:"ax"`
	Conditions  []string  `json:"c"`
	Tape        string    `json:"z"`
}

Quote is a stock quote from the market

func GetLatestQuote

func GetLatestQuote(symbol string) (*Quote, error)

GetLatestQuote returns the latest quote for a given symbol.

func GetQuotes

func GetQuotes(symbol string, params GetQuotesParams) ([]Quote, error)

GetQuotes returns the quotes for the given symbol. It blocks until all the quotes are collected. If you want to process the incoming quotes instantly, use GetQuotesAsync instead!

type QuoteItem

type QuoteItem struct {
	Quote Quote
	Error error
}

QuoteItem contains a single quote or an error

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

func GetSnapshot

func GetSnapshot(symbol string) (*Snapshot, error)

GetSnapshot returns the snapshot for a given symbol

type Sort added in v2.2.0

type Sort string

Sort represents the sort order of the results

var (
	// SortDesc means the results will be sorted in a descending order
	SortDesc Sort = "desc"
	// SortAsc means the results will be sorted in an ascending order
	SortAsc Sort = "asc"
)

List of sort values

type TimeFrame

type TimeFrame struct {
	N    int
	Unit TimeFrameUnit
}

TimeFrame is the resolution of the bars

func NewTimeFrame

func NewTimeFrame(n int, unit TimeFrameUnit) TimeFrame

func (TimeFrame) String

func (tf TimeFrame) String() string

type TimeFrameUnit

type TimeFrameUnit string

TimeFrameUnite is the base unit of the timeframe.

const (
	Min   TimeFrameUnit = "Min"
	Hour  TimeFrameUnit = "Hour"
	Day   TimeFrameUnit = "Day"
	Week  TimeFrameUnit = "Week"
	Month TimeFrameUnit = "Month"
)

List of timeframe units

type Trade

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

Trade is a stock trade that happened on the market

func GetLatestTrade

func GetLatestTrade(symbol string) (*Trade, error)

GetLatestTrade returns the latest trade for a given symbol.

func GetTrades

func GetTrades(symbol string, params GetTradesParams) ([]Trade, error)

GetTrades returns the trades for the given symbol. It blocks until all the trades are collected. If you want to process the incoming trades instantly, use GetTradesAsync instead!

type TradeItem

type TradeItem struct {
	Trade Trade
	Error error
}

TradeItem contains a single trade or an error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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