Skip to content

Commit

Permalink
PLAT-1221 Fix parallel end_time when undefine
Browse files Browse the repository at this point in the history
This MR fixes the end_time bound for parallelization when undefined. Previously it uses the user's timezone but it should be UTC
  • Loading branch information
Victor Ramirez committed Sep 18, 2024
1 parent 9531e8b commit 0388ace
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion coinmetrics/_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ def generate_ranges(
end_time = self.parse_date(
cast(datetime, self._url_params.get("end_time"))
) if self._url_params.get(
"end_time") else datetime.today()
"end_time") else datetime.utcnow().replace(microsecond=0)
for start, end in generate_ranges(
start_time,
end_time,
Expand Down
13 changes: 13 additions & 0 deletions test/test_parallel_datacollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ def test_height_increment() -> None:
end_inclusive=False
).parallel(height_increment=10).to_dataframe()
assert len(df_blocks) == 90


@pytest.mark.skipif(not cm_api_key_set, reason=REASON_TO_SKIP)
def test_end_time_undefined() -> None:
start_time = datetime.datetime.utcnow().replace(microsecond=0, second=0) - timedelta(minutes=60)
df_metrics_1m = client.get_asset_metrics(
assets='btc',
metrics='ReferenceRateUSD',
start_time=start_time,
frequency='1m'
).parallel(time_increment=timedelta(minutes=1)).to_dataframe()
assert not df_metrics_1m.empty
assert df_metrics_1m.time.min().to_pydatetime().replace(tzinfo=None) == start_time


if __name__ == '__main__':
Expand Down

0 comments on commit 0388ace

Please sign in to comment.