graph

package
v0.0.0-...-5d55e2f Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigKeyName = "id"
View Source
const ConfigSchemaStr = `` /* 1732-byte string literal not displayed */

Variables

This section is empty.

Functions

func Backtest

func Backtest(
	ctx context.Context,
	graphConfig *Configuration,
	symbol string,
	testDate date.Date,
	loc *time.Location,
	loader models.DayBarsLoader,
	showWarmup bool,
	predictor *Address,
	threshold float64,
) (*models.TimeSeries, error)

func EvalSlope

func EvalSlope(
	ctx context.Context,
	graphConfig *Configuration,
	symbol string,
	evalDate date.Date,
	loc *time.Location,
	loader models.DayBarsLoader,
	showWarmup bool,
	source, predictor *Address,
	horizon int,
) (*models.TimeSeries, error)

func GetConfigSchema

func GetConfigSchema() *gojsonschema.Schema

func GetCoreHours

func GetCoreHours(d date.Date) timespan.TimeSpan

func MaxTotalWarmupPeriod

func MaxTotalWarmupPeriod(blks Blocks, g gr.Graph[string, string], order []string) (int, error)

func Run

func Run(
	ctx context.Context,
	cfg *Configuration,
	symbol string,
	ts timespan.TimeSpan,
	loc *time.Location,
	loader models.DayBarsLoader,
	showWarmup bool,
) (*models.TimeSeries, error)

func RunDay

func RunDay(
	ctx context.Context,
	cfg *Configuration,
	symbol string,
	d date.Date,
	loc *time.Location,
	loader models.DayBarsLoader,
	showWarmup bool,
) (*models.TimeSeries, error)

Types

type Address

type Address struct {
	A, B string
}

func NewAddress

func NewAddress(a, b string) *Address

func ParseAddress

func ParseAddress(s string) (*Address, error)

func (*Address) MarshalJSON

func (addr *Address) MarshalJSON() ([]byte, error)

func (*Address) Parse

func (addr *Address) Parse(s string) error

func (*Address) String

func (addr *Address) String() string

func (*Address) UnmarshalJSON

func (addr *Address) UnmarshalJSON(d []byte) error

type BlockConfig

type BlockConfig struct {
	Name      string         `json:"name"`
	Type      string         `json:"type"`
	ParamVals map[string]any `json:"paramVals"`
	Recording []string       `json:"recording"`
}

type Blocks

type Blocks map[string]blocks.Block

func (Blocks) Connect

func (blocks Blocks) Connect(
	conns []*Connection,
) (gr.Graph[string, string], error)

func (Blocks) FindInput

func (blocks Blocks) FindInput(addr *Address) (blocks.Input, bool)

func (Blocks) FindOutput

func (blocks Blocks) FindOutput(addr *Address) (blocks.Output, bool)

func (Blocks) FindParam

func (blocks Blocks) FindParam(addr *Address) (blocks.Param, bool)

func (Blocks) Init

func (blocks Blocks) Init() error

type Configuration

type Configuration struct {
	ID          string         `json:"id" bson:"_id"`
	Name        string         `json:"name"`
	Blocks      []*BlockConfig `json:"blocks"`
	Connections []*Connection  `json:"connections"`
}

func (Configuration) ClearAllRecording

func (cfg Configuration) ClearAllRecording()

func (Configuration) FindBlockConfig

func (cfg Configuration) FindBlockConfig(name string) (*BlockConfig, bool)

func (Configuration) GetKey

func (cfg Configuration) GetKey() string

func (Configuration) MakeBlocks

func (cfg Configuration) MakeBlocks() (Blocks, []error)

func (Configuration) SetRecording

func (cfg Configuration) SetRecording(addr *Address) error

func (*Configuration) Validate

func (cfg *Configuration) Validate() []error

type Connection

type Connection struct {
	Source *Address `json:"source"`
	Target *Address `json:"target"`
}

type Graph

type Graph struct {
	*Configuration
	// contains filtered or unexported fields
}

func New

func New(cfg *Configuration) *Graph

func (*Graph) GetWarmupPeriod

func (m *Graph) GetWarmupPeriod() int

func (*Graph) Init

func (m *Graph) Init(rec blocks.Recorder) error

func (*Graph) Update

func (m *Graph) Update(bar *models.Bar)

Jump to

Keyboard shortcuts

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