Documentation
¶
Index ¶
- Constants
- type ADXStream
- type ATRPStream
- type ATRStream
- type BOLLStream
- type CCIStream
- type CMAStream
- type ChandelierStopPrice
- type ChandelierStopStream
- type CompressionLevel
- type CrossStream
- type CrossType
- type EWMAStream
- type FixedWindowVolumeProfile
- func (vp *FixedWindowVolumeProfile) EmitReset(profile map[fixedpoint.Value]fixedpoint.Value, accKLine types.KLine)
- func (vp *FixedWindowVolumeProfile) OnReset(cb func(profile map[fixedpoint.Value]fixedpoint.Value, accKLine types.KLine))
- func (vp *FixedWindowVolumeProfile) PointOfControl() (pocPrice, pocVolume fixedpoint.Value)
- func (vp *FixedWindowVolumeProfile) PointOfControlAboveEqual(priceLevel fixedpoint.Value, limit ...fixedpoint.Value) (pocPrice, pocVolume fixedpoint.Value)
- func (vp *FixedWindowVolumeProfile) PointOfControlBelowEqual(priceLevel fixedpoint.Value, limit ...fixedpoint.Value) (pocPrice, pocVolume fixedpoint.Value)
- func (vp *FixedWindowVolumeProfile) UseAvgOHLC()
- type KLineStream
- func (s *KLineStream) AddSubscriber(f func(k types.KLine))
- func (s *KLineStream) BackFill(kLines []types.KLine)
- func (s *KLineStream) EmitUpdate(k types.KLine)
- func (s *KLineStream) Last(i int) *types.KLine
- func (s *KLineStream) Length() int
- func (s *KLineStream) OnUpdate(cb func(k types.KLine))
- func (s *KLineStream) Tail(n int) types.KLineWindow
- type KLineSubscription
- type KeltnerStream
- type LiquidityDemandStream
- type MACDStream
- type MomentumDirection
- type MultiplyStream
- type PivotHighStream
- type PivotLowStream
- type PremiumStream
- type PriceStream
- func ClosePrices(source KLineSubscription) *PriceStream
- func HLC3(source KLineSubscription) *PriceStream
- func HighPrices(source KLineSubscription) *PriceStream
- func LowPrices(source KLineSubscription) *PriceStream
- func OpenPrices(source KLineSubscription) *PriceStream
- func Price(source KLineSubscription, mapper types.KLineValueMapper) *PriceStream
- func Volumes(source KLineSubscription) *PriceStream
- type RMAStream
- type RSIStream
- type SMAStream
- type SMMAStream
- type StdDevStream
- type StochStream
- type SubtractStream
- type SuperTrendBand
- type SuperTrendStream
- type TRStream
- type TTMSqueeze
- type TTMSqueezeStream
- type TradeStream
- func (s *TradeStream) AddSubscriber(f func(trade types.Trade))
- func (s *TradeStream) BackFill(trades []types.Trade)
- func (s *TradeStream) EmitUpdate(trade types.Trade)
- func (s *TradeStream) Last(i int) *types.Trade
- func (s *TradeStream) Length() int
- func (s *TradeStream) OnUpdate(cb func(trade types.Trade))
- func (s *TradeStream) Tail(n int) []types.Trade
- type VolumeLevel
- type VolumeProfile
- type VolumeProfileStream
Constants ¶
const DPeriod int = 3
const DefaultValueAreaPercentage = 0.68
DefaultValueAreaPercentage is the percentage of the total volume used to calculate the value area.
const MaxNumOfKLines = 5_000
const MaxNumOfLiquidityDemand = 3000
const MaxNumOfRMA = 1000
const MaxNumOfTrades = 5_000
const MaxSliceSize = 5000
MaxSliceSize is the maximum slice size byte size = 8 * 5000 = 40KB per slice
const TruncateSize = 1000
TruncateSize is the truncate size for the slice per truncate call
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADXStream ¶ added in v1.59.0
type ADXStream struct {
*RMAStream
Plus, Minus *types.Float64Series
// contains filtered or unexported fields
}
func ADX ¶ added in v1.59.0
func ADX(source KLineSubscription, window int) *ADXStream
type ATRPStream ¶
type ATRPStream struct {
*types.Float64Series
}
func ATRP2 ¶
func ATRP2(source KLineSubscription, window int) *ATRPStream
type ATRStream ¶
type ATRStream struct {
// embedded struct
*RMAStream
}
func ATR2 ¶
func ATR2(source KLineSubscription, window int) *ATRStream
type BOLLStream ¶
type BOLLStream struct {
// the band series
*types.Float64Series
UpBand, DownBand *types.Float64Series
SMA *SMAStream
StdDev *StdDevStream
// contains filtered or unexported fields
}
func BOLL ¶
func BOLL(source types.Float64Source, window int, k float64) *BOLLStream
BOOL2 is bollinger indicator the data flow:
priceSource ->
-> calculate SMA -> calculate stdDev -> calculate bandWidth -> get latest SMA -> upBand, downBand
func (*BOLLStream) Calculate ¶
func (s *BOLLStream) Calculate(v float64) float64
func (*BOLLStream) Truncate ¶ added in v1.61.0
func (s *BOLLStream) Truncate()
type CCIStream ¶
type CCIStream struct {
*types.Float64Series
TypicalPrice *types.Float64Series
// contains filtered or unexported fields
}
type CMAStream ¶
type CMAStream struct {
*types.Float64Series
}
func CMA2 ¶
func CMA2(source types.Float64Source) *CMAStream
type ChandelierStopPrice ¶ added in v1.64.0
type ChandelierStopPrice struct {
LongStop float64
ShortStop float64
Direction int // 1 for long, -1 for short, 0 for neutral
Switched bool
Time time.Time
}
func (*ChandelierStopPrice) String ¶ added in v1.64.0
func (c *ChandelierStopPrice) String() string
type ChandelierStopStream ¶ added in v1.64.0
type ChandelierStopStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func ChandelierStop ¶ added in v1.64.0
func ChandelierStop(source KLineSubscription, length, atrPeriod int, multiplier float64, emitDirection bool) *ChandelierStopStream
func (*ChandelierStopStream) StopPrices ¶ added in v1.64.0
func (cs *ChandelierStopStream) StopPrices() []ChandelierStopPrice
type CompressionLevel ¶ added in v1.64.0
type CompressionLevel int
const ( CompressionLevelNone CompressionLevel = iota // green dot CompressionLevelLow // black dot CompressionLevelMedium // red dot CompressionLevelHigh // orange dot )
type CrossStream ¶
type CrossStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
CrossStream subscribes 2 upstreams, and calculate the cross signal
func Cross ¶
func Cross(a, b types.Float64Source) *CrossStream
Cross creates the CrossStream object:
cross := Cross(fastEWMA, slowEWMA)
func (*CrossStream) Truncate ¶ added in v1.62.0
func (s *CrossStream) Truncate()
type EWMAStream ¶
type EWMAStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func EWMA2 ¶
func EWMA2(source types.Float64Source, window int) *EWMAStream
func (*EWMAStream) Calculate ¶
func (s *EWMAStream) Calculate(v float64) float64
func (*EWMAStream) Truncate ¶ added in v1.62.0
func (s *EWMAStream) Truncate()
type FixedWindowVolumeProfile ¶ added in v1.64.0
type FixedWindowVolumeProfile struct {
*types.Float64Series
// contains filtered or unexported fields
}
func NewFixedWindowVolumeProfile ¶ added in v1.64.0
func NewFixedWindowVolumeProfile(source KLineSubscription, window int, delta fixedpoint.Value) *FixedWindowVolumeProfile
func (*FixedWindowVolumeProfile) EmitReset ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) EmitReset(profile map[fixedpoint.Value]fixedpoint.Value, accKLine types.KLine)
func (*FixedWindowVolumeProfile) OnReset ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) OnReset(cb func(profile map[fixedpoint.Value]fixedpoint.Value, accKLine types.KLine))
func (*FixedWindowVolumeProfile) PointOfControl ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) PointOfControl() (pocPrice, pocVolume fixedpoint.Value)
func (*FixedWindowVolumeProfile) PointOfControlAboveEqual ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) PointOfControlAboveEqual(priceLevel fixedpoint.Value, limit ...fixedpoint.Value) (pocPrice, pocVolume fixedpoint.Value)
func (*FixedWindowVolumeProfile) PointOfControlBelowEqual ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) PointOfControlBelowEqual(priceLevel fixedpoint.Value, limit ...fixedpoint.Value) (pocPrice, pocVolume fixedpoint.Value)
func (*FixedWindowVolumeProfile) UseAvgOHLC ¶ added in v1.64.0
func (vp *FixedWindowVolumeProfile) UseAvgOHLC()
type KLineStream ¶
type KLineStream struct {
// contains filtered or unexported fields
}
func (*KLineStream) AddSubscriber ¶
func (s *KLineStream) AddSubscriber(f func(k types.KLine))
AddSubscriber adds the subscriber function and push historical data to the subscriber
func (*KLineStream) BackFill ¶
func (s *KLineStream) BackFill(kLines []types.KLine)
func (*KLineStream) EmitUpdate ¶
func (s *KLineStream) EmitUpdate(k types.KLine)
func (*KLineStream) Length ¶
func (s *KLineStream) Length() int
func (*KLineStream) OnUpdate ¶
func (s *KLineStream) OnUpdate(cb func(k types.KLine))
func (*KLineStream) Tail ¶ added in v1.64.0
func (s *KLineStream) Tail(n int) types.KLineWindow
type KLineSubscription ¶
type KeltnerStream ¶ added in v1.57.0
type KeltnerStream struct {
types.SeriesBase
EWMA *EWMAStream
StdDev *StdDevStream
ATR *ATRStream
Mid *types.Float64Series
FirstUpperBand, FirstLowerBand *types.Float64Series
SecondUpperBand, SecondLowerBand *types.Float64Series
ThirdUpperBand, ThirdLowerBand *types.Float64Series
// contains filtered or unexported fields
}
func Keltner ¶ added in v1.57.0
func Keltner(source KLineSubscription, window, atrLength int, atrMultipliers ...float64) *KeltnerStream
type LiquidityDemandStream ¶ added in v1.64.0
type LiquidityDemandStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func LiquidityDemand ¶ added in v1.64.0
func LiquidityDemand( klineStream KLineSubscription, iw types.IntervalWindow, ) *LiquidityDemandStream
type MACDStream ¶
type MACDStream struct {
*SubtractStream
FastEWMA, SlowEWMA, Signal *EWMAStream
Histogram *SubtractStream
// contains filtered or unexported fields
}
func MACD2 ¶
func MACD2(source types.Float64Source, shortWindow, longWindow, signalWindow int) *MACDStream
type MomentumDirection ¶ added in v1.64.0
type MomentumDirection int
const ( MomentumDirectionNeutral MomentumDirection = iota MomentumDirectionBullish MomentumDirectionBullishSlowing MomentumDirectionBearish MomentumDirectionBearishSlowing )
type MultiplyStream ¶
type MultiplyStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func Multiply ¶
func Multiply(a, b types.Float64Source) *MultiplyStream
type PivotHighStream ¶
type PivotHighStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func PivotHigh ¶ added in v1.53.0
func PivotHigh(source types.Float64Source, window int, args ...int) *PivotHighStream
type PivotLowStream ¶
type PivotLowStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func PivotLow ¶
func PivotLow(source types.Float64Source, window int, args ...int) *PivotLowStream
type PremiumStream ¶ added in v1.63.0
type PremiumStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func Premium ¶ added in v1.63.0
func Premium( priceStream1, priceStream2 *PriceStream, premiumMargin float64, ) *PremiumStream
func (*PremiumStream) Truncate ¶ added in v1.63.0
func (s *PremiumStream) Truncate()
type PriceStream ¶
type PriceStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func ClosePrices ¶
func ClosePrices(source KLineSubscription) *PriceStream
func HLC3 ¶
func HLC3(source KLineSubscription) *PriceStream
func HighPrices ¶
func HighPrices(source KLineSubscription) *PriceStream
func LowPrices ¶
func LowPrices(source KLineSubscription) *PriceStream
func OpenPrices ¶
func OpenPrices(source KLineSubscription) *PriceStream
func Price ¶
func Price(source KLineSubscription, mapper types.KLineValueMapper) *PriceStream
func Volumes ¶
func Volumes(source KLineSubscription) *PriceStream
func (*PriceStream) AddSubscriber ¶
func (s *PriceStream) AddSubscriber(f func(v float64))
AddSubscriber adds the subscriber function and push historical data to the subscriber
func (*PriceStream) PushAndEmit ¶
func (s *PriceStream) PushAndEmit(v float64)
func (*PriceStream) Truncate ¶ added in v1.62.0
func (s *PriceStream) Truncate()
type RMAStream ¶
type RMAStream struct {
// embedded structs
*types.Float64Series
// config fields
Adjust bool
// contains filtered or unexported fields
}
type RSIStream ¶
type RSIStream struct {
// embedded structs
*types.Float64Series
// contains filtered or unexported fields
}
type SMAStream ¶
type SMAStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
type SMMAStream ¶ added in v1.58.0
type SMMAStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func SMMA2 ¶ added in v1.58.0
func SMMA2(source types.Float64Source, window int) *SMMAStream
func (*SMMAStream) Calculate ¶ added in v1.58.0
func (s *SMMAStream) Calculate(v float64) float64
type StdDevStream ¶
type StdDevStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func StdDev ¶
func StdDev(source types.Float64Source, window int) *StdDevStream
func (*StdDevStream) Calculate ¶
func (s *StdDevStream) Calculate(x float64) float64
func (*StdDevStream) Truncate ¶ added in v1.61.0
func (s *StdDevStream) Truncate()
type StochStream ¶
type StochStream struct {
types.SeriesBase
K, D floats.Slice
// contains filtered or unexported fields
}
func Stoch ¶
func Stoch(source KLineSubscription, window, dPeriod int) *StochStream
Stochastic Oscillator
func (*StochStream) EmitUpdate ¶
func (S *StochStream) EmitUpdate(k float64, d float64)
func (*StochStream) OnUpdate ¶
func (S *StochStream) OnUpdate(cb func(k float64, d float64))
type SubtractStream ¶
type SubtractStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
SubtractStream subscribes 2 upstream data, and then subtract these 2 values
func Subtract ¶
func Subtract(a, b types.Float64Source) *SubtractStream
Subtract creates the SubtractStream object subtract := Subtract(longEWMA, shortEWMA)
type SuperTrendBand ¶ added in v1.64.0
type SuperTrendBand struct {
UpperBand float64
LowerBand float64
Direction int // 1 for uptrend, -1 for downtrend
Time time.Time
}
func (*SuperTrendBand) Value ¶ added in v1.64.0
func (s *SuperTrendBand) Value() float64
type SuperTrendStream ¶ added in v1.64.0
type SuperTrendStream struct {
*types.Float64Series
// contains filtered or unexported fields
}
func SuperTrend ¶ added in v1.64.0
func SuperTrend(source KLineSubscription, window int, multiplier float64) *SuperTrendStream
func (*SuperTrendStream) Entities ¶ added in v1.64.0
func (st *SuperTrendStream) Entities() []*SuperTrendBand
type TRStream ¶
type TRStream struct {
// embedded struct
*types.Float64Series
// contains filtered or unexported fields
}
This TRStream calculates the ATR first
func TR2 ¶
func TR2(source KLineSubscription) *TRStream
type TTMSqueeze ¶ added in v1.64.0
type TTMSqueeze struct {
CompressionLevel CompressionLevel
Momentum float64
MomentumDirection MomentumDirection
Time types.Time
}
type TTMSqueezeStream ¶ added in v1.64.0
type TTMSqueezeStream struct {
// contains filtered or unexported fields
}
TTM Squeeze indicator stream Reference: https://www.tradingview.com/pine/?id=PUB%3B7e9cf40f672c4ab88ac70c580a327870
func NewTTMSqueezeStream ¶ added in v1.64.0
func NewTTMSqueezeStream(source KLineSubscription, window int) *TTMSqueezeStream
func (*TTMSqueezeStream) EmitUpdate ¶ added in v1.64.0
func (T *TTMSqueezeStream) EmitUpdate(squeeze TTMSqueeze)
func (*TTMSqueezeStream) OnUpdate ¶ added in v1.64.0
func (T *TTMSqueezeStream) OnUpdate(cb func(squeeze TTMSqueeze))
type TradeStream ¶ added in v1.64.0
type TradeStream struct {
// contains filtered or unexported fields
}
func Trades ¶ added in v1.64.0
func Trades(source types.Stream, symbol string) *TradeStream
Trades creates a Trade stream that pushes the trades to the subscribers
func (*TradeStream) AddSubscriber ¶ added in v1.64.0
func (s *TradeStream) AddSubscriber(f func(trade types.Trade))
AddSubscriber adds the subscriber function and push historical data to the subscriber
func (*TradeStream) BackFill ¶ added in v1.64.0
func (s *TradeStream) BackFill(trades []types.Trade)
func (*TradeStream) EmitUpdate ¶ added in v1.64.0
func (s *TradeStream) EmitUpdate(trade types.Trade)
func (*TradeStream) Length ¶ added in v1.64.0
func (s *TradeStream) Length() int
func (*TradeStream) OnUpdate ¶ added in v1.64.0
func (s *TradeStream) OnUpdate(cb func(trade types.Trade))
type VolumeLevel ¶ added in v1.64.0
type VolumeLevel struct {
// Price is the market price, typically the high/low average of the kline.
Price float64
// Volume is the total buy and sell volume at the price.
Volume float64
}
VolumeLevel is a price and volume pair used to build a volume profile.
type VolumeProfile ¶ added in v1.64.0
type VolumeProfile struct {
// Bins is the histogram bins.
Bins []float64
// Hist is the histogram values.
Hist []float64
// POC is the point of control.
POC float64
// VAH is the value area high.
VAH float64
// VAL is the value area low.
VAL float64
// High is the highest price in the profile.
High float64
// Low is the lowest price in the profile.
Low float64
}
VolumeProfile is a histogram of market price and volume. Intent is to show the price points with most volume during a period. The profile gives key features such as:
Point of control (POC)
Value area high (VAH)
Value area low (VAL)
Session High/Low
type VolumeProfileStream ¶ added in v1.64.0
type VolumeProfileStream struct {
*types.Float64Series
VP VolumeProfile
// contains filtered or unexported fields
}
func NewVolumeProfile ¶ added in v1.64.0
func NewVolumeProfile(source KLineSubscription, window int) *VolumeProfileStream
func (*VolumeProfileStream) Truncate ¶ added in v1.64.0
func (s *VolumeProfileStream) Truncate()
Source Files
¶
- adx.go
- atr.go
- atrp.go
- boll.go
- cci.go
- chandelier_stop.go
- cma.go
- const.go
- cross.go
- ewma.go
- fixedwindowvolumeprofile.go
- fixedwindowvolumeprofile_callbacks.go
- keltner.go
- klines.go
- klinestream_callbacks.go
- liquidity_demand.go
- macd.go
- multiply.go
- pivothigh.go
- pivotlow.go
- premium.go
- price.go
- rma.go
- rsi.go
- sma.go
- smma.go
- stddev.go
- stoch.go
- stochstream_callbacks.go
- subtract.go
- supertrend.go
- tr.go
- trades.go
- tradestream_callbacks.go
- truncate.go
- ttmsqueeze.go
- ttmsqueeze_callbacks.go
- volume_profile.go