Skip to content

Commit

Permalink
Add PairCandleMissing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed May 6, 2024
1 parent f644798 commit 0eceab1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion tradingstrategy/pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ def __init__(self,

self.exchange_universe = exchange_universe

#: A hack used in a single trading pair univerwse
self.single_pair_cache: DEXPair = None

def iterate_pairs(self) -> Iterable[DEXPair]:
Expand Down Expand Up @@ -2292,4 +2293,9 @@ def _convert_to_dex_pair(data: dict, exchange_universe: ExchangeUniverse | None=
except Exception as e:
pretty = pprint.pformat(data)
raise DataDecodeFailed(f"Could not decode trading pair data:\n{pretty}") from e
return obj
return obj





6 changes: 5 additions & 1 deletion tradingstrategy/utils/groupeduniverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class NoDataAvailable(Exception):
"""Raises when the user is asking data that is empty."""


class PairCandlesMissing(KeyError):
"""Raises when the user is asking data for a pair that has no OHLCV feed."""


class PairGroupedUniverse:
"""A base class for manipulating columnar price/liquidity data by a pair.
Expand Down Expand Up @@ -177,7 +181,7 @@ def get_samples_by_pair(self, pair_id: PrimaryKey) -> pd.DataFrame:
try:
pair = self.pairs.get_group(pair_id)
except KeyError as e:
raise KeyError(f"No OHLC samples for pair id {pair_id} in {self}") from e
raise PairCandlesMissing(f"No OHLC samples for pair id {pair_id} in {self}") from e
return pair

def get_last_entries_by_pair_and_timestamp(self,
Expand Down
Empty file added tradingstrategy/utils/mapper.py
Empty file.

0 comments on commit 0eceab1

Please sign in to comment.