Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ To get started with the repository, follow these steps:
```

2. **Setup Alpaca API Keys**:
Create account on Alpaca and retrieve API key/secret: https://app.alpaca.markets/user/profile#manage-accounts. Add ALPACA_API_KEY and ALPACA_API_SECRET to environment variables.
Create account on Alpaca and retrieve API key/secret: https://app.markets/user/profile#manage-accounts. Add ALPACA_API_KEY and ALPACA_API_SECRET to environment variables.

3. **Update the `.env` file**:
```
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ services:
kafka-topic-init:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "python", "-m", "src.feed_ingestor.alpaca.healthcheck"]
test: ["CMD", "python", "-m", "src.feed_ingestor.healthcheck"]
interval: 30s
timeout: 10s
retries: 3
Expand Down
2 changes: 1 addition & 1 deletion services/feed-ingestor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt

COPY src /app/src

CMD ["python", "-m", "src.feed_ingestor.alpaca.main"]
CMD ["python", "-m", "src.feed_ingestor.main"]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import websockets

from src.feed_ingestor.alpaca.metrics import (
from src.feed_ingestor.metrics import (
NUM_ALPACA_EVENTS,
NUM_ALPACA_RESPONSES,
)
Expand All @@ -12,7 +12,7 @@


class AlpacaClient:
ALPACA_URL = "wss://stream.data.alpaca.markets"
ALPACA_URL = "wss://stream.data.markets"
ALPACA_FEED = "v2/iex"
AUTHORIZE_ACTION = "auth"
SUBSCRIBE_ACTION = "subscribe"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from src.feed_ingestor.alpaca.alpaca_client import AlpacaClient
from src.feed_ingestor.alpaca.fake_alpaca_client import FakeAlpacaClient
from src.feed_ingestor.alpaca_client import AlpacaClient
from src.feed_ingestor.fake_alpaca_client import FakeAlpacaClient

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from aiokafka import AIOKafkaProducer

from src.feed_ingestor.alpaca.metrics import NUM_EVENTS_FAILED, NUM_EVENTS_PROCESSED
from src.feed_ingestor.metrics import NUM_EVENTS_FAILED, NUM_EVENTS_PROCESSED
from src.models.bar_model import Bar
from src.models.ticker_model import Ticker

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from asyncio import Queue

from src.feed_ingestor.alpaca.bar_event_processor import BarEventProcessor
from src.feed_ingestor.alpaca.metrics import NUM_QUEUE_DEQUEUED
from src.feed_ingestor.bar_event_processor import BarEventProcessor
from src.feed_ingestor.metrics import NUM_QUEUE_DEQUEUED
from src.models.bar_model import EVENT_TYPE


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from asyncio import Queue

from src.feed_ingestor.alpaca.alpaca_client import AlpacaClient
from src.feed_ingestor.alpaca.metrics import NUM_ALPACA_ERRORS, NUM_QUEUE_ENQUEUED
from src.feed_ingestor.alpaca_client import AlpacaClient
from src.feed_ingestor.metrics import NUM_ALPACA_ERRORS, NUM_QUEUE_ENQUEUED

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random
from datetime import datetime, timezone

from src.feed_ingestor.alpaca.metrics import (
from src.feed_ingestor.metrics import (
NUM_ALPACA_EVENTS,
NUM_ALPACA_RESPONSES,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from aiokafka import AIOKafkaProducer
from prometheus_client import start_http_server

from src.feed_ingestor.alpaca.alpaca_client_factory import create_alpaca_client
from src.feed_ingestor.alpaca.bar_event_processor import BarEventProcessor
from src.feed_ingestor.alpaca.event_consumer import EventConsumer
from src.feed_ingestor.alpaca.event_producer import EventProducer
from src.feed_ingestor.alpaca_client_factory import create_alpaca_client
from src.feed_ingestor.bar_event_processor import BarEventProcessor
from src.feed_ingestor.event_consumer import EventConsumer
from src.feed_ingestor.event_producer import EventProducer
from src.models.bar_model import MINUTE_BAR_EVENT_TYPE
from src.util.environment import get_env

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from prometheus_client import REGISTRY

from src.feed_ingestor.alpaca.alpaca_client import AlpacaClient
from src.feed_ingestor.alpaca_client import AlpacaClient


class FakeWebSocket:
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_alpaca_client_get_events(monkeypatch):
def fake_connect(url):
return FakeConnect(fake_ws)

monkeypatch.setattr("src.feed_ingestor.alpaca.alpaca_client.websockets.connect", fake_connect)
monkeypatch.setattr("src.feed_ingestor.alpaca_client.websockets.connect", fake_connect)

client = AlpacaClient(api_key="key", api_secret="secret")
responses_before = REGISTRY.get_sample_value("num_alpaca_responses_total") or 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from src.feed_ingestor.alpaca.bar_event_processor import BarEventProcessor
from src.feed_ingestor.bar_event_processor import BarEventProcessor
from src.models.bar_model import (
CLOSE_PRICE,
HIGH_PRICE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

from src.feed_ingestor.alpaca.event_consumer import EventConsumer
from src.feed_ingestor.event_consumer import EventConsumer
from src.models.bar_model import EVENT_TYPE, MINUTE_BAR_EVENT_TYPE


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from src.feed_ingestor.alpaca.event_producer import EventProducer
from src.feed_ingestor.alpaca.metrics import NUM_ALPACA_ERRORS
from src.feed_ingestor.event_producer import EventProducer
from src.feed_ingestor.metrics import NUM_ALPACA_ERRORS


class FakeClient:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from src.feed_ingestor.alpaca.alpaca_client import AlpacaClient
from src.feed_ingestor.alpaca.alpaca_client_factory import create_alpaca_client
from src.feed_ingestor.alpaca.fake_alpaca_client import (
from src.feed_ingestor.alpaca_client import AlpacaClient
from src.feed_ingestor.alpaca_client_factory import create_alpaca_client
from src.feed_ingestor.fake_alpaca_client import (
ANOMALY_INTERVAL,
BASE_PRICE,
BASE_VOLUME,
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_fake_alpaca_client_waits_when_interval(monkeypatch):
async def fake_sleep(duration):
sleep_calls.append(duration)

monkeypatch.setattr("src.feed_ingestor.alpaca.fake_alpaca_client.asyncio.sleep", fake_sleep)
monkeypatch.setattr("src.feed_ingestor.fake_alpaca_client.asyncio.sleep", fake_sleep)

client = FakeAlpacaClient(interval_seconds=1)
asyncio.run(asyncio.wait_for(_get_first_event(client), timeout=0.1))
Expand All @@ -67,11 +67,11 @@ def test_fake_alpaca_client_generates_normal_variation(monkeypatch):
client._last_close_price = BASE_PRICE

monkeypatch.setattr(
"src.feed_ingestor.alpaca.fake_alpaca_client.random.uniform",
"src.feed_ingestor.fake_alpaca_client.random.uniform",
lambda *_: -0.001,
)
monkeypatch.setattr(
"src.feed_ingestor.alpaca.fake_alpaca_client.random.randint",
"src.feed_ingestor.fake_alpaca_client.random.randint",
lambda *_: 1,
)

Expand All @@ -94,7 +94,7 @@ def fake_uniform(a, b):
return 0.1 if len(uniform_calls) == 1 else 8.0

monkeypatch.setattr(
"src.feed_ingestor.alpaca.fake_alpaca_client.random.uniform",
"src.feed_ingestor.fake_alpaca_client.random.uniform",
fake_uniform,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from src.feed_ingestor.alpaca import healthcheck
from src.feed_ingestor import healthcheck


class _DummyProducer:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

import src.feed_ingestor.alpaca.main as main_module
import src.feed_ingestor.main as main_module


def _set_common_env(monkeypatch):
Expand Down