doc: add description about indicators generated by chatgpt

This commit is contained in:
zenix 2022-12-13 14:02:38 +09:00
parent 38461167ba
commit 2b62616513
23 changed files with 293 additions and 38 deletions

View File

@ -10,6 +10,14 @@ import (
// Refer: Arnaud Legoux Moving Average
// Refer: https://capital.com/arnaud-legoux-moving-average
// Also check https://github.com/DaveSkender/Stock.Indicators/blob/main/src/a-d/Alma/Alma.cs
//
// The Arnaud Legoux Moving Average (ALMA) is a technical analysis indicator that is used to smooth price data and reduce the lag associated
// with traditional moving averages. It was developed by Arnaud Legoux and is based on the weighted moving average, with the weighting factors
// determined using a Gaussian function. The ALMA is calculated by taking the weighted moving average of the input data using weighting factors
// that are based on the standard deviation of the data and the specified length of the moving average. This resulting average is then plotted
// on the price chart as a line, which can be used to make predictions about future price movements. The ALMA is typically more responsive to
// changes in the underlying data than a simple moving average, but may be less reliable in trending markets.
//
// @param offset: Gaussian applied to the combo line. 1->ema, 0->sma
// @param sigma: the standard deviation applied to the combo line. This makes the combo line sharper
//go:generate callbackgen -type ALMA

View File

@ -11,6 +11,14 @@ import (
// ATRP is the average true range percentage
// See also https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/atrp
//
// The Average True Range Percentage (ATRP) is a technical analysis indicator that measures the volatility of a security's price. It is
// calculated by dividing the Average True Range (ATR) of the security by its closing price, and then multiplying the result by 100 to convert
// it to a percentage. The ATR is a measure of the range of a security's price, taking into account gaps between trading periods and any limit
// moves (sharp price movements that are allowed under certain exchange rules). The ATR is typically smoothed using a moving average to make it
// more responsive to changes in the underlying price data. The ATRP is a useful indicator for traders because it provides a way to compare the
// volatility of different securities, regardless of their individual prices. It can also be used to identify potential entry and exit points
// for trades based on changes in the security's volatility.
//
// Calculation:
//
// ATRP = (Average True Range / Close) * 100

View File

@ -10,6 +10,15 @@ import (
// Refer: Commodity Channel Index
// Refer URL: http://www.andrewshamlet.net/2017/07/08/python-tutorial-cci
// with modification of ddof=0 to let standard deviation to be divided by N instead of N-1
//
// The Commodity Channel Index (CCI) is a technical analysis indicator that is used to identify potential overbought or oversold conditions
// in a security's price. It was originally developed for use in commodity markets, but can be applied to any security that has a sufficient
// amount of price data. The CCI is calculated by taking the difference between the security's typical price (the average of its high, low, and
// closing prices) and its moving average, and then dividing the result by the mean absolute deviation of the typical price. This resulting value
// is then plotted as a line on the price chart, with values above +100 indicating overbought conditions and values below -100 indicating
// oversold conditions. The CCI can be used by traders to identify potential entry and exit points for trades, or to confirm other technical
// analysis signals.
//go:generate callbackgen -type CCI
type CCI struct {
types.SeriesBase

View File

@ -7,6 +7,13 @@ import (
// Refer: Double Exponential Moving Average
// Refer URL: https://investopedia.com/terms/d/double-exponential-moving-average.asp
//
// The Double Exponential Moving Average (DEMA) is a technical analysis indicator that is used to smooth price data and reduce the lag
// associated with traditional moving averages. It is calculated by taking the exponentially weighted moving average of the input data,
// and then taking the exponentially weighted moving average of that result. This double-smoothing process helps to eliminate much of the noise
// in the original data and provides a more accurate representation of the underlying trend. The DEMA line is then plotted on the price chart,
// which can be used to make predictions about future price movements. The DEMA is typically more responsive to changes in the underlying data
// than a simple moving average, but may be less reliable in trending markets.
//go:generate callbackgen -type DEMA
type DEMA struct {

View File

@ -10,8 +10,15 @@ import (
// Refer: https://github.com/twopirllc/pandas-ta/blob/main/pandas_ta/trend/adx.py
//
// Directional Movement Index
// an indicator developed by J. Welles Wilder in 1978 that identifies in which
// direction the price of an asset is moving.
//
// The Directional Movement Index (DMI) is a technical analysis indicator that is used to identify the direction and strength of a trend
// in a security's price. It was developed by J. Welles Wilder and is based on the concept of the +DI and -DI lines, which measure the strength
// of upward and downward price movements, respectively. The DMI is calculated by taking the difference between the +DI and -DI lines, and then
// smoothing the result using a moving average. This resulting line is called the Average Directional Index (ADX), and is used to identify whether
// a security is trending or not. If the ADX is above a certain threshold, typically 20, it indicates that the security is in a strong trend,
// and if it is below that threshold it indicates that the security is in a sideways or choppy market. The DMI can be used by traders to confirm
// the direction and strength of a trend, or to identify potential entry and exit points for trades.
//go:generate callbackgen -type DMI
type DMI struct {
types.IntervalWindow

View File

@ -10,6 +10,14 @@ import (
// Refer: https://tradingview.com/script/aDymGrFx-Drift-Study-Inspired-by-Monte-Carlo-Simulations-with-BM-KL/
// Brownian Motion's drift factor
// could be used in Monte Carlo Simulations
//
// In the context of Brownian motion, drift can be measured by calculating the simple moving average (SMA) of the logarithm
// of the price changes of a security over a specified period of time. This SMA can be used to identify the long-term trend
// or bias in the random movement of the security's price. A security with a positive drift is said to be trending upwards,
// while a security with a negative drift is said to be trending downwards. Drift can be used by traders to identify potential
// entry and exit points for trades, or to confirm other technical analysis signals.
// It is typically used in conjunction with other indicators to provide a more comprehensive view of the security's price.
//go:generate callbackgen -type Drift
type Drift struct {
types.SeriesBase

View File

@ -6,6 +6,11 @@ import (
// Refer: Ease of Movement
// Refer URL: https://www.investopedia.com/terms/e/easeofmovement.asp
// The Ease of Movement (EOM) is a technical analysis indicator that is used to measure the relationship between the volume of a security
// and its price movement. It is calculated by dividing the difference between the high and low prices of the security by the total
// volume of the security over a specified period of time, and then multiplying the result by a constant factor. This resulting value is
// then plotted on the price chart as a line, which can be used to make predictions about future price movements. The EOM is typically
// used to identify periods of high or low trading activity, and can be used to confirm other technical analysis signals.
//go:generate callbackgen -type EMV
type EMV struct {

View File

@ -7,6 +7,15 @@ import (
"github.com/c9s/bbgo/pkg/types"
)
// Fisher Transform
//
// The Fisher Transform is a technical analysis indicator that is used to identify potential turning points in the price of a security.
// It is based on the idea that prices tend to be normally distributed, with most price movements being small and relatively insignificant.
// The Fisher Transform converts this normal distribution into a symmetrical, Gaussian distribution, with a peak at zero and a range of -1 to +1.
// This transformation allows for more accurate identification of price extremes, which can be used to make predictions about potential trend reversals.
// The Fisher Transform is calculated by taking the natural logarithm of the ratio of the security's current price to its moving average,
// and then double-smoothing the result. This resulting line is called the Fisher Transform line, and can be plotted on the price chart
// along with the security's price.
//go:generate callbackgen -type FisherTransform
type FisherTransform struct {
types.SeriesBase

View File

@ -7,6 +7,13 @@ import (
)
// Geometric Moving Average
//
// The Geometric Moving Average (GMA) is a technical analysis indicator that uses the geometric mean of a set of data points instead of
// the simple arithmetic mean used by traditional moving averages. It is calculated by taking the nth root of the product of the last n
// data points, where n is the length of the moving average. The resulting average is then plotted on the price chart as a line, which can
// be used to make predictions about future price movements. Because the GMA gives more weight to recent data points, it is typically more
// responsive to changes in the underlying data than a simple moving average.
//go:generate callbackgen -type GMA
type GMA struct {
types.SeriesBase

View File

@ -8,6 +8,12 @@ import (
// Refer: Hull Moving Average
// Refer URL: https://fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/hull-moving-average
//
// The Hull Moving Average (HMA) is a technical analysis indicator that uses a weighted moving average to reduce the lag in simple moving averages.
// It was developed by Alan Hull, who sought to create a moving average that was both fast and smooth. The HMA is calculated by first taking
// the weighted moving average of the input data using a weighting factor of W, where W is the square root of the length of the moving average.
// The result is then double-smoothed by taking the weighted moving average of this result using a weighting factor of W/2. This final average
// forms the HMA line, which can be used to make predictions about future price movements.
//go:generate callbackgen -type HULL
type HULL struct {
types.SeriesBase

View File

@ -7,13 +7,17 @@ import (
"github.com/c9s/bbgo/pkg/types"
)
/*
macd implements moving average convergence divergence indicator
// macd implements moving average convergence divergence indicator
//
// Moving Average Convergence Divergence (MACD)
// - https://www.investopedia.com/terms/m/macd.asp
// - https://school.stockcharts.com/doku.php?id=technical_indicators:macd-histogram
// The Moving Average Convergence Divergence (MACD) is a technical analysis indicator that is used to measure the relationship between
// two moving averages of a security's price. It is calculated by subtracting the longer-term moving average from the shorter-term moving
// average, and then plotting the resulting value on the price chart as a line. This line is known as the MACD line, and is typically
// used to identify potential buy or sell signals. The MACD is typically used in conjunction with a signal line, which is a moving average
// of the MACD line, to generate more accurate buy and sell signals.
Moving Average Convergence Divergence (MACD)
- https://www.investopedia.com/terms/m/macd.asp
- https://school.stockcharts.com/doku.php?id=technical_indicators:macd-histogram
*/
type MACDConfig struct {
types.IntervalWindow // 9

View File

@ -12,6 +12,13 @@ obv implements on-balance volume indicator
On-Balance Volume (OBV) Definition
- https://www.investopedia.com/terms/o/onbalancevolume.asp
On-Balance Volume (OBV) is a technical analysis indicator that uses volume information to predict changes in stock price.
The idea behind OBV is that volume precedes price: when the OBV is rising, it means that buyers are becoming more aggressive and
that the stock price is likely to follow suit. When the OBV is falling, it indicates that sellers are becoming more aggressive and
that the stock price is likely to decrease. OBV is calculated by adding the volume on days when the stock price closes higher and
subtracting the volume on days when the stock price closes lower. This running total forms the OBV line, which can then be used
to make predictions about future stock price movements.
*/
//go:generate callbackgen -type OBV
type OBV struct {

View File

@ -13,6 +13,14 @@ const MaxNumOfRMATruncateSize = 500
// Running Moving Average
// Refer: https://github.com/twopirllc/pandas-ta/blob/main/pandas_ta/overlap/rma.py#L5
// Refer: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.ewm.html#pandas-dataframe-ewm
//
// The Running Moving Average (RMA) is a technical analysis indicator that is used to smooth price data and reduce the lag associated
// with traditional moving averages. It is calculated by taking the weighted moving average of the input data, with the weighting factors
// determined by the length of the moving average. The resulting average is then plotted on the price chart as a line, which can be used to
// make predictions about future price movements. The RMA is typically more responsive to changes in the underlying data than a simple
// moving average, but may be less reliable in trending markets. It is often used in conjunction with other technical analysis indicators
// to confirm signals or provide additional information about the security's price.
//go:generate callbackgen -type RMA
type RMA struct {
types.SeriesBase

View File

@ -8,11 +8,16 @@ import (
"github.com/c9s/bbgo/pkg/types"
)
/*
rsi implements Relative Strength Index (RSI)
// rsi implements Relative Strength Index (RSI)
// https://www.investopedia.com/terms/r/rsi.asp
//
// The Relative Strength Index (RSI) is a technical analysis indicator that is used to measure the strength of a security's price. It is
// calculated by taking the average of the gains and losses of the security over a specified period of time, and then dividing the average gain
// by the average loss. This resulting value is then plotted as a line on the price chart, with values above 70 indicating overbought conditions
// and values below 30 indicating oversold conditions. The RSI can be used by traders to identify potential entry and exit points for trades,
// or to confirm other technical analysis signals. It is typically used in conjunction with other indicators to provide a more comprehensive
// view of the security's price.
https://www.investopedia.com/terms/r/rsi.asp
*/
//go:generate callbackgen -type RSI
type RSI struct {
types.SeriesBase

View File

@ -9,12 +9,16 @@ import (
const DPeriod int = 3
/*
stoch implements stochastic oscillator indicator
// Stochastic Oscillator
// - https://www.investopedia.com/terms/s/stochasticoscillator.asp
//
// The Stochastic Oscillator is a technical analysis indicator that is used to identify potential overbought or oversold conditions
// in a security's price. It is calculated by taking the current closing price of the security and comparing it to the high and low prices
// over a specified period of time. This comparison is then plotted as a line on the price chart, with values above 80 indicating overbought
// conditions and values below 20 indicating oversold conditions. The Stochastic Oscillator can be used by traders to identify potential
// entry and exit points for trades, or to confirm other technical analysis signals. It is typically used in conjunction with other indicators
// to provide a more comprehensive view of the security's price.
Stochastic Oscillator
- https://www.investopedia.com/terms/s/stochasticoscillator.asp
*/
//go:generate callbackgen -type STOCH
type STOCH struct {
types.IntervalWindow

View File

@ -12,6 +12,17 @@ import (
var logst = logrus.WithField("indicator", "supertrend")
// The Super Trend is a technical analysis indicator that is used to identify potential buy and sell signals in a security's price. It is
// calculated by combining the exponential moving average (EMA) and the average true range (ATR) of the security's price, and then plotting
// the resulting value on the price chart as a line. The Super Trend line is typically used to identify potential entry and exit points
// for trades, and can be used to confirm other technical analysis signals. It is typically more responsive to changes in the underlying
// data than other trend-following indicators, but may be less reliable in trending markets. It is important to note that the Super Trend is a
// lagging indicator, which means that it may not always provide accurate or timely signals.
//
// To use Super Trend, identify potential entry and exit points for trades by looking for crossovers or divergences between the Super Trend line
// and the security's price. For example, a buy signal may be generated when the Super Trend line crosses above the security's price, while a sell
// signal may be generated when the Super Trend line crosses below the security's price.
//go:generate callbackgen -type Supertrend
type Supertrend struct {
types.SeriesBase

View File

@ -7,6 +7,14 @@ import (
// Refer: Triple Exponential Moving Average (TEMA)
// URL: https://investopedia.com/terms/t/triple-exponential-moving-average.asp
//
// The Triple Exponential Moving Average (TEMA) is a technical analysis indicator that is used to smooth price data and reduce the lag
// associated with traditional moving averages. It is calculated by taking the exponentially weighted moving average of the input data,
// and then taking the exponentially weighted moving average of that result, and then taking the exponentially weighted moving average of
// that result. This triple-smoothing process helps to eliminate much of the noise in the original data and provides a more accurate
// representation of the underlying trend. The TEMA line is then plotted on the price chart, which can be used to make predictions about
// future price movements. The TEMA is typically more responsive to changes in the underlying data than a simple moving average, but may be
// less reliable in trending markets.
//go:generate callbackgen -type TEMA
type TEMA struct {

View File

@ -8,6 +8,15 @@ const defaultVolumeFactor = 0.7
// Refer: Tillson T3 Moving Average
// Refer URL: https://tradingpedia.com/forex-trading-indicator/t3-moving-average-indicator/
//
// The Tillson T3 Moving Average (T3) is a technical analysis indicator that is used to smooth price data and reduce the lag associated
// with traditional moving averages. It was developed by Tim Tillson and is based on the exponential moving average, with the weighting
// factors determined using a modified version of the cubic polynomial. The T3 is calculated by taking the weighted moving average of the
// input data using weighting factors that are based on the standard deviation of the data and the specified length of the moving average.
// This resulting average is then plotted on the price chart as a line, which can be used to make predictions about future price movements.
// The T3 is typically more responsive to changes in the underlying data than a simple moving average, but may be less reliable in trending
// markets.
//go:generate callbackgen -type TILL
type TILL struct {
types.SeriesBase

View File

@ -9,6 +9,13 @@ import (
// Refer: Variable Index Dynamic Average
// Refer URL: https://metatrader5.com/en/terminal/help/indicators/trend_indicators/vida
// The Variable Index Dynamic Average (VIDYA) is a technical analysis indicator that is used to smooth price data and reduce the lag
// associated with traditional moving averages. It is calculated by taking the weighted moving average of the input data, with the
// weighting factors determined using a variable index that is based on the standard deviation of the data and the specified length of
// the moving average. This resulting average is then plotted on the price chart as a line, which can be used to make predictions about
// future price movements. The VIDYA is typically more responsive to changes in the underlying data than a simple moving average, but may
// be less reliable in trending markets.
//go:generate callbackgen -type VIDYA
type VIDYA struct {
types.SeriesBase

View File

@ -0,0 +1,102 @@
package indicator
import (
"math"
"time"
"github.com/c9s/bbgo/pkg/types"
)
type trade struct {
price float64
volume float64 // +: buy, -: sell
timestamp types.Time
}
// The Volume Profile is a technical analysis tool that is used to visualize the distribution of trading volume at different price levels
// in a security. It is typically plotted as a histogram or heatmap on the price chart, with the x-axis representing the price levels and
// the y-axis representing the trading volume. The Volume Profile can be used to identify areas of support and resistance, as well as
// potential entry and exit points for trades.
type VolumeProfile struct {
types.IntervalWindow
Delta float64
profile map[float64]float64
trades []trade
minPrice float64
maxPrice float64
}
func (inc *VolumeProfile) Update(price, volume float64, timestamp types.Time) {
if inc.minPrice == 0 {
inc.minPrice = math.Inf(1)
}
if inc.maxPrice == 0 {
inc.maxPrice = math.Inf(-1)
}
inc.profile[math.Round(price/inc.Delta)] += volume
filter := timestamp.Time().Add(-time.Duration(inc.Window) * inc.Interval.Duration())
var i int
for i = 0; i < len(inc.trades); i++ {
td := inc.trades[i]
if td.timestamp.After(filter) {
break
}
inc.profile[math.Round(td.price/inc.Delta)] -= td.volume
}
inc.trades = inc.trades[i : len(inc.trades)-1]
inc.trades = append(inc.trades, trade{
price: price,
volume: volume,
timestamp: timestamp,
})
for k, _ := range inc.profile {
if k < inc.minPrice {
inc.minPrice = k
}
if k > inc.maxPrice {
inc.maxPrice = k
}
}
}
// The Point of Control (POC) is a term used in the context of Volume Profile analysis. It refers to the price level at which the most
// volume has been traded in a security over a specified period of time. The POC is typically identified by looking for the highest
// peak in the Volume Profile, and is considered to be an important level of support or resistance. It can be used by traders to
// identify potential entry and exit points for trades, or to confirm other technical analysis signals.
// Get Resistence Level by finding PoC
func (inc *VolumeProfile) PointOfControlAboveEqual(price float64, limit ...float64) (resultPrice float64, vol float64) {
filter := inc.maxPrice
if len(limit) > 0 {
filter = limit[0]
}
start := math.Round(price / inc.Delta)
vol = math.Inf(-1)
for ; start <= filter; start += inc.Delta {
abs := math.Abs(inc.profile[start])
if vol < abs {
vol = abs
resultPrice = start
}
}
return resultPrice, vol
}
// Get Support Level by finding PoC
func (inc *VolumeProfile) PointOfControlBelowEqual(price float64, limit ...float64) (resultPrice float64, vol float64) {
filter := inc.minPrice
if len(limit) > 0 {
filter = limit[0]
}
start := math.Round(price / inc.Delta)
vol = math.Inf(-1)
for ; start >= filter; start -= inc.Delta {
abs := math.Abs(inc.profile[start])
if vol < abs {
vol = abs
resultPrice = start
}
}
return resultPrice, vol
}

View File

@ -7,15 +7,21 @@ import (
"github.com/c9s/bbgo/pkg/types"
)
/*
vwap implements the volume weighted average price (VWAP) indicator:
// vwap implements the volume weighted average price (VWAP) indicator:
//
// Volume Weighted Average Price (VWAP) Definition
// - https://www.investopedia.com/terms/v/vwap.asp
//
// Volume-Weighted Average Price (VWAP) Explained
// - https://academy.binance.com/en/articles/volume-weighted-average-price-vwap-explained
//
// The Volume Weighted Average Price (VWAP) is a technical analysis indicator that is used to measure the average price of a security
// over a specified period of time, with the weighting factors determined by the volume of the security. It is calculated by taking the
// sum of the product of the price and volume for each trade, and then dividing that sum by the total volume of the security over the
// specified period of time. This resulting average is then plotted on the price chart as a line, which can be used to make predictions
// about future price movements. The VWAP is typically more accurate than other simple moving averages, as it takes into account the
// volume of the security, but may be less reliable in markets with low trading volume.
Volume Weighted Average Price (VWAP) Definition
- https://www.investopedia.com/terms/v/vwap.asp
Volume-Weighted Average Price (VWAP) Explained
- https://academy.binance.com/en/articles/volume-weighted-average-price-vwap-explained
*/
//go:generate callbackgen -type VWAP
type VWAP struct {
types.SeriesBase

View File

@ -7,16 +7,21 @@ import (
"github.com/c9s/bbgo/pkg/types"
)
/*
vwma implements the volume weighted moving average (VWMA) indicator:
// vwma implements the volume weighted moving average (VWMA) indicator:
//
// Calculation:
// pv = element-wise multiplication of close prices and volumes
// VWMA = SMA(pv, window) / SMA(volumes, window)
//
// Volume Weighted Moving Average
//- https://www.motivewave.com/studies/volume_weighted_moving_average.htm
//
// The Volume Weighted Moving Average (VWMA) is a technical analysis indicator that is used to smooth price data and reduce the lag
// associated with traditional moving averages. It is calculated by taking the weighted moving average of the input data, with the
// weighting factors determined by the volume of the security. This resulting average is then plotted on the price chart as a line,
// which can be used to make predictions about future price movements. The VWMA is typically more accurate than other simple moving
// averages, as it takes into account the volume of the security, but may be less reliable in markets with low trading volume.
Calculation:
pv = element-wise multiplication of close prices and volumes
VWMA = SMA(pv, window) / SMA(volumes, window)
Volume Weighted Moving Average
- https://www.motivewave.com/studies/volume_weighted_moving_average.htm
*/
//go:generate callbackgen -type VWMA
type VWMA struct {
types.SeriesBase
@ -79,7 +84,6 @@ func (inc *VWMA) PushK(k types.KLine) {
inc.Update(k.Close.Float64(), k.Volume.Float64())
}
func (inc *VWMA) CalculateAndUpdate(allKLines []types.KLine) {
if len(allKLines) < inc.Window {
return

View File

@ -7,6 +7,12 @@ import (
// Refer: Zero Lag Exponential Moving Average
// Refer URL: https://en.wikipedia.org/wiki/Zero_lag_exponential_moving_average
//
// The Zero Lag Exponential Moving Average (ZLEMA) is a technical analysis indicator that is used to smooth price data and reduce the
// lag associated with traditional moving averages. It is calculated by taking the exponentially weighted moving average of the input
// data, and then applying a digital filter to the resulting average to eliminate any remaining lag. This filtered average is then
// plotted on the price chart as a line, which can be used to make predictions about future price movements. The ZLEMA is typically more
// responsive to changes in the underlying data than a simple moving average, but may be less reliable in trending markets.
//go:generate callbackgen -type ZLEMA
type ZLEMA struct {