Indicator is a Golang module that provides a rich set of technical analysis indicators, strategies, and a framework for backtesting.
- Enhanced Code Quality: A complete rewrite was undertaken to achieve and maintain at least 90% code coverage.
- Improved Testability: Each indicator and strategy have dedicated test data in CSV format for easier validation.
- Streamlined Data Handling: The library was rewritten to operate on data streams (Go channels) for both inputs and outputs. If you prefer using slices, helper functions like helper.SliceToChan and helper.ChanToSlice are available. Alternatively, you can still use the v1 version.
- Configurable Indicators and Strategies: All indicators and strategies were designed to be fully configurable with no preset values.
- Generics Support: The library leverages Golang generics to support various numeric data formats.
I also have a TypeScript version of this module now at Indicator TS.
The following list of indicators are currently supported by this package:
- Absolute Price Oscillator (APO)
- Aroon Indicator
- Balance of Power (BoP)
- Chande Forecast Oscillator (CFO)
- Community Channel Index (CCI)
- Envelope
- Hull Moving Average (HMA)
- Double Exponential Moving Average (DEMA)
- Exponential Moving Average (EMA)
- Kaufman's Adaptive Moving Average (KAMA)
- Mass Index (MI)
- Moving Average Convergence Divergence (MACD)
- Moving Least Square (MLS)
- Moving Linear Regression (MLR)
- Moving Max
- Moving Min
- Moving Sum
- Parabolic SAR
- Random Index (KDJ)
- Rolling Moving Average (RMA)
- Simple Moving Average (SMA)
- Since Change
- Triple Exponential Moving Average (TEMA)
- Triangular Moving Average (TRIMA)
- Triple Exponential Average (TRIX)
- True Strength Index (TSI)
- Typical Price
- Volume Weighted Moving Average (VWMA)
- Vortex Indicator
- Weighted Moving Average (WMA)
- Awesome Oscillator
- Chaikin Oscillator
- Ichimoku Cloud
- Percentage Price Oscillator (PPO)
- Percentage Volume Oscillator (PVO)
- Relative Strength Index (RSI)
- Qstick
- Stochastic Oscillator
- Stochastic RSI
- Williams R
- Acceleration Bands
- Actual True Range (ATR)
- Bollinger Band Width
- Bollinger Bands
- Chandelier Exit
- Donchian Channel (DC)
- Keltner Channel (KC)
- Moving Standard Deviation (Std)
- Projection Oscillator (PO)
- Super Trend
- Ulcer Index (UI)
- Accumulation/Distribution (A/D)
- Chaikin Money Flow (CMF)
- Ease of Movement (EMV)
- Force Index (FI)
- Money Flow Index (MFI)
- Money Flow Multiplier (MFM)
- Money Flow Volume (MFV)
- Negative Volume Index (NVI)
- On-Balance Volume (OBV)
- Volume Price Trend (VPT)
- Volume Weighted Average Price (VWAP)
The following list of strategies are currently supported by this package:
- Absolute Price Oscillator (APO) Strategy
- Aroon Strategy
- Balance of Power (BoP) Strategy
- Chande Forecast Oscillator Strategy
- Community Channel Index (CCI) Strategy
- Double Exponential Moving Average (DEMA) Strategy
- Golden Cross Strategy
- Kaufman's Adaptive Moving Average (KAMA) Strategy
- Moving Average Convergence Divergence (MACD) Strategy
- Qstick Strategy
- Random Index (KDJ) Strategy
- Triangular Moving Average (TRIMA) Strategy
- Triple Exponential Average (TRIX) Strategy
- Triple Moving Average Crossover Strategy
- True Strength Index (TSI) Strategy
- Volume Weighted Moving Average (VWMA) Strategy
- Awesome Oscillator Strategy
- RSI Strategy
- Stochastic RSI Strategy
- Williams R Strategy
- Bollinger Bands Strategy
- Projection Oscillator Strategy
- Chaikin Money Flow Strategy
- Ease of Movement Strategy
- Force Index Strategy
- Money Flow Index Strategy
- Negative Volume Index Strategy
- Volume Weighted Average Price Strategy
Compound strategies merge multiple strategies to produce integrated recommendations. They combine individual strategies' recommendations using various decision-making logic.
Decorator strategies offer a way to alter the recommendations of other strategies.
Repository serves as a centralized storage and retrieval location for asset snapshots.
The following repository implementations are provided.
The Sync function facilitates the synchronization of assets between designated source and target repositories by employing multi-worker concurrency for enhanced efficiency. This function serves the purpose of procuring the most recent snapshots from remote repositories and seamlessly transferring them to local repositories, such as file system repositories.
The indicator-sync
command line tool also offers the capability of synchronizing data between the Tiingo Repository and the File System Repository. To illustrate its usage, consider the following example command:
$ indicator-sync \
-source-name tiingo \
-source-config $TIINGO_KEY \
-target-name filesystem \
-target-config /home/user/assets \
-days 30
This command effectively retrieves the most recent snapshots for assets residing within the /home/user/assets
directory from the Tiingo Repository. In the event that the local asset file is devoid of content, it automatically extends its reach to synchronize 30 days' worth of snapshots, ensuring a comprehensive and up-to-date repository.
The Backtest functionality, using the Outcome, rigorously evaluates the potential performance of the specified strategies applied to a defined set of assets. It generates comprehensive visual representations for each strategy-asset pairing.
backtest := strategy.NewBacktest(repository, outputDir)
backtest.Names = append(backtest.Names, "brk-b")
backtest.Strategies = append(backtest.Strategies, trend.NewApoStrategy())
err = backtest.Run()
if err != nil {
t.Fatal(err)
}
The indicator-backtest
command line tool empowers users to conduct comprehensive backtesting of assets residing within a specified repository. This capability encompasses the application of all currently recognized strategies, culminating in the generation of detailed reports within a designated output directory.
$ indicator-backtest \
-source-name filesystem \
-source-config /home/user/assets \
-output /home/user/reports \
-workers 1
Install package.
go get github.com/cinar/indicator/v2
Import indicator.
import (
"github.com/cinar/indicator/v2"
)
Anyone can contribute to Indicator library. Please make sure to read our Contributor Covenant Code of Conduct guide first. Follow the How to Contribute to Indicator to contribute. Signining a Contributor Agreement is also required to contribute to the project.
The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.
The v2.x.x
and above are dual-licensed under GNU AGPLv3 License and a commercial license. For free use and modifications of the code, you can use the AGPLv3 license. If you require commercial license with different terms, please contact me.
Copyright (c) 2021-2024 Onur Cinar.
The source code is provided under GNU AGPLv3 License.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
The version v1.x.x
is provided under MIT License.
Copyright (c) 2021-2024 Onur Cinar.
The source code is provided under MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.