Skip to content

Commit

Permalink
feat(merkle_maker): Fixed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Jul 31, 2024
1 parent 67478a2 commit ae680c8
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions pragma-sdk/pragma_sdk/offchain/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ async def get_ohlc(
path_params = {
key: value
for key, value in {
"timestamp": str(timestamp),
"interval": str(interval),
"timestamp": timestamp,
"interval": interval,
"aggregation": (
str(aggregation.value.lower()) if aggregation is not None else None
aggregation.value.lower() if aggregation is not None else None
),
}.items()
if value is not None
Expand All @@ -103,7 +103,9 @@ async def get_ohlc(
# Create connection
async with aiohttp.ClientSession() as session:
async with session.get(
url, headers=headers, params=path_params
url,
headers=headers,
params=path_params, # type: ignore[arg-type]
) as response_raw:
status_code: int = response_raw.status
response: Dict = await response_raw.json()
Expand Down Expand Up @@ -168,8 +170,8 @@ async def _create_entries(
url = f"{self.api_base_url}{endpoint}"

headers: Dict = {
"PRAGMA-TIMESTAMP": str(now),
"PRAGMA-SIGNATURE-EXPIRATION": str(expiry),
"PRAGMA-TIMESTAMP": now,
"PRAGMA-SIGNATURE-EXPIRATION": expiry,
"x-api-key": self.api_key,
}

Expand Down Expand Up @@ -218,10 +220,10 @@ async def get_entry(
params = {
key: value
for key, value in {
"routing": str(routing),
"timestamp": str(timestamp),
"interval": str(interval.value) if interval else None,
"aggregation": str(aggregation.value.lower()) if aggregation else None,
"routing": routing,
"timestamp": timestamp,
"interval": interval.value if interval else None,
"aggregation": aggregation.value.lower() if aggregation else None,
}.items()
if value is not None
}
Expand All @@ -231,7 +233,7 @@ async def get_entry(
}

async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers, params=params) as response_raw:
async with session.get(url, headers=headers, params=params) as response_raw: # type: ignore[arg-type]
status_code: int = response_raw.status
response: Dict = await response_raw.json()
if status_code == 200:
Expand Down Expand Up @@ -277,12 +279,12 @@ async def get_future_entry(
params = {
key: value
for key, value in {
"routing": str(routing),
"timestamp": str(timestamp),
"interval": str(interval.value) if interval else None,
"aggregation": str(aggregation.value.lower()) if aggregation else None,
"routing": routing,
"timestamp": timestamp,
"interval": interval.value if interval else None,
"aggregation": aggregation.value.lower() if aggregation else None,
"entry_type": "future",
"expiry": str(expiry) if expiry else None,
"expiry": expiry if expiry else None,
}.items()
if value is not None
}
Expand All @@ -292,7 +294,7 @@ async def get_future_entry(
}

async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers, params=params) as response:
async with session.get(url, headers=headers, params=params) as response: # type: ignore[arg-type]
status_code: int = response.status
json_response: Dict = await response.json()
if status_code == 200:
Expand Down Expand Up @@ -332,15 +334,15 @@ async def get_volatility(self, pair: str, start: int, end: int):
}

params = {
"start": str(start),
"end": str(end),
"start": start,
"end": end,
}

# Construct URL with parameters
url = f"{self.api_base_url}{endpoint}"
# Send GET request with headers
async with aiohttp.ClientSession() as session:
async with session.get(url, headers=headers, params=params) as response_raw:
async with session.get(url, headers=headers, params=params) as response_raw: # type: ignore[arg-type]
status_code: int = response_raw.status
response: Dict = await response_raw.json()
if status_code == 200:
Expand Down

0 comments on commit ae680c8

Please sign in to comment.