riskcontrol

package
v1.64.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: AGPL-3.0 Imports: 7 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircuitBreakRiskControl

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

func NewCircuitBreakRiskControl

func NewCircuitBreakRiskControl(
	position *types.Position,
	price *indicatorv2.EWMAStream,
	lossThreshold fixedpoint.Value,
	profitStats *types.ProfitStats,
	haltedDuration time.Duration,
) *CircuitBreakRiskControl

func (*CircuitBreakRiskControl) IsHalted

func (c *CircuitBreakRiskControl) IsHalted(t time.Time) bool

IsHalted returns whether we reached the circuit break condition set for this day?

func (*CircuitBreakRiskControl) IsOverHaltedDuration added in v1.52.0

func (c *CircuitBreakRiskControl) IsOverHaltedDuration() bool

type OrderPriceRiskControl added in v1.60.0

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

func NewOrderPriceRiskControl added in v1.60.0

func NewOrderPriceRiskControl(referencePrice *indicatorv2.EWMAStream, threshold fixedpoint.Value) *OrderPriceRiskControl

func (*OrderPriceRiskControl) IsSafe added in v1.60.0

func (r *OrderPriceRiskControl) IsSafe(side types.SideType, price fixedpoint.Value, quantity fixedpoint.Value) bool

type PositionRiskControl

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

PositionRiskControl controls the position with the given hard limit TODO: add a decorator for the order executor and move the order submission logics into the decorator

func NewPositionRiskControl

func NewPositionRiskControl(orderExecutor bbgo.OrderExecutorExtended, hardLimit, quantity fixedpoint.Value) *PositionRiskControl

func (*PositionRiskControl) EmitReleasePosition

func (p *PositionRiskControl) EmitReleasePosition(quantity fixedpoint.Value, side types.SideType)

func (*PositionRiskControl) Initialize added in v1.53.0

func (p *PositionRiskControl) Initialize(ctx context.Context, session *bbgo.ExchangeSession)

func (*PositionRiskControl) ModifiedQuantity

func (p *PositionRiskControl) ModifiedQuantity(position fixedpoint.Value) (buyQuantity, sellQuantity fixedpoint.Value)

ModifiedQuantity returns sliceQuantity controlled by position risks For buy orders, modify sliceQuantity = min(hardLimit - position, sliceQuantity), limiting by positive position For sell orders, modify sliceQuantity = min(hardLimit - (-position), sliceQuantity), limiting by negative position

Pass the current base position to this method, and it returns the maximum sliceQuantity for placing the orders. This works for both Long/Short position

func (*PositionRiskControl) OnReleasePosition

func (p *PositionRiskControl) OnReleasePosition(cb func(quantity fixedpoint.Value, side types.SideType))

Jump to

Keyboard shortcuts

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