twap

package
v0.0.0-...-a5f00ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2023 License: ISC Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeTwap  = "twap"
	TypeOrder = "order"
)

Variables

This section is empty.

Functions

func AverageSizeFillPerMinute

func AverageSizeFillPerMinute(start time.Time, end time.Time, amount decimal.Decimal) decimal.Decimal

AverageSizeFillPerMinute returns the average size of the order that has to be filled per second to reach the target amount

func Execute

func Execute(t Payload)

Execute executes the TWAP algorithm We can improve the algorithm by using a queue of orders and processing them in a separate goroutine TODO

func HandleOrderTask

func HandleOrderTask(ctx context.Context, task *asynq.Task) error

func HandleTwapTask

func HandleTwapTask(ctx context.Context, t *asynq.Task) error

HandleTwapTask handles a task for TWAP algorithm.

func NewOrderTask

func NewOrderTask(order *order.Submit) (*asynq.Task, error)

func NewTwapTask

func NewTwapTask(twap Payload) (*asynq.Task, error)

NewTwapTask represents a task for TWAP algorithm.

Types

type Payload

type Payload struct {
	Exchange          string
	AccountID         string
	Pair              currency.Pair
	Asset             asset.Item // SPOT, FUTURES, INDEX
	Start             time.Time
	End               time.Time
	TargetAmountQuote float64
	Side              order.Side
	OrderType         order.Type
	Status            string
}

Payload is the payload for the TWAP algorithm

Jump to

Keyboard shortcuts

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