Documentation ¶
Overview ¶
Package db contains order related CRUD functionality.
Index ¶
- type Agent
- func (s Agent) Create(ctx context.Context, odr Order) error
- func (s Agent) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Order, error)
- func (s Agent) QueryByID(ctx context.Context, odrID string) (Order, error)
- func (s Agent) QueryByPosition(ctx context.Context, odrID string) ([]Order, error)
- func (s Agent) QueryByUser(ctx context.Context, pageNumber int, rowsPerPage int, usrID string) ([]Order, error)
- func (s Agent) Tran(tx sqlx.ExtContext) Agent
- func (s Agent) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
- type Order
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 order access.
func NewAgent ¶
func NewAgent(log *zap.SugaredLogger, db *sqlx.DB) Agent
NewAgent constructs a data for api access.
func (Agent) QueryByPosition ¶
QueryByPosition retrieves all order for a given position.
func (Agent) QueryByUser ¶
func (s Agent) QueryByUser(ctx context.Context, pageNumber int, rowsPerPage int, usrID string) ([]Order, error)
QueryByUser gets the specified order from the database.
func (Agent) Tran ¶
func (s Agent) Tran(tx sqlx.ExtContext) Agent
Tran return new Store with transaction in it.
func (Agent) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.
type Order ¶
type Order struct { ID string `db:"order_id"` // Order ID SymbolID string `db:"symbol_id"` // SymbolID ID, this orders trades on PositionID string `db:"position_id"` // Order ID this order belongs to CreationTime time.Time `db:"creation_time"` // Order creation time Price float64 `db:"price"` // Price of the base asset Quantity float64 `db:"quantity"` // Amount of the base asset Status string `db:"status"` // Status received from binance: FILLED, NEW, CANCELED Type string `db:"type"` // For the moment only MARKET is supported Side string `db:"side"` // Either SELL or BUY }
Order defines a trading order
Click to show internal directories.
Click to hide internal directories.