File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -124,11 +124,11 @@ def compute_recommendation(ticker):
124124 if option_chain :
125125 try :
126126 exp_dates = sorted (option_chain .keys ())
127- today = datetime . today (). date ()
128- # only consider expiries strictly after today (no 0DTE)
129- exp_dates_filtered = [ d for d in exp_dates if ( datetime . strptime ( d , "%Y-%m-%d" ). date () - today ). days > 0 ]
130- if len ( exp_dates_filtered ) < 2 :
131- raise Exception ( " Not enough option data from Alpaca." )
127+ # apply 45-day window and drop 0DTE using filter_dates ()
128+ try :
129+ exp_dates_filtered = filter_dates ( exp_dates )
130+ except ValueError :
131+ return "Error: Not enough option data."
132132 underlying_price = None
133133 try :
134134 from alpaca .data .historical import StockHistoricalDataClient
You can’t perform that action at this time.
0 commit comments