plot

package
v0.0.0-...-583d1ee Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetValue

type AssetValue struct {
	Time  time.Time `json:"time"`
	Value float64   `json:"value"`
}

AssetValue represents a point in time value of an asset

type Candle

type Candle struct {
	Time   time.Time    `json:"time"`
	Open   float64      `json:"open"`
	Close  float64      `json:"close"`
	High   float64      `json:"high"`
	Low    float64      `json:"low"`
	Volume float64      `json:"volume"`
	Orders []core.Order `json:"orders"`
}

Candle represents OHLCV data with associated orders

type Chart

type Chart struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Chart handles the visualization of trading data

func NewChart

func NewChart(log core.Logger, options ...Option) (*Chart, error)

NewChart creates a new chart instance with the provided options

func (*Chart) GetFirstAvailablePair

func (c *Chart) GetFirstAvailablePair() string

GetFirstAvailablePair returns the first available pair or empty string

func (*Chart) GetPort

func (c *Chart) GetPort() int

GetPort returns the configured port

func (*Chart) GetSimulationInterval

func (c *Chart) GetSimulationInterval() time.Duration

GetSimulationInterval returns the simulation interval

func (*Chart) GetWSManager

func (c *Chart) GetWSManager() *WebSocketManager

GetWSManager returns the WebSocket manager

func (*Chart) OnCandle

func (c *Chart) OnCandle(candle core.Candle)

OnCandle handles new candle events

func (*Chart) OnOrder

func (c *Chart) OnOrder(order core.Order)

OnOrder handles new order events

func (*Chart) RegisterHandlers

func (c *Chart) RegisterHandlers(server HTTPServer)

RegisterHandlers registers all necessary handlers on the HTTP server

func (*Chart) StartCandleSimulation

func (c *Chart) StartCandleSimulation(pair string, interval time.Duration)

StartCandleSimulation starts a simulation that generates candle updates at regular intervals This is useful for testing real-time updates

func (*Chart) StartSimulation

func (c *Chart) StartSimulation()

StartSimulation starts candle simulation if configured

func (*Chart) StopCandleSimulation

func (c *Chart) StopCandleSimulation()

StopCandleSimulation stops the candle simulation

type ChartServer

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

ChartServer is a wrapper that combines a Chart with an HTTP server

func NewChartServer

func NewChartServer(chart *Chart, server HTTPServer, log core.Logger) *ChartServer

NewChartServer creates a new ChartServer

func (*ChartServer) Start

func (cs *ChartServer) Start() error

Start initializes the HTTP server for the chart

type HTTPServer

type HTTPServer interface {
	// RegisterHandler registers a handler for a specific route
	RegisterHandler(path string, handler http.HandlerFunc)

	// RegisterFileServer registers a handler to serve static files
	RegisterFileServer(path string, fs http.FileSystem)

	// Start starts the HTTP server on the specified port
	Start(port int) error
}

HTTPServer defines the interface for an HTTP server that Chart will use

type Indicator

type Indicator interface {
	Name() string
	Overlay() bool
	Warmup() int
	Metrics() []IndicatorMetric
	Load(dataframe *core.Dataframe)
}

Indicator interface defines the methods required to implement a chart indicator

type IndicatorMetric

type IndicatorMetric struct {
	Name   string
	Color  string
	Style  string
	Values core.Series[float64]
	Time   []time.Time
}

IndicatorMetric represents a single metric within an indicator

type Option

type Option func(*Chart)

Option defines a function type for configuring a Chart instance

func WithCustomIndicators

func WithCustomIndicators(indicators ...Indicator) Option

WithCustomIndicators adds custom indicators to the chart

func WithDebug

func WithDebug() Option

WithDebug enables debug mode (disables minification)

func WithPaperWallet

func WithPaperWallet(paperWallet *exchange.PaperWallet) Option

WithPaperWallet sets the paper wallet for the chart

func WithPort

func WithPort(port int) Option

WithPort sets the HTTP server port

func WithSimulation

func WithSimulation(interval time.Duration) Option

WithSimulation enables real-time candle simulation for testing

func WithStrategyIndicators

func WithStrategyIndicators(strategy core.Strategy) Option

WithStrategyIndicators sets the strategy for indicators

type Shape

type Shape struct {
	StartX time.Time `json:"x0"`
	EndX   time.Time `json:"x1"`
	StartY float64   `json:"y0"`
	EndY   float64   `json:"y1"`
	Color  string    `json:"color"`
}

Shape represents a visual shape on the chart

type StandardHTTPServer

type StandardHTTPServer struct{}

StandardHTTPServer implements the HTTPServer interface using the standard http package

func NewStandardHTTPServer

func NewStandardHTTPServer() *StandardHTTPServer

NewStandardHTTPServer creates a new instance of StandardHTTPServer

func (*StandardHTTPServer) RegisterFileServer

func (s *StandardHTTPServer) RegisterFileServer(path string, fs http.FileSystem)

RegisterFileServer registers a handler to serve static files

func (*StandardHTTPServer) RegisterHandler

func (s *StandardHTTPServer) RegisterHandler(path string, handler http.HandlerFunc)

RegisterHandler registers a handler for a specific route

func (*StandardHTTPServer) Start

func (s *StandardHTTPServer) Start(port int) error

Start starts the HTTP server on the specified port

type WebSocketManager

type WebSocketManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

WebSocketManager handles WebSocket connections

func NewWebSocketManager

func NewWebSocketManager(log core.Logger, chart *Chart) *WebSocketManager

NewWebSocketManager creates a new WebSocket manager

func (*WebSocketManager) BroadcastCandle

func (m *WebSocketManager) BroadcastCandle(candle core.Candle, pair string)

BroadcastCandle broadcasts a new candle to all clients

func (*WebSocketManager) BroadcastOrder

func (m *WebSocketManager) BroadcastOrder(order core.Order)

BroadcastOrder broadcasts a new order to all clients

func (*WebSocketManager) HandleWebSocket

func (m *WebSocketManager) HandleWebSocket(w http.ResponseWriter, r *http.Request)

HandleWebSocket handles WebSocket connections

type WebSocketMessage

type WebSocketMessage struct {
	Type    string `json:"type"`
	Payload any    `json:"payload"`
}

WebSocketMessage represents a message sent over WebSocket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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