stat4trading

package module
v0.0.0-...-06dc3bc Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateOutputDataLengthAfterMA

func CalculateOutputDataLengthAfterMA(inputDataLength, windowWidth int) int

CalculateOutputDataLengthAfterMA Calculates output data length after applying Moving Average window with width = windowWidth to incoming data set with length = inputDataLength

func EMA

func EMA(inputData []float64, windowWidth int, expectedOutputDataLength int) ([]float64, error)

EMA - ExponentialMovingAverage expectedOutputDataLength is the required parameter for self-control. It should be known BEFORE doing smoothing, and if it is calculated incorrectly you can't handle obtained result in a right way. WARNING: Strictly said, when calculating EMA, we should CUT OFF FIRST windowWidth elements before return the result - in contrast to calculating SMA / WMA, But we cut off first windowWidth-1 elements in order to unify the result and make it the SAME LENGTH as the SMA and WMA result.

func FindIntersectionDirections

func FindIntersectionDirections(referenceGraph []float64, investigatedGraph []float64) ([]string, error)

func FindMax

func FindMax[N Numeric](data []N) (N, int, error)

func FindMin

func FindMin[N Numeric](data []N) (N, int, error)

func IsDataSortedASC

func IsDataSortedASC[N Numeric](data []N) bool

func IsDataSortedDESC

func IsDataSortedDESC[N Numeric](data []N) bool

func SMA

func SMA(inputData []float64, windowWidth int, expectedOutputDataLength int) ([]float64, error)

SMA - SimpleMovingAverage expectedOutputDataLength is the required parameter for self-control. It should be known BEFORE doing smoothing, and if it is calculated incorrectly you can't handle obtained result in a right way.

func SmoothAdaptive

func SmoothAdaptive(inData []float64, passesNum int) []float64

SmoothAdaptive performs adaptive smoothing: 5-point smoothing in priority, but if there are not enough points for 5-point smoothing, it does 3-point smoothing, and if there are not enough points even for 3-p smoothing, it just returns the input

func SmoothBy3Points

func SmoothBy3Points(inData []float64, passesNum int) []float64

func SmoothBy5Points

func SmoothBy5Points(inData []float64, passesNum int) []float64

func Subtract

func Subtract(initialData []float64, deductibleData []float64) ([]float64, error)

func WMA

func WMA(inputData []float64, windowWidth int, expectedOutputDataLength int) ([]float64, error)

WMA - WeightedMovingAverage expectedOutputDataLength is the required parameter for self-control. It should be known BEFORE doing smoothing, and if it is calculated incorrectly you can't handle obtained result in a right way.

Types

type LineDefinedByParameters

type LineDefinedByParameters struct {
	ParamA float64
	ParamB float64
}

func FindEquationOfLineGivenByTwoPoints

func FindEquationOfLineGivenByTwoPoints(lineByTwoPoints LineDefinedByTwoPoints) (LineDefinedByParameters, error)

type LineDefinedByTwoPoints

type LineDefinedByTwoPoints struct {
	PointA PointCoordinates
	PointB PointCoordinates
}

type Numeric

type Numeric interface {
	int64 | float64 | int32 | float32 | int
}

type PointCoordinates

type PointCoordinates struct {
	X float64
	Y float64
}

func FindIntersectionPointOfTwoSegments

func FindIntersectionPointOfTwoSegments(lineA LineDefinedByTwoPoints, lineB LineDefinedByTwoPoints) (PointCoordinates, bool, error)

FindIntersectionPointOfTwoSegments - tries to solve a system of two linear equations and returns 3 parameters:

  1. Coordinates of intersection point if they are exist
  2. Boolean indicating if solution exists, or it does not for example, solution does not exist if: a) two lines are parallel, b) if intersection point exists, but it is outside of the common projection
  3. Error in other abnormal situation.

PLEASE NOTE: This function searches intersection of SEGMENTS, NOT LINES!!!

Jump to

Keyboard shortcuts

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