gota

package module
v0.0.0-...-8fa1ef7 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 1 Imported by: 0

README

Gota - Библиотека технического анализа на Go

Простая и эффективная библиотека для расчета технических индикаторов на финансовых данных.

📊 Поддерживаемые индикаторы

Трендовые индикаторы
  • SMA (Simple Moving Average) - Простая скользящая средняя
  • EMA (Exponential Moving Average) - Экспоненциальная скользящая средняя
  • WMA (Weighted Moving Average) - Взвешенная скользящая средняя
  • MACD (Moving Average Convergence/Divergence) - Cхождение/Расхождение скользящих средних
Индикаторы момента
  • RSI (Relative Strength Index) - Индекс относительной силы
Индикаторы волатильности
  • ATR (Average True Range) - Cредний истинный диапазон
  • Bollinger Bands - Линии(полосы) Боллинджера

🚀 Быстрый старт

Установка
import "github.com/egor-erm/gota/pkg/api"
Использование
package main

import (
    "fmt"
    "time"
    "github.com/egor-erm/gota/pkg/api"
    "github.com/egor-erm/gota/pkg/gota"
)

func main() {
    // Создание тестовых данных
    candles := createCandles()
    
    // Инициализация анализатора
    analyzer := api.NewAnalyzer(candles)
    
    // Расчет индикаторов
    sma := analyzer.SMA(10)    // SMA с периодом 10
    ema := analyzer.EMA(10)    // EMA с периодом 10
    rsi := analyzer.RSI(14)    // RSI с периодом 14
    
    fmt.Println("SMA:", sma)
    fmt.Println("EMA:", ema)
    fmt.Println("RSI:", rsi)
}

func createCandles() gota.CandleSeries {
    baseTime := time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC)
	closePrices := []float64{50.00, 52.25, 51.50, 49.75, 48.90, 51.10, 52.40,      54.20, 55.80, 56.50}
    
    candles := make([]gota.Candle, len(closePrices))
    for i := 0; i < len(closePrices); i++ {
        candles[i] = gota.NewCandle(
            baseTime.AddDate(0, 0, i),
            closePrices[i]-0.5,  // open
            closePrices[i]+1.0,  // high
            closePrices[i]-1.0,  // low
            closePrices[i],      // close
            1000.0,             // volume
        )
    }
    
    return candles
}
  • Больше примеров вы всегда можете посмотреть в папке /cmd

🔮 Планы по развитию

  • Добавление большего количества индикаторов
  • Визуализация результатов на графиках

📄 Лицензия

MIT License

✨ Можем обсудить общие планы по развитию библиотеки - https://t.me/erm_egor

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candle

type Candle struct {
	StartTime  time.Time `json:"start_time"`
	OpenPrice  float64   `json:"open"`
	HighPrice  float64   `json:"high"`
	LowPrice   float64   `json:"low"`
	ClosePrice float64   `json:"close"`
	Volume     float64   `json:"volume"`
}

Candle - структура для хранения данных по свече

func NewCandle

func NewCandle(startTime time.Time, open, high, low, close, volume float64) Candle

func (Candle) GetClosePrice

func (c Candle) GetClosePrice() float64

func (Candle) GetHighPrice

func (c Candle) GetHighPrice() float64

func (Candle) GetLowPrice

func (c Candle) GetLowPrice() float64

func (Candle) GetOpenPrice

func (c Candle) GetOpenPrice() float64

func (Candle) GetStartTime

func (c Candle) GetStartTime() time.Time

func (Candle) GetVolume

func (c Candle) GetVolume() float64

type CandleSeries

type CandleSeries []Candle

CandleSeries - структура для работы массивами свечей

func (CandleSeries) At

func (cs CandleSeries) At(index int) Candle

func (CandleSeries) Last

func (cs CandleSeries) Last(n int) CandleSeries

func (CandleSeries) LastMin

func (cs CandleSeries) LastMin(nums ...int) CandleSeries

func (CandleSeries) Len

func (cs CandleSeries) Len() int

func (CandleSeries) Slice

func (cs CandleSeries) Slice(start, end int) Series

type Series

type Series interface {
	Len() int
	At(index int) Candle
	Slice(start, end int) Series
}

Series - интерфейс для работы масивами данных

Directories

Path Synopsis
cmd
atr command
bollinger_bands command
ema command
macd command
rsi command
sma command
strategy command
visual command
wma command
indicators

Jump to

Keyboard shortcuts

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