Skip to content

Commit d09ebb8

Browse files
committed
Add zero rows check
1 parent a07e4e4 commit d09ebb8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,20 @@ def get_closed_orders(
356356
def get_ohlcv(
357357
self, symbol, time_frame, from_timestamp, market, to_timestamp=None
358358
) -> pl.DataFrame:
359+
"""
360+
Function to retrieve ohlcv data for a symbol, time frame and market
361+
362+
Args:
363+
symbol: The symbol to retrieve ohlcv data for
364+
time_frame: The time frame to retrieve ohlcv data for
365+
from_timestamp: The start date to retrieve ohlcv data from
366+
market: The market to retrieve ohlcv data from
367+
to_timestamp: The end date to retrieve ohlcv data to
368+
369+
Returns:
370+
DataFrame: The ohlcv data for the symbol, time frame and market
371+
in polars DataFrame format
372+
"""
359373

360374
if self.config is not None and "DATETIME_FORMAT" in self.config:
361375
datetime_format = self.config["DATETIME_FORMAT"]
@@ -413,8 +427,8 @@ def get_ohlcv(
413427
# Combine the Series into a DataFrame with given column names
414428
df = pl.DataFrame(data)
415429

416-
# Check if width is 0
417-
if len(df) == 0:
430+
# Check if DataFrame is empty (either rows or columns)
431+
if df.shape[0] == 0 or df.shape[1] == 0:
418432
return df
419433

420434
# Assign column names after DataFrame creation

0 commit comments

Comments
 (0)