summaryrefslogtreecommitdiff
path: root/services/data-collector
diff options
context:
space:
mode:
Diffstat (limited to 'services/data-collector')
-rw-r--r--services/data-collector/src/data_collector/main.py7
-rw-r--r--services/data-collector/tests/test_storage.py9
2 files changed, 8 insertions, 8 deletions
diff --git a/services/data-collector/src/data_collector/main.py b/services/data-collector/src/data_collector/main.py
index 8b9f301..2d44848 100644
--- a/services/data-collector/src/data_collector/main.py
+++ b/services/data-collector/src/data_collector/main.py
@@ -4,6 +4,7 @@ import asyncio
import aiohttp
+from data_collector.config import CollectorConfig
from shared.alpaca import AlpacaClient
from shared.broker import RedisBroker
from shared.db import Database
@@ -15,8 +16,6 @@ from shared.models import Candle
from shared.notifier import TelegramNotifier
from shared.shutdown import GracefulShutdown
-from data_collector.config import CollectorConfig
-
# Health check port: base + 0
HEALTH_PORT_OFFSET = 0
@@ -48,7 +47,7 @@ async def fetch_latest_bars(
volume=Decimal(str(bar["v"])),
)
candles.append(candle)
- except (aiohttp.ClientError, ConnectionError, TimeoutError, asyncio.TimeoutError) as exc:
+ except (aiohttp.ClientError, ConnectionError, TimeoutError) as exc:
log.warning("fetch_bar_network_error", symbol=symbol, error=str(exc))
except (ValueError, KeyError, TypeError) as exc:
log.warning("fetch_bar_parse_error", symbol=symbol, error=str(exc))
@@ -98,7 +97,7 @@ async def run() -> None:
# Check if market is open
try:
is_open = await alpaca.is_market_open()
- except (aiohttp.ClientError, ConnectionError, TimeoutError, asyncio.TimeoutError):
+ except (aiohttp.ClientError, ConnectionError, TimeoutError):
is_open = False
if is_open:
diff --git a/services/data-collector/tests/test_storage.py b/services/data-collector/tests/test_storage.py
index ffffa40..51f3aee 100644
--- a/services/data-collector/tests/test_storage.py
+++ b/services/data-collector/tests/test_storage.py
@@ -1,19 +1,20 @@
"""Tests for storage module."""
-import pytest
+from datetime import UTC, datetime
from decimal import Decimal
-from datetime import datetime, timezone
from unittest.mock import AsyncMock, MagicMock
-from shared.models import Candle
+import pytest
from data_collector.storage import CandleStorage
+from shared.models import Candle
+
def _make_candle(symbol: str = "AAPL") -> Candle:
return Candle(
symbol=symbol,
timeframe="1m",
- open_time=datetime(2024, 1, 1, 0, 0, 0, tzinfo=timezone.utc),
+ open_time=datetime(2024, 1, 1, 0, 0, 0, tzinfo=UTC),
open=Decimal("30000"),
high=Decimal("30100"),
low=Decimal("29900"),