runtime

package module
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: MIT Imports: 7 Imported by: 16

README

runtime

Cryptellation RunTime Library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyWorkflowName is returned when the workflow name is empty.
	ErrEmptyWorkflowName = errors.New("workflow name is empty")
	// ErrEmptyTaskQueueName is returned when the task queue name is empty.
	ErrEmptyTaskQueueName = errors.New("task queue name is empty")
)
View Source
var (
	// ErrInvalidMode is returned when the mode is invalid.
	ErrInvalidMode = errors.New("invalid mode")
)

Functions

func WithMode

func WithMode(ctx workflow.Context, mode Mode) workflow.Context

WithMode sets the mode in the context.

Types

type CallbackWorkflow added in v1.3.0

type CallbackWorkflow struct {
	Name             string
	TaskQueueName    string
	ExecutionTimeout time.Duration
}

CallbackWorkflow is the parameters of a callback workflow.

func (CallbackWorkflow) Validate added in v1.5.0

func (cw CallbackWorkflow) Validate() error

Validate validates the callback workflow.

type Callbacks added in v1.3.0

type Callbacks struct {
	OnInitCallback      CallbackWorkflow
	OnNewPricesCallback CallbackWorkflow
	OnExitCallback      CallbackWorkflow
}

Callbacks is the struct representing callbacks for ans automation through cryptellation API.

func RegisterRunnable added in v1.6.0

func RegisterRunnable(w worker.Worker, taskQueue string, r Runnable) Callbacks

RegisterRunnable registers a runnable to a worker and returns the callbacks.

func (Callbacks) Validate added in v1.5.0

func (c Callbacks) Validate() error

Validate validates the callbacks.

type Context

type Context struct {
	// ID is the ID of the run that corresponds to a backtest, a forwardtest or a live run.
	ID uuid.UUID
	// Mode is the mode of the run (backtests, forwardtest or live run).
	Mode Mode
	// Now is the time of the run.
	// It is used to simulate the time of the run for backtests.
	// On forwardtests and live runs, it is the current time.
	Now time.Time
	// ParentTaskQueue is the task queue of the parent workflow.
	// It's the one that called the callback.
	ParentTaskQueue string
}

Context is the context of a run that contains several information about the run.

type Mode

type Mode string

Mode is the mode in which a run is executed.

const (
	// ModeBacktest is the backtest mode.
	ModeBacktest Mode = "backtest"
	// ModeForwardtest is the forwardtest mode.
	ModeForwardtest Mode = "forwardtest"
	// ModeLive is the live mode.
	ModeLive Mode = "live"
)

func GetMode

func GetMode(ctx workflow.Context) Mode

GetMode returns the mode from the context.

func (Mode) String

func (m Mode) String() string

String returns the string representation of the mode.

func (Mode) Validate

func (m Mode) Validate() error

Validate validates the mode.

type OnExitCallbackWorkflowParams added in v1.3.0

type OnExitCallbackWorkflowParams struct {
	Context Context
}

OnExitCallbackWorkflowParams is the parameters of the OnExitCallbackWorkflow callback workflow.

type OnInitCallbackWorkflowParams added in v1.3.0

type OnInitCallbackWorkflowParams struct {
	Context Context
}

OnInitCallbackWorkflowParams is the parameters of the OnInitCallbackWorkflow callback workflow.

type OnNewPricesCallbackWorkflowParams added in v1.3.0

type OnNewPricesCallbackWorkflowParams struct {
	Context Context
	Ticks   []tick.Tick
}

OnNewPricesCallbackWorkflowParams is the parameters of the OnNewPricesCallbackWorkflow callback workflow.

type Runnable added in v1.6.0

type Runnable interface {
	Name() string
	OnInit(ctx workflow.Context, params OnInitCallbackWorkflowParams) error
	OnNewPrices(ctx workflow.Context, params OnNewPricesCallbackWorkflowParams) error
	OnExit(ctx workflow.Context, params OnExitCallbackWorkflowParams) error
}

Runnable is the interface for a struct that can be run on Cryptellation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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