riskcontrol

package
v0.0.0-...-c0411a1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

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

func (c *CircuitBreakRiskControl) IsOverHaltedDuration() 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

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