math

package
v0.0.0-...-2fd9363 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArithmeticMean

func ArithmeticMean(values []float64) (float64, error)

ArithmeticMean is the basic form of calculating an average. Divide the sum of all values by the length of values

func CalculateAmountWithFee

func CalculateAmountWithFee(amount, fee float64) float64

CalculateAmountWithFee returns a calculated fee included amount on fee

func CalculateFee

func CalculateFee(amount, fee float64) float64

CalculateFee returns a simple fee on amount

func CalculateNetProfit

func CalculateNetProfit(amount, priceThen, priceNow, costs float64) float64

CalculateNetProfit returns net profit

func CalculatePercentageDifference

func CalculatePercentageDifference(amount, secondAmount float64) float64

CalculatePercentageDifference returns the percentage of difference between multiple time periods

func CalculatePercentageGainOrLoss

func CalculatePercentageGainOrLoss(priceNow, priceThen float64) float64

CalculatePercentageGainOrLoss returns the percentage rise over a certain period

func CalmarRatio

func CalmarRatio(highestPrice, lowestPrice, average, riskFreeRateForPeriod float64) (float64, error)

CalmarRatio is a function of the average compounded annual rate of return versus its maximum drawdown. The higher the Calmar ratio, the better it performed on a risk-adjusted basis during the given time frame, which is mostly commonly set at 36 months

func CompoundAnnualGrowthRate

func CompoundAnnualGrowthRate(openValue, closeValue, intervalsPerYear, numberOfIntervals float64) (float64, error)

CompoundAnnualGrowthRate Calculates CAGR. Using years, intervals per year would be 1 and number of intervals would be the number of years Using days, intervals per year would be 365 and number of intervals would be the number of days

func FinancialGeometricMean

func FinancialGeometricMean(values []float64) (float64, error)

FinancialGeometricMean is a modified geometric average to assess the negative returns of investments. It accepts It adds +1 to each This does impact the final figures as it is modifying values It is still ultimately calculating a geometric average which should only be compared to other financial geometric averages

func GeometricMean

func GeometricMean(values []float64) (float64, error)

GeometricMean is an average which indicates the central tendency or typical value of a set of numbers by using the product of their values The geometric average can only process positive numbers

func InformationRatio

func InformationRatio(returnsRates, benchmarkRates []float64, averageValues, averageComparison float64) (float64, error)

InformationRatio The information ratio (IR) is a measurement of portfolio returns beyond the returns of a benchmark, usually an index, compared to the volatility of those returns. The benchmark used is typically an index that represents the market or a particular sector or industry.

func PopulationStandardDeviation

func PopulationStandardDeviation(values []float64) (float64, error)

PopulationStandardDeviation calculates standard deviation using population based calculation

func RoundFloat

func RoundFloat(x float64, prec int) float64

RoundFloat rounds your floating point number to the desired decimal place

func SampleStandardDeviation

func SampleStandardDeviation(values []float64) (float64, error)

SampleStandardDeviation standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance

func SharpeRatio

func SharpeRatio(movementPerCandle []float64, riskFreeRatePerInterval, average float64) (float64, error)

SharpeRatio returns sharpe ratio of backtest compared to risk-free

func SortinoRatio

func SortinoRatio(movementPerCandle []float64, riskFreeRatePerInterval, average float64) (float64, error)

SortinoRatio returns sortino ratio of backtest compared to risk-free

Types

This section is empty.

Jump to

Keyboard shortcuts

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