strategies

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package strategies contains all strategies which can be used by the bot. They may use one or more algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCustomStrategy

func AddCustomStrategy(s Strategy)

AddCustomStrategy adds a strategy to the available set.

func ApplyAllStrategies

func ApplyAllStrategies(wrappers []exchanges.ExchangeWrapper)

ApplyAllStrategies applies all matched strategies concurrently.

func MatchWithMarkets

func MatchWithMarkets(strategyName string, markets []*environment.Market) error

MatchWithMarkets matches a strategy with the markets.

Types

type IntervalStrategy

type IntervalStrategy struct {
	Model    StrategyModel
	Interval time.Duration
}

IntervalStrategy is an interval based strategy.

func (IntervalStrategy) Apply

func (is IntervalStrategy) Apply(wrappers []exchanges.ExchangeWrapper, markets []*environment.Market)

Apply executes Cyclically the On Update, basing on provided interval.

func (IntervalStrategy) Name

func (is IntervalStrategy) Name() string

Name returns the name of the strategy.

func (IntervalStrategy) String

func (is IntervalStrategy) String() string

String returns a string representation of the object.

type Strategy

type Strategy interface {
	Name() string                                             // Name returns the name of the strategy.
	Apply([]exchanges.ExchangeWrapper, []*environment.Market) // Apply applies the strategy when called, using the specified wrapper.
}

Strategy represents a generic strategy.

type StrategyFunc

type StrategyFunc func([]exchanges.ExchangeWrapper, []*environment.Market) error

StrategyFunc represents a standard function binded to a strategy model execution.

Can define a Setup, TearDown and Update behaviour.

type StrategyModel

type StrategyModel struct {
	Name     string
	Setup    StrategyFunc
	TearDown StrategyFunc
	OnUpdate StrategyFunc
	OnError  func(error)
}

StrategyModel represents a strategy model used by strategies.

type Tactic

type Tactic struct {
	Markets  []*environment.Market
	Strategy Strategy
}

Tactic represents the effective appliance of a strategy.

func (*Tactic) Execute

func (t *Tactic) Execute(wrappers []exchanges.ExchangeWrapper)

Execute executes effectively a tactic.

type WebsocketStrategy

type WebsocketStrategy struct {
	Model StrategyModel
}

WebsocketStrategy polls data from a websocket in real-time.

NOTE: The update function must be handled in the websocket strategy-model.

func (WebsocketStrategy) Apply

func (wss WebsocketStrategy) Apply(wrappers []exchanges.ExchangeWrapper, markets []*environment.Market)

Apply executes Cyclically the On Update, basing on provided interval.

func (WebsocketStrategy) Name

func (wss WebsocketStrategy) Name() string

Name returns the name of the strategy.

func (WebsocketStrategy) String

func (wss WebsocketStrategy) String() string

String returns a string representation of the object.

Jump to

Keyboard shortcuts

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