RustTI
A Technical Indicators library for Rust
What differentiates RustTI from other Technical Indicator packages is how configurable the functions are.
Many models were created decades ago when the work weeks were different (such as RSI, SO, Ichimoku cloud...) and the observations were made daily. For example, if one decides to study stocks the work week is 5 days, but if one studies cryptocurrencies the work week is 7 days.
RustTI allows the caller to determine their own period based on the market being studied. Everything is configurable in the RustTI functions, from period to moving average models.
A lot of online articles recommend sticking with the TI defaults as these are used by traders. I would recommend the opposite. While it is true that most day traders tend to stick to the defaults, large financial institutions such as investment banks and hedge funds have their own quantitative teams who build them custom models. This is what this package allows you to do.
Many of the functions accept parameters that allow the caller to move the technial indicators away from its default behaviour. For example, if a TI uses the mean to calculate the indicator, it can be told to use the median, or mode instead.
For this reason, RustTI is a more advanced Technical Inidcators package, and the users should have some base knowledge of the indicators they plan on using.
RustTI is split into different modules, organised by common TI areas. Each module is then split
into a single
and a bulk
submodule.
The single
submodule is used to calculate the indicator once, using the entire price slice
that is passed in.
The bulk
submodule is used to iterate over a slice of prices to calculate the indicator for a period.
Many of the functions accept parameters that will allow the caller to move away from the technial indicators from its default behaviour. For example, if a function normally uses the mean to calculate the indicator, it can be told to use the median, or mode instead. More information is given in the functions that allow this.
Documentation
Documentation can be found on DOCS.RS
rust_ti
S&P 500 Example
An example using the Rust TI for the S&P 500 can be found in examples/main.rs
The code in examples/main.rs
can be run by cloning this repo, then running the following commands:
cargo build
cargo run --example sp500
Available indicators:
Basic Indicators
basic_indicators
are basic functions that are often the foundation of more complex indicators.
Bulk
absolute_deviation
- Calculates the absolute deviationlog
- Calculates the natural logrithm of slice of priceslog_difference
- Calculates the difference between the natural logarithm at t and t-1mean
- Calculates the mean (average) of a slice of pricesmedian
- Calculates the median (middle value) of a slice of pricesmode
- Calculates the mode (most common price) of a slice of pricesstandard_deviation
- Calculates the standard deviation of a slice of pricesvariance
- Calculates the variance of slice of prices
Single
absolute_deviation
- Calculates the absolute deviationlog_difference
- Calculates the difference between the natural logarithm at t and t-1max
- Calculates the maximum of a slice of pricesmean
- Calculates the mean (average) of a slice of pricesmedian
- Calculates the median (middle value) of a slice of pricesmin
- Calculates the minimum of a slice of pricesmode
- Calculates the mode (most common price) of a slice of pricesstandard_deviation
- Calculates the standard deviation of a slice of pricesvariance
- Calculates the variance of slice of prices
Candle Indicators
candle_indicators
are indicators that are used with candle charts.
Bulk
ichimoku_cloud
- Calculates the Ichimoku Cloudmcginley_dynamic_bands
- The McGinley Dynamic version of themoving_constant_bands
mcginley_dynamic_envelopes
- The McGinley Dynamic version of themoving_constant_bands
- Calculates the moving constant bandsmoving_constant_envelopes
- Calculates the moving constant envelopes
Single
ichimoku_cloud
- Calculates the Ichimoku Cloudmcginley_dynamic_bands
- The McGinley Dynamic version of themoving_constant_bands
mcginley_dynamic_envelopes
- The McGinley Dynamic version of themoving_constant_bands
- Calculates the moving constant bandsmoving_constant_envelopes
- Calculates the moving
Chart Trends
chart_trends
shows trends on charts.
Unlike the other modules it has no bulk or single.
break_down_trends
- Breaks down the chart into different price trendsoverall_trend
- Calculates the overall trend for all price pointspeak_trend
- Calculates the trend of the peakspeaks
- Returns all the peaksvalley_trend
- Calculates trend of the valleysvalleys
- Returns all the valleys
Correlation indicators
correlation_indicators
show how closely the prices of two different assets move together.
Bulk
correlate_asset_prices
- Calculates the correlation between two assets
Single
correlate_asset_prices
- Calculates the correlation between two assets
Momentum Indicators
momentum_indicators
show how much the price is rising or falling
Bulk
chaikin_oscillator
- Calculates the Chaikin Oscillatorcommodity_channel_index
- Calculate the Commodity Channel Indexmacd_line
- Calculates the Moving Average Convergence Divergence linemcginley_dynamic_chaikin_oscillator
- Calculate the McGinley dynanic version of the Chaikin Oscillatormcginley_dynamic_commodity_channel_index
- Calculates the McGinley dynamic version of the Commodity Channel Indexmcginley_dynamic_macd_line
- Calculates the McGinley dynamic version of the Moving Average Convergence Divergence linemcginley_dynamic_rsi
- Calculates the McGinley dynamic version of the Relative Strength Indexmoney_flow_index
- Calculates the Money Flow Indexon_balance_volume
- Calculates the On-balance Volumerate_of_change
- Calculates the Rate of Changerelative_strength_index
- Calculates the Relative Strength Indexsignal_line
- Calculates the Signal line to be used with the MACD lineslow_stochastic
- Calculates the slow stochastic to be used with the stochastic oscillatorslowest_stochastic
- Calculates the slowest stochastic to be used with the stochastic oscillatorstochastic_oscillator
- Calculates the Stochastic Oscillatorwilliams_percent_r
- Calcualtes the Williams %R
Single
chaikin_oscillator
- Calculates the Chaikin Oscillatorcommodity_channel_index
- Calculate the Commodity Channel Indexmacd_line
- Calculates the Moving Average Convergence Divergence linemcginley_dynamic_chaikin_oscillator
- Calculate the McGinley dynanic version of the Chaikin Oscillatormcginley_dynamic_commodity_channel_index
- Calculates the McGinley dynamic version of the Commodity Channel Indexmcginley_dynamic_macd_line
- Calculates the McGinley dynamic version of the Moving Average Convergence Divergence linemcginley_dynamic_rsi
- Calculates the McGinley dynamic version of the Relative Strength Indexmoney_flow_index
- Calculates the Money Flow Indexon_balance_volume
- Calculates the On-balance Volumerate_of_change
- Calculates the Rate of Changerelative_strength_index
- Calculates the Relative Strength Indexsignal_line
- Calculates the Signal line to be used with the MACD lineslow_stochastic
- Calculates the slow stochastic to be used with the stochastic oscillatorslowest_stochastic
- Calculates the slowest stochastic to be used with the stochastic oscillatorstochastic_oscillator
- Calculates the Stochastic Oscillatorwilliams_percent_r
- Calcualtes the Williams %R
Moving Averages
The moving_average
module has functions used to calculate the moving average
Bulk
mcginley_dynamic
- Calculates the McGinley Dynamicmoving_average
- Calculates different types Moving Averages
Single
mcginley_dynamic
- Calculates the McGinley Dynamicmoving_average
- Calculates different types Moving Averages
Other Indicators
other_indicators
don't really fit in anywhere else
Bulk
return_on_investment
- Calculates the return on investment
Single
return_on_investment
- Calculates the return on investment
Strength Indicators
strength_indicators
show the strength of a trend
Bulk
accumulation_distribution
- Calculates the Accumulation Distribution
Single
accumulation_distribution
- Calculates the Accumulation Distribution
Trend Indicators
trend_indicators
show the trend direction of an asset
Bulk
aroon_down
- Calculates the Aroon downaroon_indicator
- Calculates the Aroon indicatoraroon_oscillator
- Calculates the Aroon Oscillatoraroon_up
- Calculates the Aroon upparabolic_time_price_system
- Calculates the parabolic time price system
Single
aroon_down
- Calculates the Aroon downaroon_indicator
- Calculates the Aroon indicatoraroon_oscillator
- Calculates the Aroon Oscillatoraroon_up
- Calculates the Aroon uplong_parabolic_time_price_system
- Calculates the parabolic time price system for long positionsshort_parabolic_time_price_system
- Calculates the parabolic time price system for short positions
Volatility Indicators
volatility_indicators
show how volatile an asset are.
Bulk
ulcer_index
- Calculates the Ulcer Index
Single
ulcer_index
- Calculates the Ulcer Index