validator

package
v0.0.0-...-4f8b792 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNegativePrice  = errors.New("price cannot be negative")
	ErrNegativeVolume = errors.New("volume cannot be negative")
	ErrInvalidOHLC    = errors.New("high must be >= open, close and >= low")
)

Functions

func CheckGaps

func CheckGaps(series []data.OHLCV, expectedIntervalMs int64) []int

CheckGaps checks for timestamp gaps in ms based on timeframe duration in ms

func DetectOutliers

func DetectOutliers(series []data.OHLCV, thresholdPct float64) []int

DetectOutliers checks for sudden abnormal price movement (e.g. > threshold % in 1 bar)

func GenerateTestFile

func GenerateTestFile(info *StrategyInfo) string

GenerateTestFile generates a test file template for a strategy

func ValidateOHLCV

func ValidateOHLCV(bar data.OHLCV) error

Types

type StrategyInfo

type StrategyInfo struct {
	PackageName  string
	StrategyName string
	Filename     string
}

StrategyInfo holds information about a strategy for test generation

func ExtractStrategyInfo

func ExtractStrategyInfo(filename string, src []byte) (*StrategyInfo, error)

ExtractStrategyInfo extracts strategy information from source code

type ValidationError

type ValidationError struct {
	Pos     token.Position
	Message string
	Rule    string
}

ValidationError represents a code validation error

func ValidateStrategy

func ValidateStrategy(filename string, src []byte) ([]ValidationError, error)

ValidateStrategy is a convenience function for validating strategy code

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Validator

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

Validator validates Go source code for strategy safety

func NewValidator

func NewValidator() *Validator

NewValidator creates a new code validator

func (*Validator) GetErrors

func (v *Validator) GetErrors() []ValidationError

GetErrors returns all validation errors

func (*Validator) ValidateFile

func (v *Validator) ValidateFile(filename string, src []byte) error

ValidateFile validates a Go source file

Jump to

Keyboard shortcuts

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