Bear Put Spread Options Flow

Profit from bearish market moves with this defined-risk options strategy using automated Node-RED trading
Illustration Blog Header

What is a Bear Put Spread?

A Bear Put Spread (also called a "Long Put Spread") is a bearish options strategy designed to profit when the underlying asset's price declines moderately. This Node-RED flow automates the entire strategy execution using the Alpaca API, including contract selection, order execution, position tracking, and performance analytics.

📉 Bearish Strategy 🛡️ Defined Risk 📋 Options Trading XLK - Tech ETF Put Options Vertical Spread
XLK
Underlying Asset
2
Option Legs
$10
Strike Width
Defined
Risk Profile

📊 Bear Put Spread Structure

BUY Put option at higher strike price (at-the-money) — costs more premium
SELL Put option at lower strike price (out-of-the-money) — receives premium to offset cost

🎯 Risk Profile: Maximum loss is limited to the net debit paid when entering the trade. Maximum profit is achieved when the underlying falls to or below the lower strike price at expiration.

Key Features

🔍 Automatic Contract Selection

Fetches available options contracts for your chosen expiration date and automatically calculates optimal strike prices based on current market price.

📊 Real-Time Position Tracking

Monitors buy leg, sell leg, and underlying positions every minute during market hours (9 AM - 3 PM ET, Monday-Friday).

💼 Multi-Account Support

Uses two paper accounts to manage the underlying stock hedge — buying shares in one account while shorting in another to create a pure options play.

📈 Performance Analytics

Tracks market value, calculates annualized returns, and exports performance metrics to CSV for detailed analysis.

🎚️ Open Interest Filtering

Filters contracts by open interest (>1000) to ensure sufficient liquidity for smooth trade execution.

⚡ Limit Order Execution

Uses limit orders for underlying stock trades to ensure precise entry prices when hedging the options position.

Flow Workflow Steps

The flow executes the bear put spread strategy in a structured sequence:

Clear Flow Variables

Reset all flow variables to ensure a clean starting state before executing the strategy.

Set Ticker & Expiration

Configure the underlying asset (XLK) and options expiration date (e.g., December 19, 2025).

Fetch Current Price

Get the real-time price of XLK to determine appropriate strike prices for the spread.

Fetch Options Contracts

Retrieve available put options contracts for the specified expiration date range.

Calculate Strike Prices

Determine buy strike (ATM) and sell strike (10 points lower) based on current price.

Buy Underlying Hedge

Purchase 100 shares of XLK in Paper Account 1 and short 100 shares in Paper Account 2.

Execute Options Trades

Buy the higher-strike put and sell the lower-strike put to establish the bear put spread.

How to Import This Flow

  1. Copy the JSON code from the box below by clicking the "Copy to Clipboard" button.
  2. Open your MachineTrader Node-RED editor.
  3. Click the hamburger menu (☰) in the top-right corner.
  4. Select Import from the dropdown menu.
  5. Paste the JSON code into the import dialog.
  6. Click Import to add the flow to your workspace.
  7. Configure your Alpaca credentials in both Paper 1 and Paper 2 configuration nodes.
  8. Click Deploy to activate the flow.

⚠️ Important: This flow requires TWO Alpaca paper trading accounts. Options trading involves substantial risk and may not be suitable for all investors. The strategy requires holding 100 shares of the underlying asset to sell covered options. Always test thoroughly before using real funds.

💡 Note: This flow trades on XLK (Technology Select Sector SPDR ETF) due to its high liquidity and relatively low volatility. You can modify the underlying asset and expiration date in the "set variables" function node. The flow monitors positions during market hours only (9 AM - 3 PM ET).

Node-RED Flow JSON

Click the button below to copy the complete flow configuration to your clipboard:

Bear Put Spread.json

📄 Note: The JSON code will be loaded dynamically. If it doesn't appear, please download the JSON file directly.

Customization Options

You can easily customize this flow to fit your options trading goals:

🔄 Change Underlying Asset

Edit the "set variables" function node to change the underlying value from XLK to any optionable stock or ETF. Ensure the asset has sufficient options liquidity.

📅 Modify Expiration Date

Update the expirationDate variable to target different expiration cycles. Consider weekly, monthly, or quarterly options based on your trading timeframe.

📊 Adjust Strike Width

The default spread width is $10. Modify the "store contracts" function to change the strikeLower = strike - 10 calculation for wider or narrower spreads.

🎚️ Filter by Open Interest

Adjust the open interest filter threshold in the "filter contracts by open_interest" function. Higher thresholds ensure better liquidity but fewer available contracts.