db

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: 6 Imported by: 0

Documentation

Overview

Package db contains candle related CRUD functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

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

func NewAgent

func NewAgent(log *zap.SugaredLogger, db *sqlx.DB) Agent

NewAgent constructs a data for api access.

func (Agent) Create

func (s Agent) Create(ctx context.Context, cdl Candle) error

Create inserts a new candle into the database.

func (Agent) Query

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

Query retrieves a list of existing candles from the database.

func (Agent) QueryByID

func (s Agent) QueryByID(ctx context.Context, cdlID string) (Candle, error)

QueryByID gets the specified candle from the database.

func (Agent) QueryBySymbolAndInterval

func (s Agent) QueryBySymbolAndInterval(ctx context.Context, pageNumber int, rowsPerPage int, smbID string, itv string) ([]Candle, error)

QueryBySymbolAndInterval gets the specified candles from the database.

func (Agent) Tran

func (s Agent) Tran(tx sqlx.ExtContext) Agent

Tran return new Agent with transaction in it.

func (Agent) WithinTran

func (s Agent) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error

WithinTran runs passed function and do commit/rollback at the end.

type Candle

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

Candle is a type of price chart used in technical analysis that displays the high, low, open, and closing prices of a security for a specific period

Jump to

Keyboard shortcuts

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