hodl

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package hodl offers a buy and hold trading algo.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeBotFromConfig

func MakeBotFromConfig(config map[string]any) (trader.Bot, error)

MakeBotFromConfig builds a valid Bot from a given set of config params.

Types

type Bot

type Bot struct {
	// BuyBarIndex is the index in the price sequence to open the position
	BuyBarIndex int

	// SellBarIndex is the index in the price sequence to close the position.
	SellBarIndex int
	// contains filtered or unexported fields
}

Bot implements a buy and hold algo. Should only be used for backtesting purposes. At a given bar index a long position is opened. Default is to buy on the first price received, call Close() to then sell the position and create a trade.

func New

func New(asset market.Asset, dealer broker.Dealer) *Bot

New returns a default Bot.

func (*Bot) Close

func (b *Bot) Close(ctx context.Context) error

Close closes any open position.

func (*Bot) ReceivePrice

func (b *Bot) ReceivePrice(ctx context.Context, price market.Kline) error

ReceivePrice updates the algo with the next market price.

func (*Bot) SetAsset added in v0.0.20

func (b *Bot) SetAsset(asset market.Asset)

SetAsset sets the asset to trade.

func (*Bot) SetDealer

func (b *Bot) SetDealer(dealer broker.Dealer)

SetDealer is the dealer to use for order execution. Should only be given a simulated dealer for backtesting.

func (*Bot) Warmup

func (b *Bot) Warmup(ctx context.Context, prices []market.Kline) error

Warmup is not used.

Jump to

Keyboard shortcuts

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