algoutil

package
v0.0.0-...-1513131 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlgoDataFilePath = "data/algo-data/" // Main file path for algorithm data

)
View Source
const (
	DummyFilePath = "data/algo-dummy/%f_%s_%d.gzip.an" // Path for dummy files
)

Variables

This section is empty.

Functions

func CreateDirectoryIfNotExists

func CreateDirectoryIfNotExists(dirPath string) error

CreateDirectoryIfNotExists checks if a directory exists, and if not, it creates the directory.

func GetAlgoNamesFromGzipDecompress

func GetAlgoNamesFromGzipDecompress(gzippedAlgorithmNames []byte) ([]algorithm.AlgorithmName, error)

func GzipCompress

func GzipCompress(data []byte) ([]byte, error)

GzipCompress compresses the data using gzip.

func GzipDecompress

func GzipDecompress(data []byte) ([]byte, error)

GzipDecompress decompresses gzip data.

Types

type AlgoDetail

type AlgoDetail struct {
	AlgorithmTypes []string                  `json:"algorithmTypes"`
	AlgorithmNames []algorithm.AlgorithmName `json:"algorithmNames"`
}

type AlgoGenerator

type AlgoGenerator interface {
	GetAlgorithms() gr_variable.ReadOnlyGrChannel[*AlgoPreEvalAlgorithmDataWithType]
	UpdateAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error
	AppendAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error
}

func NewFileSortParallelProcessAlgorithmGenerator

func NewFileSortParallelProcessAlgorithmGenerator(ctx context.Context, mc *monitor.PrometheusMonitoring, ticker, start, end string, constraints model.PerformanceConstraints, expectedLengthList []int) AlgoGenerator

func NewGenerativeAlgoGenerator

func NewGenerativeAlgoGenerator(ctx context.Context, mc *monitor.PrometheusMonitoring, types []string, ticker, start, end string, constraints model.PerformanceConstraints) AlgoGenerator

type AlgoGeneratorAdaptorManager

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

func NewAlgoGeneratorAdaptorManager

func NewAlgoGeneratorAdaptorManager(first, second []algorithm.AlgorithmName, adapterNameToObjectMap map[string]indicator_adaptor.IndicatorAdaptorCache) (*AlgoGeneratorAdaptorManager, bool)

func (*AlgoGeneratorAdaptorManager) GetAlgoName

func (am *AlgoGeneratorAdaptorManager) GetAlgoName() string

func (*AlgoGeneratorAdaptorManager) GetAllAdaptors

func (*AlgoGeneratorAdaptorManager) IsMatch

func (*AlgoGeneratorAdaptorManager) JumpNext

func (am *AlgoGeneratorAdaptorManager) JumpNext() bool

func (*AlgoGeneratorAdaptorManager) UpdateNextIndex

func (am *AlgoGeneratorAdaptorManager) UpdateNextIndex(i int)

type AlgoGeneratorAdaptorNode

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

func NewAlgoGeneratorAdaptorNode

func NewAlgoGeneratorAdaptorNode() *AlgoGeneratorAdaptorNode

func (*AlgoGeneratorAdaptorNode) Add

func (node *AlgoGeneratorAdaptorNode) Add(adaptorList []string, index int, adapterNameToObjectMap map[string]indicator_adaptor.IndicatorAdaptorCache)

func (*AlgoGeneratorAdaptorNode) CurrentNode

func (*AlgoGeneratorAdaptorNode) CurrentNodeAdaptor

func (*AlgoGeneratorAdaptorNode) CurrentNodeName

func (node *AlgoGeneratorAdaptorNode) CurrentNodeName() string

func (*AlgoGeneratorAdaptorNode) HasNext

func (node *AlgoGeneratorAdaptorNode) HasNext() bool

func (*AlgoGeneratorAdaptorNode) IsAtBeginning

func (node *AlgoGeneratorAdaptorNode) IsAtBeginning() bool

func (*AlgoGeneratorAdaptorNode) JumpNext

func (node *AlgoGeneratorAdaptorNode) JumpNext()

