Documentation
¶
Overview ¶
Package db contains position related CRUD functionality.
Index ¶
- type Agent
- func (s Agent) Create(ctx context.Context, pos Position) error
- func (s Agent) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Position, error)
- func (s Agent) QueryByID(ctx context.Context, posID string) (Position, error)
- func (s Agent) QueryByUser(ctx context.Context, pageNumber int, rowsPerPage int, usrID string) ([]Position, error)
- func (s Agent) Tran(tx sqlx.ExtContext) Agent
- func (s Agent) Update(ctx context.Context, pos Position) error
- func (s Agent) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
- type Position
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) QueryByUser ¶
func (s Agent) QueryByUser(ctx context.Context, pageNumber int, rowsPerPage int, usrID string) ([]Position, error)
QueryByUser 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) Update ¶
Update modifies data about a Position. It will error if the specified ID is invalid or does not reference an existing Position. When updating a position, it only makes sense to change its status from open to closed.
func (Agent) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.
type Position ¶
type Position struct { ID string `db:"position_id"` // Position ID SymbolID string `db:"symbol_id"` // Symbol this position is trading on UserID string `db:"user_id"` // User who created this position Side string `db:"side"` // Position side: SELL / BUY Status string `db:"status"` // Status open / closed CreationTime time.Time `db:"creation_time"` // CreationTime of the position User string `db:"user"` Symbol string `db:"symbol"` Orders string `db:"orders"` }
Position is the amount of a security, asset, or property that is owned (or sold short) by some individual or other entity. A trader or investor takes a position when they make a purchase through