A terminal-based user interface (TUI) application for viewing option chains and building option strategies using the Alpaca Markets API.
NOTE: An experiment in vibe coding with Claude Code
- 📊 View real-time stock quotes with price changes
- 📈 Display option chains with Greeks (delta, gamma, theta, vega, rho)
- 🏗️ Build option strategies with interactive wizard
- Bull Call Spread
- Bear Put Spread
- Diagonal Call Spread (dual-expiration support)
- Iron Condor
- Long Straddle
- Covered Call
- 💾 Save and manage option strategies with persistence
- ⌨️ Keyboard-driven navigation with vim-style shortcuts
- 🎨 Beautiful terminal UI with Ink and React
- 🧪 Comprehensive test suite (101 tests)
- Node.js >= 18.0.0
- Alpaca Markets account (Paper Trading supported)
npm installCreate a .env file in the project root:
cp .env.example .envEdit .env and add your Alpaca API credentials:
ALPACA_API_KEY=your_paper_api_key_here
ALPACA_API_SECRET=your_paper_api_secret_here
ALPACA_PAPER=trueGet your API keys from Alpaca Markets Dashboard.
See the Usage section below for instructions on running the app.
jesse-option-viewer-tui/
├── src/
│ ├── components/ # React/Ink UI components
│ │ ├── ExpirationSelect.tsx # Expiration date selector
│ │ ├── Header.tsx # App header
│ │ ├── OptionChain.tsx # Option chain table display
│ │ ├── SavedStrategies.tsx # Saved strategies list
│ │ ├── StatusBar.tsx # Status bar with mode indicator
│ │ ├── StrategyBuilder.tsx # Interactive strategy wizard
│ │ └── StrategySelector.tsx # Strategy type selection
│ ├── screens/ # Screen components
│ │ ├── HelpScreen.tsx # Help/keyboard shortcuts
│ │ ├── HomeScreen.tsx # Welcome screen
│ │ └── OptionChainScreen.tsx # Main option chain view
│ ├── context/ # React Context state management
│ │ └── AppContext.tsx # Global state + reducer
│ ├── lib/ # API wrappers and integrations
│ │ └── alpaca.ts # Alpaca API client
│ ├── utils/ # Utility functions
│ │ ├── fetch.ts # Rate-limited fetch + parsing
│ │ ├── formatters.ts # Number/currency formatting
│ │ ├── logger.ts # Emoji-enhanced logging
│ │ ├── storage.ts # JSON file persistence
│ │ └── strategies.ts # Strategy calculations
│ ├── types/ # TypeScript type definitions
│ │ └── index.ts
│ ├── App.tsx # Main app + global input handler
│ └── index.tsx # Entry point
├── tests/ # Test suite (Vitest)
│ ├── fetch.test.ts # API parsing tests
│ ├── strategies.test.ts # Strategy calculation tests
│ └── test-utils/
│ └── mocks.ts # Test mock factories
├── doc/ # Documentation
│ └── global-input-handler-guidelines.md
├── logs/ # Application logs (gitignored)
├── .env # API credentials (gitignored)
├── .env.example # Example environment config
├── package.json
├── tsconfig.json
├── vitest.config.ts
└── README.md
Development mode (recommended for testing):
npm run devProduction mode:
npm run build
npm start- Run
npm run dev - Press
sto enter a stock symbol (e.g., "AAPL") - Navigate through expiration dates and view option chain
- Press
bto open strategy builder - Select a strategy type and follow the wizard
s- Enter stock symbolhor?- Show helpq- Quit applicationCtrl+C- Exit
↑/↓orj/k- Navigate up/down (vim-style)e- Focus expiration selectoro- Focus option chainl- Toggle display limit (10/20/40/ALL)g- Toggle Greeks displayb- Open strategy builders- Change symbolq- Go back to home
↑/↓orj/k- Navigate optionsEnter- Select option/confirmESCorq- Cancel builderxord- Undo last leg selection1/2/3/4- Jump to specific leg (multi-leg strategies)y- Confirm save strategy
- Type text and press
Enterto submit ESC- Cancel inputBackspace- Delete last character
- Uses React Context + useReducer (not Redux)
- Centralized state in
AppContext - Follows global input handler pattern (see
doc/global-input-handler-guidelines.md)
- Direct Alpaca API calls via wrapper methods in
lib/alpaca.ts - Secure credential handling via environment variables
- Mock data support for development
- Strategies saved to JSON file in
~/.option-viewer/strategies.json - Automatic directory creation
- Error handling for file operations
npm run type-checknpm run lintnpm testWatch mode:
npm run test:watch- TypeScript project setup with strict type checking
- Dependencies installed and configured (React, Ink, Vitest)
- Alpaca API wrapper with v1beta1 and v2 endpoint support
- Project folder structure with screens, components, context
- Global input handler pattern implementation
- State management with React Context + useReducer
- Emoji-enhanced logging system with file output
- JSON file persistence for strategies (~/.option-viewer/)
- Stock quote display with real-time price changes
- Option chain display with Greeks
- Expiration date selection with days-to-expiry calculation
- Strategy builder wizard with interactive selection
- 6 option strategies implemented:
- Bull Call Spread
- Bear Put Spread
- Diagonal Call Spread (dual-expiration)
- Iron Condor (4-leg)
- Long Straddle
- Covered Call
- Strategy metrics calculation (P&L, risk/reward, breakeven)
- Saved strategies display with remove functionality
- Comprehensive test suite (101 tests)
- Type-safe API parsing with defensive validation
- Additional strategies (Butterfly, Calendar, etc.)
- Strategy comparison view
- Real-time price updates with WebSocket
- Portfolio tracking
- Historical P&L charts
The application uses emoji-enhanced logging for better debugging:
- 🔍 Debug messages
- ℹ️ Info messages
- ✅ Success messages
⚠️ Warnings- ❌ Errors
- 🌐 API calls
- 💾 Data operations
- API keys stored in environment variables (never in code)
.envfile excluded from git- Paper trading mode for safe testing
MIT
See CLAUDE.md for development guidelines and conventions.


