api

package
v0.0.0-...-a62b218 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppState

type AppState interface {
	Stats() (orders int, fills int, pnl float64)
	IsRunning() bool
	IsDryRun() bool
	MonitoredAssets() []string
	SetEmergencyStop(stop bool)
	RecentFills(limit int) []execution.Fill
	ActiveOrders() []execution.OrderState
	TrackedPositions() map[string]execution.Position
	UnrealizedPnL() float64
	RiskSnapshot() risk.Snapshot
	TradingMode() string
	PaperSnapshot() paper.Snapshot
	KPIStats() map[string]interface{}
}

AppState exposes the trading app's state for the API layer.

type BuilderProvider

type BuilderProvider interface {
	DailyVolumeJSON() interface{}
	LeaderboardJSON() interface{}
	LastSync() time.Time
}

BuilderProvider exposes builder volume data (nil if unavailable).

type PortfolioProvider

type PortfolioProvider interface {
	TotalValue() float64
	LastSync() time.Time
}

PortfolioProvider exposes portfolio data (nil if unavailable).

type Server

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

Server is a lightweight HTTP API for the trading dashboard.

func NewServer

func NewServer(addr string, appState AppState, portfolio PortfolioProvider, builder BuilderProvider) *Server

NewServer creates a new API server bound to addr.

func (*Server) SetAuthToken

func (s *Server) SetAuthToken(token string)

SetAuthToken enables lightweight token auth for all API endpoints except health and readiness.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server.

func (*Server) Start

func (s *Server) Start(_ context.Context) error

Start begins serving HTTP requests.

Jump to

Keyboard shortcuts

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