harmonic

package
v1.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2023 License: AGPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const ID = "harmonic"

Variables

This section is empty.

Functions

func DrawCumPNL

func DrawCumPNL(instanceID string, cumProfit types.Series) *types.Canvas

func DrawPNL

func DrawPNL(instanceID string, profit types.Series) *types.Canvas

Types

type AccumulatedProfitReport

type AccumulatedProfitReport struct {
	// AccumulatedProfitMAWindow Accumulated profit SMA window, in number of trades
	AccumulatedProfitMAWindow int `json:"accumulatedProfitMAWindow"`

	// IntervalWindow interval window, in days
	IntervalWindow int `json:"intervalWindow"`

	// NumberOfInterval How many intervals to output to TSV
	NumberOfInterval int `json:"NumberOfInterval"`

	// TsvReportPath The path to output report to
	TsvReportPath string `json:"tsvReportPath"`

	// AccumulatedDailyProfitWindow The window to sum up the daily profit, in days
	AccumulatedDailyProfitWindow int `json:"accumulatedDailyProfitWindow"`
	// contains filtered or unexported fields
}

AccumulatedProfitReport For accumulated profit report output

func (*AccumulatedProfitReport) DailyUpdate

func (r *AccumulatedProfitReport) DailyUpdate(tradeStats *types.TradeStats)

func (*AccumulatedProfitReport) Initialize

func (r *AccumulatedProfitReport) Initialize()

func (*AccumulatedProfitReport) Output

func (r *AccumulatedProfitReport) Output(symbol string)

Output Accumulated profit report to a TSV file

func (*AccumulatedProfitReport) RecordProfit

func (r *AccumulatedProfitReport) RecordProfit(profit fixedpoint.Value)

func (*AccumulatedProfitReport) RecordTrade

func (r *AccumulatedProfitReport) RecordTrade(fee fixedpoint.Value)

type SHARK

type SHARK struct {
	types.IntervalWindow
	types.SeriesBase

	Lows        floats.Slice
	Highs       floats.Slice
	LongScores  floats.Slice
	ShortScores floats.Slice

	Values floats.Slice

	EndTime time.Time
	// contains filtered or unexported fields
}

func (*SHARK) BindK

func (inc *SHARK) BindK(target indicator.KLineClosedEmitter, symbol string, interval types.Interval)

func (*SHARK) EmitUpdate

func (inc *SHARK) EmitUpdate(value float64)

func (*SHARK) Index

func (inc *SHARK) Index(i int) float64

func (*SHARK) Last

func (inc *SHARK) Last() float64

func (*SHARK) Length

func (inc *SHARK) Length() int

func (*SHARK) LoadK

func (inc *SHARK) LoadK(allKLines []types.KLine)

func (*SHARK) OnUpdate

func (inc *SHARK) OnUpdate(cb func(value float64))

func (*SHARK) PushK

func (inc *SHARK) PushK(k types.KLine)

func (SHARK) SharkLong

func (inc SHARK) SharkLong(highs, lows floats.Slice, p float64, lookback int) float64

func (SHARK) SharkShort

func (inc SHARK) SharkShort(highs, lows floats.Slice, p float64, lookback int) float64

func (*SHARK) Update

func (inc *SHARK) Update(high, low, price float64)

type Strategy

type Strategy struct {
	Environment *bbgo.Environment
	Symbol      string `json:"symbol"`
	Market      types.Market

	types.IntervalWindow

	// persistence fields
	Position    *types.Position    `persistence:"position"`
	ProfitStats *types.ProfitStats `persistence:"profit_stats"`
	TradeStats  *types.TradeStats  `persistence:"trade_stats"`

	ExitMethods bbgo.ExitMethodSet `json:"exits"`

	bbgo.QuantityOrAmount

	// StrategyController
	bbgo.StrategyController

	AccountValueCalculator *bbgo.AccountValueCalculator

	// whether to draw graph or not by the end of backtest
	DrawGraph       bool   `json:"drawGraph"`
	GraphPNLPath    string `json:"graphPNLPath"`
	GraphCumPNLPath string `json:"graphCumPNLPath"`

	// Accumulated profit report
	AccumulatedProfitReport *AccumulatedProfitReport `json:"accumulatedProfitReport"`
	// contains filtered or unexported fields
}

func (*Strategy) CalcAssetValue

func (s *Strategy) CalcAssetValue(price fixedpoint.Value) fixedpoint.Value

func (*Strategy) Draw

func (s *Strategy) Draw(profit, cumProfit types.Series) error

func (*Strategy) ID

func (s *Strategy) ID() string

func (*Strategy) InitDrawCommands

func (s *Strategy) InitDrawCommands(profit, cumProfit types.Series)

func (*Strategy) InstanceID

func (s *Strategy) InstanceID() string

func (*Strategy) Run

func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error

func (*Strategy) Subscribe

func (s *Strategy) Subscribe(session *bbgo.ExchangeSession)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL