Documentation
¶
Index ¶
- Variables
- type Bar
- type BaseBar
- func (candle *BaseBar) Amount() decimal.Decimal
- func (candle *BaseBar) BeginTime() time.Time
- func (candle *BaseBar) ClosePrice() decimal.Decimal
- func (candle *BaseBar) EndTime() time.Time
- func (candle *BaseBar) HighPrice() decimal.Decimal
- func (candle *BaseBar) LowPrice() decimal.Decimal
- func (candle *BaseBar) OpenPrice() decimal.Decimal
- func (candle *BaseBar) Period() time.Duration
- func (candle *BaseBar) Trades() decimal.Decimal
- func (candle *BaseBar) Volume() decimal.Decimal
- type CachedIndicator
- func (s *CachedIndicator) BarSeries() *TimeSeries
- func (i *CachedIndicator) Delete(times []uint64)
- func (series *CachedIndicator) LoadOrStore(key string, supplier func() Indicator) Indicator
- func (i *CachedIndicator) Offset(offset uint64) decimal.Decimal
- func (s *CachedIndicator) OutOfBounds(offset uint64) bool
- type Indicator
- func BaseEma(indicator Indicator, length uint64, alpha decimal.Decimal) Indicator
- func Ema(indicator Indicator, length uint64) Indicator
- func Gain(i Indicator) Indicator
- func Highest(i Indicator, length uint64) Indicator
- func Loss(i Indicator) Indicator
- func Lowest(i Indicator, length uint64) Indicator
- func Rma(indicator Indicator, length uint64) Indicator
- func Roc(i Indicator, length uint64) Indicator
- func Rsi(i Indicator, length uint64) Indicator
- func Sma(indicator Indicator, length uint64) Indicator
- type Loader
- type Rule
- type Strategy
- type TimeSeries
- func (series *TimeSeries) Add(bar Bar)
- func (series *TimeSeries) Atr(length uint64) Indicator
- func (series *TimeSeries) ClosePriceIndicator() Indicator
- func (series *TimeSeries) Cursor(i uint64) uint64
- func (series *TimeSeries) HighPriceIndicator() Indicator
- func (series *TimeSeries) LoadOrStore(id string, supplier func() Indicator) Indicator
- func (series *TimeSeries) LowPriceIndicator() Indicator
- func (series *TimeSeries) MedianPriceIndicator() Indicator
- func (series *TimeSeries) NewIndicator(id string, method func(Bar) decimal.Decimal) Indicator
- func (series *TimeSeries) Offset(i uint64) Bar
- func (series *TimeSeries) OpenPriceIndicator() Indicator
- func (series *TimeSeries) Size() uint64
- func (series *TimeSeries) Tr() Indicator
- func (series *TimeSeries) TypicalPriceIndicator() Indicator
- func (series *TimeSeries) VolumeIndicator() Indicator
Constants ¶
This section is empty.
Variables ¶
View Source
var HUNDRED = decimal.NewFromInt(100)
View Source
var ONE = decimal.NewFromInt(1)
View Source
var TWO = decimal.NewFromInt(2)
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar interface {
// the time period of the bar
Period() time.Duration
// the begin time of the bar period
BeginTime() time.Time
// the end time of the bar period
EndTime() time.Time
// the open price of the period
OpenPrice() decimal.Decimal
// the close price of the period
ClosePrice() decimal.Decimal
// the high price of the period
HighPrice() decimal.Decimal
// the low price of the period
LowPrice() decimal.Decimal
// the whole tradeNum volume in the period
Volume() decimal.Decimal
// the whole traded amount of the period
Amount() decimal.Decimal
// the number of trades in the period
Trades() decimal.Decimal
}
type BaseBar ¶
type BaseBar struct {
PeriodVal time.Duration
BeginTimeVal time.Time
EndTimeVal time.Time
OpenPriceVal decimal.Decimal
ClosePriceVal decimal.Decimal
HighPriceVal decimal.Decimal
LowPriceVal decimal.Decimal
VolumeVal decimal.Decimal
AmountVal decimal.Decimal
TradesVal decimal.Decimal
}
func (*BaseBar) ClosePrice ¶
type CachedIndicator ¶
type CachedIndicator struct {
// contains filtered or unexported fields
}
func NewCacheFrom ¶
func NewCacheFrom(series *TimeSeries, loader Loader) *CachedIndicator
func NewCachedIndicator ¶
func NewCachedIndicator(indicator Indicator, loader Loader) *CachedIndicator
func (*CachedIndicator) BarSeries ¶
func (s *CachedIndicator) BarSeries() *TimeSeries
func (*CachedIndicator) Delete ¶
func (i *CachedIndicator) Delete(times []uint64)
func (*CachedIndicator) LoadOrStore ¶
func (series *CachedIndicator) LoadOrStore(key string, supplier func() Indicator) Indicator
func (*CachedIndicator) OutOfBounds ¶
func (s *CachedIndicator) OutOfBounds(offset uint64) bool
type Indicator ¶
type Indicator interface {
// Offset value forward based on the latest value,
// Offset(0) The latest value added, Offset(1) The value of the previous period
Offset(offset uint64) decimal.Decimal
// OutOfBounds returns true if the offset is out of bounds
OutOfBounds(offset uint64) bool
// BarSeries get time series data
BarSeries() *TimeSeries
// Load the associated indicator in the current indicator cache,
// use the supply function to generate and save when it does not exist
LoadOrStore(id string, supplier func() Indicator) Indicator
// Delete remove expired data
Delete(expired []uint64)
}
func Ema ¶
Ema The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially
func Rma ¶
Rma Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.
func Roc ¶
Roc roc (rate of change) showing the difference between current value of x and the value of x that was y days ago.
type Rule ¶
A rule for strategy building. A trading rule may be composed of a combination of other rules.
type Strategy ¶
type Strategy interface {
// true to recommend to enter, false otherwise
ShouldEnter(offset uint64) bool
// true to recommend to exit, false otherwise
ShouldExit(offset uint64) bool
}
A trading strategy. A strategy is a pair of complementary rules. It may recommend to enter or to exit.
func NewStrategy ¶
type TimeSeries ¶
type TimeSeries struct {
// contains filtered or unexported fields
}
func NewLimitSeries ¶
func NewLimitSeries(period time.Duration, capacity, threshold uint64) *TimeSeries
func NewSeries ¶
func NewSeries(period time.Duration) *TimeSeries
func (*TimeSeries) Add ¶
func (series *TimeSeries) Add(bar Bar)
func (*TimeSeries) Atr ¶
func (series *TimeSeries) Atr(length uint64) Indicator
Atr (average true range) returns the RMA of true range.
func (*TimeSeries) ClosePriceIndicator ¶
func (series *TimeSeries) ClosePriceIndicator() Indicator
func (*TimeSeries) Cursor ¶
func (series *TimeSeries) Cursor(i uint64) uint64
func (*TimeSeries) HighPriceIndicator ¶
func (series *TimeSeries) HighPriceIndicator() Indicator
func (*TimeSeries) LoadOrStore ¶
func (series *TimeSeries) LoadOrStore(id string, supplier func() Indicator) Indicator
func (*TimeSeries) LowPriceIndicator ¶
func (series *TimeSeries) LowPriceIndicator() Indicator
func (*TimeSeries) MedianPriceIndicator ¶
func (series *TimeSeries) MedianPriceIndicator() Indicator
func (*TimeSeries) NewIndicator ¶
func (*TimeSeries) Offset ¶
func (series *TimeSeries) Offset(i uint64) Bar
func (*TimeSeries) OpenPriceIndicator ¶
func (series *TimeSeries) OpenPriceIndicator() Indicator
func (*TimeSeries) Size ¶
func (series *TimeSeries) Size() uint64
func (*TimeSeries) TypicalPriceIndicator ¶
func (series *TimeSeries) TypicalPriceIndicator() Indicator
func (*TimeSeries) VolumeIndicator ¶
func (series *TimeSeries) VolumeIndicator() Indicator
Source Files
¶
Click to show internal directories.
Click to hide internal directories.