order

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 order provides middleware utilities around orders. It wraps calls to the database and to the binance endpoints.

Index

Constants

This section is empty.

Variables

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

Set of error variables for CRUD operations.

Functions

This section is empty.

Types

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, brk broker.Broker) Core

NewCore constructs a core for user api access.

func (Core) Create

func (c Core) Create(ctx context.Context, nOdr NewOrder, now time.Time) (Order, error)

Create inserts a new order into the database.

func (Core) Query

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

Query gets the specified orders.

func (Core) QueryByID

func (c Core) QueryByID(ctx context.Context, odrID string) (Order, error)

QueryByID gets the specified order from the database.

func (Core) QueryByUser

func (c Core) QueryByUser(ctx context.Context, pageNumber int, rowsPerPage int, usrID string) ([]Order, error)

QueryByUser gets the specified orders from the database given a userId.

type NewOrder

type NewOrder struct {
	PositionID string  `json:"position_id" validate:"required"`
	SymbolID   string  `json:"-"`
	Symbol     string  `json:"-"`
	Quantity   float64 `json:"quantity" validate:"required"`
	Side       string  `json:"side" validate:"required"`
}

NewOrder contains information needed to create a new Order.

type Order

type Order struct {
	ID           string    `json:"order_id"`
	SymbolID     string    `json:"symbol_id"`
	PositionID   string    `json:"position_id"`
	CreationTime time.Time `json:"creation_time"`
	Price        float64   `json:"price"`
	Quantity     float64   `json:"quantity"`
	Status       string    `json:"status"`
	Type         string    `json:"type"`
	Side         string    `json:"side"`
}

Order represents an individual order

Directories

Path Synopsis
Package binance manages orders using the binance api
Package binance manages orders using the binance api
Package db contains order related CRUD functionality.
Package db contains order related CRUD functionality.

Jump to

Keyboard shortcuts

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