blocks

package
v0.0.0-...-bbd37fe Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None ConstraintType = iota
	Less
	LessEqual
	Greater
	GreaterEqual
	RangeIncl
	RangeExcl
	OneOf

	StrNone         = "none"
	StrLess         = "less"
	StrLessEqual    = "lessEqal"
	StrGreater      = "greater"
	StrGreaterEqual = "greaterEqual"
	StrRangeIncl    = "rangeIncl"
	StrRangeExcl    = "rangeExcl"
	StrOneOf        = "oneOf"
)
View Source
const (
	NameIn     = "in"
	NameK      = "k"
	NameLength = "length"
	NameOut    = "out"
	NamePeriod = "period"
	NameTrend  = "trend"
)
View Source
const (
	SchemaPeriod = `{
		"type": "integer",
		"minimum": 1,
		"maximum": 1000,
	}`
)
View Source
const (
	TypeFloat64 = "float64"
)

Variables

This section is empty.

Functions

func ClearOutputs

func ClearOutputs(blk Block)

Types

type Block

type Block interface {
	GetType() string
	GetDescription() string
	GetParams() Params
	GetInputs() Inputs
	GetOutputs() Outputs
	GetWarmupPeriod() int

	IsWarm() bool

	Init() error
	Update(current *models.Bar, isLast bool)
}

type Constraint

type Constraint interface {
	GetType() ConstraintType
	GetLimits() []any
}

type ConstraintType

type ConstraintType int

func (ConstraintType) String

func (t ConstraintType) String() string

type FloatParam

type FloatParam struct {
	// contains filtered or unexported fields
}

func NewFloatParam

func NewFloatParam(defaultVal float64, constr *TypedConstraint[float64]) *FloatParam

func (FloatParam) GetConstraint

func (p FloatParam) GetConstraint() Constraint

func (FloatParam) GetCurrentVal

func (p FloatParam) GetCurrentVal() any

func (FloatParam) GetDefaultVal

func (p FloatParam) GetDefaultVal() any

func (FloatParam) GetValueType

func (p FloatParam) GetValueType() string

func (FloatParam) SetCurrentVal

func (p FloatParam) SetCurrentVal(val any) error

type Input

type Input interface {
	GetType() string

	IsAsynchronous() bool
	IsConnected() bool
	IsOptional() bool
	IsValueSet() bool

	Connect(Output) error
}

type Inputs

type Inputs map[string]Input

type IntParam

type IntParam struct {
	// contains filtered or unexported fields
}

func NewIntParam

func NewIntParam(defaultVal int, constr *TypedConstraint[int]) *IntParam

func (IntParam) GetConstraint

func (p IntParam) GetConstraint() Constraint

func (IntParam) GetCurrentVal

func (p IntParam) GetCurrentVal() any

func (IntParam) GetDefaultVal

func (p IntParam) GetDefaultVal() any

func (IntParam) GetValueType

func (p IntParam) GetValueType() string

func (*IntParam) SetCurrentVal

func (p *IntParam) SetCurrentVal(val any) error

type Output

type Output interface {
	GetType() string
	GetConnected() []Input

	IsAsynchronous() bool
	IsConnected() bool
	ClearValue()
	IsValueSet() bool

	Connect(Input) error
	DisconnectAll()
}

type Outputs

type Outputs map[string]Output

type Param

type Param interface {
	GetValueType() string
	GetDefaultVal() any
	GetConstraint() Constraint
	GetCurrentVal() any
	SetCurrentVal(any) error
}

type ParamVals

type ParamVals map[string]any

type Params

type Params map[string]Param

func (Params) GetNonDefaultValues

func (ps Params) GetNonDefaultValues() ParamVals

func (Params) GetSortedNames

func (ps Params) GetSortedNames() []string

func (Params) SetValuesOrDefault

func (ps Params) SetValuesOrDefault(vals ParamVals) error

type Recorder

type Recorder interface {
	Init(valNames []string) error
	Process(map[string]models.TimeValue[float64])
}

type TypedConstraint

type TypedConstraint[T goconstraints.Ordered] struct {
	Type   ConstraintType
	Limits []T
}

func NewGreater

func NewGreater[T goconstraints.Ordered](val T) *TypedConstraint[T]

func NewGreaterEqual

func NewGreaterEqual[T goconstraints.Ordered](val T) *TypedConstraint[T]

func NewLess

func NewLess[T goconstraints.Ordered](val T) *TypedConstraint[T]

func NewLessEqual

func NewLessEqual[T goconstraints.Ordered](val T) *TypedConstraint[T]

func NewNone

func NewNone[T goconstraints.Ordered]() *TypedConstraint[T]

func NewOneOf

func NewOneOf[T goconstraints.Ordered](vals []T) *TypedConstraint[T]

func NewRangeExcl

func NewRangeExcl[T goconstraints.Ordered](start, end T) *TypedConstraint[T]

func NewRangeIncl

func NewRangeIncl[T goconstraints.Ordered](start, end T) *TypedConstraint[T]

func (*TypedConstraint[T]) CheckVal

func (c *TypedConstraint[T]) CheckVal(val T) error

func (*TypedConstraint[T]) GetLimits

func (c *TypedConstraint[T]) GetLimits() []any

func (*TypedConstraint[T]) GetType

func (c *TypedConstraint[T]) GetType() ConstraintType

type TypedInput

type TypedInput[T any] struct {
	Type     string
	Optional bool
	// contains filtered or unexported fields
}

