{"repo":"sdcoffey/techan","free":true,"listed":false,"github":"https://github.com/sdcoffey/techan","clone":"git clone https://github.com/sdcoffey/techan.git","description":"Technical Analysis Library for Golang","language":"Go","stars":908,"topics":["bitcoin","cryptocurrency","go","golang","stock","stock-market","technical-analysis","trading-bot","trading-strategies"],"license":"MIT","category":"dev_tool","readme_excerpt":"## Techan\n![](https://travis-ci.org/sdcoffey/techan.svg?branch=master)\n\n[![codecov](https://codecov.io/gh/sdcoffey/techan/branch/master/graph/badge.svg)](https://codecov.io/gh/sdcoffey/techan)\n\nTechAn 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.\n\n## Features \n* Basic and advanced technical analysis indicators\n* Profit and trade analysis\n* Strategy building\n\n### Installation\n```sh\n$ go get github.com/sdcoffey/techan\n```\n\n### Quickstart\n```go\nseries := techan.NewTimeSeries()\n\n// fetch this from your preferred exchange\ndataset := [][]string{\n\t// Timestamp, Open, Close, High, Low, volume\n\t{\"1234567\", \"1\", \"2\", \"3\", \"5\", \"6\"},\n}\n\nfor _, datum := range dataset {\n\tstart, _ := strconv.ParseInt(datum[0], 10, 64)\n\tperiod := techan.NewTimePeriod(time.Unix(start, 0), time.Hour*24)\n\n\tcandle := techan.NewCandle(period)\n\tcandle.OpenPrice = big.NewFromString(datum[1])\n\tcandle.ClosePrice = big.NewFromString(datum[2])\n\tcandle.MaxPrice = big.NewFromString(datum[3])\n\tcandle.MinPrice = big.NewFromString(datum[4])\n\n\tseries.AddCandle(candle)\n}\n\nclosePrices := techan.NewClosePriceIndicator(series)\nmovingAverage := techan.NewEMAIndicator(closePrices, 10) // Create an exponential moving average with a window of 10\n\nif series.LastIndex() >= 9 {\n\tfmt.Println(movingAverage.Calculate(series.LastIndex()).FormattedString(2))\n}\n```\n\nWindowed indicators such as SMA and EMA return `0` until enough data exists to fill their first window. For example, a 10-period EMA starts producing calculated values at index `9`.\n\n### Creating trading strategies\n```go\nindicator := techan.NewClosePriceIndicator(series)\n\n// record trades on this object\nrecord := techan.NewTradingRecord()\n\nentryConstant := techan.NewConstantIndicator(30)\nexitConstant := techan.NewConstantIndicator(10)\n\n// Is satisfied when the price ema moves above 30 and the current position is new\nentryRule := techan.And(\n\ttechan.NewCrossUpIndicatorRule(entryConstant, indicator),\n\ttechan.PositionNewRule{})\n\t\n// Is satisfied when the price ema moves below 10 and the current position is open\nexitRule := techan.And(\n\ttechan.NewCrossDownIndicatorRule(indicator, exitConstant),\n\ttechan.PositionOpenRule{})\n\nstrategy := techan.RuleStrategy{\n\tUnstablePeriod: 10, // Period before which ShouldEnter and ShouldExit will always return false\n\tEntryRule:      entryRule,\n\tExitRule:       exitRule,\n}\n\nstrategy.ShouldEnter(0, record) // returns false\n```\n\n### Enjoying this project?\nAre you using techan in production? You can sponsor its development by buying me a coffee! ☕\n\n**ETH:** `0x2D9d3A1c16F118A3a59d0e446d574e1F01F62949`\n\n### Credits\nTechan 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.\n\n### License\n\nTechan is released under the MIT license. See [LICENSE](./LICENSE) for details.\n","default_branch":"main","files":97,"tree":[".codecov.yml",".github/workflows/test.yml",".gitignore","CHANGELOG.md","LICENSE","Makefile","README.md","analysis.go","analysis_test.go","cached_indicator.go","candle.go","candle_test.go","example/basic.go","example/strategy.go","go.mod","go.sum","indicator.go","indicator_aroon.go","indicator_aroon_test.go","indicator_average.go","indicator_average_test.go","indicator_average_true_range.go","indicator_average_true_range_test.go","indicator_basic.go","indicator_basic_test.go","indicator_bollinger_band.go","indicator_bollinger_band_test.go","indicator_cci.go","indicator_cci_test.go","indicator_constant.go","indicator_constant_test.go","indicator_derivative.go","indicator_derivative_test.go","indicator_difference.go","indicator_difference_test.go","indicator_exponential_moving_average.go","indicator_exponential_moving_average_test.go","indicator_fixed.go","indicator_fixed_test.go","indicator_gains.go","indicator_gains_test.go","indicator_keltner_channel.go","indicator_keltner_channel_test.go","indicator_macd.go","indicator_macd_test.go","indicator_maximum_drawdown.go","indicator_maximum_drawdown_test.go","indicator_maximum_value.go","indicator_maximum_value_test.go","indicator_mean_deviation.go","indicator_mean_deviation_test.go","indicator_minimum_value.go","indicator_minimum_value_test.go","indicator_modified_moving_average.go","indicator_modified_moving_average_test.go","indicator_relative_strength.go","indicator_relative_strength_test.go","indicator_relative_vigor_index.go","indicator_relative_vigor_index_test.go","indicator_simple_moving_average.go","indicator_simple_moving_average_test.go","indicator_standard_deviation.go","indicator_standard_deviation_test.go","indicator_stochastic_oscillator.go","indicator_stochastic_oscillator_test.go","indicator_trend.go","indicator_trend_test.go","indicator_true_range.go","indicator_true_range_test.go","indicator_variance.go","indicator_variance_test.go","indicator_windowed_standard_deviation.go","math.go","math_test.go","order.go","position.go","position_test.go","rule.go","rule_cross.go","rule_cross_test.go","rule_increase_decrease.go","rule_increase_decrease_test.go","rule_position.go","rule_position_test.go","rule_stop.go","rule_stop_test.go","rule_test.go","scripts/release.sh","strategy.go","strategy_test.go","testutils.go","timeperiod.go","timeperiod_test.go","timeseries.go","timeseries_test.go","tradingrecord.go","tradingrecord_test.go"],"storefront":"/r/sdcoffey","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sdcoffey/techan/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}