func (*AlgoGeneratorAdaptorNode) Reset

func (node *AlgoGeneratorAdaptorNode) Reset()

type AlgoGzipDetail

type AlgoGzipDetail struct {
	AlgorithmTypes        []string `json:"algorithmTypes"`
	GzippedAlgorithmNames []byte   `json:"algorithmNames"`
}

type AlgoLengthDetail

type AlgoLengthDetail struct {
	Length int                   `json:"length"`
	Types  map[string]AlgoDetail `json:"algorithmTypes"`
}

type AlgoLengthGzipDetail

type AlgoLengthGzipDetail struct {
	Length int                       `json:"length"`
	Types  map[string]AlgoGzipDetail `json:"algorithmTypes"`
}

type AlgoLengthsGroup

type AlgoLengthsGroup struct {
	Lengths map[int]AlgoLengthDetail `json:"lengths"`
}

type AlgoLengthsGzipGroup

type AlgoLengthsGzipGroup struct {
	Lengths map[int]AlgoLengthGzipDetail `json:"lengths"`
}

type AlgoNamePairHeap

type AlgoNamePairHeap []*AlgoGeneratorAdaptorManager

MinHeap for AlgoNamePair

func (AlgoNamePairHeap) Len

func (h AlgoNamePairHeap) Len() int

func (AlgoNamePairHeap) Less

func (h AlgoNamePairHeap) Less(i, j int) bool

func (*AlgoNamePairHeap) Pop

func (h *AlgoNamePairHeap) Pop() interface{}

func (*AlgoNamePairHeap) Push

func (h *AlgoNamePairHeap) Push(x interface{})

func (AlgoNamePairHeap) Swap

func (h AlgoNamePairHeap) Swap(i, j int)

type AlgoPreEvalAlgorithmData

type AlgoPreEvalAlgorithmData struct {
	UniqueAdapterNameToObjectMap map[string]indicator_adaptor.IndicatorAdaptorCache
	AlgoNamePresent              map[string]struct{}                               // Set to track existing algorithm names
	AlgoNameHeapPresent          *AlgoNamePairHeap                                 // Replaced map with AlgoNamePairHeap
	ListOfAlgos                  gr_variable.GrChannel[algorithm.TradingAlgorithm] // List to store the algorithms
}

func (*AlgoPreEvalAlgorithmData) CleanUp

func (apea *AlgoPreEvalAlgorithmData) CleanUp()

type AlgoPreEvalAlgorithmDataWithType

type AlgoPreEvalAlgorithmDataWithType struct {
	AlgoType                 string
	AlgoPreEvalAlgorithmData *AlgoPreEvalAlgorithmData
}

AlgoPreEvalAlgorithmDataWithType combines the original struct with a new AlgoType field.

type DummyAlgoDetails

type DummyAlgoDetails struct {
	CompressedAlgorithmNamesList [][]byte `json:"algorithmNames"`
}

DummyAlgoDetails represents the structure for maintaining compressed algorithm names.

type DummyDataMaintainer

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

DummyDataMaintainer is responsible for maintaining dummy algorithm data.

func NewDummyDataMaintainer

func NewDummyDataMaintainer() *DummyDataMaintainer

NewDummyDataMaintainer creates a new instance of DummyDataMaintainer with the current start time.

func (*DummyDataMaintainer) AppendAlgorithmDetails

func (d *DummyDataMaintainer) AppendAlgorithmDetails(adaptorType string, allAlgorithmsName []algorithm.AlgorithmName, constraints model2.PerformanceConstraints) error

AppendAlgorithmDetails appends gzipped algorithm details to the dummy file.

func (*DummyDataMaintainer) ReadFromDummyFile

func (d *DummyDataMaintainer) ReadFromDummyFile(adaptorType string, constraints model2.PerformanceConstraints) ([]algorithm.AlgorithmName, error)

ReadFromDummyFile reads and decompresses the algorithm data from the dummy file.

type FileAlgorithmJsonGzipStorage

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

func NewFileAlgorithmJsonGzipStorage

