Documentation ¶
Overview ¶
Package risk offers an API to evaluate trade risk. Used in conjunction with the money package to size positions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FullRisker ¶
type FullRisker struct {
// contains filtered or unexported fields
}
FullRisker assumes that the current price is the maximum downside risk. This is equivalent to assumming a position size of 1 and no stopp loss.
func (*FullRisker) ReceivePrice ¶
ReceivePrice updates the FullRisker with the next price.
func (*FullRisker) Risk ¶
func (r *FullRisker) Risk() decimal.Decimal
Risk returns a unitary measure of risk based on the current price. Will always be the current price.
func (*FullRisker) Valid ¶
func (r *FullRisker) Valid() bool
Valid returns true if the risker has enough data to be calculated. Will always return true.
type Risker ¶
type Risker interface { // ReceivePrice updates the risker with the next price. market.Receiver // Risk returns a unitary measure of risk based on the current price. Risk() decimal.Decimal // Valid returns true if the risker has enough data to be calculated. Valid() bool }
Risker is an interface that defines the methods needed to evaluate trade risk.
type SDRisker ¶
SDRisker is a Risker that uses the standard deviation of a moving window.
func NewSDRisker ¶
NewSDRisker returns a new SDRisker.
func (*SDRisker) ReceivePrice ¶
ReceivePrice updates the SDRisker with the next price.