tools

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxOrderAttempts = 3

MaxOrderAttempts is how many times a Scheduler sends the order of a condition met, once per Update while it fails: past it, the condition is dropped, an error logged, never sent again.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderCondition deprecated

type OrderCondition struct {
	Condition func(df *xtrader.Dataframe) bool
	Size      float64
	Side      xtrader.SideType
	// contains filtered or unexported fields
}

OrderCondition is an order at the market a Scheduler sends once Condition is met.

Deprecated: see Scheduler.

type Scheduler deprecated

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

Scheduler sends an order at the market once a condition is met on a candle, the condition dropped once sent, or after MaxOrderAttempts failures.

Deprecated: no agent uses it, only the unregistered strategy of agents/strategies.NewTrailing. Kept until its removal is decided.

func NewScheduler deprecated

func NewScheduler(pair string) *Scheduler

NewScheduler returns a scheduler of the orders of pair.

Deprecated: see Scheduler.

func (*Scheduler) BuyWhen

func (s *Scheduler) BuyWhen(size float64, condition func(df *xtrader.Dataframe) bool)

func (*Scheduler) SellWhen

func (s *Scheduler) SellWhen(size float64, condition func(df *xtrader.Dataframe) bool)

func (*Scheduler) Update

func (s *Scheduler) Update(df *xtrader.Dataframe, broker service.Broker)

Update sends the orders of the conditions met on df. One that fails is sent again on the next Update its condition is met, MaxOrderAttempts times at most, eg: refused by the broker for good.

type TrailingStop deprecated

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

TrailingStop follows the best price of a position, its stop moved by as much as the price moves in favor of the position, never back: of a BUY when started with the stop below the price, of a SELL when above it.

Deprecated: no agent uses it, only the unregistered strategy of agents/strategies.NewTrailing; the agents trail their stops at the broker, see agents/strategies (trailing-atr). Kept until its removal is decided.

func NewTrailingStop deprecated

func NewTrailingStop() *TrailingStop

NewTrailingStop returns a trailing stop not started.

Deprecated: see TrailingStop.

func (TrailingStop) Active

func (t TrailingStop) Active() bool

func (*TrailingStop) Start

func (t *TrailingStop) Start(current, stop float64)

Start follows a position at current with its stop: of a SELL when stop is above current, else of a BUY.

func (*TrailingStop) Stop

func (t *TrailingStop) Stop()

func (*TrailingStop) Update

func (t *TrailingStop) Update(current float64) bool

Update moves the stop with a price better than the best one since the start, by as much, so a price back from a worse one doesn't move it, and tells whether current reached it: at or below it for a BUY, at or above it for a SELL.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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