Documentation ¶
Overview ¶
* Copyright 2021 The Cerebro Authors * * Licensed under the GNU General Public License v3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * <https:fsf.org/> * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2021 The Cerebro Authors * * Licensed under the GNU General Public License v3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * <https:fsf.org/> * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2021 The Cerebro Authors * * Licensed under the GNU General Public License v3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * <https:fsf.org/> * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* Copyright 2021 The Cerebro Authors * * Licensed under the GNU General Public License v3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * <https:fsf.org/> * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- Variables
- func NewRsiIndicator(period int) *rsiIndicator
- func Resampler(last *Candle, tk Tick, compress time.Duration) error
- func Rma(period int, values []float64) []float64
- type Candle
- type CandleBuffer
- func (c *CandleBuffer) Cap() int
- func (c *CandleBuffer) Len() int
- func (c *CandleBuffer) Less(i, j int) bool
- func (c *CandleBuffer) Next(n int) []Candle
- func (c *CandleBuffer) Read(p []Candle) (n int, err error)
- func (c *CandleBuffer) Reset()
- func (c *CandleBuffer) Swap(i, j int)
- func (c *CandleBuffer) Truncate(n int)
- func (c *CandleBuffer) Write(p []Candle) (n int, err error)
- type CandleType
- type Candles
- func (c Candles) BollingerBand(period int) (bottom []Indicate[float64], mid []Indicate[float64], top []Indicate[float64])
- func (c Candles) Envelope(period int, up, down float64) (sma, upper, lower []Indicate[float64])
- func (c Candles) Len() int
- func (c Candles) Less(i, j int) bool
- func (c Candles) MACD(fast, slow, signal int) (macdLine []Indicate[float64], signalLine []Indicate[float64])
- func (c Candles) Mean() float64
- func (c Candles) StandardDeviation() float64
- func (c Candles) StochasticFast(k, d, period int) (K, D []Indicate[float64])
- func (c Candles) StochasticSlow(k, d, period int) (K, D []Indicate[float64])
- func (c Candles) Swap(i, j int)
- func (c Candles) VolumeRatio(nday int) []Indicate[float64]
- type Indicate
- type Indicator
- type InternalIndicator
- type Packet
- type Spread
- type Tick
- type Ticks
- type TradeHistory
- type Value
Constants ¶
This section is empty.
Variables ¶
var (
ErrOverDate = e.Error{Code: 1, Message: "raise unexpected error"}
)
Functions ¶
func NewRsiIndicator ¶
func NewRsiIndicator(period int) *rsiIndicator
Types ¶
type Candle ¶
type Candle struct { Date time.Time `json:"date"` Code string `json:"code"` Type CandleType `gorm:"-"` Open int64 `json:"open"` High int64 `json:"high"` Low int64 `json:"low"` Close int64 `json:"close"` Volume int64 `json:"volume"` Amount int64 `json:"amount"` IndicateValue int64 `json:"indicateValue"` }
type CandleBuffer ¶
type CandleBuffer struct {
// contains filtered or unexported fields
}
func NewCandleBuffer ¶
func NewCandleBuffer(c []Candle) *CandleBuffer
func (*CandleBuffer) Cap ¶
func (c *CandleBuffer) Cap() int
func (*CandleBuffer) Len ¶
func (c *CandleBuffer) Len() int
func (*CandleBuffer) Less ¶
func (c *CandleBuffer) Less(i, j int) bool
func (*CandleBuffer) Next ¶
func (c *CandleBuffer) Next(n int) []Candle
func (*CandleBuffer) Reset ¶
func (c *CandleBuffer) Reset()
func (*CandleBuffer) Swap ¶
func (c *CandleBuffer) Swap(i, j int)
func (*CandleBuffer) Truncate ¶
func (c *CandleBuffer) Truncate(n int)
type CandleType ¶
type CandleType int
const ( Min CandleType = iota + 1 Min3 Min5 Min15 Min60 Day )
func (CandleType) Duration ¶
func (c CandleType) Duration() time.Duration
type Candles ¶
type Candles []Candle
func (Candles) BollingerBand ¶
func (c Candles) BollingerBand(period int) (bottom []Indicate[float64], mid []Indicate[float64], top []Indicate[float64])
calculate bollinger band with candle period is the number of candles to calculate the mean and standard deviation of the candle period must be greater than 1 and day
func (Candles) StandardDeviation ¶
func (Candles) StochasticFast ¶
func (Candles) StochasticSlow ¶
type Indicate ¶
type Indicate[T comparable] struct { Data T Date time.Time RawData float64 `json:"rawData,omitempty"` }
type Indicator ¶
type Indicator struct {
// contains filtered or unexported fields
}
func CombineWithF ¶
func (Indicator) ROI ¶
Roi is rate of increase or decrease per duration Roi is calculated by (end - start) / start * 100 (%) return every tick
func (Indicator) Transaction ¶
type InternalIndicator ¶
InternalIndicator only for internal use