func NewFileAlgorithmJsonGzipStorage(ticker, filename string, interval int) *FileAlgorithmJsonGzipStorage

func NewFileAlgorithmJsonGzipStorageFromPrefixAndTimestamp

func NewFileAlgorithmJsonGzipStorageFromPrefixAndTimestamp(ticker, prefix, start, end string) *FileAlgorithmJsonGzipStorage

func NewFileAlgorithmJsonGzipStorageFromTimestamp

func NewFileAlgorithmJsonGzipStorageFromTimestamp(ticker, start, end string) *FileAlgorithmJsonGzipStorage

func (*FileAlgorithmJsonGzipStorage) AppendAlgorithmDetails

func (f *FileAlgorithmJsonGzipStorage) AppendAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error

AppendAlgorithmDetails updates the algorithm details in the data file.

func (*FileAlgorithmJsonGzipStorage) ReadAlgorithmsFromFiles

func (f *FileAlgorithmJsonGzipStorage) ReadAlgorithmsFromFiles(constraints model.PerformanceConstraints, lengths []int) ([]AlgoLengthDetail, error)

ReadAlgorithmsFromFiles reads the algorithm details from the file based on the given constraints and returns a list of AlgoLengthGzipDetail structures for the specified lengths.

func (*FileAlgorithmJsonGzipStorage) ReadIntervalPerformanceGzipAlgorithm

func (f *FileAlgorithmJsonGzipStorage) ReadIntervalPerformanceGzipAlgorithm() (IntervalPerformanceGzipAlgorithm, error)

ReadIntervalPerformanceGzipAlgorithm reads the JSON data from the file and returns an IntervalPerformanceGzipAlgorithm.

func (*FileAlgorithmJsonGzipStorage) UpdateAlgorithmDetails

func (f *FileAlgorithmJsonGzipStorage) UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error

UpdateAlgorithmDetails updates the algorithm details in the data file.

type FileAlgorithmJsonStorage

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

FileAlgorithmJsonStorage implements the AlgorithmStorage interface using file-based storage.

func NewFileAlgorithmJsonStorage

func NewFileAlgorithmJsonStorage(ticker, filename string, interval int) *FileAlgorithmJsonStorage

func NewFileAlgorithmJsonStorageFromPrefixAndTimestamp

func NewFileAlgorithmJsonStorageFromPrefixAndTimestamp(ticker, prefix, start, end string) *FileAlgorithmJsonStorage

func NewFileAlgorithmJsonStorageFromTimestamp

func NewFileAlgorithmJsonStorageFromTimestamp(ticker, start, end string) *FileAlgorithmJsonStorage

func (*FileAlgorithmJsonStorage) AppendAlgorithmDetails

func (f *FileAlgorithmJsonStorage) AppendAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error

AppendAlgorithmDetails updates the algorithm details in the data file.

func (*FileAlgorithmJsonStorage) ReadAlgorithmsFromFiles

func (f *FileAlgorithmJsonStorage) ReadAlgorithmsFromFiles(constraints model.PerformanceConstraints, lengths []int) ([]AlgoLengthDetail, error)

ReadAlgorithmsFromFiles reads the algorithm details from the file based on the given constraints and returns a list of AlgoLengthDetail structures for the specified lengths.

func (*FileAlgorithmJsonStorage) ReadIntervalPerformanceAlgorithm

func (f *FileAlgorithmJsonStorage) ReadIntervalPerformanceAlgorithm() (IntervalPerformanceAlgorithm, error)

ReadIntervalPerformanceAlgorithm reads the JSON data from the file and returns an IntervalPerformanceAlgorithm.

func (*FileAlgorithmJsonStorage) UpdateAlgorithmDetails

func (f *FileAlgorithmJsonStorage) UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error

type FileAlgorithmProtoGzipStorage

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

FileAlgorithmProtoGzipStorage is a storage structure for handling algorithm data in gzip format.

func (*FileAlgorithmProtoGzipStorage) AppendAlgorithmDetails

