riskcontrol

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 7 Imported by: ? modules, 0 packages

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

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