Skip to content

Commit

Permalink
Remove dydx v3 and apply some refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirEven committed Oct 31, 2024
1 parent 07add57 commit a17e9f1
Show file tree
Hide file tree
Showing 21 changed files with 24 additions and 2,172 deletions.
36 changes: 0 additions & 36 deletions locast/candle/dydx/dydx_candle_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,3 @@ def to_candle(self, exchange_candle: Dict[str, Any]) -> Candle:
)
except Exception as e:
raise ValueError(f"Error converting dict to Candle: {str(e)}") from e


class DydxV3CandleMapping(ExchangeCandleMapping):
def to_candle(self, exchange_candle: Dict[str, Any]) -> Candle:
try:
started_at = string_to_datetime(exchange_candle["startedAt"])
market = exchange_candle["market"]
resolution = DydxResolution.notation_to_resolution_detail(
exchange_candle["resolution"]
)
p_low = Decimal(exchange_candle["low"])
p_high = Decimal(exchange_candle["high"])
p_open = Decimal(exchange_candle["open"])
p_close = Decimal(exchange_candle["close"])
base_token_volume = Decimal(exchange_candle["baseTokenVolume"])
trades = int(exchange_candle["trades"])
usd_volume = Decimal(exchange_candle["usdVolume"])
starting_open_interest = Decimal(exchange_candle["startingOpenInterest"])

return Candle(
id=None,
exchange=Exchange.DYDX,
market=market,
resolution=resolution,
started_at=started_at,
open=p_open,
high=p_high,
low=p_low,
close=p_close,
base_token_volume=base_token_volume,
trades=trades,
usd_volume=usd_volume,
starting_open_interest=starting_open_interest,
)
except Exception as e:
raise ValueError(f"Error converting dict to Candle: {str(e)}") from e
1 change: 0 additions & 1 deletion locast/candle/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


class Exchange(Enum):
DYDX = "dydx"
DYDX_V4 = "dydx_v4"
66 changes: 0 additions & 66 deletions locast/candle_fetcher/dydx/api_fetcher/dydx_v3_fetcher.py

This file was deleted.

2 changes: 1 addition & 1 deletion locast/candle_fetcher/dydx/api_fetcher/dydx_v4_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ async def fetch(
)

except Exception as e:
raise APIException(self._exchange, market, resolution, e)
raise APIException(self._exchange, market, resolution, e) from e

return self._mapper.to_candles(response["candles"])
4 changes: 2 additions & 2 deletions locast/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def log_missing_candles(
missing_candle_dates: List[datetime],
) -> None:
n = len(missing_candle_dates)
vi = "candles" if n > 1 else "candle"
candles = "candles" if n > 1 else "candle"
detail = f"{market}, {resolution.notation}"
print(
f"{emoji} Attention: {exchange.name} failed to deliver {n} {vi} for {detail} {emoji}"
f"{emoji} Attention: {exchange.name} failed to deliver {n} {candles} for {detail} {emoji}"
)
for date in missing_candle_dates:
print(f" ❌ Candle missing: {date}.")
Expand Down
33 changes: 1 addition & 32 deletions notebooks/candle_storage_bench.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"🏁 RUN #1 💥\n",
"Mocked Amount (ETH-USD): 439201.\n",
"Time to store 439201 candles: (79.52 seconds).\n",
"Time to retrieve 439201 candles: (15.82 seconds).\n",
"Candles retrieved from 2024-01-01 00:00:00+00:00, to: 2024-11-01 00:00:00+00:00.\n",
"Time to get cluster info: (0.04 seconds).\n",
"Tail started at: 2024-01-01 00:00:00+00:00.\n",
"Head started at: 2024-11-01 00:00:00+00:00.\n",
"Time to delete cluster: (2.03 seconds).\n",
"Cluster info: ClusterInfo(newest_candle=None, oldest_candle=None, size=0, is_uptodate=False).\n",
"❌ Deleting db file...\n",
"🏁 RUN #2 💥\n",
"Mocked Amount (ETH-USD): 439201.\n",
"Time to store 439201 candles: (81.22 seconds).\n",
"Time to retrieve 439201 candles: (14.28 seconds).\n",
"Candles retrieved from 2024-01-01 00:00:00+00:00, to: 2024-11-01 00:00:00+00:00.\n",
"Time to get cluster info: (0.15 seconds).\n",
"Tail started at: 2024-01-01 00:00:00+00:00.\n",
"Head started at: 2024-11-01 00:00:00+00:00.\n",
"Time to delete cluster: (2.48 seconds).\n",
"Cluster info: ClusterInfo(newest_candle=None, oldest_candle=None, size=0, is_uptodate=False).\n",
"❌ Deleting db file...\n",
"🏁 RUN #3 💥\n",
"Mocked Amount (ETH-USD): 439201.\n"
]
}
],
"outputs": [],
"source": [
"import os\n",
"from statistics import mean\n",
Expand Down
127 changes: 0 additions & 127 deletions notebooks/example_dydx_v3.ipynb

This file was deleted.

Loading

0 comments on commit a17e9f1

Please sign in to comment.