bot

package
v0.0.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const UnlimitedVolatilityWindowLength = 0

UnlimitedVolatilityWindowLength is a constant that can be used to indicate that the volatilityWindow should have an unlimited length. Warning: this should only be used for testing purposes. Growing the volatilityWindow indefinitely can lead to memory leaks.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

func New

func New(config *config.Configuration, market market.Market, db database.Database) *Bot

func (*Bot) Start

func (b *Bot) Start(ctx context.Context)

Start starts monitoring the market for price changes.

type VolatilityWindow

type VolatilityWindow struct {
	// contains filtered or unexported fields
}

func NewVolatilityWindow

func NewVolatilityWindow(maxLength int) *VolatilityWindow

NewVolatilityWindow creates a new volatilityWindow of records. The volatilityWindow can be used to monitor the price changes of coins over time. It's a rolling window of records, so the volatilityWindow will never exceed the given max length.

func (*VolatilityWindow) AddRecord

func (h *VolatilityWindow) AddRecord(coins market.CoinMap)

AddRecord adds a new record to the volatilityWindow.

func (*VolatilityWindow) GetLatestRecord

func (h *VolatilityWindow) GetLatestRecord() VolatilityWindowRecord

GetLatestRecord returns the latest record in the volatilityWindow.

func (*VolatilityWindow) IdentifyVolatileCoins

func (h *VolatilityWindow) IdentifyVolatileCoins(percentage float64) market.VolatileCoins

IdentifyVolatileCoins returns the coins that have a price change of more than the given percentage. Returns a map of coin symbols and their respective price change percentage over the current time window of the volatilityWindow.

func (*VolatilityWindow) Max

Max returns the record with the highest price for the given coin.

func (*VolatilityWindow) Min

Min returns the record with the lowest price for the given coin.

func (*VolatilityWindow) Size

func (h *VolatilityWindow) Size() int

Size returns the number of records in the volatilityWindow.

type VolatilityWindowRecord

type VolatilityWindowRecord struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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