Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safe fetch ohlcv dydx method #686

Merged
merged 7 commits into from
Feb 28, 2024

Conversation

graceful-coder
Copy link
Collaborator

PR towards solving #493.

Changes proposed in this PR:

  • Added safe_fetch_ohlcv_dydx() to fetch_ohlcv.py file using the same convention as safe_fetch_ohlcv_ccxt()
  • Added happy path unit test
  • Added new time utility function to_iso_timestr() to convert UnixTimeMs to string format expected by dydx

Copy link
Member

@trentmc trentmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving this, subject to the small changes suggested.

Then go ahead and merge, once all tests pass.

@@ -55,6 +56,49 @@ def safe_fetch_ohlcv_ccxt(
return None


@enforce_types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main comment: overall this looks great! Low complexity, obvious to read. +10

My other comments are specific things.

100,
)
result = safe_fetch_ohlcv_dydx("dydx", symbol, timeframe, since, limit)
assert_safe_fetch_ohlcv_dydx_ok(result)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a separate function, vs just having the three lines here? Are you going to reuse it for more tests?

  • If yes, ok.
  • If no, move the three lines of the function into here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Resolved: I moved the assertions into the unit test function test_safe_fetch_ohlcv_dydx().

Comment on lines +81 to +85
def to_iso_timestr(self) -> str:
dt: datetime = self.to_dt()

return dt.strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z" # tack on timezone

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

And, this needs a unit test, next to the other time_types unit tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: Added test_ut_to_iso_timestr() to test_time_types.py

@graceful-coder graceful-coder merged commit 188d022 into main Feb 28, 2024
5 checks passed
@graceful-coder graceful-coder deleted the issue-493-add-safe_fetch_ohlcv_dydx-method branch February 28, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants