Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automated Python trading bot for earnings calendar spread options with Kelly Criterion, Alpaca API integration, and Google Sheets tracking.

License

NotificationsYou must be signed in to change notification settings

ProgramComputer/earnings-trade-automation

Repository files navigation

Automated trading bot for executing earnings calendar spread strategies using options in a workflow automation. Integrates with Google Sheets for trade tracking and Alpaca for order execution.

Features

  • Automated Earnings Calendar Spread Trading: Opens and closes calendar spreads around earnings events based on strict screening criteria.
  • Kelly Criterion Position Sizing: Uses a 10% Kelly fraction for optimal, risk-managed position sizing.
  • Google Sheets Integration: Tracks trades and workflow status in a Google Sheet via Apps Script.
  • Alpaca API Integration: Places and closes trades automatically using Alpaca brokerage API.
  • Configurable and Extensible: Modular codebase for easy strategy tweaks and integration.

Strategy Overview

We implement an earnings volatility selling strategy focusing on calendar spreads around earnings events:

  • Rationale: Implied volatility spikes ahead of earnings due to hedgers and speculators, creating an opportunity to profit from IV crush and muted stock moves.
  • Trade Structure: At-the-money calendar spreads with a 30-day expiration gap for stability, offering controlled risk compared to straddles.
  • Screening Criteria: Filter for high-probability trades using:
    • Term Structure Slope: Negative slope between front-month and 45-day expirations (backwardation).
    • 30-Day Average Volume: Ensures sufficient liquidity and price-insensitive demand.
    • IV/RV Ratio: High implied-to-realized volatility ratio indicates overpriced options.
  • Position Sizing: Apply a 10% Kelly fraction for optimal, risk-managed sizing.

Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/earnings-calendar-spread-bot.gitcd earnings-calendar-spread-bot

2. Google Sheets Set Up (Optional)

Create a copy ofhttps://docs.google.com/spreadsheets/d/1qOu4PJtcpYwLZgFFIpVr8FXD12dXoWZaKxSeg9FR7lU/ and add code.gs to App Script

3. Set Up Environment Variables

Create a.env file in the root directory with your credentials:

APCA_API_KEY_ID=your-alpaca-keyAPCA_API_SECRET_KEY=your-alpaca-secretGOOGLE_SCRIPT_URL=your-google-apps-script-urlALPACA_PAPER=true  # Set to 'false' to use live trading (default is 'true' for paper trading)

4. Install Dependencies

pip install -r requirements.txt

5. Reset Local Trade Database

Before running the bot for the first time (or to start fresh), delete the existing SQLite database file:

rm trades.db# Mac/Linuxdel trades.db# Windows (PowerShell)

6. Run the Bot

python automation.py

7. Automate with GitHub Actions

  • Fork the repository to your GitHub account (required to enable Actions).
  • In your fork, navigate toSettings > Secrets > Actions and add your environment variables.
  • Enable the GitHub Actions workflow in theActions tab.

Example Workflow

  • Screen for Earnings: Bot fetches tomorrow's earnings tickers.
  • Screening & Sizing: For each ticker, applies IV/volume/slope criteria and calculates position size using Kelly.
  • Open Trades: Places calendar spread trades at the correct time (BMO/AMC logic).
  • Track & Close: Monitors open trades and closes them at the correct time, updating Google Sheets.

Disclaimer

This software is provided solely for educational and research purposes. It is not intended to provide investment advice. The developers are not financial advisors and accept no responsibility for any financial decisions or losses resulting from the use of this software. Always consult a professional financial advisor before making any investment decisions.


Happy trading, and trade responsibly!

About

Automated Python trading bot for earnings calendar spread options with Kelly Criterion, Alpaca API integration, and Google Sheets tracking.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp