5 releases

0.3.0 Oct 31, 2023
0.2.4 Oct 3, 2023
0.2.3 Sep 12, 2023
0.2.1 Sep 3, 2023
0.2.0 Aug 29, 2023

#136 in Finance

MIT license

130KB
2K SLoC

Donate with Bitcoin! Donate with Ethereum! Donate with BNB!
crates.io version crates.io downloads

TATK, Technical Analysis Toolkit

The objective of this crate is analyzing signals and indicators of data and providing additional tools for accurate analysis. There are several other wonderful crates that implement similar algorithms, however they did not meet my personal needs or had minor errors in their calculations.

[dependencies]
tatk = { git = "https://github.com/ohkthx/tatk-rs" }

Features

  • Momentum / Moving Averages
    • Simple Moving Average (SMA)
    • Exponential Moving Average (EMA)
    • Double Exponential Moving Average (DEMA)
    • McGinley Dynamic Indicator (MD)
    • On-Balance Volume (OBV)
    • Rate of Change (ROC)
  • Oscillators
    • Relative Strength Index (RSI)
    • Moving Average Convergence and Divergence (MACD)
    • Bollinger Bands (BBands)
    • True Range (TR)
    • Average True Range (ATR)
  • Others
    • Linear Regression (LineReg)
    • Variance (Var(X))
    • Standard Deviation (SD/STDEV)
    • Cross (Cross), checks two lines for Golden or Death cross.
  • Macros, Traits, and Derives

Documentation

Most of the documentation can be accessed by clicking the following link: docs.rs. That documentation is automatically generated and also accessible from crates.io.

Traits

The following traits are either used by the crate on indicators or to be defined by the user for additional functionality.

  • Indicator
    • Stats - Basic statistics for the indicator such as: sum, mean, variance, and standard deviation.
    • Period - Period of window of the data for the indicator.
    • Next - Add a new data point to the indicator to recalculate value.
  • User Defined
    • AsValue - Alternative value that can be passed to an Indicators Next.
    • Open - Opening value for the data type.
    • Close - Closing value for the data type.
    • Low - Lowest value for the data type.
    • High - Highest value for the data type.
    • Volume - Total volume for the data type.
  • Others
    • Hl2 - Average of the Highest and Lowest values, requires High and Low to be defined.
    • Hlc3 - Average of the Highest, Lowest, and Close values, requires High, Low, and Close to be defined.
    • Ohlc4 - Average of the Open, Highest, Lowest, and Close values, requires Open, High, Low, and Close to be defined.

Examples

Following examples can be ran with: cargo run --example short_id

  • Simple Moving Average (SMA): sma.rs
  • Exponential Moving Average (EMA): ema.rs
  • Double Exponential Moving Average (DEMA): dema.rs
  • Moving Average Convergence Divergence (MACD): macd.rs
  • Relative Strength Indicator (RSI): rsi.rs
  • Bollinger Bands (BBands): bbands.rs
  • Average True Range (ATR): atr.rs
  • McGinley Dynamic Indicator (MD): md.rs
  • On-Balance Volume (OBV): obv.rs
  • Rate of Change (ROC): roc.rs
  • Linear Regression (LineReg): linereg.rs
  • Traits (Traits): user_traits.rs

Tips Appreciated!

Wallet addresses are provided below, or click the badges above!

Ethereum (ETH): 0x7d75f6a9c021fcc70691fec73368198823fb0f60
Bitcoin (BTC):  bc1q75w3cgutug8qdxw3jlmqnkjlv9alt3jr7ftha0
Binance (BNB):  0x7d75f6a9c021fcc70691fec73368198823fb0f60

Dependencies

~230–670KB
~16K SLoC