Documentation
¶
Index ¶
- Constants
- Variables
- func CancelOrder(orderID string, cfg *config.Config, store keyring.Store) tea.Cmd
- func ConfigPath() string
- func FetchAccounts(cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchHistory(cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchHistoryWithToken(cfg *config.Config, store keyring.Store, nextToken string) tea.Cmd
- func FetchInstrumentInfo(symbol string, cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchOptionChain(symbol, expiration string, cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchOptionExpirations(symbol string, cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchOptionGreeks(symbols []string, cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchOrders(cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchPortfolio(cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchTradeQuote(symbol string, cfg *config.Config, store keyring.Store) tea.Cmd
- func FetchWatchlistQuotes(symbols []string, cfg *config.Config, store keyring.Store) tea.Cmd
- func PlaceOrder(m *TradeModel, cfg *config.Config, store keyring.Store) tea.Cmd
- func SaveConfig(cfg *UIConfig) error
- func TableStyles() table.Styles
- type Account
- type AccountChangedMsg
- type AccountsErrorMsg
- type AccountsLoadedMsg
- type AccountsResponse
- type AssetInstrumentErrorMsg
- type AssetInstrumentLoadedMsg
- type AssetSelectedMsg
- type AssetSelectorCancelledMsg
- type AssetSelectorMode
- type AssetSelectorModel
- func (m *AssetSelectorModel) SetPortfolioData(positions []Position)
- func (m *AssetSelectorModel) SetWatchlistData(symbols []string, quotes map[string]Quote)
- func (m *AssetSelectorModel) Update(msg tea.Msg, cfg *config.Config, store keyring.Store) (*AssetSelectorModel, tea.Cmd)
- func (m *AssetSelectorModel) View() string
- type BuyingPower
- type CostBasis
- type Equity
- type Gain
- type GreeksDisplayMode
- type HistoryErrorMsg
- type HistoryLoadedMsg
- type HistoryModel
- type HistoryResponse
- type HistoryState
- type Instrument
- type Model
- type OptionChainErrorMsg
- type OptionChainLoadedMsg
- type OptionExpirationsErrorMsg
- type OptionExpirationsLoadedMsg
- type OptionGreeksLoadedMsg
- type OptionQuoteLoadedMsg
- type OptionsFocus
- type OptionsModel
- type OptionsState
- type Order
- type OrderCancelErrorMsg
- type OrderCancelledMsg
- type OrdersErrorMsg
- type OrdersLoadedMsg
- type OrdersMode
- type OrdersModel
- type OrdersResponse
- type OrdersState
- type Portfolio
- type PortfolioErrorMsg
- type PortfolioLoadedMsg
- type PortfolioModel
- type PortfolioState
- type Position
- type Price
- type Quote
- type QuoteInstrument
- type QuoteRequest
- type QuotesResponse
- type TickMsg
- type ToolbarFocusMsg
- type TradeField
- type TradeMode
- type TradeModel
- func (m *TradeModel) FocusSymbol() tea.Cmd
- func (m *TradeModel) IsTextFieldFocused() bool
- func (m *TradeModel) RefocusCurrent() tea.Cmd
- func (m *TradeModel) SetSymbol(symbol string)
- func (m *TradeModel) SetWatchlistData(symbols []string, quotes map[string]Quote)
- func (m *TradeModel) Update(msg tea.Msg, cfg *config.Config, store keyring.Store) (*TradeModel, tea.Cmd)
- func (m *TradeModel) View() string
- type TradeOrderErrorMsg
- type TradeOrderPlacedMsg
- type TradeOrderType
- type TradeQuoteErrorMsg
- type TradeQuoteMsg
- type TradeSide
- type TradeState
- type Transaction
- type UIConfig
- type View
- type WatchlistErrorMsg
- type WatchlistMode
- type WatchlistModel
- type WatchlistQuotesMsg
- type WatchlistSavedMsg
- type WatchlistState
Constants ¶
const ( ColorPrimary = lipgloss.Color("39") // Cyan/blue ColorMuted = lipgloss.Color("241") // Gray ColorBackground = lipgloss.Color("236") // Dark gray ColorSelected = lipgloss.Color("57") // Purple ColorSelectedFg = lipgloss.Color("229") // Light yellow ColorGreen = lipgloss.Color("82") // Green for gains ColorRed = lipgloss.Color("196") // Red for losses ColorWarning = lipgloss.Color("220") // Yellow for warnings )
Color constants
Variables ¶
var ( HeaderStyle = lipgloss.NewStyle(). Bold(true). Foreground(ColorPrimary). Background(ColorBackground). Padding(0, 1) ContentStyle = lipgloss.NewStyle(). Padding(1, 2) KeyStyle = lipgloss.NewStyle(). Foreground(ColorPrimary). Bold(true) DescStyle = lipgloss.NewStyle(). Foreground(ColorMuted) SummaryStyle = lipgloss.NewStyle().Bold(true) LabelStyle = lipgloss.NewStyle().Foreground(ColorMuted) ValueStyle = lipgloss.NewStyle().Bold(true) GreenStyle = lipgloss.NewStyle().Foreground(ColorGreen) RedStyle = lipgloss.NewStyle().Foreground(ColorRed) ErrorStyle = lipgloss.NewStyle().Foreground(ColorRed) WarningStyle = lipgloss.NewStyle(). Foreground(ColorWarning). Bold(true) InputStyle = lipgloss.NewStyle(). Border(lipgloss.RoundedBorder()). BorderForeground(ColorPrimary). Padding(0, 1) )
Shared styles
Functions ¶
func CancelOrder ¶
CancelOrder returns a command that cancels an order.
func FetchAccounts ¶
FetchAccounts returns a command that fetches the list of accounts.
func FetchHistory ¶
FetchHistory returns a command that fetches transaction history.
func FetchHistoryWithToken ¶
FetchHistoryWithToken returns a command that fetches history with optional pagination token.
func FetchInstrumentInfo ¶
FetchInstrumentInfo returns a command that fetches instrument information.
func FetchOptionChain ¶
FetchOptionChain returns a command that fetches the option chain.
func FetchOptionExpirations ¶
FetchOptionExpirations returns a command that fetches option expirations.
func FetchOptionGreeks ¶
FetchOptionGreeks returns a command that fetches greeks for option symbols.
func FetchOrders ¶
FetchOrders returns a command that fetches open orders.
func FetchPortfolio ¶
FetchPortfolio returns a command that fetches portfolio data.
func FetchTradeQuote ¶
FetchTradeQuote returns a command that fetches a quote for the trade form.
func FetchWatchlistQuotes ¶
FetchWatchlistQuotes returns a command that fetches quotes for watchlist symbols.
func PlaceOrder ¶
PlaceOrder returns a command that places an order.
func TableStyles ¶
TableStyles returns the default table styles for TUI tables.
Types ¶
type AccountChangedMsg ¶
type AccountChangedMsg struct {
AccountID string
}
AccountChangedMsg is sent when the user switches accounts.
type AccountsErrorMsg ¶
type AccountsErrorMsg struct {
Err error
}
AccountsErrorMsg is sent when account loading fails.
type AccountsLoadedMsg ¶
type AccountsLoadedMsg struct {
Accounts []Account
}
AccountsLoadedMsg is sent when accounts are loaded successfully.
type AssetInstrumentErrorMsg ¶
AssetInstrumentErrorMsg is sent when instrument lookup fails.
type AssetInstrumentLoadedMsg ¶
AssetInstrumentLoadedMsg is sent when instrument info is loaded.
type AssetSelectedMsg ¶
type AssetSelectedMsg struct {
Symbol string
Type string
Name string
Optionable bool
Quote *Quote // Optional quote data if available
}
AssetSelectedMsg is sent when an asset is selected.
type AssetSelectorCancelledMsg ¶
type AssetSelectorCancelledMsg struct{}
AssetSelectorCancelledMsg is sent when the selector is cancelled.
type AssetSelectorMode ¶
type AssetSelectorMode int
AssetSelectorMode represents the current mode of the asset selector.
const ( AssetSelectorModeSearch AssetSelectorMode = iota AssetSelectorModeWatchlist AssetSelectorModePortfolio )
type AssetSelectorModel ¶
type AssetSelectorModel struct {
Mode AssetSelectorMode
SearchInput textinput.Model
Cursor int
// Data sources
WatchSymbols []string
WatchQuotes map[string]Quote
Positions []Position
// Search results
SearchSymbol string
SearchResult *AssetInstrumentLoadedMsg
SearchLoading bool
SearchErr error
// Dimensions
Width int
Height int
}
AssetSelectorModel holds the state for the asset selector component.
func NewAssetSelectorModel ¶
func NewAssetSelectorModel(mode AssetSelectorMode) *AssetSelectorModel
NewAssetSelectorModel creates a new asset selector in the specified mode.
func (*AssetSelectorModel) SetPortfolioData ¶
func (m *AssetSelectorModel) SetPortfolioData(positions []Position)
SetPortfolioData sets the portfolio data for the selector.
func (*AssetSelectorModel) SetWatchlistData ¶
func (m *AssetSelectorModel) SetWatchlistData(symbols []string, quotes map[string]Quote)
SetWatchlistData sets the watchlist data for the selector.
func (*AssetSelectorModel) Update ¶
func (m *AssetSelectorModel) Update(msg tea.Msg, cfg *config.Config, store keyring.Store) (*AssetSelectorModel, tea.Cmd)
Update handles messages for the asset selector.
func (*AssetSelectorModel) View ¶
func (m *AssetSelectorModel) View() string
View renders the asset selector.
type GreeksDisplayMode ¶
type GreeksDisplayMode int
GreeksDisplayMode represents how Greeks are displayed.
const ( GreeksDisplayCompact GreeksDisplayMode = iota // Delta, Theta, IV inline GreeksDisplayExpanded // All Greeks: Delta, Gamma, Theta, Vega, Rho, IV )
type HistoryErrorMsg ¶
type HistoryErrorMsg struct {
Err error
}
HistoryErrorMsg is sent when history loading fails.
type HistoryLoadedMsg ¶
type HistoryLoadedMsg struct {
Transactions []Transaction
NextToken string
}
HistoryLoadedMsg is sent when history is loaded successfully.
type HistoryModel ¶
type HistoryModel struct {
State HistoryState
Transactions []Transaction
Err error
LastUpdated time.Time
Table table.Model
// Pagination
NextToken string
HasMore bool
LoadingMore bool
// Detail panel
ShowDetail bool
DetailIndex int
}
HistoryModel holds the state for the history view.
func NewHistoryModel ¶
func NewHistoryModel() *HistoryModel
NewHistoryModel creates a new history model.
func (*HistoryModel) FooterKeys ¶
func (m *HistoryModel) FooterKeys(keys []struct{ key, desc string }) []struct{ key, desc string }
FooterKeys returns the footer keys for the history view.
func (*HistoryModel) SelectedTransaction ¶
func (m *HistoryModel) SelectedTransaction() *Transaction
SelectedTransaction returns the currently selected transaction, if any.
func (*HistoryModel) SetHeight ¶
func (m *HistoryModel) SetHeight(height int)
SetHeight sets the table height.
func (*HistoryModel) Update ¶
func (m *HistoryModel) Update(msg tea.Msg) (*HistoryModel, tea.Cmd, bool)
Update handles messages for the history view. Returns the model, command, and whether the event was handled.
type HistoryState ¶
type HistoryState int
HistoryState represents the loading state of history data.
const ( HistoryStateLoading HistoryState = iota HistoryStateLoaded HistoryStateError )
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the main bubbletea model for the TUI.
type OptionChainErrorMsg ¶
type OptionChainErrorMsg struct {
Err error
}
OptionChainErrorMsg is sent when loading the chain fails.
type OptionChainLoadedMsg ¶
type OptionChainLoadedMsg struct {
Chain *api.OptionChainResponse
}
OptionChainLoadedMsg is sent when the option chain is loaded.
type OptionExpirationsErrorMsg ¶
type OptionExpirationsErrorMsg struct {
Err error
}
OptionExpirationsErrorMsg is sent when loading expirations fails.
type OptionExpirationsLoadedMsg ¶
OptionExpirationsLoadedMsg is sent when expirations are loaded.
type OptionGreeksLoadedMsg ¶
type OptionGreeksLoadedMsg struct {
Greeks []api.OptionGreeks
}
OptionGreeksLoadedMsg is sent when greeks are loaded.
type OptionQuoteLoadedMsg ¶
type OptionQuoteLoadedMsg struct {
Last string
}
OptionQuoteLoadedMsg is sent when the underlying quote is loaded.
type OptionsFocus ¶
type OptionsFocus int
OptionsFocus represents what is currently focused.
const ( OptionsFocusSymbol OptionsFocus = iota OptionsFocusExpiration OptionsFocusCalls OptionsFocusPuts )
type OptionsModel ¶
type OptionsModel struct {
State OptionsState
Focus OptionsFocus
Err error
LastUpdated time.Time
// Symbol input
SymbolInput textinput.Model
Symbol string
Quote *Quote
// Expirations
Expirations []string
SelectedExpiration int
// Option chain data
Chain *api.OptionChainResponse
Greeks map[string]api.GreeksData
CallsCursor int
PutsCursor int
GreeksMode GreeksDisplayMode
Height int
OptionsBP string
// Detail panel
ShowDetailPanel bool
SelectedOption *api.OptionQuote
// Asset selector (for watchlist/portfolio selection)
AssetSelector *AssetSelectorModel
ShowAssetSelector bool
}
OptionsModel holds the state for the options view.
func NewOptionsModel ¶
func NewOptionsModel() *OptionsModel
NewOptionsModel creates a new options model.
func (*OptionsModel) FooterKeys ¶
func (m *OptionsModel) FooterKeys(keys []struct{ key, desc string }) []struct{ key, desc string }
FooterKeys returns the footer keys for the options view.
func (*OptionsModel) SetHeight ¶
func (m *OptionsModel) SetHeight(h int)
SetHeight sets the available height for the options chain.
type OptionsState ¶
type OptionsState int
OptionsState represents the current state of the options view.
const ( OptionsStateIdle OptionsState = iota OptionsStateLoadingExpirations OptionsStateSelectingExpiration OptionsStateLoadingChain OptionsStateChainLoaded OptionsStateError )
type OrderCancelErrorMsg ¶
type OrderCancelErrorMsg struct {
Err error
}
OrderCancelErrorMsg is sent when order cancellation fails.
type OrderCancelledMsg ¶
type OrderCancelledMsg struct {
OrderID string
}
OrderCancelledMsg is sent when an order is cancelled.
type OrdersErrorMsg ¶
type OrdersErrorMsg struct {
Err error
}
OrdersErrorMsg is sent when orders loading fails.
type OrdersLoadedMsg ¶
type OrdersLoadedMsg struct {
Orders []Order
}
OrdersLoadedMsg is sent when orders are loaded successfully.
type OrdersMode ¶
type OrdersMode int
OrdersMode represents the input mode of the orders view.
const ( OrdersModeNormal OrdersMode = iota OrdersModeCanceling )
type OrdersModel ¶
type OrdersModel struct {
State OrdersState
Orders []Order
Err error
LastUpdated time.Time
Table table.Model
Mode OrdersMode
CancelOrderID string
CancelSymbol string
}
OrdersModel holds the state for the orders view.
func (*OrdersModel) SelectedOrder ¶
func (m *OrdersModel) SelectedOrder() *Order
SelectedOrder returns the currently selected order, if any.
func (*OrdersModel) SetHeight ¶
func (m *OrdersModel) SetHeight(height int)
SetHeight sets the table height.
type OrdersState ¶
type OrdersState int
OrdersState represents the loading state of orders data.
const ( OrdersStateLoading OrdersState = iota OrdersStateLoaded OrdersStateError )
type PortfolioErrorMsg ¶
type PortfolioErrorMsg struct {
Err error
}
PortfolioErrorMsg is sent when portfolio loading fails.
type PortfolioLoadedMsg ¶
type PortfolioLoadedMsg struct {
Portfolio Portfolio
}
PortfolioLoadedMsg is sent when portfolio data is loaded successfully.
type PortfolioModel ¶
type PortfolioModel struct {
State PortfolioState
Data Portfolio
Err error
LastUpdated time.Time
Table table.Model
}
PortfolioModel holds the state for the portfolio view.
func NewPortfolioModel ¶
func NewPortfolioModel() *PortfolioModel
NewPortfolioModel creates a new portfolio model.
func (*PortfolioModel) SetHeight ¶
func (m *PortfolioModel) SetHeight(height int)
SetHeight sets the table height.
func (*PortfolioModel) Update ¶
func (m *PortfolioModel) Update(msg tea.Msg) (*PortfolioModel, tea.Cmd)
Update handles messages for the portfolio view.
func (*PortfolioModel) View ¶
func (m *PortfolioModel) View() string
View renders the portfolio view.
type PortfolioState ¶
type PortfolioState int
PortfolioState represents the loading state of portfolio data.
const ( PortfolioStateLoading PortfolioState = iota PortfolioStateLoaded PortfolioStateError )
type ToolbarFocusMsg ¶
type ToolbarFocusMsg struct{}
ToolbarFocusMsg is sent when a child view requests toolbar focus.
type TradeField ¶
type TradeField int
TradeField represents the currently focused input field.
const ( TradeFieldSymbol TradeField = iota TradeFieldSide TradeFieldOrderType TradeFieldQuantity TradeFieldLimitPrice )
type TradeModel ¶
type TradeModel struct {
State TradeState
Mode TradeMode
Err error
LastError string
// Form fields
FocusedField TradeField
SymbolInput textinput.Model
QuantityInput textinput.Model
LimitPriceInput textinput.Model
// Selections
Side TradeSide
OrderType TradeOrderType
// Quote data for the symbol
Quote *Quote
QuoteLoaded bool
// Order result
OrderID string
OrderSymbol string
// Asset selector
AssetSelector *AssetSelectorModel
ShowAssetSelector bool
// Watchlist data for asset selector (set by parent)
WatchlistSymbols []string
WatchlistQuotes map[string]Quote
}
TradeModel holds the state for the trade view.
func (*TradeModel) FocusSymbol ¶
func (m *TradeModel) FocusSymbol() tea.Cmd
FocusSymbol ensures the symbol input is focused when entering the trade view. Returns a tea.Cmd for the cursor blink animation.
func (*TradeModel) IsTextFieldFocused ¶
func (m *TradeModel) IsTextFieldFocused() bool
IsTextFieldFocused returns true if focus is on a text input field.
func (*TradeModel) RefocusCurrent ¶
func (m *TradeModel) RefocusCurrent() tea.Cmd
RefocusCurrent refocuses the currently focused field (used when returning from toolbar). Returns a tea.Cmd for the cursor blink animation.
func (*TradeModel) SetSymbol ¶
func (m *TradeModel) SetSymbol(symbol string)
SetSymbol sets the symbol to trade (called when jumping from watchlist).
func (*TradeModel) SetWatchlistData ¶
func (m *TradeModel) SetWatchlistData(symbols []string, quotes map[string]Quote)
SetWatchlistData sets the watchlist data for the asset selector.
type TradeOrderErrorMsg ¶
type TradeOrderErrorMsg struct {
Err error
}
TradeOrderErrorMsg is sent when placing an order fails.
type TradeOrderPlacedMsg ¶
TradeOrderPlacedMsg is sent when an order is placed successfully.
type TradeOrderType ¶
type TradeOrderType int
TradeOrderType represents market or limit order.
const ( TradeOrderTypeMarket TradeOrderType = iota TradeOrderTypeLimit )
func (TradeOrderType) String ¶
func (t TradeOrderType) String() string
type TradeQuoteErrorMsg ¶
type TradeQuoteErrorMsg struct {
Err error
}
TradeQuoteErrorMsg is sent when fetching a quote fails.
type TradeQuoteMsg ¶
type TradeQuoteMsg struct {
Quote Quote
}
TradeQuoteMsg is sent when a quote is fetched for the trade form.
type TradeState ¶
type TradeState int
TradeState represents the current state of the trade view.
const ( TradeStateIdle TradeState = iota TradeStateFetchingQuote TradeStateReady TradeStateSubmitting TradeStateSuccess TradeStateError )
type UIConfig ¶
type UIConfig struct {
Watchlist []string `yaml:"watchlist,omitempty"`
}
UIConfig holds TUI-specific configuration separate from CLI config.
type WatchlistErrorMsg ¶
type WatchlistErrorMsg struct {
Err error
}
WatchlistErrorMsg is sent when watchlist loading fails.
type WatchlistMode ¶
type WatchlistMode int
WatchlistMode represents the input mode of the watchlist view.
const ( WatchlistModeNormal WatchlistMode = iota WatchlistModeAdding WatchlistModeDeleting )
type WatchlistModel ¶
type WatchlistModel struct {
State WatchlistState
Symbols []string
Quotes map[string]Quote
Err error
LastUpdated time.Time
Table table.Model
Mode WatchlistMode
AddInput textinput.Model
DeleteSymbol string
}
WatchlistModel holds the state for the watchlist view.
func NewWatchlistModel ¶
func NewWatchlistModel(symbols []string) *WatchlistModel
NewWatchlistModel creates a new watchlist model.
func (*WatchlistModel) SelectedSymbol ¶
func (m *WatchlistModel) SelectedSymbol() string
SelectedSymbol returns the currently selected symbol, if any.
func (*WatchlistModel) SetHeight ¶
func (m *WatchlistModel) SetHeight(height int)
SetHeight sets the table height.
func (*WatchlistModel) Update ¶
func (m *WatchlistModel) Update(msg tea.Msg, uiCfg *UIConfig) (*WatchlistModel, tea.Cmd, bool)
Update handles messages for the watchlist view. Returns the model, command, and whether the event was handled.
func (*WatchlistModel) View ¶
func (m *WatchlistModel) View() string
View renders the watchlist view.
type WatchlistQuotesMsg ¶
WatchlistQuotesMsg is sent when watchlist quotes are loaded.
type WatchlistSavedMsg ¶
type WatchlistSavedMsg struct{}
WatchlistSavedMsg is sent when watchlist config is saved.
type WatchlistState ¶
type WatchlistState int
WatchlistState represents the loading state of watchlist data.
const ( WatchlistStateLoading WatchlistState = iota WatchlistStateLoaded WatchlistStateError )