fix: Correct interval format and enhance data fetching error handling in ATR-EMA scanner
This commit is contained in:
parent
86686125f3
commit
114e0f6165
@ -56,8 +56,19 @@ def run_atr_ema_target_scanner(min_price: float, max_price: float, min_volume: i
|
|||||||
|
|
||||||
for ticker, current_price, current_volume, last_update in stocks:
|
for ticker, current_price, current_volume, last_update in stocks:
|
||||||
try:
|
try:
|
||||||
df = get_stock_data(ticker, start_date, end_date, "1D")
|
# Validate interval and fetch data
|
||||||
if df.empty or len(df) < 50:
|
VALID_INTERVALS = ["1d", "5m", "15m", "30m", "1h", "4h", "1w"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
df = get_stock_data(ticker, start_date, end_date, "1d")
|
||||||
|
if df.empty or len(df) < 50:
|
||||||
|
print(f"⚠️ {ticker}: Insufficient historical data ({len(df)} bars)")
|
||||||
|
continue
|
||||||
|
if "1d" not in VALID_INTERVALS:
|
||||||
|
raise ValueError(f"Invalid interval format. Must be one of: {VALID_INTERVALS}")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Data fetch failed for {ticker}: {str(e)}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
results = indicator.calculate(df)
|
results = indicator.calculate(df)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user