irr

package
v0.0.0-...-cb4139d Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "irr"

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 NRR

type NRR struct {
	types.IntervalWindow
	types.SeriesBase

	RankingWindow int

	Values       floats.Slice
	RankedValues floats.Slice
	ReturnValues floats.Slice

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

func (*NRR) BindK

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

func (*NRR) EmitUpdate

func (inc *NRR) EmitUpdate(value float64)

func (*NRR) Index

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

func (*NRR) Last

func (inc *NRR) Last(i int) float64

func (*NRR) Length

func (inc *NRR) Length() int

func (*NRR) LoadK

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

func (*NRR) OnUpdate

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

func (*NRR) PushK

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

func (*NRR) Update

func (inc *NRR) Update(openPrice, closePrice 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, cumProfitDollar 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