tinkoff

package module
v0.0.0-...-eeee698 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: MIT Imports: 8 Imported by: 0

README

tinkoff-quotes

tinkoff investments quotes stream

package main

import ( "log" "os" "time"

"github.com/alexeykaravan/tinkoff-quotes"

)

func main() { quotesChanal := make(chan tinkoff.Quote, 1024)

t := tinkoff.New("")

curr, err := t.GetStocks()
if err != nil {
	log.Fatal(err)
}

go func() {
	timer := time.NewTicker(5 * time.Second)

	err := t.SubscribeForQuotes(curr, quotesChanal)
	if err != nil {
		log.Println(err)
	}

	<-timer.C
}()

for quote := range quotesChanal {
	log.Println(quote)
}

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

type Instrument

type Instrument struct {
	Figi              string  `json:"figi"`
	Ticker            string  `json:"ticker"`
	MinPriceIncrement float64 `json:"minPriceIncrement"`
	Lot               int     `json:"lot"`
	Currency          string  `json:"currency"`
	Name              string  `json:"name"`
	Type              string  `json:"type"`
}

Instruments ...

type Message

type Message struct {
	TrackingID string  `json:"trackingId"`
	Payload    Payload `json:"payload"`
	Status     string  `json:"status"`
}

Message ...

type OrderBook

type OrderBook struct {
	FIGI  string          `json:"figi"`
	Depth int             `json:"depth"`
	Bids  []PriceQuantity `json:"bids"`
	Asks  []PriceQuantity `json:"asks"`
}

type Payload

type Payload struct {
	Instruments []Instrument `json:"instruments"`
	Total       int          `json:"total"`
}

Payload ...

type PriceQuantity

type PriceQuantity [2]float64

type Quote

type Quote struct {
	Symbol string
	Bid    float64
	Ask    float64
	Time   time.Time
}

Quote ...

type Symbol

type Symbol struct {
	Name string
	Type string
	Figi string
}

Symbol ...

type Tinkoff

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

Tinkoff ...

func New

func New(key string) *Tinkoff

New ...

func (*Tinkoff) GetBonds

func (t *Tinkoff) GetBonds() ([]Instrument, error)

GetBonds ...

func (*Tinkoff) GetCurrencies

func (t *Tinkoff) GetCurrencies() ([]Instrument, error)

GetCurrencies ...

func (*Tinkoff) GetEtfs

func (t *Tinkoff) GetEtfs() ([]Instrument, error)

GetEtfs ...

func (*Tinkoff) GetStocks

func (t *Tinkoff) GetStocks() ([]Instrument, error)

GetStocks ...

func (*Tinkoff) SubscribeForQuotes

func (t *Tinkoff) SubscribeForQuotes(instruments []Instrument, ch chan<- Quote) error

SubscribeForQuotes ...

Jump to

Keyboard shortcuts

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