func NewTypedInput

func NewTypedInput[T any]() *TypedInput[T]

func NewTypedInputOptional

func NewTypedInputOptional[T any]() *TypedInput[T]

func (*TypedInput[T]) Connect

func (in *TypedInput[T]) Connect(o Output) error

func (*TypedInput[T]) GetType

func (in *TypedInput[T]) GetType() string

func (*TypedInput[T]) GetValue

func (in *TypedInput[T]) GetValue() T

func (*TypedInput[T]) IsAsynchronous

func (in *TypedInput[T]) IsAsynchronous() bool

func (*TypedInput[T]) IsConnected

func (in *TypedInput[T]) IsConnected() bool

func (*TypedInput[T]) IsOptional

func (in *TypedInput[T]) IsOptional() bool

func (*TypedInput[T]) IsValueSet

func (in *TypedInput[T]) IsValueSet() bool

type TypedInputAsync

type TypedInputAsync[T any] struct {
	Type     string
	Optional bool
	// contains filtered or unexported fields
}

func NewTypedInputAsync

func NewTypedInputAsync[T any]() *TypedInputAsync[T]

func NewTypedInputAsyncOptional

func NewTypedInputAsyncOptional[T any]() *TypedInputAsync[T]

func (*TypedInputAsync[T]) Connect

func (in *TypedInputAsync[T]) Connect(o Output) error

func (*TypedInputAsync[T]) GetTime

func (in *TypedInputAsync[T]) GetTime() time.Time

func (*TypedInputAsync[T]) GetType

func (in *TypedInputAsync[T]) GetType() string

func (*TypedInputAsync[T]) GetValue

func (in *TypedInputAsync[T]) GetValue() T

func (*TypedInputAsync[T]) IsAsynchronous

func (in *TypedInputAsync[T]) IsAsynchronous() bool

func (*TypedInputAsync[T]) IsConnected

func (in *TypedInputAsync[T]) IsConnected() bool

func (*TypedInputAsync[T]) IsOptional

func (in *TypedInputAsync[T]) IsOptional() bool

func (*TypedInputAsync[T]) IsValueSet

func (in *TypedInputAsync[T]) IsValueSet() bool

type TypedOutput

type TypedOutput[T any] struct {
	Type string

	Ins []*TypedInput[T]
	// contains filtered or unexported fields
}

func NewTypedOutput

func NewTypedOutput[T any]() *TypedOutput[T]

func (*TypedOutput[T]) ClearValue

func (out *TypedOutput[T]) ClearValue()

func (*TypedOutput[T]) Connect

func (out *TypedOutput[T]) Connect(i Input) error

func (*TypedOutput[T]) DisconnectAll

func (out *TypedOutput[T]) DisconnectAll()

func (*TypedOutput[T]) GetConnected

func (out *TypedOutput[T]) GetConnected() []Input

func (*TypedOutput[T]) GetType

func (out *TypedOutput[T]) GetType() string

func (*TypedOutput[T]) GetValue

func (out *TypedOutput[T]) GetValue() T

func (*TypedOutput[T]) IsAsynchronous

func (out *TypedOutput[T]) IsAsynchronous() bool

func (*TypedOutput[T]) IsConnected

func (out *TypedOutput[T]) IsConnected() bool

func (*TypedOutput[T]) IsValueSet

func (out *TypedOutput[T]) IsValueSet() bool

func (*TypedOutput[T]) SetIfConnected

func (out *TypedOutput[T]) SetIfConnected(calcVal func() T)

func (*TypedOutput[T]) SetValue

func (out *TypedOutput[T]) SetValue(val T)

type TypedOutputAsync

type TypedOutputAsync[T any] struct {
	Type string

	Ins []*TypedInputAsync[T]
	// contains filtered or unexported fields
}

func NewTypedOutputAsync

func NewTypedOutputAsync[T any]() *TypedOutputAsync[T]

func (*TypedOutputAsync[T]) ClearValue

func (out *TypedOutputAsync[T]) ClearValue()

func (*TypedOutputAsync[T]) Connect

func (out *TypedOutputAsync[T]) Connect(i Input) error

func (*TypedOutputAsync[T]) DisconnectAll

func (out *TypedOutputAsync[T]) DisconnectAll()

func (*TypedOutputAsync[T]) GetConnected

func (out *TypedOutputAsync[T]) GetConnected() []Input

func (*TypedOutputAsync[T]) GetType

func (out *TypedOutputAsync[T]) GetType() string

func (*TypedOutputAsync[T]) GetValue

func (out *TypedOutputAsync[T]) GetValue() T

func (*TypedOutputAsync[T]) IsAsynchronous

func (out *TypedOutputAsync[T]) IsAsynchronous() bool

func (*TypedOutputAsync[T]) IsConnected

func (out *TypedOutputAsync[T]) IsConnected() bool

func (*TypedOutputAsync[T]) IsValueSet

func (out *TypedOutputAsync[T]) IsValueSet() bool

func (*TypedOutputAsync[T]) SetIfConnected

func (out *TypedOutputAsync[T]) SetIfConnected(t time.Time, calcVal func() T)

func (*TypedOutputAsync[T]) SetTimeValue

func (out *TypedOutputAsync[T]) SetTimeValue(t time.Time, val T)

Directories

Path Synopsis
Package mock_blocks is a generated GoMock package.
Package mock_blocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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