Skip to content

Commit

Permalink
Merge pull request #3 from ahrenstein/GeminiAPITryCatch
Browse files Browse the repository at this point in the history
Quick Gemini API fix
  • Loading branch information
ahrenstein authored May 14, 2021
2 parents cadce1c + d3cd4c0 commit eec5f5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Crypto Dip Buying Bot: Changelog
================================
A list of all the changes made to this repo, and the bot it contains

Version 0.3.1
-------------

1. Minor fixes around Gemini API calls when Gemini is having a service outage.
The bot should no longer crash but API outages do prevent data from being gathered or Txs occurring

Version 0.3.0
-------------

Expand Down
4 changes: 2 additions & 2 deletions SourceCode/gemini_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def get_coin_price(api_url: str, currency: str) -> float:
# Instantiate Gemini and query the price
coin_price = -1
api_query = "/v1/pricefeed"
price_feeds = requests.get(api_url + api_query).json()
try:
price_feeds = requests.get(api_url + api_query).json()
for feed in price_feeds:
if feed.get('pair') == currency + "USD":
coin_price = float(feed.get('price'))
Expand All @@ -117,8 +117,8 @@ def verify_balance(api_url: str, config_file: str, buy_amount: float) -> bool:
# Instantiate Gemini and query the price
gemini_creds = get_gemini_creds_from_file(config_file)
api_query = "/v1/balances"
result = gemini_api_call(api_url, gemini_creds[0], gemini_creds[1], api_query)
try:
result = gemini_api_call(api_url, gemini_creds[0], gemini_creds[1], api_query)
for account in result:
if account.get('currency') == "USD":
balance = float(account.get('amount'))
Expand Down

0 comments on commit eec5f5b

Please sign in to comment.