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.
🎯 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.
Fetches available options contracts for your chosen expiration date and automatically calculates optimal strike prices based on current market price.
Monitors buy leg, sell leg, and underlying positions every minute during market hours (9 AM - 3 PM ET, Monday-Friday).
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.
Tracks market value, calculates annualized returns, and exports performance metrics to CSV for detailed analysis.
Filters contracts by open interest (>1000) to ensure sufficient liquidity for smooth trade execution.
Uses limit orders for underlying stock trades to ensure precise entry prices when hedging the options position.
The flow executes the bear put spread strategy in a structured sequence:
Reset all flow variables to ensure a clean starting state before executing the strategy.
Configure the underlying asset (XLK) and options expiration date (e.g., December 19, 2025).
Get the real-time price of XLK to determine appropriate strike prices for the spread.
Retrieve available put options contracts for the specified expiration date range.
Determine buy strike (ATM) and sell strike (10 points lower) based on current price.
Purchase 100 shares of XLK in Paper Account 1 and short 100 shares in Paper Account 2.
Buy the higher-strike put and sell the lower-strike put to establish the bear put spread.
⚠️ 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).
Click the button below to copy the complete flow configuration to your clipboard:
📄 Note: The JSON code will be loaded dynamically. If it doesn't appear, please download the JSON file directly.
You can easily customize this flow to fit your options trading goals:
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.
Update the expirationDate variable to target different expiration cycles. Consider weekly, monthly, or quarterly options based on your trading timeframe.
The default spread width is $10. Modify the "store contracts" function to change the strikeLower = strike - 10 calculation for wider or narrower spreads.
Adjust the open interest filter threshold in the "filter contracts by open_interest" function. Higher thresholds ensure better liquidity but fewer available contracts.