service

package
v0.0.0-...-ad4babd Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SpotLimiter    = rate.NewLimiter(20, 1200)
	FuturesLimiter = rate.NewLimiter(40, 2400)
)
View Source
var INTERVAL_2_DURATION = map[string]time.Duration{
	"1m":  1 * time.Minute,
	"3m":  3 * time.Minute,
	"5m":  5 * time.Minute,
	"15m": 15 * time.Minute,
	"30m": 30 * time.Minute,
	"1h":  1 * time.Hour,
	"2h":  2 * time.Hour,
	"4h":  4 * time.Hour,
	"6h":  6 * time.Hour,
	"8h":  8 * time.Hour,
	"12h": 12 * time.Hour,
	"1d":  1 * 24 * time.Hour,
	"3d":  3 * 24 * time.Hour,
	"1w":  7 * 24 * time.Hour,
	"1M":  31 * 24 * time.Hour,
}

Functions

func NewSymbolInterval

func NewSymbolInterval(class Class, symbol, interval string) *symbolInterval

func RateWait

func RateWait(ctx context.Context, class Class, method, path string, query url.Values)

Types

type BookTicker

type BookTicker struct {
	Symbol      string `json:"symbol"`
	BidPrice    string `json:"bidPrice"`
	BidQuantity string `json:"bidQty"`
	AskPrice    string `json:"askPrice"`
	AskQuantity string `json:"askQty"`
}

type Class

type Class string
var FUTURES Class = "FUTURES"
var SPOT Class = "SPOT"

type Depth

type Depth struct {
	LastUpdateID int64
	Time         int64
	TradeTime    int64
	Bids         []futures.Bid
	Asks         []futures.Ask
}

type DepthSrv

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

func NewDepthSrv

func NewDepthSrv(ctx context.Context, si *symbolInterval) *DepthSrv

func (*DepthSrv) GetDepth

func (s *DepthSrv) GetDepth() *Depth

func (*DepthSrv) Start

func (s *DepthSrv) Start()

func (*DepthSrv) Stop

func (s *DepthSrv) Stop()

type ExchangeInfoSrv

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

func NewExchangeInfoSrv

func NewExchangeInfoSrv(ctx context.Context, si *symbolInterval) *ExchangeInfoSrv

func (*ExchangeInfoSrv) GetExchangeInfo

func (s *ExchangeInfoSrv) GetExchangeInfo() []byte

func (*ExchangeInfoSrv) Start

func (s *ExchangeInfoSrv) Start()

func (*ExchangeInfoSrv) Stop

func (s *ExchangeInfoSrv) Stop()

Nothing to do

type Kline

type Kline struct {
	OpenTime                 int64
	Open                     string
	High                     string
	Low                      string
	Close                    string
	Volume                   string
	CloseTime                int64
	QuoteAssetVolume         string
	TradeNum                 int64
	TakerBuyBaseAssetVolume  string
	TakerBuyQuoteAssetVolume string
}

type KlinesSrv

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

func NewKlinesSrv

func NewKlinesSrv(ctx context.Context, si *symbolInterval) *KlinesSrv

func (*KlinesSrv) GetKlines

func (s *KlinesSrv) GetKlines() []*Kline

func (*KlinesSrv) Start

func (s *KlinesSrv) Start()

func (*KlinesSrv) Stop

func (s *KlinesSrv) Stop()

type Service

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

func NewService

func NewService(ctx context.Context, class Class) *Service

func (*Service) Depth

func (s *Service) Depth(symbol string) *Depth

func (*Service) ExchangeInfo

func (s *Service) ExchangeInfo() []byte

func (*Service) Klines

func (s *Service) Klines(symbol, interval string) []*Kline

func (*Service) Ticker

func (s *Service) Ticker(symbol string) *Ticker24hr

type Ticker24hr

type Ticker24hr struct {
	Symbol             string `json:"symbol"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	WeightedAvgPrice   string `json:"weightedAvgPrice"`
	PrevClosePrice     string `json:"prevClosePrice"`
	LastPrice          string `json:"lastPrice"`
	LastQty            string `json:"lastQty"`
	BidPrice           string `json:"bidPrice"`
	AskPrice           string `json:"askPrice"`
	OpenPrice          string `json:"openPrice"`
	HighPrice          string `json:"highPrice"`
	LowPrice           string `json:"lowPrice"`
	Volume             string `json:"volume"`
	QuoteVolume        string `json:"quoteVolume"`
	OpenTime           int64  `json:"openTime"`
	CloseTime          int64  `json:"closeTime"`
	FirstID            int64  `json:"firstId"`
	LastID             int64  `json:"lastId"`
	Count              int64  `json:"count"`
}

type TickerSrv

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

func NewTickerSrv

func NewTickerSrv(ctx context.Context, si *symbolInterval) *TickerSrv

func (*TickerSrv) GetTicker

func (s *TickerSrv) GetTicker() *Ticker24hr

func (*TickerSrv) Start

func (s *TickerSrv) Start()

func (*TickerSrv) Stop

func (s *TickerSrv) Stop()

Jump to

Keyboard shortcuts

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