calc

package
v0.0.0-...-27f069a Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Call = iota
	Put
)

Variables

This section is empty.

Functions

func ExpandSpan

func ExpandSpan(span ValueSpan, direction bool) []float64

Expand a ValueSpan in a given direction direction = true -> expand from Low to High direction = false -> expand from High to Low

func NormalizedCDF

func NormalizedCDF(x float64) float64

Standard normal cumulative distribution function

func Round

func Round(value float64, places int32) float64

Types

type Asset

type Asset struct {
	Name       string
	Volatility float64
	RfReturn   float64
}

type CalcInstrumentRequest

type CalcInstrumentRequest struct {
	ChainValue bool
	ChainFunc  bool
}

type CalcInstrumentResult

type CalcInstrumentResult struct {
	ChainValueHits   int64
	ChainValueMisses int64
	ChainFuncHits    int64
	ChainFuncMisses  int64
}

type Chain

type Chain [][][]OptionPosition

type ChainCalculator

type ChainCalculator struct {
	sync.RWMutex
	OptionType   int
	Volatility   float64
	RiskFreeRate float64
	ExpiryInDays float64
	// contains filtered or unexported fields
}

func NewChainCalculator

func NewChainCalculator(ctx *context.Context, optionType int, volatility, riskFreeRate, expiryInDays float64, calcOptions *ChainOptions) (*ChainCalculator, error)

func (*ChainCalculator) BlackScholesCall

func (occ *ChainCalculator) BlackScholesCall(ctx *context.Context, assetPrice, strikePrice, daysToExpiry float64, position *OptionPosition) error

func (*ChainCalculator) BlackScholesPut

func (occ *ChainCalculator) BlackScholesPut(ctx *context.Context, assetPrice, strikePrice, daysToExpiry float64, position *OptionPosition) error

Black-Scholes formula for put option price

func (*ChainCalculator) ComputeChain

func (occ *ChainCalculator) ComputeChain(ctx *context.Context, assetPriceSpan, strikePriceSpan, daysToExpirySpan *ValueSpan) (Chain, error)

func (*ChainCalculator) GetCalcInstrumentResult

func (occ *ChainCalculator) GetCalcInstrumentResult() CalcInstrumentResult

type ChainOptions

type ChainOptions struct {
	InstrumentRequest CalcInstrumentRequest
}

For context values

type Option

type Option struct {
	Asset  Asset
	Type   int
	Strike float64
	Expiry float64
}

type OptionPosition

type OptionPosition struct {
	Price        float64
	Strike       float64
	DaysToExpiry float64
}

type ValueSpan

type ValueSpan struct {
	Low  float64
	High float64
	Step float64
}

For Option Chain calculatins

Jump to

Keyboard shortcuts

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