skeleton

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const ID = "skeleton"

ID is the unique strategy ID, it needs to be in all lower case For example, grid strategy uses "grid"

Variables

This section is empty.

Functions

This section is empty.

Types

type State added in v1.36.0

type State struct {
	Counter int `json:"counter,omitempty"`
}

State is a struct contains the information that we want to keep in the persistence layer, for example, redis or json file.

type Strategy

type Strategy struct {
	Symbol string `json:"symbol"`

	// State is a state of your strategy
	// When BBGO shuts down, everything in the memory will be dropped
	// If you need to store something and restore this information back,
	// Simply define the "persistence" tag
	State *State `persistence:"state"`
}

Strategy is a struct that contains the settings of your strategy. These settings will be loaded from the BBGO YAML config file "bbgo.yaml" automatically.

func (*Strategy) ID added in v1.11.0

func (s *Strategy) ID() string

ID should return the identity of this strategy

func (*Strategy) InstanceID added in v1.36.0

func (s *Strategy) InstanceID() string

InstanceID returns the identity of the current instance of this strategy. You may have multiple instance of a strategy, with different symbols and settings. This value will be used for persistence layer to separate the storage.

Run:

redis-cli KEYS "*"

And you will see how this instance ID is used in redis.

func (*Strategy) Run

func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error

This strategy simply spent all available quote currency to buy the symbol whenever kline gets closed

func (*Strategy) Subscribe

func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)

Subscribe method subscribes specific market data from the given session. Before BBGO is connected to the exchange, we need to collect what we want to subscribe. Here the strategy needs kline data, so it adds the kline subscription.

Jump to

Keyboard shortcuts

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