candle

package
v0.0.0-...-c46be8d Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package candle provides middleware utilities around candles. It wraps calls to the database.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound              = errors.New("candle not found")
	ErrAuthenticationFailure = errors.New("authentication failed")
	ErrInvalidID             = errors.New("ID is not in its proper form")
	ErrInvalidCandle         = errors.New("candle is not valid")
)

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

type Candle

type Candle struct {
	ID         string    `json:"id"`
	SymbolID   string    `json:"symbol_id"`
	Symbol     string    `json:"symbol"`
	Interval   string    `json:"interval"`
	OpenTime   time.Time `json:"open_time"`
	OpenPrice  float64   `json:"open_price"`
	ClosePrice float64   `json:"close_price"`
	CloseTime  time.Time `json:"close_time"`
	Low        float64   `json:"low"`
	High       float64   `json:"high"`
	Volume     float64   `json:"volume"`
}

Candle represents an individual candle

type Core

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

Core manages the set of API's for candle access.

func NewCore

func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB, broker broker.Broker) Core

NewCore constructs a core for user api access.

func (Core) Create

func (c Core) Create(ctx context.Context, nCdl NewCandle) (Candle, error)

Create inserts a new candle into the database. The new candle is the last closed candle in binance for the given symbol / interval.

func (Core) Query

func (c Core) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Candle, error)

Query gets the specified candle from the database.

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, cdlID string) (Candle, error)

QueryByID gets the specified candle from the database.

func (Core) QueryBySymbolAndInterval

func (c Core) QueryBySymbolAndInterval(ctx context.Context, pageNumber int, rowsPerPage int, sblID string, cItv string) ([]Candle, error)

QueryBySymbolAndInterval gets the specified candle from the database.

func (Core) Seed

func (c Core) Seed(ctx context.Context, nCdl NewCandle, n int) error

Seed creates n candles for symbol and interval.

type NewCandle

type NewCandle struct {
	SymbolID string `json:"symbol_id" validate:"required"`
	Symbol   string `json:"symbol"`
	Interval string `json:"interval" validate:"required"`
}

Directories

Path Synopsis
Package binance manages candles using the binance api
Package binance manages candles using the binance api
Package db contains candle related CRUD functionality.
Package db contains candle related CRUD functionality.

Jump to

Keyboard shortcuts

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