func (f *FileAlgorithmProtoGzipStorage) AppendAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model2.PerformanceConstraints) error

AppendAlgorithmDetails creates or appends to a dummy file with gzipped algorithm details. If a file with the same name already exists, it will panic.

func (*FileAlgorithmProtoGzipStorage) ReadAlgorithmsFromFiles

func (f *FileAlgorithmProtoGzipStorage) ReadAlgorithmsFromFiles(constraints model2.PerformanceConstraints, lengths []int) ([]AlgoLengthDetail, error)

ReadAlgorithmsFromFiles reads the algorithm details from the file based on the given constraints and returns a list of AlgoGzipLengthDetail structures for the specified lengths.

func (*FileAlgorithmProtoGzipStorage) ReadIntervalPerformanceGzipAlgorithm

func (f *FileAlgorithmProtoGzipStorage) ReadIntervalPerformanceGzipAlgorithm() (*model.IntervalPerformanceGzipAlgorithm, error)

ReadIntervalPerformanceGzipAlgorithm reads the Protobuf data from the file and returns an IntervalPerformanceGzipAlgorithm.

func (*FileAlgorithmProtoGzipStorage) UpdateAlgorithmDetails

func (f *FileAlgorithmProtoGzipStorage) UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model2.PerformanceConstraints) error

UpdateAlgorithmDetails updates the algorithm details in the data file. UpdateAlgorithmDetails reads from the dummy file, ungzips, merges, and writes to the main file.

type FileAlgorithmProtoStorage

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

func NewFileAlgorithmProtoStorage

func NewFileAlgorithmProtoStorage(filename string, interval int) *FileAlgorithmProtoStorage

func NewFileAlgorithmProtoStorageFromPrefixAndTimestamp

func NewFileAlgorithmProtoStorageFromPrefixAndTimestamp(prefix, start, end string) *FileAlgorithmProtoStorage

func NewFileAlgorithmProtoStorageFromTimestamp

func NewFileAlgorithmProtoStorageFromTimestamp(start, end string) *FileAlgorithmProtoStorage

func (*FileAlgorithmProtoStorage) ReadAlgorithmsFromFiles

func (f *FileAlgorithmProtoStorage) ReadAlgorithmsFromFiles(constraints model2.PerformanceConstraints, lengths []int) ([]*model.AlgoLengthDetail, error)

ReadAlgorithmsFromFiles reads the algorithm details from the file based on the given constraints and returns a list of AlgoLengthDetail structures for the specified lengths.

func (*FileAlgorithmProtoStorage) ReadIntervalPerformanceAlgorithm

func (f *FileAlgorithmProtoStorage) ReadIntervalPerformanceAlgorithm() (*model.IntervalPerformanceAlgorithm, error)

ReadIntervalPerformanceAlgorithm reads the Protobuf data from the file and returns an IntervalPerformanceAlgorithm.

func (*FileAlgorithmProtoStorage) UpdateAlgorithmDetails

func (f *FileAlgorithmProtoStorage) UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model2.PerformanceConstraints) error

UpdateAlgorithmDetails updates the algorithm details in the data file.

type FileAlgorithmStorage

type FileAlgorithmStorage interface {
	ReadAlgorithmsFromFiles(constraints model.PerformanceConstraints, lengths []int) ([]AlgoLengthDetail, error)
	UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error
	AppendAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model.PerformanceConstraints) error
}

FileAlgorithmStorage implements the AlgorithmStorage interface using file-based storage.

func NewFileAlgorithmStorageFromTimestamp

func NewFileAlgorithmStorageFromTimestamp(ticker, start, end string) FileAlgorithmStorage

type FileSortParallelProcessGenericAlgorithmGenerator

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

func NewFileSortParallelProcessGenericAlgorithmGenerator

func NewFileSortParallelProcessGenericAlgorithmGenerator(ctx context.Context, mc *monitor.PrometheusMonitoring, ticker, start, end string, constraints model.PerformanceConstraints, expectedLengthList []int) *FileSortParallelProcessGenericAlgorithmGenerator

