blas

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DoubleBottom = "W底"
	DoubleTop    = "M头"
)

Variables

This section is empty.

Functions

func Asc added in v0.5.9

func Asc[T cmp.Ordered](x, y T) int

Asc 升序

func Desc added in v0.5.9

func Desc[T cmp.Ordered](x, y T) int

Desc 降序

Types

type Analysis

type Analysis interface {
	// Normalize 归一化处理(Initialize)
	Normalize() error
	// Process 加工处理
	Process() error
	// At 获取数据, 返回即时值, 最高值, 最低值
	At(n int) (current, high, low float64)
	// Match 匹配
	Match()
}

Analysis 分析接口

type DataSample

type DataSample interface {
	Time(n int) string             // 时间
	Len() int                      // 数据长度
	Current(n int) float64         // 当前值
	High(n int) float64            // 最高
	Low(n int) float64             // 最低
	Volume(n int) float64          // 量
	Chart(name string) *plot.Chart // 图表
}

DataSample 数据样本

type KLineSample

type KLineSample struct {
	// contains filtered or unexported fields
}

KLineSample K线样板的实现

func LoadKLineSample

func LoadKLineSample(data []base.KLine) KLineSample

LoadKLineSample 加载K线样本

func (KLineSample) Chart added in v0.5.9

func (k KLineSample) Chart(name string) *plot.Chart

func (KLineSample) Current

func (k KLineSample) Current(n int) float64

func (KLineSample) High

func (k KLineSample) High(n int) float64

func (KLineSample) Len

func (k KLineSample) Len() int

func (KLineSample) Low

func (k KLineSample) Low(n int) float64

func (KLineSample) Time

func (k KLineSample) Time(n int) string

func (KLineSample) Volume added in v0.5.9

func (k KLineSample) Volume(n int) float64

type OperationalSignal

type OperationalSignal struct {
	Signal TendencyDirection // 操作信号
	Digits int               // 保留小数点几位
}

OperationalSignal 操作信号

type Pattern

type Pattern interface {
	// Fit 拟合, 输出支撑线, 颈线, 压力线
	Fit() (neckLine, supportLine, pressureLine num.Line)
	// ExportSeries 输出图表
	ExportSeries(sample DataSample) []plot.Series
	// NeckSeries 输出颈线
	NeckSeries(sample DataSample) []plot.Series
}

Pattern 模式, 形态

type TendencyDirection

type TendencyDirection = uint8

TendencyDirection 交易方向

const (
	TradingKeep              TendencyDirection = 0x00   // 持股
	TradingBuy               TendencyDirection = 1 << 6 // 买入,01xxxxxx
	TradingSell              TendencyDirection = 1 << 7 // 卖出,10xxxxxx
	TradingBottomDivergence  TendencyDirection = 0x01   // 底背离
	TradingTopDivergence     TendencyDirection = 0x02   // 顶背离
	TradingConsistentRise    TendencyDirection = 0x03   // 一致性上涨
	TradingConsistentDecline TendencyDirection = 0x04   // 一致性下跌
)

type Triangle added in v0.6.0

type Triangle struct {
	OperationalSignal
	Top         num.DataPoint // 顶或者底作为颈线
	Left        num.DataPoint // 左
	Right       num.DataPoint // 右
	PremiumRate float64       // 交易信号触发后的溢价率
	Name        string        // 形态名称
}

Triangle 三角形, W底和M头

双底的颈线有两个, 水平方向的TOP以及TOP于左右连线的平行线, 上升空间为top到底部区间的2倍

func MatchTriangle added in v0.6.0

func MatchTriangle(waves Waves) *Triangle

MatchTriangle 模式匹配 三角形

func (*Triangle) Analyze added in v0.6.0

func (this *Triangle) Analyze(data []float64) []num.LinerTrend

Analyze 趋势分析

func (*Triangle) Detect added in v0.6.0

func (this *Triangle) Detect(data []float64) (neck, support, pressure float64, neckTendency, supportTendency, pressureTendency int)

Detect 检测最近的趋势

func (*Triangle) Export added in v0.6.0

func (this *Triangle) Export(data []float64) []plot.Series

Export 导出趋势线图表数据

func (*Triangle) ExportSeries added in v0.6.0

func (this *Triangle) ExportSeries(sample DataSample) []plot.Series

func (*Triangle) Fit added in v0.6.0

func (this *Triangle) Fit() (neckLine, supportLine, pressureLine num.Line)

Fit 拟合

输出支撑线, 颈线, 压力线

func (*Triangle) IsUp added in v0.6.0

func (this *Triangle) IsUp() bool

IsUp 上W, 下M

func (*Triangle) Space added in v0.6.0

func (this *Triangle) Space(periods int)

Space 计算溢价空间

type Wave

type Wave struct {
	// contains filtered or unexported fields
}

Wave 波浪 波峰波谷

func FindPeaks added in v0.6.5

func FindPeaks(n int, data func(x int) float64) Wave

FindPeaks 波峰波谷

搜寻收盘价的高低点

type Waves

type Waves struct {
	Data        []float64       // 原始数据
	Peaks       []num.DataPoint // 波峰位置存储
	Valleys     []num.DataPoint // 波谷位置存储
	PeakCount   int             // 所识别的波峰计数
	ValleyCount int             // 所识别的波谷计数
	Digits      int             // 小数点几位
	State       int8            // 点状态
	LastHigh    num.DataPoint   // 最新的高点
	LastLow     num.DataPoint   // 最新的地点
}

Waves 波浪 波峰波谷

func HighAndLow added in v0.6.5

func HighAndLow(sample DataSample, code ...string) Waves

HighAndLow 关注低点高点变化的波浪

func PeaksAndValleys added in v0.6.1

func PeaksAndValleys(sample DataSample, code ...string) Waves

PeaksAndValleys 创建一个新的波浪

高点的波峰, 低点的波谷

func (Waves) Len added in v0.6.0

func (this Waves) Len() int

type WavesTendency added in v0.6.1

type WavesTendency = int

WavesTendency 波段趋势

const (
	TendencyPrice          WavesTendency = 0 // 股价主导
	TendencyLinear         WavesTendency = 1 // 线性趋势主导
	TendencyPriceAndLinear WavesTendency = 2 // 股价和趋势并存
)

type Wedge

type Wedge struct {
	OperationalSignal
	TopLeft     num.DataPoint // 顶 - 左
	TopRight    num.DataPoint // 顶 - 右
	BottomLeft  num.DataPoint // 底 - 左
	BottomRight num.DataPoint // 底 - 右
}

Wedge 楔形

func MatchWedge

func MatchWedge(waves Waves) *Wedge

MatchWedge 模式匹配 楔形

func (*Wedge) Cross added in v0.6.3

func (this *Wedge) Cross() (dp, top, bottom num.DataPoint, ok bool)

func (*Wedge) ExportSeries

func (this *Wedge) ExportSeries(sample DataSample) []plot.Series

func (*Wedge) Fit added in v0.6.1

func (this *Wedge) Fit() (neckLine, supportLine, pressureLine num.Line)

func (*Wedge) NeckLines added in v0.6.1

func (this *Wedge) NeckLines() []num.Line

func (*Wedge) NeckSeries added in v0.6.1

func (this *Wedge) NeckSeries(sample DataSample) []plot.Series

Jump to

Keyboard shortcuts

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