Skip to content

Commit 2dfd565

Browse files
Add times
1 parent b92d2af commit 2dfd565

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

.github/workflows/config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ name: Earnings Trade Automation
33
# This workflow runs on push, pull request, and at key US market times for trade open/close (per trade_key_points.md)
44
on:
55
schedule:
6-
# 9:45 AM ET (13:45 UTC) and 3:45 PM ET (19:45 UTC), Monday-Friday
7-
- cron: '45 13 * * 1-5' # 9:45 AM ET, for closing trades
8-
- cron: '45 19 * * 1-5' # 3:45 PM ET, for opening trades
6+
# 9:45 AM ET (Eastern Time)
7+
- cron: '45 13 * * 1-5' # 9:45 AM ET during EST (UTC-5)
8+
- cron: '45 14 * * 1-5' # 9:45 AM ET during EDT (UTC-4)
9+
# 3:45 PM ET (Eastern Time)
10+
- cron: '45 19 * * 1-5' # 3:45 PM ET during EST (UTC-5)
11+
- cron: '45 20 * * 1-5' # 3:45 PM ET during EDT (UTC-4)
912

1013
jobs:
1114
build:

requirements.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1+
alpaca-py==0.39.3
2+
annotated-types==0.7.0
13
beautifulsoup4==4.13.4
24
certifi==2025.1.31
35
charset-normalizer==3.4.1
6+
FreeSimpleGUI==5.1.1
47
frozendict==2.4.6
58
idna==3.10
9+
msgpack==1.1.0
610
multitasking==0.0.11
711
numpy==2.1.0
812
pandas==2.2.3
913
peewee==3.17.9
1014
platformdirs==4.3.7
15+
pydantic==2.11.3
16+
pydantic_core==2.33.1
1117
python-dateutil==2.9.0.post0
1218
python-dotenv==1.1.0
1319
pytz==2025.2
1420
requests==2.32.3
1521
scipy==1.15.1
1622
six==1.17.0
1723
soupsieve==2.6
24+
sseclient-py==1.8.0
25+
typing-inspection==0.4.0
1826
typing_extensions==4.13.2
1927
tzdata==2025.2
2028
urllib3==2.4.0
29+
websockets==15.0.1
2130
yfinance==0.2.54
22-
alpaca-py

trade_workflow.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import yfinance as yf
88
from alpaca.data.historical import OptionHistoricalDataClient
99
from alpaca.data.requests import OptionLatestQuoteRequest
10+
from zoneinfo import ZoneInfo
1011

1112
load_dotenv()
1213
GOOGLE_SCRIPT_URL = os.environ.get("GOOGLE_SCRIPT_URL")
@@ -47,22 +48,24 @@ def update_trade(trade_data):
4748
return None
4849

4950
def is_time_to_open(earnings_date, when):
50-
now = datetime.now()
51+
eastern = ZoneInfo("America/New_York")
52+
now = datetime.now(tz=eastern)
5153
market_close = time(16, 0)
5254
if when == "BMO":
53-
open_dt = datetime.combine(earnings_date - timedelta(days=1), market_close) - timedelta(minutes=15)
55+
open_dt = datetime.combine(earnings_date - timedelta(days=1), market_close, tzinfo=eastern) - timedelta(minutes=15)
5456
else: # AMC
55-
open_dt = datetime.combine(earnings_date, market_close) - timedelta(minutes=15)
56-
return now >= open_dt and now < open_dt + timedelta(minutes=30)
57+
open_dt = datetime.combine(earnings_date, market_close, tzinfo=eastern) - timedelta(minutes=15)
58+
return open_dt <= now < open_dt + timedelta(minutes=30)
5759

5860
def is_time_to_close(earnings_date, when):
59-
now = datetime.now()
61+
eastern = ZoneInfo("America/New_York")
62+
now = datetime.now(tz=eastern)
6063
open_time = time(9, 30)
6164
if when == "BMO":
62-
close_dt = datetime.combine(earnings_date, open_time) + timedelta(minutes=15)
65+
close_dt = datetime.combine(earnings_date, open_time, tzinfo=eastern) + timedelta(minutes=15)
6366
else: # AMC
64-
close_dt = datetime.combine(earnings_date + timedelta(days=1), open_time) + timedelta(minutes=15)
65-
return now >= close_dt and now < close_dt + timedelta(minutes=30)
67+
close_dt = datetime.combine(earnings_date + timedelta(days=1), open_time, tzinfo=eastern) + timedelta(minutes=15)
68+
return close_dt <= now < close_dt + timedelta(minutes=30)
6669

6770
def select_expiries_and_strike_yahoo(stock, earnings_date):
6871
"""

0 commit comments

Comments
 (0)