Skip to content

Commit 82f300b

Browse files
committed
Replace milliseconds in date comparison
1 parent fd541a8 commit 82f300b

File tree

1 file changed

+9
-5
lines changed
  • investing_algorithm_framework/infrastructure/models/market_data_sources

1 file changed

+9
-5
lines changed

investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ def prepare_data(
9898
TimeFrame.from_string(self.timeframe).amount_of_minutes
9999
)
100100
)
101-
self.backtest_data_start_date = backtest_data_start_date
102-
self.backtest_data_index_date = backtest_data_start_date
103-
self.backtest_data_end_date = backtest_end_date
101+
self.backtest_data_start_date = backtest_data_start_date\
102+
.replace(microsecond=0)
103+
self.backtest_data_index_date = backtest_data_start_date\
104+
.replace(microsecond=0)
105+
self.backtest_data_end_date = backtest_end_date.replace(microsecond=0)
104106

105107
# Creating the backtest data directory and file
106108
self.backtest_data_directory = os.path.join(
@@ -112,7 +114,7 @@ def prepare_data(
112114
os.mkdir(self.backtest_data_directory)
113115

114116
file_path = self._create_file_path()
115-
print(self._data_source_exists(file_path))
117+
116118
if not self._data_source_exists(file_path):
117119
if not os.path.isfile(file_path):
118120
try:
@@ -165,7 +167,9 @@ def get_data(self, backtest_index_date, **kwargs):
165167
from_timestamp = backtest_index_date - timedelta(
166168
minutes=self.total_minutes_timeframe
167169
)
168-
self.backtest_data_index_date = backtest_index_date
170+
self.backtest_data_index_date = backtest_index_date\
171+
.replace(microsecond=0)
172+
from_timestamp = from_timestamp.replace(microsecond=0)
169173

170174
if from_timestamp < self.backtest_data_start_date:
171175
raise OperationalException(

0 commit comments

Comments
 (0)