backtest

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTickSubscriptionAlreadyExists = errors.New("tick subscription already exists")
	ErrInvalidExchange               = errors.New("invalid exchange")
	ErrNoDataForOrderValidation      = errors.New("no data for order validation")
	ErrStartAfterEnd                 = errors.New("start after end")
	ErrInvalidPricePeriod            = errors.New("invalid price period")
)
View Source
var (
	ErrInvalidMode = errors.New("invalid mode")
)

Functions

This section is empty.

Types

type Backtest

type Backtest struct {
	ID                  uuid.UUID                  `json:"id"`
	Parameters          Parameters                 `json:"parameters"`
	CurrentCandlestick  CurrentCandlestick         `json:"current_candlestick"`
	Accounts            map[string]account.Account `json:"accounts"`
	PricesSubscriptions []event.PricesSubscription `json:"prices_subscriptions"`
	Orders              []order.Order              `json:"orders"`
}

func New

func New(payload NewPayload) (Backtest, error)

func (*Backtest) AddOrder

func (bt *Backtest) AddOrder(ord order.Order, cs candlestick.Candlestick) error

func (*Backtest) Advance

func (bt *Backtest) Advance() (done bool, err error)

func (*Backtest) CreateTickSubscription

func (bt *Backtest) CreateTickSubscription(exchange string, pair string) (event.PricesSubscription, error)

func (Backtest) CurrentTime

func (bt Backtest) CurrentTime() string

func (Backtest) Done

func (bt Backtest) Done() bool

func (Backtest) MarshalBinary

func (bt Backtest) MarshalBinary() ([]byte, error)

func (*Backtest) SetCurrentTime

func (bt *Backtest) SetCurrentTime(ts time.Time)

func (*Backtest) UnmarshalBinary

func (bt *Backtest) UnmarshalBinary(data []byte) error

type CurrentCandlestick

type CurrentCandlestick struct {
	Time  time.Time
	Price candlestick.Price
}

Current candlestick based on candlestick step

type Mode

type Mode string
const (
	ModeIsFullOHLC  Mode = "full_ohlc"
	ModeIsCloseOHLC Mode = "close_ohlc"
)

func (Mode) Opt

func (m Mode) Opt() *Mode

func (Mode) String

func (m Mode) String() string

func (Mode) Validate

func (m Mode) Validate() error

type NewPayload

type NewPayload struct {
	Accounts  map[string]account.Account
	StartTime time.Time
	EndTime   *time.Time

	Mode        *Mode
	PricePeriod *period.Symbol
}

func (*NewPayload) EmptyFieldsToDefault

func (payload *NewPayload) EmptyFieldsToDefault() *NewPayload

func (NewPayload) Validate

func (payload NewPayload) Validate() error

type Parameters

type Parameters struct {
	StartTime   time.Time     `json:"start_time"`
	EndTime     time.Time     `json:"end_time"`
	Mode        Mode          `json:"mode"`
	PricePeriod period.Symbol `json:"price_period"`
}

Jump to

Keyboard shortcuts

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