Documentation
¶
Index ¶
- type AssetValue
- type Candle
- type Chart
- func (c *Chart) GetFirstAvailablePair() string
- func (c *Chart) GetPort() int
- func (c *Chart) GetSimulationInterval() time.Duration
- func (c *Chart) GetWSManager() *WebSocketManager
- func (c *Chart) OnCandle(candle core.Candle)
- func (c *Chart) OnOrder(order core.Order)
- func (c *Chart) RegisterHandlers(server HTTPServer)
- func (c *Chart) StartCandleSimulation(pair string, interval time.Duration)
- func (c *Chart) StartSimulation()
- func (c *Chart) StopCandleSimulation()
- type ChartServer
- type HTTPServer
- type Indicator
- type IndicatorMetric
- type Option
- type Shape
- type StandardHTTPServer
- type WebSocketManager
- type WebSocketMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetValue ¶
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 ¶
Chart handles the visualization of trading data
func (*Chart) GetFirstAvailablePair ¶
GetFirstAvailablePair returns the first available pair or empty string
func (*Chart) GetSimulationInterval ¶
GetSimulationInterval returns the simulation interval
func (*Chart) GetWSManager ¶
func (c *Chart) GetWSManager() *WebSocketManager
GetWSManager returns the WebSocket manager
func (*Chart) RegisterHandlers ¶
func (c *Chart) RegisterHandlers(server HTTPServer)
RegisterHandlers registers all necessary handlers on the HTTP server
func (*Chart) StartCandleSimulation ¶
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 ¶
WithCustomIndicators adds custom indicators to the chart
func WithPaperWallet ¶
func WithPaperWallet(paperWallet *exchange.PaperWallet) Option
WithPaperWallet sets the paper wallet for the chart
func WithSimulation ¶
WithSimulation enables real-time candle simulation for testing
func WithStrategyIndicators ¶
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 ¶
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 ¶
WebSocketMessage represents a message sent over WebSocket