summaryrefslogtreecommitdiff
path: root/services/strategy-engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'services/strategy-engine/src')
-rw-r--r--services/strategy-engine/src/strategy_engine/main.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/services/strategy-engine/src/strategy_engine/main.py b/services/strategy-engine/src/strategy_engine/main.py
index 411c54b..2852b53 100644
--- a/services/strategy-engine/src/strategy_engine/main.py
+++ b/services/strategy-engine/src/strategy_engine/main.py
@@ -5,6 +5,8 @@ from datetime import datetime
from pathlib import Path
import zoneinfo
+import aiohttp
+
from shared.alpaca import AlpacaClient
from shared.broker import RedisBroker
from shared.db import Database
@@ -64,8 +66,17 @@ async def run_stock_selector(
log.info("stock_selector_complete", picks=[s.symbol for s in selections])
else:
log.info("stock_selector_no_picks")
+ except (
+ aiohttp.ClientError,
+ ConnectionError,
+ TimeoutError,
+ asyncio.TimeoutError,
+ ) as exc:
+ log.warning("stock_selector_network_error", error=str(exc))
+ except (ValueError, KeyError, TypeError) as exc:
+ log.warning("stock_selector_data_error", error=str(exc))
except Exception as exc:
- log.error("stock_selector_error", error=str(exc))
+ log.error("stock_selector_error", error=str(exc), exc_info=True)
await asyncio.sleep(120) # Sleep past this minute
else:
await asyncio.sleep(30)
@@ -137,7 +148,7 @@ async def run() -> None:
await shutdown.wait()
except Exception as exc:
- log.error("fatal_error", error=str(exc))
+ log.error("fatal_error", error=str(exc), exc_info=True)
await notifier.send_error(str(exc), "strategy-engine")
raise
finally: