Replace print statements with proper logging for consistent log file output

This commit is contained in:
justin committed 2026-02-04 16:36:16 -07:00
1 parent e210dc7a4a
commit e615473d22
2 files changed
+10 -5

No files matched your search

+2 -1
View File
@@ -95,5 +95,6 @@ class AlpacaClient:
return float(status.filled_avg_price) return float(status.filled_avg_price)
return None return None
except Exception as e: except Exception as e:
print(f"Order placement error: {e}") import logging
logging.error(f"Order placement error: {e}")
return None return None
+8 -4
View File
@@ -1,9 +1,12 @@
import pandas as pd import pandas as pd
from datetime import datetime from datetime import datetime
import logging
from .indicators import ema, sma, rsi, adx, atr, bollinger, macd from .indicators import ema, sma, rsi, adx, atr, bollinger, macd
from .api import AlpacaClient from .api import AlpacaClient
from .utils import EASTERN from .utils import EASTERN
logger = logging.getLogger(__name__)
def check_volume(bars: pd.DataFrame, multiplier: float): def check_volume(bars: pd.DataFrame, multiplier: float):
if len(bars) < 20 or "volume" not in bars.columns: if len(bars) < 20 or "volume" not in bars.columns:
return True return True
@@ -84,15 +87,16 @@ def get_vix(client: AlpacaClient, symbol: str, use_vix_filter: bool):
if len(vix) > 0: if len(vix) > 0:
return vix["close"].iloc[-1] return vix["close"].iloc[-1]
except Exception as e: except Exception as e:
print(f"Warning: VIX data unavailable: {e}") logger.warning(f"VIX data unavailable: {e}")
try: try:
spy = client.get_bars(symbol, "1Day", limit=20) spy = client.get_bars(symbol, "1Day", limit=20)
if len(spy) >= 20: if len(spy) >= 20:
returns = spy["close"].pct_change() returns = spy["close"].pct_change()
calculated_vix = returns.std() * (252 ** 0.5) * 100 calculated_vix = returns.std() * (252 ** 0.5) * 100
print(f"Using calculated volatility as VIX proxy: {calculated_vix:.1f}") logger.info(f"Using calculated volatility as VIX proxy: {calculated_vix:.1f}")
return calculated_vix return calculated_vix
except Exception as e: except Exception as e:
print(f"Warning: Could not calculate volatility: {e}") logger.warning(f"Could not calculate volatility: {e}")
print("Warning: VIX data unavailable, skipping VIX filter for this iteration") logger.warning("VIX data unavailable, skipping VIX filter for this iteration")
return 0
return 0 return 0