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

Documentation

Overview

Package db contains symbol 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, sbl Symbol) error

Create inserts a new symbol into the database.

func (Agent) Query

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

Query retrieves a list of existing candles from the database.

func (Agent) QueryByID

func (s Agent) QueryByID(ctx context.Context, sblID string) (Symbol, error)

QueryByID gets the specified symbol from the database.

func (Agent) QueryBySymbol

func (s Agent) QueryBySymbol(ctx context.Context, sSbl string) (Symbol, error)

QueryBySymbol gets the specified symbols 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 Symbol

type Symbol struct {
	ID                         string `db:"symbol_id"`
	Symbol                     string `db:"symbol"`
	Status                     string `db:"status"`
	BaseAsset                  string `db:"base_asset"`
	BaseAssetPrecision         int    `db:"base_asset_precision"`
	QuoteAsset                 string `db:"quote_asset"`
	QuotePrecision             int    `db:"quote_precision"`
	BaseCommissionPrecision    int    `db:"base_commission_precision"`
	QuoteCommissionPrecision   int    `db:"quote_commission_precision"`
	IcebergAllowed             bool   `db:"iceberg_allowed"`
	OcoAllowed                 bool   `db:"oco_allowed"`
	QuoteOrderQtyMarketAllowed bool   `db:"quote_order_qty_market_allowed"`
	IsSpotTradingAllowed       bool   `db:"is_spot_trading_allowed"`
	IsMarginTradingAllowed     bool   `db:"is_margin_trading_allowed"`
}

Symbol is a function whereby you have two different currencies that can be traded between one another. When buying and selling a cryptocurrency, it is often swapped with local currency. For example, If you're looking to buy or sell Bitcoin with U.S. Dollar, the trading pair would be BTC to USD

Jump to

Keyboard shortcuts

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