Skip to content

Commit

Permalink
Fix issue with exactly one liquidity candle dataframe
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Oct 31, 2024
1 parent 817f069 commit 0217826
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tradingstrategy/liquidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ def get_liquidity_with_tolerance(
# so one does not need to open ipdb to inspect faulty data
try:
first_sample = candles_per_pair.iloc[0]
second_sample = candles_per_pair.iloc[1]
if len(candles_per_pair) >= 2:
second_sample = candles_per_pair.iloc[1]
else:
second_sample = first_sample
last_sample = candles_per_pair.iloc[-1]
except KeyError:
raise LiquidityDataUnavailable(
Expand Down

0 comments on commit 0217826

Please sign in to comment.