From 37d542f47aadd2c086820bfcaebaab7f83c4724f Mon Sep 17 00:00:00 2001 From: Revil Wang Date: Fri, 14 Aug 2020 11:30:30 +0800 Subject: [PATCH 1/2] add GateApiException --- README.md | 8 ++- docs/DeliveryApi.md | 112 +++++++++++++++++++++++-------- docs/FuturesApi.md | 112 +++++++++++++++++++++++-------- docs/FuturesOrder.md | 2 +- docs/MarginApi.md | 64 +++++++++++++----- docs/SpotApi.md | 68 ++++++++++++++----- docs/WalletApi.md | 24 +++++-- docs/WithdrawalApi.md | 4 +- gate_api/__init__.py | 2 +- gate_api/api_client.py | 11 ++- gate_api/configuration.py | 4 +- gate_api/exceptions.py | 17 +++++ gate_api/models/futures_order.py | 5 +- setup.py | 2 +- 14 files changed, 326 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index 951933d..feaa913 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ APIv4 provides spot, margin and futures trading operations. There are public API This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: -- API version: 4.15.2 -- Package version: 4.15.2 +- API version: 4.15.3 +- Package version: 4.15.3 - Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts) @@ -73,7 +73,7 @@ Please follow the [installation procedure](#installation--usage) and then run th from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. @@ -91,6 +91,8 @@ try: # List all futures contracts api_response = api_instance.list_delivery_contracts(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e) diff --git a/docs/DeliveryApi.md b/docs/DeliveryApi.md index 5c1d34c..69a8fb4 100644 --- a/docs/DeliveryApi.md +++ b/docs/DeliveryApi.md @@ -44,7 +44,7 @@ List all futures contracts ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -60,6 +60,8 @@ try: # List all futures contracts api_response = api_instance.list_delivery_contracts(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e) ``` @@ -100,7 +102,7 @@ Get a single contract ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -117,6 +119,8 @@ try: # Get a single contract api_response = api_instance.get_delivery_contract(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->get_delivery_contract: %s\n" % e) ``` @@ -160,7 +164,7 @@ Bids will be sorted by price from high to low, while asks sorted reversely ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -179,6 +183,8 @@ try: # Futures order book api_response = api_instance.list_delivery_order_book(settle, contract, interval=interval, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_order_book: %s\n" % e) ``` @@ -222,7 +228,7 @@ Futures trading history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -243,6 +249,8 @@ try: # Futures trading history api_response = api_instance.list_delivery_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_trades: %s\n" % e) ``` @@ -290,7 +298,7 @@ Return specified contract candlesticks. If prefix `contract` with `mark_`, the c ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -311,6 +319,8 @@ try: # Get futures candlesticks api_response = api_instance.list_delivery_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_candlesticks: %s\n" % e) ``` @@ -356,7 +366,7 @@ List futures tickers ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -373,6 +383,8 @@ try: # List futures tickers api_response = api_instance.list_delivery_tickers(settle, contract=contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_tickers: %s\n" % e) ``` @@ -414,7 +426,7 @@ Futures insurance balance history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -431,6 +443,8 @@ try: # Futures insurance balance history api_response = api_instance.list_delivery_insurance_ledger(settle, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_insurance_ledger: %s\n" % e) ``` @@ -473,7 +487,7 @@ Query futures account ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -497,6 +511,8 @@ try: # Query futures account api_response = api_instance.list_delivery_accounts(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_accounts: %s\n" % e) ``` @@ -538,7 +554,7 @@ Query account book ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -566,6 +582,8 @@ try: # Query account book api_response = api_instance.list_delivery_account_book(settle, limit=limit, _from=_from, to=to, type=type) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_account_book: %s\n" % e) ``` @@ -611,7 +629,7 @@ List all positions of a user ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -635,6 +653,8 @@ try: # List all positions of a user api_response = api_instance.list_delivery_positions(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_positions: %s\n" % e) ``` @@ -676,7 +696,7 @@ Get single position ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -701,6 +721,8 @@ try: # Get single position api_response = api_instance.get_delivery_position(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->get_delivery_position: %s\n" % e) ``` @@ -743,7 +765,7 @@ Update position margin ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -769,6 +791,8 @@ try: # Update position margin api_response = api_instance.update_delivery_position_margin(settle, contract, change) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->update_delivery_position_margin: %s\n" % e) ``` @@ -812,7 +836,7 @@ Update position leverage ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -838,6 +862,8 @@ try: # Update position leverage api_response = api_instance.update_delivery_position_leverage(settle, contract, leverage) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->update_delivery_position_leverage: %s\n" % e) ``` @@ -881,7 +907,7 @@ Update position risk limit ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -907,6 +933,8 @@ try: # Update position risk limit api_response = api_instance.update_delivery_position_risk_limit(settle, contract, risk_limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->update_delivery_position_risk_limit: %s\n" % e) ``` @@ -952,7 +980,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -982,6 +1010,8 @@ try: # List futures orders api_response = api_instance.list_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset, last_id=last_id, count_total=count_total) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_orders: %s\n" % e) ``` @@ -1031,7 +1061,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1056,6 +1086,8 @@ try: # Create a futures order api_response = api_instance.create_delivery_order(settle, futures_order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->create_delivery_order: %s\n" % e) ``` @@ -1100,7 +1132,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1126,6 +1158,8 @@ try: # Cancel all `open` orders matched api_response = api_instance.cancel_delivery_orders(settle, contract, side=side) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->cancel_delivery_orders: %s\n" % e) ``` @@ -1171,7 +1205,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1196,6 +1230,8 @@ try: # Get a single order api_response = api_instance.get_delivery_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->get_delivery_order: %s\n" % e) ``` @@ -1238,7 +1274,7 @@ Cancel a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1263,6 +1299,8 @@ try: # Cancel a single order api_response = api_instance.cancel_delivery_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->cancel_delivery_order: %s\n" % e) ``` @@ -1305,7 +1343,7 @@ List personal trading history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1335,6 +1373,8 @@ try: # List personal trading history api_response = api_instance.get_my_delivery_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->get_my_delivery_trades: %s\n" % e) ``` @@ -1382,7 +1422,7 @@ List position close history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1408,6 +1448,8 @@ try: # List position close history api_response = api_instance.list_delivery_position_close(settle, contract=contract, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_position_close: %s\n" % e) ``` @@ -1451,7 +1493,7 @@ List liquidation history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1478,6 +1520,8 @@ try: # List liquidation history api_response = api_instance.list_delivery_liquidates(settle, contract=contract, limit=limit, at=at) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_liquidates: %s\n" % e) ``` @@ -1522,7 +1566,7 @@ List settlement history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1549,6 +1593,8 @@ try: # List settlement history api_response = api_instance.list_delivery_settlements(settle, contract=contract, limit=limit, at=at) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_delivery_settlements: %s\n" % e) ``` @@ -1593,7 +1639,7 @@ List all auto orders ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1621,6 +1667,8 @@ try: # List all auto orders api_response = api_instance.list_price_triggered_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->list_price_triggered_delivery_orders: %s\n" % e) ``` @@ -1666,7 +1714,7 @@ Create a price-triggered order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1691,6 +1739,8 @@ try: # Create a price-triggered order api_response = api_instance.create_price_triggered_delivery_order(settle, futures_price_triggered_order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->create_price_triggered_delivery_order: %s\n" % e) ``` @@ -1733,7 +1783,7 @@ Cancel all open orders ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1758,6 +1808,8 @@ try: # Cancel all open orders api_response = api_instance.cancel_price_triggered_delivery_order_list(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order_list: %s\n" % e) ``` @@ -1800,7 +1852,7 @@ Get a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1825,6 +1877,8 @@ try: # Get a single order api_response = api_instance.get_price_triggered_delivery_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->get_price_triggered_delivery_order: %s\n" % e) ``` @@ -1867,7 +1921,7 @@ Cancel a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1892,6 +1946,8 @@ try: # Cancel a single order api_response = api_instance.cancel_price_triggered_delivery_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order: %s\n" % e) ``` diff --git a/docs/FuturesApi.md b/docs/FuturesApi.md index 224a44d..0bc9ca5 100644 --- a/docs/FuturesApi.md +++ b/docs/FuturesApi.md @@ -44,7 +44,7 @@ List all futures contracts ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -60,6 +60,8 @@ try: # List all futures contracts api_response = api_instance.list_futures_contracts(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_contracts: %s\n" % e) ``` @@ -100,7 +102,7 @@ Get a single contract ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -117,6 +119,8 @@ try: # Get a single contract api_response = api_instance.get_futures_contract(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->get_futures_contract: %s\n" % e) ``` @@ -160,7 +164,7 @@ Bids will be sorted by price from high to low, while asks sorted reversely ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -179,6 +183,8 @@ try: # Futures order book api_response = api_instance.list_futures_order_book(settle, contract, interval=interval, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_order_book: %s\n" % e) ``` @@ -222,7 +228,7 @@ Futures trading history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -243,6 +249,8 @@ try: # Futures trading history api_response = api_instance.list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_trades: %s\n" % e) ``` @@ -290,7 +298,7 @@ Return specified contract candlesticks. If prefix `contract` with `mark_`, the c ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -311,6 +319,8 @@ try: # Get futures candlesticks api_response = api_instance.list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_candlesticks: %s\n" % e) ``` @@ -356,7 +366,7 @@ List futures tickers ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -373,6 +383,8 @@ try: # List futures tickers api_response = api_instance.list_futures_tickers(settle, contract=contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_tickers: %s\n" % e) ``` @@ -414,7 +426,7 @@ Funding rate history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -432,6 +444,8 @@ try: # Funding rate history api_response = api_instance.list_futures_funding_rate_history(settle, contract, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_funding_rate_history: %s\n" % e) ``` @@ -474,7 +488,7 @@ Futures insurance balance history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -491,6 +505,8 @@ try: # Futures insurance balance history api_response = api_instance.list_futures_insurance_ledger(settle, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_insurance_ledger: %s\n" % e) ``` @@ -533,7 +549,7 @@ Query futures account ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -557,6 +573,8 @@ try: # Query futures account api_response = api_instance.list_futures_accounts(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_accounts: %s\n" % e) ``` @@ -598,7 +616,7 @@ Query account book ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -626,6 +644,8 @@ try: # Query account book api_response = api_instance.list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_account_book: %s\n" % e) ``` @@ -671,7 +691,7 @@ List all positions of a user ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -695,6 +715,8 @@ try: # List all positions of a user api_response = api_instance.list_positions(settle) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_positions: %s\n" % e) ``` @@ -736,7 +758,7 @@ Get single position ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -761,6 +783,8 @@ try: # Get single position api_response = api_instance.get_position(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->get_position: %s\n" % e) ``` @@ -803,7 +827,7 @@ Update position margin ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -829,6 +853,8 @@ try: # Update position margin api_response = api_instance.update_position_margin(settle, contract, change) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->update_position_margin: %s\n" % e) ``` @@ -872,7 +898,7 @@ Update position leverage ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -898,6 +924,8 @@ try: # Update position leverage api_response = api_instance.update_position_leverage(settle, contract, leverage) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->update_position_leverage: %s\n" % e) ``` @@ -941,7 +969,7 @@ Update position risk limit ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -967,6 +995,8 @@ try: # Update position risk limit api_response = api_instance.update_position_risk_limit(settle, contract, risk_limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->update_position_risk_limit: %s\n" % e) ``` @@ -1012,7 +1042,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1042,6 +1072,8 @@ try: # List futures orders api_response = api_instance.list_futures_orders(settle, contract, status, limit=limit, offset=offset, last_id=last_id, count_total=count_total) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_futures_orders: %s\n" % e) ``` @@ -1091,7 +1123,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1116,6 +1148,8 @@ try: # Create a futures order api_response = api_instance.create_futures_order(settle, futures_order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->create_futures_order: %s\n" % e) ``` @@ -1160,7 +1194,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1186,6 +1220,8 @@ try: # Cancel all `open` orders matched api_response = api_instance.cancel_futures_orders(settle, contract, side=side) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->cancel_futures_orders: %s\n" % e) ``` @@ -1231,7 +1267,7 @@ Zero-fill order cannot be retrieved 60 seconds after cancellation ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1256,6 +1292,8 @@ try: # Get a single order api_response = api_instance.get_futures_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->get_futures_order: %s\n" % e) ``` @@ -1298,7 +1336,7 @@ Cancel a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1323,6 +1361,8 @@ try: # Cancel a single order api_response = api_instance.cancel_futures_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->cancel_futures_order: %s\n" % e) ``` @@ -1365,7 +1405,7 @@ List personal trading history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1395,6 +1435,8 @@ try: # List personal trading history api_response = api_instance.get_my_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->get_my_trades: %s\n" % e) ``` @@ -1442,7 +1484,7 @@ List position close history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1468,6 +1510,8 @@ try: # List position close history api_response = api_instance.list_position_close(settle, contract=contract, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_position_close: %s\n" % e) ``` @@ -1511,7 +1555,7 @@ List liquidation history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1538,6 +1582,8 @@ try: # List liquidation history api_response = api_instance.list_liquidates(settle, contract=contract, limit=limit, at=at) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_liquidates: %s\n" % e) ``` @@ -1582,7 +1628,7 @@ List all auto orders ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1610,6 +1656,8 @@ try: # List all auto orders api_response = api_instance.list_price_triggered_orders(settle, status, contract=contract, limit=limit, offset=offset) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->list_price_triggered_orders: %s\n" % e) ``` @@ -1655,7 +1703,7 @@ Create a price-triggered order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1680,6 +1728,8 @@ try: # Create a price-triggered order api_response = api_instance.create_price_triggered_order(settle, futures_price_triggered_order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->create_price_triggered_order: %s\n" % e) ``` @@ -1722,7 +1772,7 @@ Cancel all open orders ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1747,6 +1797,8 @@ try: # Cancel all open orders api_response = api_instance.cancel_price_triggered_order_list(settle, contract) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->cancel_price_triggered_order_list: %s\n" % e) ``` @@ -1789,7 +1841,7 @@ Get a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1814,6 +1866,8 @@ try: # Get a single order api_response = api_instance.get_price_triggered_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->get_price_triggered_order: %s\n" % e) ``` @@ -1856,7 +1910,7 @@ Cancel a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1881,6 +1935,8 @@ try: # Cancel a single order api_response = api_instance.cancel_price_triggered_order(settle, order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling FuturesApi->cancel_price_triggered_order: %s\n" % e) ``` diff --git a/docs/FuturesOrder.md b/docs/FuturesOrder.md index 9953129..51eb628 100644 --- a/docs/FuturesOrder.md +++ b/docs/FuturesOrder.md @@ -11,7 +11,7 @@ Name | Type | Description | Notes **finish_as** | **str** | How the order is finished. - filled: all filled - cancelled: manually cancelled - liquidated: cancelled because of liquidation - ioc: time in force is `IOC`, finish immediately - auto_deleveraged: finished by ADL - reduce_only: cancelled because of increasing position while `reduce-only` set | [optional] [readonly] **status** | **str** | Order status - `open`: waiting to be traded - `finished`: finished | [optional] [readonly] **contract** | **str** | Futures contract | -**size** | **int** | Order size. Specify positive number to make a bid, and negative number to ask | [optional] +**size** | **int** | Order size. Specify positive number to make a bid, and negative number to ask | **iceberg** | **int** | Display size for iceberg order. 0 for non-iceberg. Note that you would pay the taker fee for the hidden size | [optional] **price** | **str** | Order price. 0 for market order with `tif` set as `ioc` | [optional] **close** | **bool** | Set as `true` to close the position, with `size` set to 0 | [optional] [default to False] diff --git a/docs/MarginApi.md b/docs/MarginApi.md index 8c24d0c..e9584a1 100644 --- a/docs/MarginApi.md +++ b/docs/MarginApi.md @@ -32,7 +32,7 @@ List all supported currency pairs supported in margin trading ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -47,6 +47,8 @@ try: # List all supported currency pairs supported in margin trading api_response = api_instance.list_margin_currency_pairs() print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_margin_currency_pairs: %s\n" % e) ``` @@ -84,7 +86,7 @@ Order book of lending loans ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -100,6 +102,8 @@ try: # Order book of lending loans api_response = api_instance.list_funding_book(currency) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_funding_book: %s\n" % e) ``` @@ -141,7 +145,7 @@ Margin account list ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -165,6 +169,8 @@ try: # Margin account list api_response = api_instance.list_margin_accounts(currency_pair=currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_margin_accounts: %s\n" % e) ``` @@ -208,7 +214,7 @@ Only transferring from or to margin account are provided for now. Time range all ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -237,6 +243,8 @@ try: # List margin account balance change history api_response = api_instance.list_margin_account_book(currency=currency, currency_pair=currency_pair, _from=_from, to=to, page=page, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_margin_account_book: %s\n" % e) ``` @@ -283,7 +291,7 @@ Funding account list ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -307,6 +315,8 @@ try: # Funding account list api_response = api_instance.list_funding_accounts(currency=currency) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_funding_accounts: %s\n" % e) ``` @@ -348,7 +358,7 @@ List all loans ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -379,6 +389,8 @@ try: # List all loans api_response = api_instance.list_loans(status, side, currency=currency, currency_pair=currency_pair, sort_by=sort_by, reverse_sort=reverse_sort, page=page, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_loans: %s\n" % e) ``` @@ -427,7 +439,7 @@ Lend or borrow ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -451,6 +463,8 @@ try: # Lend or borrow api_response = api_instance.create_loan(loan) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->create_loan: %s\n" % e) ``` @@ -492,7 +506,7 @@ Merge multiple lending loans ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -517,6 +531,8 @@ try: # Merge multiple lending loans api_response = api_instance.merge_loans(currency, ids) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->merge_loans: %s\n" % e) ``` @@ -559,7 +575,7 @@ Retrieve one single loan detail ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -584,6 +600,8 @@ try: # Retrieve one single loan detail api_response = api_instance.get_loan(loan_id, side) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->get_loan: %s\n" % e) ``` @@ -628,7 +646,7 @@ Only lending loans can be cancelled ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -653,6 +671,8 @@ try: # Cancel lending loan api_response = api_instance.cancel_loan(loan_id, currency) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->cancel_loan: %s\n" % e) ``` @@ -697,7 +717,7 @@ Only `auto_renew` modification is supported currently ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -722,6 +742,8 @@ try: # Modify a loan api_response = api_instance.update_loan(loan_id, loan_patch) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->update_loan: %s\n" % e) ``` @@ -764,7 +786,7 @@ List loan repayment records ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -788,6 +810,8 @@ try: # List loan repayment records api_response = api_instance.list_loan_repayments(loan_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_loan_repayments: %s\n" % e) ``` @@ -829,7 +853,7 @@ Repay a loan ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -854,6 +878,8 @@ try: # Repay a loan api_response = api_instance.repay_loan(loan_id, repay_request) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->repay_loan: %s\n" % e) ``` @@ -896,7 +922,7 @@ List repayment records of specified loan ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -923,6 +949,8 @@ try: # List repayment records of specified loan api_response = api_instance.list_loan_records(loan_id, status=status, page=page, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->list_loan_records: %s\n" % e) ``` @@ -967,7 +995,7 @@ Get one single loan record ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -992,6 +1020,8 @@ try: # Get one single loan record api_response = api_instance.get_loan_record(loan_record_id, loan_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->get_loan_record: %s\n" % e) ``` @@ -1036,7 +1066,7 @@ Only `auto_renew` modification is supported currently ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1061,6 +1091,8 @@ try: # Modify a loan record api_response = api_instance.update_loan_record(loan_record_id, loan_patch) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling MarginApi->update_loan_record: %s\n" % e) ``` diff --git a/docs/SpotApi.md b/docs/SpotApi.md index 4cf4fa0..c8dfbea 100644 --- a/docs/SpotApi.md +++ b/docs/SpotApi.md @@ -33,7 +33,7 @@ List all currency pairs supported ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -48,6 +48,8 @@ try: # List all currency pairs supported api_response = api_instance.list_currency_pairs() print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_currency_pairs: %s\n" % e) ``` @@ -85,7 +87,7 @@ Get detail of one single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -101,6 +103,8 @@ try: # Get detail of one single order api_response = api_instance.get_currency_pair(currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->get_currency_pair: %s\n" % e) ``` @@ -143,7 +147,7 @@ Return only related data if `currency_pair` is specified; otherwise return all o ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -159,6 +163,8 @@ try: # Retrieve ticker information api_response = api_instance.list_tickers(currency_pair=currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_tickers: %s\n" % e) ``` @@ -201,7 +207,7 @@ Order book will be sorted by price from high to low on bids; reversed on asks ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -219,6 +225,8 @@ try: # Retrieve order book api_response = api_instance.list_order_book(currency_pair, interval=interval, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_order_book: %s\n" % e) ``` @@ -261,7 +269,7 @@ Retrieve market trades ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -279,6 +287,8 @@ try: # Retrieve market trades api_response = api_instance.list_trades(currency_pair, limit=limit, last_id=last_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_trades: %s\n" % e) ``` @@ -323,7 +333,7 @@ Maximum of 1000 points are returned in one query. Be sure not to exceed the limi ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. configuration = gate_api.Configuration( @@ -343,6 +353,8 @@ try: # Market candlesticks api_response = api_instance.list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_candlesticks: %s\n" % e) ``` @@ -388,7 +400,7 @@ Query user trading fee rates ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -412,6 +424,8 @@ try: # Query user trading fee rates api_response = api_instance.get_fee(currency_pair=currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->get_fee: %s\n" % e) ``` @@ -453,7 +467,7 @@ List spot accounts ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -477,6 +491,8 @@ try: # List spot accounts api_response = api_instance.list_spot_accounts(currency=currency) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_spot_accounts: %s\n" % e) ``` @@ -520,7 +536,7 @@ Batch orders requirements: 1. custom order field `text` is required 2. At most ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -544,6 +560,8 @@ try: # Create a batch of orders api_response = api_instance.create_batch_orders(order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->create_batch_orders: %s\n" % e) ``` @@ -587,7 +605,7 @@ List open orders in all currency pairs. Note that pagination parameters affect ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -612,6 +630,8 @@ try: # List all open orders api_response = api_instance.list_all_open_orders(page=page, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_all_open_orders: %s\n" % e) ``` @@ -654,7 +674,7 @@ List orders ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -681,6 +701,8 @@ try: # List orders api_response = api_instance.list_orders(currency_pair, status, page=page, limit=limit) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_orders: %s\n" % e) ``` @@ -725,7 +747,7 @@ Create an order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -749,6 +771,8 @@ try: # Create an order api_response = api_instance.create_order(order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->create_order: %s\n" % e) ``` @@ -790,7 +814,7 @@ Cancel all `open` orders in specified currency pair ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -816,6 +840,8 @@ try: # Cancel all `open` orders in specified currency pair api_response = api_instance.cancel_orders(currency_pair, side=side, account=account) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->cancel_orders: %s\n" % e) ``` @@ -861,7 +887,7 @@ Multiple currency pairs can be specified, but maximum 20 orders are allowed per ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -885,6 +911,8 @@ try: # Cancel a batch of orders with an ID list api_response = api_instance.cancel_batch_orders(cancel_order) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->cancel_batch_orders: %s\n" % e) ``` @@ -926,7 +954,7 @@ Get a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -951,6 +979,8 @@ try: # Get a single order api_response = api_instance.get_order(order_id, currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->get_order: %s\n" % e) ``` @@ -993,7 +1023,7 @@ Cancel a single order ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1018,6 +1048,8 @@ try: # Cancel a single order api_response = api_instance.cancel_order(order_id, currency_pair) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->cancel_order: %s\n" % e) ``` @@ -1060,7 +1092,7 @@ List personal trading history ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -1087,6 +1119,8 @@ try: # List personal trading history api_response = api_instance.list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling SpotApi->list_my_trades: %s\n" % e) ``` diff --git a/docs/WalletApi.md b/docs/WalletApi.md index 21f5474..e053018 100644 --- a/docs/WalletApi.md +++ b/docs/WalletApi.md @@ -23,7 +23,7 @@ Generate currency deposit address ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -47,6 +47,8 @@ try: # Generate currency deposit address api_response = api_instance.get_deposit_address(currency) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->get_deposit_address: %s\n" % e) ``` @@ -90,7 +92,7 @@ Record time range cannot exceed 30 days ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -118,6 +120,8 @@ try: # Retrieve withdrawal records api_response = api_instance.list_withdrawals(currency=currency, _from=_from, to=to, limit=limit, offset=offset) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->list_withdrawals: %s\n" % e) ``` @@ -165,7 +169,7 @@ Record time range cannot exceed 30 days ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -193,6 +197,8 @@ try: # Retrieve deposit records api_response = api_instance.list_deposits(currency=currency, _from=_from, to=to, limit=limit, offset=offset) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->list_deposits: %s\n" % e) ``` @@ -240,7 +246,7 @@ Transfer between different accounts. Currently support transfers between the fol ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -263,6 +269,8 @@ transfer = gate_api.Transfer() # Transfer | try: # Transfer between trading accounts api_instance.transfer(transfer) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->transfer: %s\n" % e) ``` @@ -306,7 +314,7 @@ Record time range cannot exceed 30 days > Note: only records after 2020-04-10 c ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -334,6 +342,8 @@ try: # Transfer records between main and sub accounts api_response = api_instance.list_sub_account_transfers(sub_uid=sub_uid, _from=_from, to=to, limit=limit, offset=offset) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->list_sub_account_transfers: %s\n" % e) ``` @@ -379,7 +389,7 @@ Transfer between main and sub accounts ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -402,6 +412,8 @@ sub_account_transfer = gate_api.SubAccountTransfer() # SubAccountTransfer | try: # Transfer between main and sub accounts api_instance.transfer_with_sub_account(sub_account_transfer) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WalletApi->transfer_with_sub_account: %s\n" % e) ``` diff --git a/docs/WithdrawalApi.md b/docs/WithdrawalApi.md index a45ac37..c9ea8b6 100644 --- a/docs/WithdrawalApi.md +++ b/docs/WithdrawalApi.md @@ -18,7 +18,7 @@ Withdraw ```python from __future__ import print_function import gate_api -from gate_api.exceptions import ApiException +from gate_api.exceptions import ApiException, GateApiException # Defining the host is optional and defaults to https://api.gateio.ws/api/v4 # See configuration.py for a list of all supported configuration parameters. # The client must configure the authentication and authorization parameters @@ -42,6 +42,8 @@ try: # Withdraw api_response = api_instance.withdraw(ledger_record) print(api_response) +except GateApiException as ex: + print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message)) except ApiException as e: print("Exception when calling WithdrawalApi->withdraw: %s\n" % e) ``` diff --git a/gate_api/__init__.py b/gate_api/__init__.py index 02e4168..f8c066e 100644 --- a/gate_api/__init__.py +++ b/gate_api/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import -__version__ = "4.15.2" +__version__ = "4.15.3" # import apis into sdk package from gate_api.api.delivery_api import DeliveryApi diff --git a/gate_api/api_client.py b/gate_api/api_client.py index a4d2c06..a84fd8a 100644 --- a/gate_api/api_client.py +++ b/gate_api/api_client.py @@ -32,7 +32,7 @@ from gate_api.configuration import Configuration import gate_api.models from gate_api import rest -from gate_api.exceptions import ApiValueError, ApiException +from gate_api.exceptions import ApiValueError, ApiException, GateApiException class ApiClient(object): @@ -82,7 +82,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, cook self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/4.15.2/python' + self.user_agent = 'OpenAPI-Generator/4.15.3/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): @@ -199,7 +199,12 @@ def __call_api( ) except ApiException as e: e.body = e.body.decode('utf-8') if six.PY3 else e.body - raise e + try: + err = json.loads(e.body) + except ValueError: + raise e + else: + raise GateApiException(err.get('label'), err.get('message'), err.get('detail'), e) content_type = response_data.getheader('content-type') diff --git a/gate_api/configuration.py b/gate_api/configuration.py index 7850577..20ad74b 100644 --- a/gate_api/configuration.py +++ b/gate_api/configuration.py @@ -316,8 +316,8 @@ def to_debug_report(self): "Python SDK Debug Report:\n" "OS: {env}\n" "Python Version: {pyversion}\n" - "Version of the API: 4.15.2\n" - "SDK Package Version: 4.15.2".format(env=sys.platform, pyversion=sys.version) + "Version of the API: 4.15.3\n" + "SDK Package Version: 4.15.3".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/gate_api/exceptions.py b/gate_api/exceptions.py index 697fc65..0e26730 100644 --- a/gate_api/exceptions.py +++ b/gate_api/exceptions.py @@ -105,6 +105,23 @@ def __str__(self): return error_message +class GateApiException(ApiException): + def __init__(self, label=None, message=None, detail=None, exp=None): + """Init GateApiException from ApiException + + :param str label: error label parsed + :param str message: error message parsed + :param str detail: possible error message parsed + :param ApiException exp: parent exception + """ + self.label = label + self.message = detail if detail else message + self.status = exp.status + self.reason = exp.reason + self.body = exp.body + self.headers = exp.headers + + def render_path(path_to_item): """Returns a string representation of a path""" result = "" diff --git a/gate_api/models/futures_order.py b/gate_api/models/futures_order.py index 1dccd96..35f5c35 100644 --- a/gate_api/models/futures_order.py +++ b/gate_api/models/futures_order.py @@ -151,8 +151,7 @@ def __init__( if status is not None: self.status = status self.contract = contract - if size is not None: - self.size = size + self.size = size if iceberg is not None: self.iceberg = iceberg if price is not None: @@ -377,6 +376,8 @@ def size(self, size): :param size: The size of this FuturesOrder. # noqa: E501 :type: int """ + if self.local_vars_configuration.client_side_validation and size is None: # noqa: E501 + raise ValueError("Invalid value for `size`, must not be `None`") # noqa: E501 self._size = size diff --git a/setup.py b/setup.py index 1f641dc..49d16b7 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "gate-api" -VERSION = "4.15.2" +VERSION = "4.15.3" # To install the library, run the following # # python setup.py install From 003731005886593779fdc17913f4326cb1415d1d Mon Sep 17 00:00:00 2001 From: Revil Wang Date: Fri, 14 Aug 2020 19:15:49 +0800 Subject: [PATCH 2/2] add missing Contract field --- docs/Contract.md | 1 + docs/DeliveryContract.md | 1 + gate_api/api_client.py | 2 ++ gate_api/models/contract.py | 31 +++++++++++++++++++++++++++- gate_api/models/delivery_contract.py | 31 +++++++++++++++++++++++++++- 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/docs/Contract.md b/docs/Contract.md index 207b653..9967664 100644 --- a/docs/Contract.md +++ b/docs/Contract.md @@ -35,6 +35,7 @@ Name | Type | Description | Notes **position_size** | **int** | Current total long position size | [optional] **config_change_time** | **float** | Configuration's last changed time | [optional] **in_delisting** | **bool** | Contract is delisting | [optional] +**orders_limit** | **int** | Maximum number of open orders | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/DeliveryContract.md b/docs/DeliveryContract.md index 9568e5d..79b47fb 100644 --- a/docs/DeliveryContract.md +++ b/docs/DeliveryContract.md @@ -41,6 +41,7 @@ Name | Type | Description | Notes **position_size** | **int** | Current total long position size | [optional] **config_change_time** | **float** | Configuration's last changed time | [optional] **in_delisting** | **bool** | Contract is delisting | [optional] +**orders_limit** | **int** | Maximum number of open orders | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/gate_api/api_client.py b/gate_api/api_client.py index a84fd8a..065f316 100644 --- a/gate_api/api_client.py +++ b/gate_api/api_client.py @@ -204,6 +204,8 @@ def __call_api( except ValueError: raise e else: + if not err.get('label'): + raise e raise GateApiException(err.get('label'), err.get('message'), err.get('detail'), e) content_type = response_data.getheader('content-type') diff --git a/gate_api/models/contract.py b/gate_api/models/contract.py index fdbf5e0..14e1219 100644 --- a/gate_api/models/contract.py +++ b/gate_api/models/contract.py @@ -64,6 +64,7 @@ class Contract(object): 'position_size': 'int', 'config_change_time': 'float', 'in_delisting': 'bool', + 'orders_limit': 'int', } attribute_map = { @@ -98,6 +99,7 @@ class Contract(object): 'position_size': 'position_size', 'config_change_time': 'config_change_time', 'in_delisting': 'in_delisting', + 'orders_limit': 'orders_limit', } def __init__( @@ -133,9 +135,10 @@ def __init__( position_size=None, config_change_time=None, in_delisting=None, + orders_limit=None, local_vars_configuration=None, ): # noqa: E501 - # type: (str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, float, str, str, str, int, int, str, str, str, int, int, int, int, float, bool, Configuration) -> None + # type: (str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, float, str, str, str, int, int, str, str, str, int, int, int, int, float, bool, int, Configuration) -> None """Contract - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -172,6 +175,7 @@ def __init__( self._position_size = None self._config_change_time = None self._in_delisting = None + self._orders_limit = None self.discriminator = None if name is not None: @@ -236,6 +240,8 @@ def __init__( self.config_change_time = config_change_time if in_delisting is not None: self.in_delisting = in_delisting + if orders_limit is not None: + self.orders_limit = orders_limit @property def name(self): @@ -962,6 +968,29 @@ def in_delisting(self, in_delisting): self._in_delisting = in_delisting + @property + def orders_limit(self): + """Gets the orders_limit of this Contract. # noqa: E501 + + Maximum number of open orders # noqa: E501 + + :return: The orders_limit of this Contract. # noqa: E501 + :rtype: int + """ + return self._orders_limit + + @orders_limit.setter + def orders_limit(self, orders_limit): + """Sets the orders_limit of this Contract. + + Maximum number of open orders # noqa: E501 + + :param orders_limit: The orders_limit of this Contract. # noqa: E501 + :type: int + """ + + self._orders_limit = orders_limit + def to_dict(self): """Returns the model properties as a dict""" result = {} diff --git a/gate_api/models/delivery_contract.py b/gate_api/models/delivery_contract.py index 5ec221d..643c964 100644 --- a/gate_api/models/delivery_contract.py +++ b/gate_api/models/delivery_contract.py @@ -70,6 +70,7 @@ class DeliveryContract(object): 'position_size': 'int', 'config_change_time': 'float', 'in_delisting': 'bool', + 'orders_limit': 'int', } attribute_map = { @@ -110,6 +111,7 @@ class DeliveryContract(object): 'position_size': 'position_size', 'config_change_time': 'config_change_time', 'in_delisting': 'in_delisting', + 'orders_limit': 'orders_limit', } def __init__( @@ -151,9 +153,10 @@ def __init__( position_size=None, config_change_time=None, in_delisting=None, + orders_limit=None, local_vars_configuration=None, ): # noqa: E501 - # type: (str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, int, int, str, str, str, int, int, str, str, str, int, int, int, int, float, bool, Configuration) -> None + # type: (str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, int, int, str, str, str, int, int, str, str, str, int, int, int, int, float, bool, int, Configuration) -> None """DeliveryContract - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -196,6 +199,7 @@ def __init__( self._position_size = None self._config_change_time = None self._in_delisting = None + self._orders_limit = None self.discriminator = None if name is not None: @@ -272,6 +276,8 @@ def __init__( self.config_change_time = config_change_time if in_delisting is not None: self.in_delisting = in_delisting + if orders_limit is not None: + self.orders_limit = orders_limit @property def name(self): @@ -1141,6 +1147,29 @@ def in_delisting(self, in_delisting): self._in_delisting = in_delisting + @property + def orders_limit(self): + """Gets the orders_limit of this DeliveryContract. # noqa: E501 + + Maximum number of open orders # noqa: E501 + + :return: The orders_limit of this DeliveryContract. # noqa: E501 + :rtype: int + """ + return self._orders_limit + + @orders_limit.setter + def orders_limit(self, orders_limit): + """Sets the orders_limit of this DeliveryContract. + + Maximum number of open orders # noqa: E501 + + :param orders_limit: The orders_limit of this DeliveryContract. # noqa: E501 + :type: int + """ + + self._orders_limit = orders_limit + def to_dict(self): """Returns the model properties as a dict""" result = {}