Skip to content

Commit

Permalink
Add window size check to ccxt data source
Browse files Browse the repository at this point in the history
  • Loading branch information
MDUYN committed Jul 2, 2024
1 parent 662e92b commit d8ec46c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ def get_data(self, **kwargs):
if self.config is not None:
market_service.config = self.config

if "window_size" in kwargs:
self.window_size = kwargs["window_size"]

if "start_date" in kwargs:
start_date = kwargs["start_date"]

Expand All @@ -451,6 +454,14 @@ def get_data(self, **kwargs):
)

if "end_date" not in kwargs:

if self.window_size is None:
raise OperationalException(
"Either end_date or window_size "
"should be passed as a "
"parameter for CCXTOHLCVMarketDataSource"
)

end_date = self.create_end_date(
start_date, self.timeframe, self.window_size
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ def get_data(self, **kwargs):
end_date = kwargs.get("end_date")
backtest_index_date = kwargs.get("backtest_index_date")

if "window_size" in kwargs:
self.window_size = kwargs["window_size"]

if start_date is None \
and end_date is None \
and backtest_index_date is None:
Expand All @@ -97,11 +100,27 @@ def get_data(self, **kwargs):

if backtest_index_date is not None:
end_date = backtest_index_date

if self.window_size is None:
raise OperationalException(
"Either end_date or window_size "
"should be passed as a "
"parameter for CCXTOHLCVMarketDataSource"
)

start_date = self.create_start_date(
end_date, self.timeframe, self.window_size
)
else:
if start_date is None:

if self.window_size is None:
raise OperationalException(
"Either end_date or window_size "
"should be passed as a "
"parameter for CCXTOHLCVMarketDataSource"
)

start_date = self.create_start_date(
end_date, self.timeframe, self.window_size
)
Expand All @@ -111,20 +130,6 @@ def get_data(self, **kwargs):
start_date, self.timeframe, self.window_size
)

# # Check if start or end date are out of range with
# # the dates of the datasource.
# if self._start_date_data_source > start_date:
# raise OperationalException(
# f"Given start date {start_date} is before the start date "
# f"of the data source {self._start_date_data_source}"
# )
#
# if self._end_date_data_source < end_date:
# raise OperationalException(
# f"End date {end_date} is after the end date "
# f"of the data source {self._end_date_data_source}"
# )

df = polars.read_csv(
self.csv_file_path, columns=self._columns, separator=","
)
Expand Down

0 comments on commit d8ec46c

Please sign in to comment.