Documentation ¶
Index ¶
- Variables
- func ByFigi(figi string) pb.InstrumentRequest
- func ByPositionUid(positionUid string) pb.InstrumentRequest
- func ByTicker(ticker string, classCode string) pb.InstrumentRequest
- func ByUid(uid string) pb.InstrumentRequest
- func FloatToQuotation(f float64) *pb.Quotation
- func QuotationToFloat(q *pb.Quotation) float64
- type CandleSubscription
- type Client
- func (c *Client) AllShares(ctx context.Context) ([]*pb.Share, error)
- func (c *Client) Close() error
- func (c *Client) DownloadHistoryData(ctx context.Context, figi string, year int) ([]*pb.HistoricCandle, error)
- func (c *Client) GetCandles(ctx context.Context, uid string, from time.Time, to time.Time, ...) ([]*pb.HistoricCandle, error)
- func (c *Client) NewMarketDataStream(ctx context.Context, logger Logger) (*MarketDataStream, error)
- func (c *Client) ShareBy(ctx context.Context, request *pb.InstrumentRequest) (*pb.Share, error)
- func (c *Client) Shares(ctx context.Context, status pb.InstrumentStatus, ...) ([]*pb.Share, error)
- type Logger
- type MarketDataStream
- type NoopLogger
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ByFigi ¶
func ByFigi(figi string) pb.InstrumentRequest
func ByPositionUid ¶
func ByPositionUid(positionUid string) pb.InstrumentRequest
func ByUid ¶
func ByUid(uid string) pb.InstrumentRequest
func FloatToQuotation ¶
FloatToQuotation converts float64 to Quotation type with proper scaling
func QuotationToFloat ¶
QuotationToFloat converts Quotation type to float64 with proper scaling
Types ¶
type CandleSubscription ¶
type CandleSubscription struct { // InstrumentId stores unique instrument id that is used in candleSubscriptions as key InstrumentId string // contains filtered or unexported fields }
CandleSubscription represents handler for candles stream.
func (*CandleSubscription) Recv ¶
func (cs *CandleSubscription) Recv() <-chan *pb.Candle
Recv returns read only channel with candles market data
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates SDK client that will be used for all communications with investapi
By default it configures default TLS transport credentials and oauth2.StaticTokenSource for PerRPCCredentials
func (*Client) DownloadHistoryData ¶
func (c *Client) DownloadHistoryData(ctx context.Context, figi string, year int) ([]*pb.HistoricCandle, error)
DownloadHistoryData downloads zip file with all 1-minute candles from history-data endpoint and returns it as slice of protobufs in investapi format.
func (*Client) GetCandles ¶
func (c *Client) GetCandles(ctx context.Context, uid string, from time.Time, to time.Time, interval pb.CandleInterval) ([]*pb.HistoricCandle, error)
GetCandles splits interval into day chunks and loads HistoricCandle for it.
func (*Client) NewMarketDataStream ¶
NewMarketDataStream returns a new MarketDataStream to create subscriptions.
type Logger ¶
type Logger interface { Debug(msg string, keyvals ...interface{}) Info(msg string, keyvals ...interface{}) Warn(msg string, keyvals ...interface{}) Error(msg string, keyvals ...interface{}) }
Logger interface for structural logging
type MarketDataStream ¶
type MarketDataStream struct {
// contains filtered or unexported fields
}
MarketDataStream provides interface for managing subscriptions through one stream instance. Channels with data will receive market data from single underlying stream. Subscription will be automatically cancelled when no more channels are listening for it.
func (*MarketDataStream) Close ¶
func (m *MarketDataStream) Close()
Close cancels the MarketDataStream context, which will stop listening on stream
func (*MarketDataStream) SubscribeCandle ¶
func (m *MarketDataStream) SubscribeCandle(id string, waitingClose bool) (*CandleSubscription, error)
SubscribeCandle creates subscriptions for candle with specified id. If subscription already exists – only new channel will be created.
func (*MarketDataStream) UnsubscribeCandle ¶
func (m *MarketDataStream) UnsubscribeCandle(s *CandleSubscription) error
UnsubscribeCandle closes CandleSubscription and removes subscription from subscriptions map. If no more subscription are present with same id – subscription will be cancelled.
type NoopLogger ¶
type NoopLogger struct{}
NoopLogger implements Logger interface but does nothing
func (NoopLogger) Debug ¶
func (NoopLogger) Debug(msg string, keyvals ...interface{})
func (NoopLogger) Error ¶
func (NoopLogger) Error(msg string, keyvals ...interface{})
func (NoopLogger) Info ¶
func (NoopLogger) Info(msg string, keyvals ...interface{})
func (NoopLogger) Warn ¶
func (NoopLogger) Warn(msg string, keyvals ...interface{})