Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micahparks/go-rsi
The Relative Strength Index (RSI) technical analysis algorithm implemented in Golang.
https://github.com/micahparks/go-rsi
go golang rsi techincal-analysis
Last synced: about 6 hours ago
JSON representation
The Relative Strength Index (RSI) technical analysis algorithm implemented in Golang.
- Host: GitHub
- URL: https://github.com/micahparks/go-rsi
- Owner: MicahParks
- License: mit
- Created: 2021-10-04T21:18:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-02T14:51:42.000Z (11 days ago)
- Last Synced: 2025-01-02T15:36:43.927Z (11 days ago)
- Topics: go, golang, rsi, techincal-analysis
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Reference](https://pkg.go.dev/badge/github.com/MicahParks/go-rsi/v2.svg)](https://pkg.go.dev/github.com/MicahParks/go-rsi/v2) [![Go Report Card](https://goreportcard.com/badge/github.com/MicahParks/go-rsi/v2)](https://goreportcard.com/report/github.com/MicahParks/go-rsi/v2)
# go-rsi
The Relative Strength Index (RSI) technical analysis algorithm implemented in Golang.```go
import "github.com/MicahParks/go-rsi/v2"
```# Usage
For full examples, please see the `examples` directory.## Preconditions
1. Gather test data.
2. Decide on the number of periods, `p`, for the RSI algorithm. Populate a slice of prices whose length is `p + 1`.```go
// Determine the number of periods for the initial inputs. Defaults to 14.
const initialLength = rsi.DefaultPeriods + 1
initial := prices[:initialLength]
```## Step 1
Create the RSI data structure and get the first result.
```go
r, result := rsi.New(initial)
```## Step 2
Use the remaining data to calculate the RSI value for that period.
```go
remaining := prices[initialLength:]
for i, next := range remaining {
result = r.Calculate(next)
}
```# Testing
There is 100% test coverage and benchmarks for this project. Here is an example benchmark result:
```
$ go test -bench .
goos: linux
goarch: amd64
pkg: github.com/MicahParks/go-rsi/v2
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
BenchmarkBigRSI_Calculate-6 1000000000 0.0001744 ns/op
BenchmarkRSI_Calculate-6 1000000000 0.0000017 ns/op
PASS
ok github.com/MicahParks/go-rsi/v2 0.005s
```# Other Technical Algorithms
Looking for some other technical analysis algorithms? Here are some other ones I've implemented:
* Accumulation/Distribution (A/D): [go-ad](https://github.com/MicahParks/go-ad)
* Chaikin: [go-chaikin](https://github.com/MicahParks/go-chaikin)
* Moving Average Convergence Divergence (MACD), Exponential Moving Average (EMA), Simple Moving Average (SMA):
[go-ma](https://github.com/MicahParks/go-ma)
* Relative Strength Index (RSI): [go-rsi](https://github.com/MicahParks/go-rsi)# Resources
I built and tested this package using these resources:
* [Investopedia](https://www.investopedia.com/terms/r/rsi.asp)
* [Invest Excel](https://investexcel.net/relative-strength-index-spreadsheet/)