From a31d430b1f2cab6f4ac3a33f301e15d17df20187 Mon Sep 17 00:00:00 2001 From: dougle Date: Tue, 4 May 2021 21:28:12 -0700 Subject: [PATCH 1/6] Can now read all transfers in! --- gemini/private_client.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gemini/private_client.py b/gemini/private_client.py index 476ed80..5d21676 100644 --- a/gemini/private_client.py +++ b/gemini/private_client.py @@ -311,6 +311,27 @@ def withdraw_to_address(self, currency, address, amount): } return self.api_query('/v1/withdraw/{}'.format(currency), payload) + # Transfers API + @typeassert(limit_transfers=int, show_completed_deposit_advances=bool) + def get_past_transfers(self, limit_transfers=None, show_completed_deposit_advances=False): + """ + Returns all the past transfers associated with the API. + Providing a limit_trade is optional. + Whether to display completed deposit advances. False by default. Must be set True to activate. Defaults to False. + + Args: + limit_trades(int): Default value is 500 + show_completed_deposit_advances(bool): Default value is False + + Results: + array: An array of of dicts of the past transfers + """ + payload = { + "limit_transfers": 500 if limit_transfers is None else limit_transfers, + "show_completed_deposit_advances": show_completed_deposit_advances + } + return self.api_query('/v1/transfers', payload) + # HeartBeat API def revive_hearbeat(self): """ From 5dd11dd1e00e9f56fa17b49811c22033b3b27ee9 Mon Sep 17 00:00:00 2001 From: mtusman Date: Mon, 10 May 2021 19:36:56 +0100 Subject: [PATCH 2/6] Changed version following the addition of get past transfers endpoint --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 55ce563..6db9b49 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='gemini-python', - version='0.2.0', + version='0.2.1', packages=['gemini'], url='https://github.com/mtusman/gemini-python', license='MIT', From c839a0e129f6e445cf676bafd8d3ebe82187b736 Mon Sep 17 00:00:00 2001 From: TheTallMan67 Date: Tue, 21 Dec 2021 22:27:51 -0500 Subject: [PATCH 3/6] Added support for public endpoint https://docs.gemini.com/rest-api/#symbol-details --- gemini/public_client.py | 25 +++++++++++++++++++++++++ tests/test_public_client.py | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/gemini/public_client.py b/gemini/public_client.py index 946f55b..1b61a6a 100644 --- a/gemini/public_client.py +++ b/gemini/public_client.py @@ -29,6 +29,31 @@ def symbols(self): r = requests.get(self.public_base_url + '/symbols') return r.json() + @typeassert(product_id=str) + def symbol_details(self, product_id): + """ + This endpoint retrieves extra detail on supported symbols, such as + minimum order size, tick size, quote increment and more. + + Args: + product_id(str): Can be any value in self.symbols() + + Returns: + dict:tick_size, quote_increment, min_order_size, status and wrap_enabled + example: { + "symbol":"BTCUSD", + "base_currency":"BTC", + "quote_currency":"USD", + "tick_size":1e-08, + "quote_increment":0.01, + "min_order_size":"0.00001", + "status":"open", + "wrap_enabled":false + } + """ + r = requests.get(self.public_base_url + '/symbols/details/' + product_id) + return r.json() + @typeassert(product_id=str) def get_ticker(self, product_id): """ diff --git a/tests/test_public_client.py b/tests/test_public_client.py index 6151a89..c81c248 100644 --- a/tests/test_public_client.py +++ b/tests/test_public_client.py @@ -44,3 +44,16 @@ def test_symbols(self): r = client() symbols = r.symbols() assert type(symbols) is list + + def test_symbol_details(self): + r = client() + symbol_details = r.symbol_details("BTCUSD") + assert type(symbol_details) is dict + assert "symbol" in symbol_details + assert "base_currency" in symbol_details + assert "quote_currency" in symbol_details + assert "tick_size" in symbol_details + assert "quote_increment" in symbol_details + assert "min_order_size" in symbol_details + assert "status" in symbol_details + assert "wrap_enabled" in symbol_details From d135767016161e899530cce3bacc9b7167337784 Mon Sep 17 00:00:00 2001 From: TheTallMan67 Date: Tue, 21 Dec 2021 22:36:02 -0500 Subject: [PATCH 4/6] Updating README with new public endpoint --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 5b9e06b..a0e73c1 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,10 @@ r = gemini.PublicClient(sandbox=True) ```python r.symbols() ``` +- [symbol_details](https://docs.gemini.com/rest-api/#symbol-details) +```python +r.symbol_details("BTCUSD") +``` - [get_ticker](https://docs.gemini.com/rest-api/#ticker) ```python r.get_ticker("BTCUSD") From 8c3c476ba357a1388cba688b5168d7996c75848d Mon Sep 17 00:00:00 2001 From: TheTallMan67 Date: Mon, 27 Dec 2021 21:15:38 -0500 Subject: [PATCH 5/6] Added support for private endpoint https://docs.gemini.com/rest-api/#wrap-order --- gemini/private_client.py | 26 ++++++++++++++++++++++++++ tests/test_private_client.py | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/gemini/private_client.py b/gemini/private_client.py index 5d21676..b2b276d 100644 --- a/gemini/private_client.py +++ b/gemini/private_client.py @@ -134,6 +134,32 @@ def cancel_order(self, order_id): } return self.api_query('/v1/order/cancel', payload) + @typeassert(symbol=str, amount=str, side=str) + def wrap_order(self, symbol, amount, side): + """ + This endpoint wraps and unwraps Gemini issued assets. + + Args: + symbol(str): Only GUSDUSD + amount(str): The amount of currency you want to buy/sell. + side(str): Either "buy" or "sell" + + Results: + dict: Returns the orderId + "pair + "price + "priceCurrency + "side + "quantity + "quantityCurrency, totalSpend, totalSpendCurrency, fee, feeCurrency, depositFee, depositFeeCurrency + example: { + """ + payload = { + 'amount': amount, + 'side': side, + } + return self.api_query('/v1/wrap/{}'.format(symbol), payload) + def cancel_session_orders(self): """ Used for the cancellation of all orders in a session. diff --git a/tests/test_private_client.py b/tests/test_private_client.py index 6416d48..0598c95 100644 --- a/tests/test_private_client.py +++ b/tests/test_private_client.py @@ -72,6 +72,26 @@ def test_cancel_orders(self): assert "result" in cancel_all_orders assert "details" in cancel_all_orders + def test_wrap_order(self): + r = client() + wrap_order = r.wrap_order("GUSDUSD", "10", "buy") + assert type(wrap_order) is dict + # Endpoint not supported on sandbox + assert "error" in wrap_order #{'error': 'Encountered an error attempting to place a wrap/unwrap trade.'} + # assert "orderId" in wrap_order + # assert "pair" in wrap_order + # assert "price" in wrap_order + # assert "priceCurrency" in wrap_order + # assert "side" in wrap_order + # assert "quantity" in wrap_order + # assert "quantityCurrency" in wrap_order + # assert "totalSpend" in wrap_order + # assert "totalSpendCurrency" in wrap_order + # assert "fee" in wrap_order + # assert "feeCurrency" in wrap_order + # assert "depositFee" in wrap_order + # assert "depositFeeCurrency" in wrap_order + def test_status_of_orders(self): r = client() new_order = r.new_order("BTCUSD", "0.02", "6400.28", "buy", ["maker-or-cancel"]) From 91a1a23b663b350326c048f40a7443a82dc41654 Mon Sep 17 00:00:00 2001 From: TheTallMan67 Date: Mon, 27 Dec 2021 21:19:17 -0500 Subject: [PATCH 6/6] Updating README with private endpoint --- README.md | 4 ++++ gemini/private_client.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b9e06b..93aad7a 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ r.new_order("BTCUSD", "200", "6000", "buy") ```python r.cancel_order("866403510") ``` +- [wrap_order](https://docs.gemini.com/rest-api/#wrap-order) +```python +r.wrap_order("GUSDUSD", "10", "buy") +``` - [cancel_session_orders](https://docs.gemini.com/rest-api/#cancel-all-session-orders) ```python r.cancel_session_orders() diff --git a/gemini/private_client.py b/gemini/private_client.py index b2b276d..690d049 100644 --- a/gemini/private_client.py +++ b/gemini/private_client.py @@ -152,7 +152,6 @@ def wrap_order(self, symbol, amount, side): "side "quantity "quantityCurrency, totalSpend, totalSpendCurrency, fee, feeCurrency, depositFee, depositFeeCurrency - example: { """ payload = { 'amount': amount,