func (*FileSortParallelProcessGenericAlgorithmGenerator) AppendAlgorithmDetails

func (ag *FileSortParallelProcessGenericAlgorithmGenerator) AppendAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error

func (*FileSortParallelProcessGenericAlgorithmGenerator) GetAlgorithms

func (*FileSortParallelProcessGenericAlgorithmGenerator) PrepareAlgorithmDetails

func (ag *FileSortParallelProcessGenericAlgorithmGenerator) PrepareAlgorithmDetails(expectedLengthList []int)

New Method for Reading Algorithms and Preparing Details

func (*FileSortParallelProcessGenericAlgorithmGenerator) UpdateAlgorithmDetails

func (ag *FileSortParallelProcessGenericAlgorithmGenerator) UpdateAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error

type GenerativeAlgoGenerator

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

func (*GenerativeAlgoGenerator) AppendAlgorithmDetails

func (ag *GenerativeAlgoGenerator) AppendAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error

func (*GenerativeAlgoGenerator) GetAlgorithms

func (*GenerativeAlgoGenerator) GetGenerativeAlgoAdaptors

func (ag *GenerativeAlgoGenerator) GetGenerativeAlgoAdaptors(algoType string) []indicator_adaptor.IndicatorAdaptor

func (*GenerativeAlgoGenerator) UpdateAlgorithmDetails

func (ag *GenerativeAlgoGenerator) UpdateAlgorithmDetails(allAlgorithmsName []algorithm.AlgorithmName, adaptorType string) error

type IFileAlgorithmProtoGzipStorage

type IFileAlgorithmProtoGzipStorage interface {
	ReadIntervalPerformanceGzipAlgorithm() (*model.IntervalPerformanceGzipAlgorithm, error)
	UpdateAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model2.PerformanceConstraints) error
	AppendAlgorithmDetails(ctx context.Context, allAlgorithmsName []algorithm.AlgorithmName, adaptorType string, constraints model2.PerformanceConstraints) error
	ReadAlgorithmsFromFiles(constraints model2.PerformanceConstraints, lengths []int) ([]AlgoLengthDetail, error)
}

FileAlgorithmStorage defines an interface for storing and managing algorithm data.

func NewFileAlgorithmProtoGzipStorage

func NewFileAlgorithmProtoGzipStorage(ticker, filename string, interval int) IFileAlgorithmProtoGzipStorage

NewFileAlgorithmProtoGzipStorage creates a new instance of FileAlgorithmProtoGzipStorage.

func NewFileAlgorithmProtoGzipStorageFromPrefixAndTimestamp

func NewFileAlgorithmProtoGzipStorageFromPrefixAndTimestamp(ticker, prefix, start, end string) IFileAlgorithmProtoGzipStorage

NewFileAlgorithmProtoGzipStorageFromPrefixAndTimestamp creates a new instance with a prefix and timestamp.

func NewFileAlgorithmProtoGzipStorageFromTimestamp

func NewFileAlgorithmProtoGzipStorageFromTimestamp(ticker, start, end string) IFileAlgorithmProtoGzipStorage

NewFileAlgorithmProtoGzipStorageFromTimestamp creates a new instance based on a timestamp.

type IntervalPerformanceAlgorithm

type IntervalPerformanceAlgorithm struct {
	IntervalConstraints map[int]PerformanceConstraintsGroup `json:"timeConstraints"`
}

type IntervalPerformanceGzipAlgorithm

type IntervalPerformanceGzipAlgorithm struct {
	IntervalConstraints map[int]PerformanceConstraintsGzipGroup `json:"timeConstraints"`
}

type PerformanceConstraintsGroup

type PerformanceConstraintsGroup struct {
	Interval    int
	Constraints map[string]AlgoLengthsGroup `json:"constraints"`
}

type PerformanceConstraintsGzipGroup

type PerformanceConstraintsGzipGroup struct {
	Interval    int
	Constraints map[string]AlgoLengthsGzipGroup `json:"constraints"`
}

Jump to

Keyboard shortcuts

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