Skip to content

Commit eca6356

Browse files
committed
♻️ Add GetEntryParams model and utility functions for default entry parameters
1 parent fe9aed6 commit eca6356

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

pragma/models/schemas.py

+10
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,13 @@ class AggregatedOnchainResponse(BaseModel):
3232
macd: str = Field(default="N/A", description="Moving Average Convergence Divergence")
3333
error: str | None = Field(default=None, description="Error message if any")
3434
isUnsupported: bool = Field(default=False, description="Flag indicating if the pair is unsupported")
35+
36+
37+
class GetEntryParams(BaseModel):
38+
"""Parameters for entry requests."""
39+
40+
aggregation: str | None = None
41+
entry_type: str | None = None
42+
interval: str | None = None
43+
routing: bool = True
44+
timestamp: int | None = None

pragma/models/utils.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Utility functions for the models"""
2+
3+
DEFAULT_PAIRS = ["ETH/USD", "BTC/USD"]
4+
5+
# Default entry parameters matching API.devnet
6+
DEFAULT_ENTRY_PARAMS = {
7+
"aggregation": "median",
8+
"entry_type": None, # Changeable from the frontend
9+
"interval": None, # Changeable from the frontend
10+
"routing": True,
11+
"timestamp": None,
12+
}

pragma/routers/endpoints/streaming.py

+2-23
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,18 @@
44
import httpx
55
from fastapi import APIRouter, Depends, Query
66
from fastapi.responses import StreamingResponse
7-
from pydantic import BaseModel
87

98
from pragma.client.client import PragmaApiClient
109
from pragma.client.token import get_api_client
10+
from pragma.models.schemas import GetEntryParams
11+
from pragma.models.utils import DEFAULT_ENTRY_PARAMS
1112
from pragma.utils.logging import logger
1213

1314
app = APIRouter(
1415
prefix="/data/multi",
1516
)
1617

1718

18-
class GetEntryParams(BaseModel):
19-
"""Parameters for entry requests."""
20-
21-
aggregation: str | None = None
22-
entry_type: str | None = None
23-
interval: str | None = None
24-
routing: bool = True
25-
timestamp: int | None = None
26-
27-
28-
DEFAULT_PAIRS = ["ETH/USD", "BTC/USD"]
29-
30-
# Default entry parameters matching API.devnet
31-
DEFAULT_ENTRY_PARAMS = {
32-
"aggregation": "median",
33-
"entry_type": None, # Changeable from the frontend
34-
"interval": None, # Changeable from the frontend
35-
"routing": True,
36-
"timestamp": None,
37-
}
38-
39-
4019
@app.get(
4120
"/stream",
4221
responses={

0 commit comments

Comments
 (0)