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

New FI support: Gemini crypto exchange #45

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

Zburatorul
Copy link
Collaborator

Adds ability to download trades, transfers and balances from Gemini.
Interactive mode not implemented, just runs regular path.
Also had to modify mypy.ini to get tests to complete.

@Zburatorul Zburatorul requested a review from carljm October 18, 2021 01:12
@Zburatorul
Copy link
Collaborator Author

@carljm, would like a review from you please. This PR makes sense before the other one, as it fixes a mypy issue with failing tests.

@bayesianmind
Copy link
Contributor

Appreciate you adding a new downloader @Zburatorul ! Hopefully @carljm can review and merge.

Copy link
Collaborator

@carljm carljm left a comment

Choose a reason for hiding this comment

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

Seems OK to me, a few minor comments. In terms of the functionality, if I were using this I would prefer it to store dated output files and never touch or overwrite previously-downloaded files (and ideally detect date of last download, if any, and not always re-download entire history.) But I don't think this behavior is a prerequisite for merge.

finance_dl/gemini.py Outdated Show resolved Hide resolved
Comment on lines 41 to 44
Interactive shell:
==================

From the interactive shell, type: `self.run()` to start the scraper.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your PR description says something about interactive mode not being supported, that seems inconsistent with this? I'm not sure what that means, though, as far as I know scrapers don't need to do anything special to support interactive mode. Maybe I'm misunderstanding what you meant by not supporting interactive mode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They do require more work. You need to pop a Python interpreter for the user. I'll just mark it as not implemented and leave it for another day.


# Merge and Date
for bal in balances:
bal['price'] = bal['price'] = prices[bal['currency']]\
Copy link
Collaborator

Choose a reason for hiding this comment

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

No reason to duplicate bal['price'] = twice 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.

yup

Copy link
Collaborator

Choose a reason for hiding this comment

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

This duplication is still present

@Zburatorul
Copy link
Collaborator Author

Zburatorul commented Nov 11, 2021

I observed issues with rate limiting, so I had some fun wrapping the requests in some retrying logic.
I also reworked the disk writing to not overwrite old downloads, and also take them into account and not re-download.
@carljm, ready for you to have another look.

Copy link
Collaborator

@carljm carljm left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +93 to +101
time.sleep(wait)
try:
r = requests.get(url) if get else requests.post(url, headers=headers)
self.last_req_ts = time.time()
r.raise_for_status()
return r.json()
except requests.HTTPError as exc:
if exc.response.status_code not in self.RETRY_CODES:
raise exc
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this method could be refactored to avoid duplicating this block of code (if nothing else, by extracting it to a separate method), but I don't feel strongly about it.


# Merge and Date
for bal in balances:
bal['price'] = bal['price'] = prices[bal['currency']]\
Copy link
Collaborator

Choose a reason for hiding this comment

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

This duplication is still present

@Zburatorul Zburatorul merged commit 70e9385 into jbms:master Nov 11, 2021
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.

3 participants