ticker

package
v0.0.0-...-81ab215 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProcessTicker

func ProcessTicker(tickerNew *Price) error

ProcessTicker processes incoming tickers, creating or updating the Tickers list

func SubscribeTicker

func SubscribeTicker(exchange string, p currency.Pair, a asset.Item) (dispatch.Pipe, error)

SubscribeTicker subcribes to a ticker and returns a communication channel to stream new ticker updates

func SubscribeToExchangeTickers

func SubscribeToExchangeTickers(exchange string) (dispatch.Pipe, error)

SubscribeToExchangeTickers subcribes to all tickers on an exchange

Types

type Price

type Price struct {
	Last         float64       `json:"Last"`
	High         float64       `json:"High"`
	Low          float64       `json:"Low"`
	Bid          float64       `json:"Bid"`
	Ask          float64       `json:"Ask"`
	Volume       float64       `json:"Volume"`
	QuoteVolume  float64       `json:"QuoteVolume"`
	PriceATH     float64       `json:"PriceATH"`
	Open         float64       `json:"Open"`
	Close        float64       `json:"Close"`
	Pair         currency.Pair `json:"Pair"`
	ExchangeName string        `json:"exchangeName"`
	AssetType    asset.Item    `json:"assetType"`
	LastUpdated  time.Time

	// Funding rate field variables
	FlashReturnRate       float64
	BidPeriod             float64
	BidSize               float64
	AskPeriod             float64
	AskSize               float64
	FlashReturnRateAmount float64
}

Price struct stores the currency pair and pricing information

func GetTicker

func GetTicker(exchange string, p currency.Pair, tickerType asset.Item) (*Price, error)

GetTicker checks and returns a requested ticker if it exists

type Service

type Service struct {
	Tickers  map[string]map[*currency.Item]map[*currency.Item]map[asset.Item]*Ticker
	Exchange map[string]uuid.UUID

	sync.RWMutex
	// contains filtered or unexported fields
}

Service holds ticker information for each individual exchange

func (*Service) GetAssociations

func (s *Service) GetAssociations(p *Price, fmtName string) ([]uuid.UUID, error)

GetAssociations links a singular book with it's dispatch associations

func (*Service) SetItemID

func (s *Service) SetItemID(p *Price, fmtName string) error

SetItemID retrieves and sets dispatch mux publish IDs

func (*Service) Update

func (s *Service) Update(p *Price) error

Update updates ticker price

type Ticker

type Ticker struct {
	Price
	Main  uuid.UUID
	Assoc []uuid.UUID
}

Ticker struct holds the ticker information for a currency pair and type

Jump to

Keyboard shortcuts

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