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

Fix sandbox mode #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion gemini_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ def __init__(self, status_code, response_json):

class GeminiApiConnection(object):

def __init__(self, client_key: str, client_secret: str):
def __init__(self, client_key: str, client_secret: str, sandbox: bool):
self.client_key = client_key
self.client_secret = client_secret.encode()
self.sandbox = sandbox


def _make_public_request(self, endpoint: str):
base_url = "https://api.gemini.com/v1"
if self.sandbox:
base_url = "https://api.sandbox.gemini.com/v1"
url = base_url + endpoint

r = requests.get(url)
Expand All @@ -38,6 +41,8 @@ def _make_public_request(self, endpoint: str):

def _make_authenticated_request(self, verb: str, endpoint: str, payload: dict = {}):
base_url = "https://api.gemini.com/v1"
if self.sandbox:
base_url = "https://api.sandbox.gemini.com/v1"
url = base_url + endpoint

t = datetime.datetime.now()
Expand Down
2 changes: 1 addition & 1 deletion gemini_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_timestamp():
aws_secret_access_key = config.get(config_section, 'AWS_SECRET_ACCESS_KEY')
aws_region = config.get(config_section, 'AWS_REGION')

gemini_api_conn = GeminiApiConnection(client_key=client_key, client_secret=secret_key)
gemini_api_conn = GeminiApiConnection(client_key=client_key, client_secret=secret_key, sandbox=sandbox_mode)

# Configure the market details
symbol_details = gemini_api_conn.symbol_details(market_name)
Expand Down