Trade Single Leg ThinkOrSwim
Places a single-leg trade (stock or option) through TD Ameritrade/ThinkOrSwim brokerage. This function executes REAL trades with real money.
Prerequisites
- Active TD Ameritrade/Schwab brokerage account
- API connection configured in MarketXLS
- Sufficient buying power/margin
Parameters
| Parameter | Required | Description |
|---|---|---|
| TradeType | Yes | 'equity' for stocks, 'option' for options |
| Symbol | Yes | Stock ticker symbol |
| Quantity | Yes | Number of shares or contracts |
| OrderSide | Yes | Order direction (see below) |
| OrderType | Yes | MARKET, LIMIT, STOP, STOP_LIMIT |
| Duration | No | DAY, GTC, FOK |
| SymbolOption | No | TDA option symbol (options only) |
| Price | No | Limit price |
| TriggerPrice | No | Stop trigger price |
Order Sides (UPPERCASE)
| For Stocks | For Options |
|---|---|
| BUY | BUY_TO_OPEN |
| SELL | BUY_TO_CLOSE |
| - | SELL_TO_OPEN |
| - | SELL_TO_CLOSE |
WARNING
This function places REAL trades. Always verify parameters before executing.
Examples
Stock trades
=TradeSingleLegThinkOrSwim("equity", "AAPL", 100, "BUY", "MARKET")=TradeSingleLegThinkOrSwim("equity", "MSFT", 50, "SELL", "LIMIT", "DAY", , 380)Option trades
=TradeSingleLegThinkOrSwim("option", "AAPL", 5, "BUY_TO_OPEN", "LIMIT", "DAY", "AAPL_011924C180", 5.50)=TradeSingleLegThinkOrSwim("option", "SPY", 10, "SELL_TO_CLOSE", "MARKET", , "SPY_011924P475")Stop orders
=TradeSingleLegThinkOrSwim("equity", "TSLA", 25, "SELL", "STOP", "GTC", , , 200)When to Use
- Placing stock buy/sell orders through ThinkOrSwim
- Executing single-leg option trades via TDA
- Setting limit or stop orders
- Automating trade execution from Excel
When NOT to Use
| Scenario | Use Instead |
|---|---|
| Multi-leg option strategies | TradeMultiLegThinkOrSwim() |
| Tradier broker | TradeSingleLegTradier() |
| Orion broker | TradeSingleLegOrion() |
| Just need quotes | Last(), Option_Last_Price() |
Common Issues & FAQ
Q: Why is my order rejected? A: Common reasons:
- Insufficient buying power
- Invalid option symbol format (TDA uses different format)
- Market closed
- Account restrictions
Q: What option symbol format does TDA use? A: TDA format: SYMBOL_MMDDYYCP + STRIKE (e.g., AAPL_011924C180) This is different from standard OCC format.
Q: What's the difference between DAY and GTC? A: DAY = order expires end of day. GTC = good til cancelled (up to 60 days).
