Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/micahparks/go-chaikin
The Chaikin Oscillator technical analysis algorithm implemented in Golang.
https://github.com/micahparks/go-chaikin
chaikin chaikin-algorithm go golang technical-analysis
Last synced: about 6 hours ago
JSON representation
The Chaikin Oscillator technical analysis algorithm implemented in Golang.
- Host: GitHub
- URL: https://github.com/micahparks/go-chaikin
- Owner: MicahParks
- License: mit
- Created: 2021-11-14T16:56:30.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-02T14:49:21.000Z (11 days ago)
- Last Synced: 2025-01-02T15:34:18.469Z (11 days ago)
- Topics: chaikin, chaikin-algorithm, go, golang, technical-analysis
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go Reference](https://pkg.go.dev/badge/github.com/MicahParks/go-chaikin.svg)](https://pkg.go.dev/github.com/MicahParks/go-chaikin) [![Go Report Card](https://goreportcard.com/badge/github.com/MicahParks/go-chaikin)](https://goreportcard.com/report/github.com/MicahParks/go-chaikin)
# go-chaikin
The Chaikin Oscillator technical analysis algorithm implemented in Golang.```go
import "github.com/MicahParks/go-chaikin"
```# Usage
For full examples, please see the `examples` directory.## Step 1
Gather the initial input. This is 10 periods of inputs for the Accumulation Distribution Line. It is the minimum number
of periods required to produce one result for the Chaikin Oscillator. The value, `10` is stored in `chaikin.LongEMA`
constant.The input must be put into an array, not a slice. Make sure to fill all 10 indices of the array.
```go
initial := [chaikin.LongEMA]ad.Input{}
for i := 0; i < chaikin.LongEMA; i++ {
initial[i] = ad.Input{
Close: closePrices[i],
Low: low[i],
High: high[i],
Volume: volume[i],
}
}
```## Step 2
Create the Chaikin Oscillator data structure from the initial input array. This will also produce the first Chaikin
Oscillator point as well as its corresponding Accumulation Distribution Line point.
```go
cha, firstResult, adLine := chaikin.New(initial)
```## Step 3
Use the subsequent periods to calculate the next points for the Chaikin Oscillator and Accumulation Distribution Line.
```go
result, adLine = cha.Calculate(ad.Input{
Close: closePrices[i],
Low: low[i],
High: high[i],
Volume: volume[i],
})
```# Somewhat complete example (without data)
```go
package mainimport (
"log"
"os""github.com/MicahParks/go-ad"
"github.com/MicahParks/go-chaikin"
)func main() {
// Create a logger.
logger := log.New(os.Stdout, "", 0)// Create the initial input.
initial := [chaikin.LongEMA]ad.Input{}
for i := 0; i < chaikin.LongEMA; i++ {
initial[i] = ad.Input{
Close: closePrices[i],
Low: low[i],
High: high[i],
Volume: volume[i],
}
}// Create the Chaikin Oscillator data structure as well as its first data point and the corresponding Accumulation
// Distribution Line point.
cha, result, adLine := chaikin.New(initial)
logger.Printf("%.4f, %.4f", adLine, result)// Use every subsequent period's data to calculate the next points on the Chaikin Oscillator and Accumulation
// Distribution Line.
for i := range open[chaikin.LongEMA:] {
i += chaikin.LongEMAresult, adLine = cha.Calculate(ad.Input{
Close: closePrices[i],
Low: low[i],
High: high[i],
Volume: volume[i],
})
logger.Printf("%.4f, %.4f", adLine, result)
}
}
```# 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-chaikin
cpu: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
BenchmarkChaikin_Calculate-6 1000000000 0.0000017 ns/op
BenchmarkBigChaikin_Calculate-6 1000000000 0.0000891 ns/op
PASS
ok github.com/MicahParks/go-chaikin 0.004s
```# 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/c/chaikinoscillator.asp)
* [Invest Excel](https://investexcel.net/chaikin-oscillator-spreadsheet-vba/)