Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdcoffey/techan
Technical Analysis Library for Golang
https://github.com/sdcoffey/techan
bitcoin cryptocurrency go golang stock stock-market technical-analysis trading-bot trading-strategies
Last synced: about 2 months ago
JSON representation
Technical Analysis Library for Golang
- Host: GitHub
- URL: https://github.com/sdcoffey/techan
- Owner: sdcoffey
- License: mit
- Created: 2017-03-08T03:04:08.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-09-13T21:16:18.000Z (about 1 year ago)
- Last Synced: 2024-07-31T20:51:36.163Z (4 months ago)
- Topics: bitcoin, cryptocurrency, go, golang, stock, stock-market, technical-analysis, trading-bot, trading-strategies
- Language: Go
- Homepage: https://godoc.org/github.com/sdcoffey/techan
- Size: 180 KB
- Stars: 817
- Watchers: 53
- Forks: 143
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - techan - Technical analysis library with advanced market analysis and trading strategies. (Financial / Search and Analytic Databases)
- awesome-crypto-trading-bots - TechAn - TechAn is a technical analysis library for Go! It provides basic and advanced technical analysis indicators, profit and trade analysis and strategy building. (Technical analysis libraries)
- awesome-crypto-trading-bots - TechAn - TechAn is a technical analysis library for Go! It provides basic and advanced technical analysis indicators, profit and trade analysis and strategy building. (Technical analysis libraries)
- awesome-go - techan - Technical Analysis Library for Golang - ★ 76 (Financial)
- awesome-go-extra - techan - 03-08T03:04:08Z|2022-05-12T18:10:57Z| (Financial / Advanced Console UIs)
- awesome - techan - Technical Analysis Library for Golang (Go)
README
## Techan
![](https://travis-ci.org/sdcoffey/techan.svg?branch=master)[![codecov](https://codecov.io/gh/sdcoffey/techan/branch/master/graph/badge.svg)](https://codecov.io/gh/sdcoffey/techan)
TechAn is a **tech**nical **an**alysis library for Go! It provides a suite of tools and frameworks to analyze financial data and make trading decisions.
## Features
* Basic and advanced technical analysis indicators
* Profit and trade analysis
* Strategy building### Installation
```sh
$ go get github.com/sdcoffey/techan
```### Quickstart
```go
series := techan.NewTimeSeries()// fetch this from your preferred exchange
dataset := [][]string{
// Timestamp, Open, Close, High, Low, volume
{"1234567", "1", "2", "3", "5", "6"},
}for _, datum := range dataset {
start, _ := strconv.ParseInt(datum[0], 10, 64)
period := techan.NewTimePeriod(time.Unix(start, 0), time.Hour*24)candle := techan.NewCandle(period)
candle.OpenPrice = big.NewFromString(datum[1])
candle.ClosePrice = big.NewFromString(datum[2])
candle.MaxPrice = big.NewFromString(datum[3])
candle.MinPrice = big.NewFromString(datum[4])series.AddCandle(candle)
}closePrices := techan.NewClosePriceIndicator(series)
movingAverage := techan.NewEMAIndicator(closePrices, 10) // Create an exponential moving average with a window of 10fmt.Println(movingAverage.Calculate(0).FormattedString(2))
```### Creating trading strategies
```go
indicator := techan.NewClosePriceIndicator(series)// record trades on this object
record := techan.NewTradingRecord()entryConstant := techan.NewConstantIndicator(30)
exitConstant := techan.NewConstantIndicator(10)// Is satisfied when the price ema moves above 30 and the current position is new
entryRule := techan.And(
techan.NewCrossUpIndicatorRule(entryConstant, indicator),
techan.PositionNewRule{})
// Is satisfied when the price ema moves below 10 and the current position is open
exitRule := techan.And(
techan.NewCrossDownIndicatorRule(indicator, exitConstant),
techan.PositionOpenRule{})strategy := techan.RuleStrategy{
UnstablePeriod: 10, // Period before which ShouldEnter and ShouldExit will always return false
EntryRule: entryRule,
ExitRule: exitRule,
}strategy.ShouldEnter(0, record) // returns false
```### Enjoying this project?
Are you using techan in production? You can sponsor its development by buying me a coffee! ☕**ETH:** `0x2D9d3A1c16F118A3a59d0e446d574e1F01F62949`
### Credits
Techan is heavily influenced by the great [ta4j](https://github.com/ta4j/ta4j). Many of the ideas and frameworks in this library owe their genesis to the great work done over there.### License
Techan is released under the MIT license. See [LICENSE](./LICENSE) for details.