model

package
v0.0.0-...-e2be882 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvolveAsInt

func EvolveAsInt(i int, r float64) int

func EvolveFloat

func EvolveFloat(f float64, r float64, limit float64) float64

EvolveFloat evolves a float number f is the number to be used as base r is the bias for producing a bigger or smaller number than the initial limit is the highest possible value for the new generated float. It acts as a cap

Types

type Action

type Action struct {
	Key      model.Key
	Type     model.Type
	Price    float64
	Time     time.Time
	Duration time.Duration
	PnL      float64
}

Action defines an action of a type

type Benchmark

type Benchmark struct {
	Exchange map[model.Key]*local.Exchange
	Wallet   map[model.Key]*trader.ExchangeTrader
	Actions  map[model.Key][]Action
	Profit   map[model.Key][]client.Report
	Timer    map[model.Coin]int64
	// contains filtered or unexported fields
}

Benchmark is responsible for tracking the performance of signals

func NewBenchmarks

func NewBenchmarks() *Benchmark

func (*Benchmark) Add

func (b *Benchmark) Add(key model.Key, trade model.Tick, signal Signal, config *Config) (client.Report, bool, error)

func (*Benchmark) Reset

func (b *Benchmark) Reset(coin model.Coin, key model.Key)

type Buffer

type Buffer struct {
	Interval time.Duration
	History  bool
}

type ByScore

type ByScore []Performance

func (ByScore) Len

func (p ByScore) Len() int

func (ByScore) Less

func (p ByScore) Less(i, j int) bool

func (ByScore) Swap

func (p ByScore) Swap(i, j int)

type Config

type Config struct {
	// Segments defines the configuration for different segments of analysis
	// it can relate to same coin with different observation intervals or different coins
	Segments SegmentConfig
	// Position defines the configuration for the position tracking and closing decisions
	Position Position
	// Option defines the algorithm running config options like logging level etc ...
	Option Option
	// Buffer defines the minimal grouping interval for observing positions
	Buffer Buffer
	// Segment defines the minimal grouping interval for market analysis
	Segment Buffer
}

Config defines the configuration for the collector.

func (*Config) GetSegments

func (c *Config) GetSegments(coin model.Coin, duration time.Duration) map[model.Key]Segments

GetSegments returns the segments that match the given parameters.

func (*Config) SetGap

func (c *Config) SetGap(coin model.Coin, gap float64) *Config

func (*Config) SetPrecisionThreshold

func (c *Config) SetPrecisionThreshold(coin model.Coin, network string, precision float64) *Config

type ConfigSegment

type ConfigSegment func(coin model.Coin) func(cfg SegmentConfig) SegmentConfig

type Detail

type Detail struct {
	Type  string `json:"type"`
	Hash  string `json:"hash"`
	Index int    `json:"index"`
}

Detail defines the network details to distinguish between different objects

func NetworkType

func NetworkType(n string) Detail

func (Detail) ToString

func (detail Detail) ToString() string

type Meta

type Meta struct {
	Key    model.Key  `json:"key"`
	Tick   model.Tick `json:"tick"`
	Active bool       `json:"active"`
}

type Model

type Model struct {
	Detail       Detail  `json:"type"`
	BufferSize   int     `json:"buffer"`
	Threshold    float64 `json:"threshold"`
	Spread       float64 `json:"spread"`
	Size         []int   `json:"size"`
	Features     []int   `json:"features"`
	MaxEpochs    int     `json:"max_epochs"`
	LearningRate float64 `json:"learning_rate"`
	Multi        bool    `json:"multi"`
}

Model defines the ml model config. BufferSize defines the size of the history buffer for the model reducing the buffer size will make the model more reactiv Threshold defines the model precision in order to make use of it increasing the threshold will reduce trading activity, but make the trading decisions more accurate Spread is used to quantize outputs of the model to make the output more simple Size defines the internal size of the model reducing the size will make the model more reactive Features defines the number of features to be used by the model depends strictly on the stats output MaxEpochs defines the maximmum epochs for the training process LearningRate defines the learning rate for the model

func NewConfig

func NewConfig(p ...[]float64) Model

NewConfig defines a numeric way to initialise the config we will use it mostly to do hyperparameter tuning

func (Model) Format

func (m Model) Format() string

func (Model) ToSlice

func (m Model) ToSlice() [][]float64

type Option

type Option struct {
	Trace     map[string]bool
	Log       bool
	Debug     bool
	Benchmark bool
}

type Performance

type Performance struct {
	Config [][]float64
	Score  float64
}

type Position

type Position struct {
	OpenValue      float64
	StopLoss       float64
	TakeProfit     float64
	TrackingConfig []*model.TrackingConfig
}

type SegmentConfig

type SegmentConfig map[model.Key]Segments

func (SegmentConfig) AddConfig

func (sgm SegmentConfig) AddConfig(add ...func(cfg SegmentConfig) SegmentConfig) SegmentConfig

type Segments

type Segments struct {
	Stats  Stats  `json:"stats"`
	Trader Trader `json:"log"`
}

Segments defines the look back and ahead segment number. LookBack : the number of segments taken into account from the recent past LookAhead : the number of segments to be anticipated Gap : the numeric threshold for the price movement in regard to the current segment.

type Signal

type Signal struct {
	Key       model.Key           `json:"Index"`
	Detail    Detail              `json:"detail"`
	Time      time.Time           `json:"time"`
	Price     float64             `json:"price"`
	Type      model.Type          `json:"type"`
	Precision float64             `json:"precision"`
	Gap       float64             `json:"gap"`
	Trend     float64             `json:"trend"`
	Factor    float64             `json:"factor"`
	Weight    int                 `json:"weight"`
	Live      bool                `json:"live"`
	Buffer    []float64           `json:"buffer"`
	Spectrum  *coin_math.Spectrum `json:"-"`
}

Signal represents a signal from the ml processor.

func (*Signal) Filter

func (signal *Signal) Filter(threshold int) bool

func (Signal) String

func (signal Signal) String() string

func (Signal) ToString

func (signal Signal) ToString() string

type Stats

type Stats struct {
	LookBack  int     `json:"prev"`
	LookAhead int     `json:"next"`
	Gap       float64 `json:"gap"`
	Live      bool    `json:"live"`
	Model     []Model `json:"model"`
}

Stats defines the statistical properties of the set

func (Stats) Format

func (s Stats) Format() string

type Trader

type Trader struct {
	BufferTime     float64 `json:"buffer_time"`
	PriceThreshold float64 `json:"price_threshold"`
	Weight         int     `json:"weight"`
	Live           bool    `json:"live"`
}

Trader defines the trading configuration for signals BufferTime defines the time to wait for a signal to be confirmed by actual trading PriceThreshold defines the price threshold to verify the model performance within the above buffertime Weight defines the weight required by the model for the corresponding signal to be taken into account

func (Trader) Format

func (t Trader) Format() string

type Vector

type Vector struct {
	Meta    Meta      `json:"meta"`
	PrevIn  []float64 `json:"prev_in"`
	PrevOut []float64 `json:"prev_out"`
	NewIn   []float64 `json:"new_in"`
}

func (Vector) String

func (v Vector) String() string

Jump to

Keyboard shortcuts

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