diff --git a/.gitignore b/.gitignore index a655050..43995bd 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,9 @@ coverage.xml *,cover .hypothesis/ venv/ +.venv/ .python-version +.pytest_cache # Translations *.mo diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a086da0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,33 @@ +# ref: https://docs.gitlab.com/ee/ci/README.html + +stages: + - test + +.nosetest: + stage: test + script: + - pip install -r requirements.txt + - pip install -r test-requirements.txt + - pytest --cov=gate_api + +nosetest-2.7: + extends: .nosetest + image: python:2.7-alpine +nosetest-3.3: + extends: .nosetest + image: python:3.3-alpine +nosetest-3.4: + extends: .nosetest + image: python:3.4-alpine +nosetest-3.5: + extends: .nosetest + image: python:3.5-alpine +nosetest-3.6: + extends: .nosetest + image: python:3.6-alpine +nosetest-3.7: + extends: .nosetest + image: python:3.7-alpine +nosetest-3.8: + extends: .nosetest + image: python:3.8-alpine diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore deleted file mode 100644 index 7484ee5..0000000 --- a/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION deleted file mode 100644 index 2c6109e..0000000 --- a/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -3.3.4 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 86211e2..4e32d1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,12 @@ python: - "3.3" - "3.4" - "3.5" - #- "3.5-dev" # 3.5 development branch - #- "nightly" # points to the latest development branch e.g. 3.6-dev + - "3.6" + - "3.7" + - "3.8" # command to install dependencies -install: "pip install -r requirements.txt" +install: + - "pip install -r requirements.txt" + - "pip install -r test-requirements.txt" # command to run tests -script: nosetests +script: pytest --cov=gate_api diff --git a/README.md b/README.md index be2d914..951933d 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,34 @@ 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.14.0 -- Package version: 4.14.0 +- API version: 4.15.2 +- Package version: 4.15.2 - Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts) -## Specific note for 4.8.0 +## Versioning -**BREAKING** change: +Trying our best to follow the [semantic versioning](https://semver.org/), while enjoying recent features +provided by programming language and libraries, from 4.15.2, one major versioning difference will be +introduced: -4.8.0 add new support with different settle currency for futures API(BTC is the only one allowed before), which makes ALL methods in FuturesApi REQUIRE an additional `settle` parameter. +If extra code rewrite is required when you upgrade the SDK, such as: -But previous `/futures/xxx` APIs are still preserved for compatibility usage(will be treated as BTC), so if one of the following condition is met: +- some outdated programming language version support is dropped +- API method signature has breaking changes. -- Changing all your futures method call to include `settle` is not a big issue for you -- You need to use futures settled in non-BTC currency +**the MAJOR version will be incremented, but the MINOR and PATCH version are still following REST API's +instead of resetting to 0**, so that you can recognize it has some breaking changes, but still getting +the idea of from which REST API version the change is introduced. -then you'd better move to 4.8.0 and changes all your futures method call to pass in `settle` parameter. Otherwise, you can stick to version<=4.7.3, -but will not receive any future API upgrade support +For example, the previous REST API and SDK version are both 4.14.0. But if we decide to introduce +some breaking changes in SDK along with REST API 4.15.2 upgrade, then the version of next SDK release +will be 5.15.2(the MAJOR version is incremented to denote breaking changes, but the MINOR and PATCH +version are identical to REST API's instead of resetting them to 0) + +If MAJOR version is incremented, make sure you read the release note on +[Releases](https://github.com/gateio/gateapi-python/releases) +page ## Requirements. @@ -29,7 +39,7 @@ Python 2.7 and 3.4+ ## Installation & Usage ### pip install -If the python package is hosted on Github, you can install directly from Github +If the python package is hosted on a repository, you can install directly using: ```sh pip install git+https://github.com/gateio/gateapi-python.git @@ -38,7 +48,7 @@ pip install git+https://github.com/gateio/gateapi-python.git Then import the package: ```python -import gate_api +import gate_api ``` ### Setuptools @@ -61,29 +71,28 @@ Please follow the [installation procedure](#installation--usage) and then run th ```python from __future__ import print_function + import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' -# uncomment the next line if using the API with another host -# configuration.host = 'https://some-other-host' -# configuration.proxy = 'http://localhost:1080' # uncomment to proxy through a http proxy -# configuration.verify_ssl = False # uncomment to turn off ssl verification -# More connection configuration is available in `Configuration` model. - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException + +# 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( + host = "https://api.gateio.ws/api/v4" +) + + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -order_id = '12345' # str | ID returned on order successfully being created try: - # Cancel a single order - api_response = api_instance.cancel_delivery_order(settle, order_id) + # List all futures contracts + api_response = api_instance.list_delivery_contracts(settle) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->cancel_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e) ``` @@ -93,97 +102,100 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*DeliveryApi* | [**cancel_delivery_order**](docs/DeliveryApi.md#cancel_delivery_order) | **DELETE** /delivery/{settle}/orders/{order_id} | Cancel a single order -*DeliveryApi* | [**cancel_delivery_orders**](docs/DeliveryApi.md#cancel_delivery_orders) | **DELETE** /delivery/{settle}/orders | Cancel all `open` orders matched -*DeliveryApi* | [**cancel_price_triggered_delivery_order**](docs/DeliveryApi.md#cancel_price_triggered_delivery_order) | **DELETE** /delivery/{settle}/price_orders/{order_id} | Cancel a single order -*DeliveryApi* | [**cancel_price_triggered_delivery_order_list**](docs/DeliveryApi.md#cancel_price_triggered_delivery_order_list) | **DELETE** /delivery/{settle}/price_orders | Cancel all open orders -*DeliveryApi* | [**create_delivery_order**](docs/DeliveryApi.md#create_delivery_order) | **POST** /delivery/{settle}/orders | Create a futures order -*DeliveryApi* | [**create_price_triggered_delivery_order**](docs/DeliveryApi.md#create_price_triggered_delivery_order) | **POST** /delivery/{settle}/price_orders | Create a price-triggered order +*DeliveryApi* | [**list_delivery_contracts**](docs/DeliveryApi.md#list_delivery_contracts) | **GET** /delivery/{settle}/contracts | List all futures contracts *DeliveryApi* | [**get_delivery_contract**](docs/DeliveryApi.md#get_delivery_contract) | **GET** /delivery/{settle}/contracts/{contract} | Get a single contract -*DeliveryApi* | [**get_delivery_order**](docs/DeliveryApi.md#get_delivery_order) | **GET** /delivery/{settle}/orders/{order_id} | Get a single order -*DeliveryApi* | [**get_delivery_position**](docs/DeliveryApi.md#get_delivery_position) | **GET** /delivery/{settle}/positions/{contract} | Get single position -*DeliveryApi* | [**get_my_delivery_trades**](docs/DeliveryApi.md#get_my_delivery_trades) | **GET** /delivery/{settle}/my_trades | List personal trading history -*DeliveryApi* | [**get_price_triggered_delivery_order**](docs/DeliveryApi.md#get_price_triggered_delivery_order) | **GET** /delivery/{settle}/price_orders/{order_id} | Get a single order -*DeliveryApi* | [**list_delivery_account_book**](docs/DeliveryApi.md#list_delivery_account_book) | **GET** /delivery/{settle}/account_book | Query account book -*DeliveryApi* | [**list_delivery_accounts**](docs/DeliveryApi.md#list_delivery_accounts) | **GET** /delivery/{settle}/accounts | Query futures account +*DeliveryApi* | [**list_delivery_order_book**](docs/DeliveryApi.md#list_delivery_order_book) | **GET** /delivery/{settle}/order_book | Futures order book +*DeliveryApi* | [**list_delivery_trades**](docs/DeliveryApi.md#list_delivery_trades) | **GET** /delivery/{settle}/trades | Futures trading history *DeliveryApi* | [**list_delivery_candlesticks**](docs/DeliveryApi.md#list_delivery_candlesticks) | **GET** /delivery/{settle}/candlesticks | Get futures candlesticks -*DeliveryApi* | [**list_delivery_contracts**](docs/DeliveryApi.md#list_delivery_contracts) | **GET** /delivery/{settle}/contracts | List all futures contracts +*DeliveryApi* | [**list_delivery_tickers**](docs/DeliveryApi.md#list_delivery_tickers) | **GET** /delivery/{settle}/tickers | List futures tickers *DeliveryApi* | [**list_delivery_insurance_ledger**](docs/DeliveryApi.md#list_delivery_insurance_ledger) | **GET** /delivery/{settle}/insurance | Futures insurance balance history -*DeliveryApi* | [**list_delivery_liquidates**](docs/DeliveryApi.md#list_delivery_liquidates) | **GET** /delivery/{settle}/liquidates | List liquidation history -*DeliveryApi* | [**list_delivery_order_book**](docs/DeliveryApi.md#list_delivery_order_book) | **GET** /delivery/{settle}/order_book | Futures order book +*DeliveryApi* | [**list_delivery_accounts**](docs/DeliveryApi.md#list_delivery_accounts) | **GET** /delivery/{settle}/accounts | Query futures account +*DeliveryApi* | [**list_delivery_account_book**](docs/DeliveryApi.md#list_delivery_account_book) | **GET** /delivery/{settle}/account_book | Query account book +*DeliveryApi* | [**list_delivery_positions**](docs/DeliveryApi.md#list_delivery_positions) | **GET** /delivery/{settle}/positions | List all positions of a user +*DeliveryApi* | [**get_delivery_position**](docs/DeliveryApi.md#get_delivery_position) | **GET** /delivery/{settle}/positions/{contract} | Get single position +*DeliveryApi* | [**update_delivery_position_margin**](docs/DeliveryApi.md#update_delivery_position_margin) | **POST** /delivery/{settle}/positions/{contract}/margin | Update position margin +*DeliveryApi* | [**update_delivery_position_leverage**](docs/DeliveryApi.md#update_delivery_position_leverage) | **POST** /delivery/{settle}/positions/{contract}/leverage | Update position leverage +*DeliveryApi* | [**update_delivery_position_risk_limit**](docs/DeliveryApi.md#update_delivery_position_risk_limit) | **POST** /delivery/{settle}/positions/{contract}/risk_limit | Update position risk limit *DeliveryApi* | [**list_delivery_orders**](docs/DeliveryApi.md#list_delivery_orders) | **GET** /delivery/{settle}/orders | List futures orders +*DeliveryApi* | [**create_delivery_order**](docs/DeliveryApi.md#create_delivery_order) | **POST** /delivery/{settle}/orders | Create a futures order +*DeliveryApi* | [**cancel_delivery_orders**](docs/DeliveryApi.md#cancel_delivery_orders) | **DELETE** /delivery/{settle}/orders | Cancel all `open` orders matched +*DeliveryApi* | [**get_delivery_order**](docs/DeliveryApi.md#get_delivery_order) | **GET** /delivery/{settle}/orders/{order_id} | Get a single order +*DeliveryApi* | [**cancel_delivery_order**](docs/DeliveryApi.md#cancel_delivery_order) | **DELETE** /delivery/{settle}/orders/{order_id} | Cancel a single order +*DeliveryApi* | [**get_my_delivery_trades**](docs/DeliveryApi.md#get_my_delivery_trades) | **GET** /delivery/{settle}/my_trades | List personal trading history *DeliveryApi* | [**list_delivery_position_close**](docs/DeliveryApi.md#list_delivery_position_close) | **GET** /delivery/{settle}/position_close | List position close history -*DeliveryApi* | [**list_delivery_positions**](docs/DeliveryApi.md#list_delivery_positions) | **GET** /delivery/{settle}/positions | List all positions of a user +*DeliveryApi* | [**list_delivery_liquidates**](docs/DeliveryApi.md#list_delivery_liquidates) | **GET** /delivery/{settle}/liquidates | List liquidation history *DeliveryApi* | [**list_delivery_settlements**](docs/DeliveryApi.md#list_delivery_settlements) | **GET** /delivery/{settle}/settlements | List settlement history -*DeliveryApi* | [**list_delivery_tickers**](docs/DeliveryApi.md#list_delivery_tickers) | **GET** /delivery/{settle}/tickers | List futures tickers -*DeliveryApi* | [**list_delivery_trades**](docs/DeliveryApi.md#list_delivery_trades) | **GET** /delivery/{settle}/trades | Futures trading history *DeliveryApi* | [**list_price_triggered_delivery_orders**](docs/DeliveryApi.md#list_price_triggered_delivery_orders) | **GET** /delivery/{settle}/price_orders | List all auto orders -*DeliveryApi* | [**update_delivery_position_leverage**](docs/DeliveryApi.md#update_delivery_position_leverage) | **POST** /delivery/{settle}/positions/{contract}/leverage | Update position leverage -*DeliveryApi* | [**update_delivery_position_margin**](docs/DeliveryApi.md#update_delivery_position_margin) | **POST** /delivery/{settle}/positions/{contract}/margin | Update position margin -*DeliveryApi* | [**update_delivery_position_risk_limit**](docs/DeliveryApi.md#update_delivery_position_risk_limit) | **POST** /delivery/{settle}/positions/{contract}/risk_limit | Update position risk limit -*FuturesApi* | [**cancel_futures_order**](docs/FuturesApi.md#cancel_futures_order) | **DELETE** /futures/{settle}/orders/{order_id} | Cancel a single order -*FuturesApi* | [**cancel_futures_orders**](docs/FuturesApi.md#cancel_futures_orders) | **DELETE** /futures/{settle}/orders | Cancel all `open` orders matched -*FuturesApi* | [**cancel_price_triggered_order**](docs/FuturesApi.md#cancel_price_triggered_order) | **DELETE** /futures/{settle}/price_orders/{order_id} | Cancel a single order -*FuturesApi* | [**cancel_price_triggered_order_list**](docs/FuturesApi.md#cancel_price_triggered_order_list) | **DELETE** /futures/{settle}/price_orders | Cancel all open orders -*FuturesApi* | [**create_futures_order**](docs/FuturesApi.md#create_futures_order) | **POST** /futures/{settle}/orders | Create a futures order -*FuturesApi* | [**create_price_triggered_order**](docs/FuturesApi.md#create_price_triggered_order) | **POST** /futures/{settle}/price_orders | Create a price-triggered order +*DeliveryApi* | [**create_price_triggered_delivery_order**](docs/DeliveryApi.md#create_price_triggered_delivery_order) | **POST** /delivery/{settle}/price_orders | Create a price-triggered order +*DeliveryApi* | [**cancel_price_triggered_delivery_order_list**](docs/DeliveryApi.md#cancel_price_triggered_delivery_order_list) | **DELETE** /delivery/{settle}/price_orders | Cancel all open orders +*DeliveryApi* | [**get_price_triggered_delivery_order**](docs/DeliveryApi.md#get_price_triggered_delivery_order) | **GET** /delivery/{settle}/price_orders/{order_id} | Get a single order +*DeliveryApi* | [**cancel_price_triggered_delivery_order**](docs/DeliveryApi.md#cancel_price_triggered_delivery_order) | **DELETE** /delivery/{settle}/price_orders/{order_id} | Cancel a single order +*FuturesApi* | [**list_futures_contracts**](docs/FuturesApi.md#list_futures_contracts) | **GET** /futures/{settle}/contracts | List all futures contracts *FuturesApi* | [**get_futures_contract**](docs/FuturesApi.md#get_futures_contract) | **GET** /futures/{settle}/contracts/{contract} | Get a single contract -*FuturesApi* | [**get_futures_order**](docs/FuturesApi.md#get_futures_order) | **GET** /futures/{settle}/orders/{order_id} | Get a single order -*FuturesApi* | [**get_my_trades**](docs/FuturesApi.md#get_my_trades) | **GET** /futures/{settle}/my_trades | List personal trading history -*FuturesApi* | [**get_position**](docs/FuturesApi.md#get_position) | **GET** /futures/{settle}/positions/{contract} | Get single position -*FuturesApi* | [**get_price_triggered_order**](docs/FuturesApi.md#get_price_triggered_order) | **GET** /futures/{settle}/price_orders/{order_id} | Get a single order -*FuturesApi* | [**list_futures_account_book**](docs/FuturesApi.md#list_futures_account_book) | **GET** /futures/{settle}/account_book | Query account book -*FuturesApi* | [**list_futures_accounts**](docs/FuturesApi.md#list_futures_accounts) | **GET** /futures/{settle}/accounts | Query futures account +*FuturesApi* | [**list_futures_order_book**](docs/FuturesApi.md#list_futures_order_book) | **GET** /futures/{settle}/order_book | Futures order book +*FuturesApi* | [**list_futures_trades**](docs/FuturesApi.md#list_futures_trades) | **GET** /futures/{settle}/trades | Futures trading history *FuturesApi* | [**list_futures_candlesticks**](docs/FuturesApi.md#list_futures_candlesticks) | **GET** /futures/{settle}/candlesticks | Get futures candlesticks -*FuturesApi* | [**list_futures_contracts**](docs/FuturesApi.md#list_futures_contracts) | **GET** /futures/{settle}/contracts | List all futures contracts +*FuturesApi* | [**list_futures_tickers**](docs/FuturesApi.md#list_futures_tickers) | **GET** /futures/{settle}/tickers | List futures tickers *FuturesApi* | [**list_futures_funding_rate_history**](docs/FuturesApi.md#list_futures_funding_rate_history) | **GET** /futures/{settle}/funding_rate | Funding rate history *FuturesApi* | [**list_futures_insurance_ledger**](docs/FuturesApi.md#list_futures_insurance_ledger) | **GET** /futures/{settle}/insurance | Futures insurance balance history -*FuturesApi* | [**list_futures_order_book**](docs/FuturesApi.md#list_futures_order_book) | **GET** /futures/{settle}/order_book | Futures order book -*FuturesApi* | [**list_futures_orders**](docs/FuturesApi.md#list_futures_orders) | **GET** /futures/{settle}/orders | List futures orders -*FuturesApi* | [**list_futures_tickers**](docs/FuturesApi.md#list_futures_tickers) | **GET** /futures/{settle}/tickers | List futures tickers -*FuturesApi* | [**list_futures_trades**](docs/FuturesApi.md#list_futures_trades) | **GET** /futures/{settle}/trades | Futures trading history -*FuturesApi* | [**list_liquidates**](docs/FuturesApi.md#list_liquidates) | **GET** /futures/{settle}/liquidates | List liquidation history -*FuturesApi* | [**list_position_close**](docs/FuturesApi.md#list_position_close) | **GET** /futures/{settle}/position_close | List position close history +*FuturesApi* | [**list_futures_accounts**](docs/FuturesApi.md#list_futures_accounts) | **GET** /futures/{settle}/accounts | Query futures account +*FuturesApi* | [**list_futures_account_book**](docs/FuturesApi.md#list_futures_account_book) | **GET** /futures/{settle}/account_book | Query account book *FuturesApi* | [**list_positions**](docs/FuturesApi.md#list_positions) | **GET** /futures/{settle}/positions | List all positions of a user -*FuturesApi* | [**list_price_triggered_orders**](docs/FuturesApi.md#list_price_triggered_orders) | **GET** /futures/{settle}/price_orders | List all auto orders -*FuturesApi* | [**update_position_leverage**](docs/FuturesApi.md#update_position_leverage) | **POST** /futures/{settle}/positions/{contract}/leverage | Update position leverage +*FuturesApi* | [**get_position**](docs/FuturesApi.md#get_position) | **GET** /futures/{settle}/positions/{contract} | Get single position *FuturesApi* | [**update_position_margin**](docs/FuturesApi.md#update_position_margin) | **POST** /futures/{settle}/positions/{contract}/margin | Update position margin +*FuturesApi* | [**update_position_leverage**](docs/FuturesApi.md#update_position_leverage) | **POST** /futures/{settle}/positions/{contract}/leverage | Update position leverage *FuturesApi* | [**update_position_risk_limit**](docs/FuturesApi.md#update_position_risk_limit) | **POST** /futures/{settle}/positions/{contract}/risk_limit | Update position risk limit -*MarginApi* | [**cancel_loan**](docs/MarginApi.md#cancel_loan) | **DELETE** /margin/loans/{loan_id} | Cancel lending loan -*MarginApi* | [**create_loan**](docs/MarginApi.md#create_loan) | **POST** /margin/loans | Lend or borrow -*MarginApi* | [**get_loan**](docs/MarginApi.md#get_loan) | **GET** /margin/loans/{loan_id} | Retrieve one single loan detail -*MarginApi* | [**get_loan_record**](docs/MarginApi.md#get_loan_record) | **GET** /margin/loan_records/{loan_record_id} | Get one single loan record -*MarginApi* | [**list_funding_accounts**](docs/MarginApi.md#list_funding_accounts) | **GET** /margin/funding_accounts | Funding account list +*FuturesApi* | [**list_futures_orders**](docs/FuturesApi.md#list_futures_orders) | **GET** /futures/{settle}/orders | List futures orders +*FuturesApi* | [**create_futures_order**](docs/FuturesApi.md#create_futures_order) | **POST** /futures/{settle}/orders | Create a futures order +*FuturesApi* | [**cancel_futures_orders**](docs/FuturesApi.md#cancel_futures_orders) | **DELETE** /futures/{settle}/orders | Cancel all `open` orders matched +*FuturesApi* | [**get_futures_order**](docs/FuturesApi.md#get_futures_order) | **GET** /futures/{settle}/orders/{order_id} | Get a single order +*FuturesApi* | [**cancel_futures_order**](docs/FuturesApi.md#cancel_futures_order) | **DELETE** /futures/{settle}/orders/{order_id} | Cancel a single order +*FuturesApi* | [**get_my_trades**](docs/FuturesApi.md#get_my_trades) | **GET** /futures/{settle}/my_trades | List personal trading history +*FuturesApi* | [**list_position_close**](docs/FuturesApi.md#list_position_close) | **GET** /futures/{settle}/position_close | List position close history +*FuturesApi* | [**list_liquidates**](docs/FuturesApi.md#list_liquidates) | **GET** /futures/{settle}/liquidates | List liquidation history +*FuturesApi* | [**list_price_triggered_orders**](docs/FuturesApi.md#list_price_triggered_orders) | **GET** /futures/{settle}/price_orders | List all auto orders +*FuturesApi* | [**create_price_triggered_order**](docs/FuturesApi.md#create_price_triggered_order) | **POST** /futures/{settle}/price_orders | Create a price-triggered order +*FuturesApi* | [**cancel_price_triggered_order_list**](docs/FuturesApi.md#cancel_price_triggered_order_list) | **DELETE** /futures/{settle}/price_orders | Cancel all open orders +*FuturesApi* | [**get_price_triggered_order**](docs/FuturesApi.md#get_price_triggered_order) | **GET** /futures/{settle}/price_orders/{order_id} | Get a single order +*FuturesApi* | [**cancel_price_triggered_order**](docs/FuturesApi.md#cancel_price_triggered_order) | **DELETE** /futures/{settle}/price_orders/{order_id} | Cancel a single order +*MarginApi* | [**list_margin_currency_pairs**](docs/MarginApi.md#list_margin_currency_pairs) | **GET** /margin/currency_pairs | List all supported currency pairs supported in margin trading *MarginApi* | [**list_funding_book**](docs/MarginApi.md#list_funding_book) | **GET** /margin/funding_book | Order book of lending loans -*MarginApi* | [**list_loan_records**](docs/MarginApi.md#list_loan_records) | **GET** /margin/loan_records | List repayment records of specified loan -*MarginApi* | [**list_loan_repayments**](docs/MarginApi.md#list_loan_repayments) | **GET** /margin/loans/{loan_id}/repayment | List loan repayment records -*MarginApi* | [**list_loans**](docs/MarginApi.md#list_loans) | **GET** /margin/loans | List all loans *MarginApi* | [**list_margin_accounts**](docs/MarginApi.md#list_margin_accounts) | **GET** /margin/accounts | Margin account list -*MarginApi* | [**list_margin_currency_pairs**](docs/MarginApi.md#list_margin_currency_pairs) | **GET** /margin/currency_pairs | List all supported currency pairs supported in margin trading +*MarginApi* | [**list_margin_account_book**](docs/MarginApi.md#list_margin_account_book) | **GET** /margin/account_book | List margin account balance change history +*MarginApi* | [**list_funding_accounts**](docs/MarginApi.md#list_funding_accounts) | **GET** /margin/funding_accounts | Funding account list +*MarginApi* | [**list_loans**](docs/MarginApi.md#list_loans) | **GET** /margin/loans | List all loans +*MarginApi* | [**create_loan**](docs/MarginApi.md#create_loan) | **POST** /margin/loans | Lend or borrow *MarginApi* | [**merge_loans**](docs/MarginApi.md#merge_loans) | **POST** /margin/merged_loans | Merge multiple lending loans -*MarginApi* | [**repay_loan**](docs/MarginApi.md#repay_loan) | **POST** /margin/loans/{loan_id}/repayment | Repay a loan +*MarginApi* | [**get_loan**](docs/MarginApi.md#get_loan) | **GET** /margin/loans/{loan_id} | Retrieve one single loan detail +*MarginApi* | [**cancel_loan**](docs/MarginApi.md#cancel_loan) | **DELETE** /margin/loans/{loan_id} | Cancel lending loan *MarginApi* | [**update_loan**](docs/MarginApi.md#update_loan) | **PATCH** /margin/loans/{loan_id} | Modify a loan +*MarginApi* | [**list_loan_repayments**](docs/MarginApi.md#list_loan_repayments) | **GET** /margin/loans/{loan_id}/repayment | List loan repayment records +*MarginApi* | [**repay_loan**](docs/MarginApi.md#repay_loan) | **POST** /margin/loans/{loan_id}/repayment | Repay a loan +*MarginApi* | [**list_loan_records**](docs/MarginApi.md#list_loan_records) | **GET** /margin/loan_records | List repayment records of specified loan +*MarginApi* | [**get_loan_record**](docs/MarginApi.md#get_loan_record) | **GET** /margin/loan_records/{loan_record_id} | Get one single loan record *MarginApi* | [**update_loan_record**](docs/MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record -*SpotApi* | [**cancel_batch_orders**](docs/SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list -*SpotApi* | [**cancel_order**](docs/SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order -*SpotApi* | [**cancel_orders**](docs/SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair +*SpotApi* | [**list_currency_pairs**](docs/SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported +*SpotApi* | [**get_currency_pair**](docs/SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order +*SpotApi* | [**list_tickers**](docs/SpotApi.md#list_tickers) | **GET** /spot/tickers | Retrieve ticker information +*SpotApi* | [**list_order_book**](docs/SpotApi.md#list_order_book) | **GET** /spot/order_book | Retrieve order book +*SpotApi* | [**list_trades**](docs/SpotApi.md#list_trades) | **GET** /spot/trades | Retrieve market trades +*SpotApi* | [**list_candlesticks**](docs/SpotApi.md#list_candlesticks) | **GET** /spot/candlesticks | Market candlesticks +*SpotApi* | [**get_fee**](docs/SpotApi.md#get_fee) | **GET** /spot/fee | Query user trading fee rates +*SpotApi* | [**list_spot_accounts**](docs/SpotApi.md#list_spot_accounts) | **GET** /spot/accounts | List spot accounts *SpotApi* | [**create_batch_orders**](docs/SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders +*SpotApi* | [**list_all_open_orders**](docs/SpotApi.md#list_all_open_orders) | **GET** /spot/open_orders | List all open orders +*SpotApi* | [**list_orders**](docs/SpotApi.md#list_orders) | **GET** /spot/orders | List orders *SpotApi* | [**create_order**](docs/SpotApi.md#create_order) | **POST** /spot/orders | Create an order -*SpotApi* | [**get_currency_pair**](docs/SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order +*SpotApi* | [**cancel_orders**](docs/SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair +*SpotApi* | [**cancel_batch_orders**](docs/SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list *SpotApi* | [**get_order**](docs/SpotApi.md#get_order) | **GET** /spot/orders/{order_id} | Get a single order -*SpotApi* | [**list_candlesticks**](docs/SpotApi.md#list_candlesticks) | **GET** /spot/candlesticks | Market candlesticks -*SpotApi* | [**list_currency_pairs**](docs/SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported +*SpotApi* | [**cancel_order**](docs/SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order *SpotApi* | [**list_my_trades**](docs/SpotApi.md#list_my_trades) | **GET** /spot/my_trades | List personal trading history -*SpotApi* | [**list_order_book**](docs/SpotApi.md#list_order_book) | **GET** /spot/order_book | Retrieve order book -*SpotApi* | [**list_orders**](docs/SpotApi.md#list_orders) | **GET** /spot/orders | List orders -*SpotApi* | [**list_spot_accounts**](docs/SpotApi.md#list_spot_accounts) | **GET** /spot/accounts | List spot accounts -*SpotApi* | [**list_tickers**](docs/SpotApi.md#list_tickers) | **GET** /spot/tickers | Retrieve ticker information -*SpotApi* | [**list_trades**](docs/SpotApi.md#list_trades) | **GET** /spot/trades | Retrieve market trades *WalletApi* | [**get_deposit_address**](docs/WalletApi.md#get_deposit_address) | **GET** /wallet/deposit_address | Generate currency deposit address +*WalletApi* | [**list_withdrawals**](docs/WalletApi.md#list_withdrawals) | **GET** /wallet/withdrawals | Retrieve withdrawal records *WalletApi* | [**list_deposits**](docs/WalletApi.md#list_deposits) | **GET** /wallet/deposits | Retrieve deposit records +*WalletApi* | [**transfer**](docs/WalletApi.md#transfer) | **POST** /wallet/transfers | Transfer between trading accounts *WalletApi* | [**list_sub_account_transfers**](docs/WalletApi.md#list_sub_account_transfers) | **GET** /wallet/sub_account_transfers | Transfer records between main and sub accounts -*WalletApi* | [**list_withdrawals**](docs/WalletApi.md#list_withdrawals) | **GET** /wallet/withdrawals | Retrieve withdrawal records -*WalletApi* | [**transfer**](docs/WalletApi.md#transfer) | **POST** /wallet/transfers | Transfer between accounts *WalletApi* | [**transfer_with_sub_account**](docs/WalletApi.md#transfer_with_sub_account) | **POST** /wallet/sub_account_transfers | Transfer between main and sub accounts *WithdrawalApi* | [**withdraw**](docs/WithdrawalApi.md#withdraw) | **POST** /withdrawals | Withdraw @@ -213,16 +225,17 @@ Class | Method | HTTP request | Description - [FuturesPriceTriggeredOrder](docs/FuturesPriceTriggeredOrder.md) - [FuturesTicker](docs/FuturesTicker.md) - [FuturesTrade](docs/FuturesTrade.md) - - [GateErrorResponse](docs/GateErrorResponse.md) - [InsuranceRecord](docs/InsuranceRecord.md) - [LedgerRecord](docs/LedgerRecord.md) - [Loan](docs/Loan.md) - [LoanPatch](docs/LoanPatch.md) - [LoanRecord](docs/LoanRecord.md) - [MarginAccount](docs/MarginAccount.md) + - [MarginAccountBook](docs/MarginAccountBook.md) - [MarginAccountCurrency](docs/MarginAccountCurrency.md) - [MarginCurrencyPair](docs/MarginCurrencyPair.md) - [MyFuturesTrade](docs/MyFuturesTrade.md) + - [OpenOrders](docs/OpenOrders.md) - [Order](docs/Order.md) - [OrderBook](docs/OrderBook.md) - [Position](docs/Position.md) @@ -234,10 +247,22 @@ Class | Method | HTTP request | Description - [SubAccountTransfer](docs/SubAccountTransfer.md) - [Ticker](docs/Ticker.md) - [Trade](docs/Trade.md) + - [TradeFee](docs/TradeFee.md) - [Transfer](docs/Transfer.md) - [TriggerOrderResponse](docs/TriggerOrderResponse.md) +## Documentation For Authorization + + +## apiv4 + +Authentication with APIv4 key and secret + +For details, refer to: +[APIv4 signed request requirements](https://www.gate.io/docs/apiv4/en/index.html#apiv4-signed-request-requirements) + + ## Author support@mail.gate.io diff --git a/docs/BatchOrder.md b/docs/BatchOrder.md index b9e3160..b6dce80 100644 --- a/docs/BatchOrder.md +++ b/docs/BatchOrder.md @@ -1,16 +1,17 @@ # BatchOrder +Batch order details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) | [optional] +**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) | [optional] **succeeded** | **bool** | Whether order succeeds | [optional] **label** | **str** | Error label, empty string if order succeeds | [optional] **message** | **str** | Detailed error message, empty string if order succeeds | [optional] -**id** | **str** | Order ID | [optional] -**create_time** | **str** | Order creation time | [optional] -**update_time** | **str** | Order last modification time | [optional] -**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] +**id** | **str** | Order ID | [optional] [readonly] +**create_time** | **str** | Order creation time | [optional] [readonly] +**update_time** | **str** | Order last modification time | [optional] [readonly] +**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] [readonly] **currency_pair** | **str** | Currency pair | [optional] **type** | **str** | Order type. limit - limit order | [optional] [default to 'limit'] **account** | **str** | Account type. spot - use spot account; margin - use margin account | [optional] [default to 'spot'] @@ -19,16 +20,16 @@ Name | Type | Description | Notes **price** | **str** | Order price | [optional] **time_in_force** | **str** | Time in force - gtc: GoodTillCancelled - ioc: ImmediateOrCancelled, taker only - poc: PendingOrCancelled, makes a post-only order that always enjoys a maker fee | [optional] [default to 'gtc'] **auto_borrow** | **bool** | Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. | [optional] -**left** | **str** | Amount left to fill | [optional] -**fill_price** | **str** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] -**filled_total** | **str** | Total filled in quote currency | [optional] -**fee** | **str** | Fee deducted | [optional] -**fee_currency** | **str** | Fee currency unit | [optional] -**point_fee** | **str** | Point used to deduct fee | [optional] -**gt_fee** | **str** | GT used to deduct fee | [optional] -**gt_discount** | **bool** | Whether GT fee discount is used | [optional] -**rebated_fee** | **str** | Rebated fee | [optional] -**rebated_fee_currency** | **str** | Rebated fee currency unit | [optional] +**left** | **str** | Amount left to fill | [optional] [readonly] +**fill_price** | **str** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] [readonly] +**filled_total** | **str** | Total filled in quote currency | [optional] [readonly] +**fee** | **str** | Fee deducted | [optional] [readonly] +**fee_currency** | **str** | Fee currency unit | [optional] [readonly] +**point_fee** | **str** | Point used to deduct fee | [optional] [readonly] +**gt_fee** | **str** | GT used to deduct fee | [optional] [readonly] +**gt_discount** | **bool** | Whether GT fee discount is used | [optional] [readonly] +**rebated_fee** | **str** | Rebated fee | [optional] [readonly] +**rebated_fee_currency** | **str** | Rebated fee currency unit | [optional] [readonly] [[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/CancelOrder.md b/docs/CancelOrder.md index bd7bb48..40c482e 100644 --- a/docs/CancelOrder.md +++ b/docs/CancelOrder.md @@ -1,5 +1,6 @@ # CancelOrder +Info of order to be cancelled ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/CancelOrderResult.md b/docs/CancelOrderResult.md index 3ebaa54..7a0d514 100644 --- a/docs/CancelOrderResult.md +++ b/docs/CancelOrderResult.md @@ -1,5 +1,6 @@ # CancelOrderResult +Order cancellation result ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/Contract.md b/docs/Contract.md index 9ee2f6a..207b653 100644 --- a/docs/Contract.md +++ b/docs/Contract.md @@ -1,5 +1,6 @@ # Contract +Futures contract details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/CurrencyPair.md b/docs/CurrencyPair.md index 40bf7a0..58dd3e0 100644 --- a/docs/CurrencyPair.md +++ b/docs/CurrencyPair.md @@ -1,5 +1,6 @@ # CurrencyPair +Spot currency pair ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/DeliveryApi.md b/docs/DeliveryApi.md index c28f7e9..5c1d34c 100644 --- a/docs/DeliveryApi.md +++ b/docs/DeliveryApi.md @@ -4,63 +4,64 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- -[**cancel_delivery_order**](DeliveryApi.md#cancel_delivery_order) | **DELETE** /delivery/{settle}/orders/{order_id} | Cancel a single order -[**cancel_delivery_orders**](DeliveryApi.md#cancel_delivery_orders) | **DELETE** /delivery/{settle}/orders | Cancel all `open` orders matched -[**cancel_price_triggered_delivery_order**](DeliveryApi.md#cancel_price_triggered_delivery_order) | **DELETE** /delivery/{settle}/price_orders/{order_id} | Cancel a single order -[**cancel_price_triggered_delivery_order_list**](DeliveryApi.md#cancel_price_triggered_delivery_order_list) | **DELETE** /delivery/{settle}/price_orders | Cancel all open orders -[**create_delivery_order**](DeliveryApi.md#create_delivery_order) | **POST** /delivery/{settle}/orders | Create a futures order -[**create_price_triggered_delivery_order**](DeliveryApi.md#create_price_triggered_delivery_order) | **POST** /delivery/{settle}/price_orders | Create a price-triggered order +[**list_delivery_contracts**](DeliveryApi.md#list_delivery_contracts) | **GET** /delivery/{settle}/contracts | List all futures contracts [**get_delivery_contract**](DeliveryApi.md#get_delivery_contract) | **GET** /delivery/{settle}/contracts/{contract} | Get a single contract -[**get_delivery_order**](DeliveryApi.md#get_delivery_order) | **GET** /delivery/{settle}/orders/{order_id} | Get a single order -[**get_delivery_position**](DeliveryApi.md#get_delivery_position) | **GET** /delivery/{settle}/positions/{contract} | Get single position -[**get_my_delivery_trades**](DeliveryApi.md#get_my_delivery_trades) | **GET** /delivery/{settle}/my_trades | List personal trading history -[**get_price_triggered_delivery_order**](DeliveryApi.md#get_price_triggered_delivery_order) | **GET** /delivery/{settle}/price_orders/{order_id} | Get a single order -[**list_delivery_account_book**](DeliveryApi.md#list_delivery_account_book) | **GET** /delivery/{settle}/account_book | Query account book -[**list_delivery_accounts**](DeliveryApi.md#list_delivery_accounts) | **GET** /delivery/{settle}/accounts | Query futures account +[**list_delivery_order_book**](DeliveryApi.md#list_delivery_order_book) | **GET** /delivery/{settle}/order_book | Futures order book +[**list_delivery_trades**](DeliveryApi.md#list_delivery_trades) | **GET** /delivery/{settle}/trades | Futures trading history [**list_delivery_candlesticks**](DeliveryApi.md#list_delivery_candlesticks) | **GET** /delivery/{settle}/candlesticks | Get futures candlesticks -[**list_delivery_contracts**](DeliveryApi.md#list_delivery_contracts) | **GET** /delivery/{settle}/contracts | List all futures contracts +[**list_delivery_tickers**](DeliveryApi.md#list_delivery_tickers) | **GET** /delivery/{settle}/tickers | List futures tickers [**list_delivery_insurance_ledger**](DeliveryApi.md#list_delivery_insurance_ledger) | **GET** /delivery/{settle}/insurance | Futures insurance balance history -[**list_delivery_liquidates**](DeliveryApi.md#list_delivery_liquidates) | **GET** /delivery/{settle}/liquidates | List liquidation history -[**list_delivery_order_book**](DeliveryApi.md#list_delivery_order_book) | **GET** /delivery/{settle}/order_book | Futures order book +[**list_delivery_accounts**](DeliveryApi.md#list_delivery_accounts) | **GET** /delivery/{settle}/accounts | Query futures account +[**list_delivery_account_book**](DeliveryApi.md#list_delivery_account_book) | **GET** /delivery/{settle}/account_book | Query account book +[**list_delivery_positions**](DeliveryApi.md#list_delivery_positions) | **GET** /delivery/{settle}/positions | List all positions of a user +[**get_delivery_position**](DeliveryApi.md#get_delivery_position) | **GET** /delivery/{settle}/positions/{contract} | Get single position +[**update_delivery_position_margin**](DeliveryApi.md#update_delivery_position_margin) | **POST** /delivery/{settle}/positions/{contract}/margin | Update position margin +[**update_delivery_position_leverage**](DeliveryApi.md#update_delivery_position_leverage) | **POST** /delivery/{settle}/positions/{contract}/leverage | Update position leverage +[**update_delivery_position_risk_limit**](DeliveryApi.md#update_delivery_position_risk_limit) | **POST** /delivery/{settle}/positions/{contract}/risk_limit | Update position risk limit [**list_delivery_orders**](DeliveryApi.md#list_delivery_orders) | **GET** /delivery/{settle}/orders | List futures orders +[**create_delivery_order**](DeliveryApi.md#create_delivery_order) | **POST** /delivery/{settle}/orders | Create a futures order +[**cancel_delivery_orders**](DeliveryApi.md#cancel_delivery_orders) | **DELETE** /delivery/{settle}/orders | Cancel all `open` orders matched +[**get_delivery_order**](DeliveryApi.md#get_delivery_order) | **GET** /delivery/{settle}/orders/{order_id} | Get a single order +[**cancel_delivery_order**](DeliveryApi.md#cancel_delivery_order) | **DELETE** /delivery/{settle}/orders/{order_id} | Cancel a single order +[**get_my_delivery_trades**](DeliveryApi.md#get_my_delivery_trades) | **GET** /delivery/{settle}/my_trades | List personal trading history [**list_delivery_position_close**](DeliveryApi.md#list_delivery_position_close) | **GET** /delivery/{settle}/position_close | List position close history -[**list_delivery_positions**](DeliveryApi.md#list_delivery_positions) | **GET** /delivery/{settle}/positions | List all positions of a user +[**list_delivery_liquidates**](DeliveryApi.md#list_delivery_liquidates) | **GET** /delivery/{settle}/liquidates | List liquidation history [**list_delivery_settlements**](DeliveryApi.md#list_delivery_settlements) | **GET** /delivery/{settle}/settlements | List settlement history -[**list_delivery_tickers**](DeliveryApi.md#list_delivery_tickers) | **GET** /delivery/{settle}/tickers | List futures tickers -[**list_delivery_trades**](DeliveryApi.md#list_delivery_trades) | **GET** /delivery/{settle}/trades | Futures trading history [**list_price_triggered_delivery_orders**](DeliveryApi.md#list_price_triggered_delivery_orders) | **GET** /delivery/{settle}/price_orders | List all auto orders -[**update_delivery_position_leverage**](DeliveryApi.md#update_delivery_position_leverage) | **POST** /delivery/{settle}/positions/{contract}/leverage | Update position leverage -[**update_delivery_position_margin**](DeliveryApi.md#update_delivery_position_margin) | **POST** /delivery/{settle}/positions/{contract}/margin | Update position margin -[**update_delivery_position_risk_limit**](DeliveryApi.md#update_delivery_position_risk_limit) | **POST** /delivery/{settle}/positions/{contract}/risk_limit | Update position risk limit +[**create_price_triggered_delivery_order**](DeliveryApi.md#create_price_triggered_delivery_order) | **POST** /delivery/{settle}/price_orders | Create a price-triggered order +[**cancel_price_triggered_delivery_order_list**](DeliveryApi.md#cancel_price_triggered_delivery_order_list) | **DELETE** /delivery/{settle}/price_orders | Cancel all open orders +[**get_price_triggered_delivery_order**](DeliveryApi.md#get_price_triggered_delivery_order) | **GET** /delivery/{settle}/price_orders/{order_id} | Get a single order +[**cancel_price_triggered_delivery_order**](DeliveryApi.md#cancel_price_triggered_delivery_order) | **DELETE** /delivery/{settle}/price_orders/{order_id} | Cancel a single order -# **cancel_delivery_order** -> FuturesOrder cancel_delivery_order(settle, order_id) +# **list_delivery_contracts** +> list[DeliveryContract] list_delivery_contracts(settle) -Cancel a single order +List all futures contracts ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -order_id = '12345' # str | ID returned on order successfully being created try: - # Cancel a single order - api_response = api_instance.cancel_delivery_order(settle, order_id) + # List all futures contracts + api_response = api_instance.list_delivery_contracts(settle) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->cancel_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e) ``` ### Parameters @@ -68,53 +69,56 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**FuturesOrder**](FuturesOrder.md) +[**list[DeliveryContract]**](DeliveryContract.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | -# **cancel_delivery_orders** -> list[FuturesOrder] cancel_delivery_orders(settle, contract, side=side) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Cancel all `open` orders matched +# **get_delivery_contract** +> DeliveryContract get_delivery_contract(settle, contract) -Zero-fill order cannot be retrieved 60 seconds after cancellation +Get a single contract ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -side = 'ask' # str | All bids or asks. Both included in not specified (optional) +contract = 'BTC_USDT_20200814' # str | Futures contract try: - # Cancel all `open` orders matched - api_response = api_instance.cancel_delivery_orders(settle, contract, side=side) + # Get a single contract + api_response = api_instance.get_delivery_contract(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->cancel_delivery_orders: %s\n" % e) + print("Exception when calling DeliveryApi->get_delivery_contract: %s\n" % e) ``` ### Parameters @@ -123,50 +127,60 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | **contract** | **str**| Futures contract | - **side** | **str**| All bids or asks. Both included in not specified | [optional] ### Return type -[**list[FuturesOrder]**](FuturesOrder.md) +[**DeliveryContract**](DeliveryContract.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Contract information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_price_triggered_delivery_order** -> FuturesPriceTriggeredOrder cancel_price_triggered_delivery_order(settle, order_id) +# **list_delivery_order_book** +> FuturesOrderBook list_delivery_order_book(settle, contract, interval=interval, limit=limit) -Cancel a single order +Futures order book + +Bids will be sorted by price from high to low, while asks sorted reversely ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -order_id = 'order_id_example' # str | ID returned on order successfully being created +contract = 'BTC_USDT_20200814' # str | Futures contract +interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') +limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) try: - # Cancel a single order - api_response = api_instance.cancel_price_triggered_delivery_order(settle, order_id) + # Futures order book + api_response = api_instance.list_delivery_order_book(settle, contract, interval=interval, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_order_book: %s\n" % e) ``` ### Parameters @@ -174,50 +188,63 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **order_id** | **str**| ID returned on order successfully being created | + **contract** | **str**| Futures contract | + **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] + **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] ### Return type -[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) +[**FuturesOrderBook**](FuturesOrderBook.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order book retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_price_triggered_delivery_order_list** -> list[FuturesPriceTriggeredOrder] cancel_price_triggered_delivery_order_list(settle, contract) +# **list_delivery_trades** +> list[FuturesTrade] list_delivery_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) -Cancel all open orders +Futures trading history ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USD' # str | Futures contract +contract = 'BTC_USDT_20200814' # str | Futures contract +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +last_id = '12345' # str | Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range (optional) +_from = 1546905600 # float | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. (optional) +to = 1546935600 # float | Specify end time in Unix seconds, default to current time (optional) try: - # Cancel all open orders - api_response = api_instance.cancel_price_triggered_delivery_order_list(settle, contract) + # 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 ApiException as e: - print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order_list: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_trades: %s\n" % e) ``` ### Parameters @@ -226,51 +253,66 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | **contract** | **str**| Futures contract | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **last_id** | **str**| Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range | [optional] + **_from** | **float**| Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. | [optional] + **to** | **float**| Specify end time in Unix seconds, default to current time | [optional] ### Return type -[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) +[**list[FuturesTrade]**](FuturesTrade.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_delivery_order** -> FuturesOrder create_delivery_order(settle, futures_order) +# **list_delivery_candlesticks** +> list[FuturesCandlestick] list_delivery_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) -Create a futures order +Get futures candlesticks -Zero-fill order cannot be retrieved 60 seconds after cancellation +Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -futures_order = gate_api.FuturesOrder() # FuturesOrder | +contract = 'BTC_USDT_20200814' # str | Futures contract +_from = 1546905600 # float | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) +to = 1546935600 # float | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) +limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) +interval = '5m' # str | Interval time between data points (optional) (default to '5m') try: - # Create a futures order - api_response = api_instance.create_delivery_order(settle, futures_order) + # Get futures candlesticks + api_response = api_instance.list_delivery_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->create_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_candlesticks: %s\n" % e) ``` ### Parameters @@ -278,50 +320,61 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **futures_order** | [**FuturesOrder**](FuturesOrder.md)| | + **contract** | **str**| Futures contract | + **_from** | **float**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] + **to** | **float**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] + **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] + **interval** | **str**| Interval time between data points | [optional] [default to '5m'] ### Return type -[**FuturesOrder**](FuturesOrder.md) +[**list[FuturesCandlestick]**](FuturesCandlestick.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_price_triggered_delivery_order** -> TriggerOrderResponse create_price_triggered_delivery_order(settle, futures_price_triggered_order) +# **list_delivery_tickers** +> list[FuturesTicker] list_delivery_tickers(settle, contract=contract) -Create a price-triggered order +List futures tickers ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -futures_price_triggered_order = gate_api.FuturesPriceTriggeredOrder() # FuturesPriceTriggeredOrder | +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) try: - # Create a price-triggered order - api_response = api_instance.create_price_triggered_delivery_order(settle, futures_price_triggered_order) + # List futures tickers + api_response = api_instance.list_delivery_tickers(settle, contract=contract) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->create_price_triggered_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_tickers: %s\n" % e) ``` ### Parameters @@ -329,46 +382,57 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **futures_price_triggered_order** | [**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md)| | + **contract** | **str**| Futures contract | [optional] ### Return type -[**TriggerOrderResponse**](TriggerOrderResponse.md) +[**list[FuturesTicker]**](FuturesTicker.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_delivery_contract** -> DeliveryContract get_delivery_contract(settle, contract) +# **list_delivery_insurance_ledger** +> list[InsuranceRecord] list_delivery_insurance_ledger(settle, limit=limit) -Get a single contract +Futures insurance balance history ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) try: - # Get a single contract - api_response = api_instance.get_delivery_contract(settle, contract) + # Futures insurance balance history + api_response = api_instance.list_delivery_insurance_ledger(settle, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->get_delivery_contract: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_insurance_ledger: %s\n" % e) ``` ### Parameters @@ -376,11 +440,11 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] ### Return type -[**DeliveryContract**](DeliveryContract.md) +[**list[InsuranceRecord]**](InsuranceRecord.md) ### Authorization @@ -391,37 +455,50 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | -# **get_delivery_order** -> FuturesOrder get_delivery_order(settle, order_id) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Get a single order +# **list_delivery_accounts** +> FuturesAccount list_delivery_accounts(settle) -Zero-fill order cannot be retrieved 60 seconds after cancellation +Query futures account ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -order_id = '12345' # str | ID returned on order successfully being created try: - # Get a single order - api_response = api_instance.get_delivery_order(settle, order_id) + # Query futures account + api_response = api_instance.list_delivery_accounts(settle) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->get_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_accounts: %s\n" % e) ``` ### Parameters @@ -429,50 +506,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**FuturesOrder**](FuturesOrder.md) +[**FuturesAccount**](FuturesAccount.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_delivery_position** -> Position get_delivery_position(settle, contract) +# **list_delivery_account_book** +> list[FuturesAccountBook] list_delivery_account_book(settle, limit=limit, _from=_from, to=to, type=type) -Get single position +Query account book ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +_from = 1547706332 # int | Start timestamp (optional) +to = 1547706332 # int | End timestamp (optional) +type = 'dnw' # str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate (optional) try: - # Get single position - api_response = api_instance.get_delivery_position(settle, contract) + # Query account book + api_response = api_instance.list_delivery_account_book(settle, limit=limit, _from=_from, to=to, type=type) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->get_delivery_position: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_account_book: %s\n" % e) ``` ### Parameters @@ -480,55 +575,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **_from** | **int**| Start timestamp | [optional] + **to** | **int**| End timestamp | [optional] + **type** | **str**| Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate | [optional] ### Return type -[**Position**](Position.md) +[**list[FuturesAccountBook]**](FuturesAccountBook.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_my_delivery_trades** -> list[MyFuturesTrade] get_my_delivery_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) +# **list_delivery_positions** +> list[Position] list_delivery_positions(settle) -List personal trading history +List all positions of a user ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) -order = 12345 # int | Futures order ID, return related data only if specified (optional) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -offset = 0 # int | List offset, starting from 0 (optional) (default to 0) -last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) -count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) 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) + # List all positions of a user + api_response = api_instance.list_delivery_positions(settle) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->get_my_delivery_trades: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_positions: %s\n" % e) ``` ### Parameters @@ -536,55 +644,65 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | [optional] - **order** | **int**| Futures order ID, return related data only if specified | [optional] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] - **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] - **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] ### Return type -[**list[MyFuturesTrade]**](MyFuturesTrade.md) +[**list[Position]**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_price_triggered_delivery_order** -> FuturesPriceTriggeredOrder get_price_triggered_delivery_order(settle, order_id) +# **get_delivery_position** +> Position get_delivery_position(settle, contract) -Get a single order +Get single position ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -order_id = 'order_id_example' # str | ID returned on order successfully being created +contract = 'BTC_USDT_20200814' # str | Futures contract try: - # Get a single order - api_response = api_instance.get_price_triggered_delivery_order(settle, order_id) + # Get single position + api_response = api_instance.get_delivery_position(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->get_price_triggered_delivery_order: %s\n" % e) + print("Exception when calling DeliveryApi->get_delivery_position: %s\n" % e) ``` ### Parameters @@ -592,53 +710,67 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **order_id** | **str**| ID returned on order successfully being created | + **contract** | **str**| Futures contract | ### Return type -[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) +[**Position**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_account_book** -> list[FuturesAccountBook] list_delivery_account_book(settle, limit=limit, _from=_from, to=to, type=type) +# **update_delivery_position_margin** +> Position update_delivery_position_margin(settle, contract, change) -Query account book +Update position margin ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -_from = 1547706332 # int | Start timestamp (optional) -to = 1547706332 # int | End timestamp (optional) -type = 'dnw' # str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate (optional) +contract = 'BTC_USDT_20200814' # str | Futures contract +change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise. try: - # Query account book - api_response = api_instance.list_delivery_account_book(settle, limit=limit, _from=_from, to=to, type=type) + # Update position margin + api_response = api_instance.update_delivery_position_margin(settle, contract, change) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_account_book: %s\n" % e) + print("Exception when calling DeliveryApi->update_delivery_position_margin: %s\n" % e) ``` ### Parameters @@ -646,52 +778,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **_from** | **int**| Start timestamp | [optional] - **to** | **int**| End timestamp | [optional] - **type** | **str**| Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate | [optional] + **contract** | **str**| Futures contract | + **change** | **str**| Margin change. Use positive number to increase margin, negative number otherwise. | ### Return type -[**list[FuturesAccountBook]**](FuturesAccountBook.md) +[**Position**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_accounts** -> FuturesAccount list_delivery_accounts(settle) +# **update_delivery_position_leverage** +> Position update_delivery_position_leverage(settle, contract, leverage) -Query futures account +Update position leverage ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency +contract = 'BTC_USDT_20200814' # str | Futures contract +leverage = '10' # str | New position leverage try: - # Query futures account - api_response = api_instance.list_delivery_accounts(settle) + # Update position leverage + api_response = api_instance.update_delivery_position_leverage(settle, contract, leverage) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_accounts: %s\n" % e) + print("Exception when calling DeliveryApi->update_delivery_position_leverage: %s\n" % e) ``` ### Parameters @@ -699,51 +847,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | + **contract** | **str**| Futures contract | + **leverage** | **str**| New position leverage | ### Return type -[**FuturesAccount**](FuturesAccount.md) +[**Position**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | -# **list_delivery_candlesticks** -> list[FuturesCandlestick] list_delivery_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Get futures candlesticks +# **update_delivery_position_risk_limit** +> Position update_delivery_position_risk_limit(settle, contract, risk_limit) -Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` +Update position risk limit ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -_from = 1546905600 # float | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) -to = 1546935600 # float | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) -limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) -interval = '5m' # str | Interval time between data points (optional) (default to '5m') +contract = 'BTC_USDT_20200814' # str | Futures contract +risk_limit = '10' # str | New position risk limit try: - # Get futures candlesticks - api_response = api_instance.list_delivery_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) + # Update position risk limit + api_response = api_instance.update_delivery_position_risk_limit(settle, contract, risk_limit) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_candlesticks: %s\n" % e) + print("Exception when calling DeliveryApi->update_delivery_position_risk_limit: %s\n" % e) ``` ### Parameters @@ -752,48 +917,73 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | **contract** | **str**| Futures contract | - **_from** | **float**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] - **to** | **float**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] - **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] - **interval** | **str**| Interval time between data points | [optional] [default to '5m'] + **risk_limit** | **str**| New position risk limit | ### Return type -[**list[FuturesCandlestick]**](FuturesCandlestick.md) +[**Position**](Position.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_contracts** -> list[DeliveryContract] list_delivery_contracts(settle) +# **list_delivery_orders** +> list[FuturesOrder] list_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset, last_id=last_id, count_total=count_total) -List all futures contracts +List futures orders + +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency +status = 'open' # str | List orders based on status +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +offset = 0 # int | List offset, starting from 0 (optional) (default to 0) +last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) +count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) try: - # List all futures contracts - api_response = api_instance.list_delivery_contracts(settle) + # 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 ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_contracts: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_orders: %s\n" % e) ``` ### Parameters @@ -801,45 +991,73 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | + **status** | **str**| List orders based on status | + **contract** | **str**| Futures contract | [optional] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] + **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] + **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] ### Return type -[**list[DeliveryContract]**](DeliveryContract.md) +[**list[FuturesOrder]**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | * X-Pagination-Limit - Request limit specified
* X-Pagination-Offset - Request offset specified
* X-Pagination-Total - Total number matched. Only returned on `count_total` set to 1
| + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_insurance_ledger** -> list[InsuranceRecord] list_delivery_insurance_ledger(settle, limit=limit) +# **create_delivery_order** +> FuturesOrder create_delivery_order(settle, futures_order) -Futures insurance balance history +Create a futures order + +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +futures_order = gate_api.FuturesOrder() # FuturesOrder | try: - # Futures insurance balance history - api_response = api_instance.list_delivery_insurance_ledger(settle, limit=limit) + # Create a futures order + api_response = api_instance.create_delivery_order(settle, futures_order) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_insurance_ledger: %s\n" % e) + print("Exception when calling DeliveryApi->create_delivery_order: %s\n" % e) ``` ### Parameters @@ -847,52 +1065,139 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **futures_order** | [**FuturesOrder**](FuturesOrder.md)| | ### Return type -[**list[InsuranceRecord]**](InsuranceRecord.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Order details | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_liquidates** -> list[FuturesLiquidate] list_delivery_liquidates(settle, contract=contract, limit=limit, at=at) +# **cancel_delivery_orders** +> list[FuturesOrder] cancel_delivery_orders(settle, contract, side=side) -List liquidation history +Cancel all `open` orders matched + +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) +settle = 'usdt' # str | Settle currency +contract = 'BTC_USDT_20200814' # str | Futures contract +side = 'ask' # str | All bids or asks. Both included in not specified (optional) -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' +try: + # Cancel all `open` orders matched + api_response = api_instance.cancel_delivery_orders(settle, contract, side=side) + print(api_response) +except ApiException as e: + print("Exception when calling DeliveryApi->cancel_delivery_orders: %s\n" % e) +``` -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) -settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -at = 0 # int | Specify a liquidation timestamp (optional) (default to 0) +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **settle** | **str**| Settle currency | + **contract** | **str**| Futures contract | + **side** | **str**| All bids or asks. Both included in not specified | [optional] + +### Return type + +[**list[FuturesOrder]**](FuturesOrder.md) + +### Authorization + +[apiv4](../README.md#apiv4) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | All orders matched cancelled | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_delivery_order** +> FuturesOrder get_delivery_order(settle, order_id) + +Get a single order + +Zero-fill order cannot be retrieved 60 seconds after cancellation + +### Example + +* Api Key Authentication (apiv4): +```python +from __future__ import print_function +import gate_api +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) +settle = 'usdt' # str | Settle currency +order_id = '12345' # str | ID returned on order successfully being created try: - # List liquidation history - api_response = api_instance.list_delivery_liquidates(settle, contract=contract, limit=limit, at=at) + # Get a single order + api_response = api_instance.get_delivery_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_liquidates: %s\n" % e) + print("Exception when calling DeliveryApi->get_delivery_order: %s\n" % e) ``` ### Parameters @@ -900,52 +1205,66 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | [optional] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **at** | **int**| Specify a liquidation timestamp | [optional] [default to 0] + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**list[FuturesLiquidate]**](FuturesLiquidate.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order details | - | -# **list_delivery_order_book** -> FuturesOrderBook list_delivery_order_book(settle, contract, interval=interval, limit=limit) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Futures order book +# **cancel_delivery_order** +> FuturesOrder cancel_delivery_order(settle, order_id) -Bids will be sorted by price from high to low, while asks sorted reversely +Cancel a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') -limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) +order_id = '12345' # str | ID returned on order successfully being created try: - # Futures order book - api_response = api_instance.list_delivery_order_book(settle, contract, interval=interval, limit=limit) + # Cancel a single order + api_response = api_instance.cancel_delivery_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_order_book: %s\n" % e) + print("Exception when calling DeliveryApi->cancel_delivery_order: %s\n" % e) ``` ### Parameters @@ -953,59 +1272,71 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | - **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] - **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**FuturesOrderBook**](FuturesOrderBook.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order details | - | -# **list_delivery_orders** -> list[FuturesOrder] list_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset, last_id=last_id, count_total=count_total) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -List futures orders +# **get_my_delivery_trades** +> list[MyFuturesTrade] get_my_delivery_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) -Zero-fill order cannot be retrieved 60 seconds after cancellation +List personal trading history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -status = 'open' # str | List orders based on status -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) +order = 12345 # int | Futures order ID, return related data only if specified (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) offset = 0 # int | List offset, starting from 0 (optional) (default to 0) last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) 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) + # 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 ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_orders: %s\n" % e) + print("Exception when calling DeliveryApi->get_my_delivery_trades: %s\n" % e) ``` ### Parameters @@ -1013,8 +1344,8 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **status** | **str**| List orders based on status | **contract** | **str**| Futures contract | [optional] + **order** | **int**| Futures order ID, return related data only if specified | [optional] **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] @@ -1022,17 +1353,22 @@ Name | Type | Description | Notes ### Return type -[**list[FuturesOrder]**](FuturesOrder.md) +[**list[MyFuturesTrade]**](MyFuturesTrade.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | * X-Pagination-Limit - Request limit specified
* X-Pagination-Offset - Request offset specified
* X-Pagination-Total - Total number matched. Only returned on `count_total` set to 1
| + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **list_delivery_position_close** @@ -1042,19 +1378,30 @@ List position close history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) try: @@ -1079,41 +1426,60 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_positions** -> list[Position] list_delivery_positions(settle) +# **list_delivery_liquidates** +> list[FuturesLiquidate] list_delivery_liquidates(settle, contract=contract, limit=limit, at=at) -List all positions of a user +List liquidation history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +at = 0 # int | Specify a liquidation timestamp (optional) (default to 0) try: - # List all positions of a user - api_response = api_instance.list_delivery_positions(settle) + # List liquidation history + api_response = api_instance.list_delivery_liquidates(settle, contract=contract, limit=limit, at=at) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_positions: %s\n" % e) + print("Exception when calling DeliveryApi->list_delivery_liquidates: %s\n" % e) ``` ### Parameters @@ -1121,20 +1487,28 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | + **contract** | **str**| Futures contract | [optional] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **at** | **int**| Specify a liquidation timestamp | [optional] [default to 0] ### Return type -[**list[Position]**](Position.md) +[**list[FuturesLiquidate]**](FuturesLiquidate.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **list_delivery_settlements** @@ -1144,19 +1518,30 @@ List settlement history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) +contract = 'BTC_USDT_20200814' # str | Futures contract (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) at = 0 # int | Specify a settlement timestamp (optional) (default to 0) @@ -1183,89 +1568,61 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **list_delivery_tickers** -> list[FuturesTicker] list_delivery_tickers(settle, contract=contract) - -List futures tickers - -### Example - -```python -from __future__ import print_function -import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() -settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract (optional) - -try: - # List futures tickers - api_response = api_instance.list_delivery_tickers(settle, contract=contract) - print(api_response) -except ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_tickers: %s\n" % e) -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | [optional] - -### Return type - -[**list[FuturesTicker]**](FuturesTicker.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_delivery_trades** -> list[FuturesTrade] list_delivery_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) +# **list_price_triggered_delivery_orders** +> list[FuturesPriceTriggeredOrder] list_price_triggered_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset) -Futures trading history +List all auto orders ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.DeliveryApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract +status = 'status_example' # str | List orders based on status +contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -last_id = '12345' # str | Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range (optional) -_from = 1546905600 # float | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. (optional) -to = 1546935600 # float | Specify end time in Unix seconds, default to current time (optional) +offset = 0 # int | List offset, starting from 0 (optional) (default to 0) try: - # Futures trading history - api_response = api_instance.list_delivery_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) + # 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 ApiException as e: - print("Exception when calling DeliveryApi->list_delivery_trades: %s\n" % e) + print("Exception when calling DeliveryApi->list_price_triggered_delivery_orders: %s\n" % e) ``` ### Parameters @@ -1273,57 +1630,69 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | + **status** | **str**| List orders based on status | + **contract** | **str**| Futures contract, return related data only if specified | [optional] **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **last_id** | **str**| Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range | [optional] - **_from** | **float**| Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. | [optional] - **to** | **float**| Specify end time in Unix seconds, default to current time | [optional] + **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] ### Return type -[**list[FuturesTrade]**](FuturesTrade.md) +[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_price_triggered_delivery_orders** -> list[FuturesPriceTriggeredOrder] list_price_triggered_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset) +# **create_price_triggered_delivery_order** +> TriggerOrderResponse create_price_triggered_delivery_order(settle, futures_price_triggered_order) -List all auto orders +Create a price-triggered order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -status = 'status_example' # str | List orders based on status -contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -offset = 0 # int | List offset, starting from 0 (optional) (default to 0) +futures_price_triggered_order = gate_api.FuturesPriceTriggeredOrder() # FuturesPriceTriggeredOrder | try: - # List all auto orders - api_response = api_instance.list_price_triggered_delivery_orders(settle, status, contract=contract, limit=limit, offset=offset) + # Create a price-triggered order + api_response = api_instance.create_price_triggered_delivery_order(settle, futures_price_triggered_order) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->list_price_triggered_delivery_orders: %s\n" % e) + print("Exception when calling DeliveryApi->create_price_triggered_delivery_order: %s\n" % e) ``` ### Parameters @@ -1331,54 +1700,66 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **status** | **str**| List orders based on status | - **contract** | **str**| Futures contract, return related data only if specified | [optional] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] + **futures_price_triggered_order** | [**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md)| | ### Return type -[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) +[**TriggerOrderResponse**](TriggerOrderResponse.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Order created | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_delivery_position_leverage** -> Position update_delivery_position_leverage(settle, contract, leverage) +# **cancel_price_triggered_delivery_order_list** +> list[FuturesPriceTriggeredOrder] cancel_price_triggered_delivery_order_list(settle, contract) -Update position leverage +Cancel all open orders ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -leverage = '10' # str | New position leverage +contract = 'BTC_USD' # str | Futures contract try: - # Update position leverage - api_response = api_instance.update_delivery_position_leverage(settle, contract, leverage) + # Cancel all open orders + api_response = api_instance.cancel_price_triggered_delivery_order_list(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->update_delivery_position_leverage: %s\n" % e) + print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order_list: %s\n" % e) ``` ### Parameters @@ -1387,51 +1768,65 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | **contract** | **str**| Futures contract | - **leverage** | **str**| New position leverage | ### Return type -[**Position**](Position.md) +[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Batch cancellation request accepted. Query order status by listing orders | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_delivery_position_margin** -> Position update_delivery_position_margin(settle, contract, change) +# **get_price_triggered_delivery_order** +> FuturesPriceTriggeredOrder get_price_triggered_delivery_order(settle, order_id) -Update position margin +Get a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise. +order_id = 'order_id_example' # str | ID returned on order successfully being created try: - # Update position margin - api_response = api_instance.update_delivery_position_margin(settle, contract, change) + # Get a single order + api_response = api_instance.get_price_triggered_delivery_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->update_delivery_position_margin: %s\n" % e) + print("Exception when calling DeliveryApi->get_price_triggered_delivery_order: %s\n" % e) ``` ### Parameters @@ -1439,52 +1834,66 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | - **change** | **str**| Margin change. Use positive number to increase margin, negative number otherwise. | + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**Position**](Position.md) +[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Auto order detail | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_delivery_position_risk_limit** -> Position update_delivery_position_risk_limit(settle, contract, risk_limit) +# **cancel_price_triggered_delivery_order** +> FuturesPriceTriggeredOrder cancel_price_triggered_delivery_order(settle, order_id) -Update position risk limit +Cancel a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.DeliveryApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.DeliveryApi(api_client) settle = 'usdt' # str | Settle currency -contract = 'BTC_USDT_WEEKLY_20200703' # str | Futures contract -risk_limit = '10' # str | New position risk limit +order_id = 'order_id_example' # str | ID returned on order successfully being created try: - # Update position risk limit - api_response = api_instance.update_delivery_position_risk_limit(settle, contract, risk_limit) + # Cancel a single order + api_response = api_instance.cancel_price_triggered_delivery_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling DeliveryApi->update_delivery_position_risk_limit: %s\n" % e) + print("Exception when calling DeliveryApi->cancel_price_triggered_delivery_order: %s\n" % e) ``` ### Parameters @@ -1492,21 +1901,25 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | - **contract** | **str**| Futures contract | - **risk_limit** | **str**| New position risk limit | + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**Position**](Position.md) +[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Auto order detail | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/DeliveryContract.md b/docs/DeliveryContract.md index 15b709d..9568e5d 100644 --- a/docs/DeliveryContract.md +++ b/docs/DeliveryContract.md @@ -1,10 +1,11 @@ # DeliveryContract +Futures contract details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **name** | **str** | Futures contract | [optional] -**underling** | **str** | Underlying | [optional] +**underlying** | **str** | Underlying | [optional] **cycle** | **str** | Cycle type, e.g. WEEKLY, QUARTERLY | [optional] **type** | **str** | Futures contract type | [optional] **quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional] diff --git a/docs/DeliverySettlement.md b/docs/DeliverySettlement.md index 7b04e20..06a479a 100644 --- a/docs/DeliverySettlement.md +++ b/docs/DeliverySettlement.md @@ -3,15 +3,15 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**time** | **int** | Liquidation time | [optional] -**contract** | **str** | Futures contract | [optional] -**leverage** | **str** | Position leverage | [optional] -**size** | **int** | Position size | [optional] -**margin** | **str** | Position margin | [optional] -**entry_price** | **str** | Average entry price | [optional] -**settle_price** | **str** | Settled price | [optional] -**profit** | **str** | Profit | [optional] -**fee** | **str** | Fee deducted | [optional] +**time** | **int** | Liquidation time | [optional] [readonly] +**contract** | **str** | Futures contract | [optional] [readonly] +**leverage** | **str** | Position leverage | [optional] [readonly] +**size** | **int** | Position size | [optional] [readonly] +**margin** | **str** | Position margin | [optional] [readonly] +**entry_price** | **str** | Average entry price | [optional] [readonly] +**settle_price** | **str** | Settled price | [optional] [readonly] +**profit** | **str** | Profit | [optional] [readonly] +**fee** | **str** | Fee deducted | [optional] [readonly] [[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/FuturesApi.md b/docs/FuturesApi.md index adb8ee6..224a44d 100644 --- a/docs/FuturesApi.md +++ b/docs/FuturesApi.md @@ -4,63 +4,64 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- -[**cancel_futures_order**](FuturesApi.md#cancel_futures_order) | **DELETE** /futures/{settle}/orders/{order_id} | Cancel a single order -[**cancel_futures_orders**](FuturesApi.md#cancel_futures_orders) | **DELETE** /futures/{settle}/orders | Cancel all `open` orders matched -[**cancel_price_triggered_order**](FuturesApi.md#cancel_price_triggered_order) | **DELETE** /futures/{settle}/price_orders/{order_id} | Cancel a single order -[**cancel_price_triggered_order_list**](FuturesApi.md#cancel_price_triggered_order_list) | **DELETE** /futures/{settle}/price_orders | Cancel all open orders -[**create_futures_order**](FuturesApi.md#create_futures_order) | **POST** /futures/{settle}/orders | Create a futures order -[**create_price_triggered_order**](FuturesApi.md#create_price_triggered_order) | **POST** /futures/{settle}/price_orders | Create a price-triggered order +[**list_futures_contracts**](FuturesApi.md#list_futures_contracts) | **GET** /futures/{settle}/contracts | List all futures contracts [**get_futures_contract**](FuturesApi.md#get_futures_contract) | **GET** /futures/{settle}/contracts/{contract} | Get a single contract -[**get_futures_order**](FuturesApi.md#get_futures_order) | **GET** /futures/{settle}/orders/{order_id} | Get a single order -[**get_my_trades**](FuturesApi.md#get_my_trades) | **GET** /futures/{settle}/my_trades | List personal trading history -[**get_position**](FuturesApi.md#get_position) | **GET** /futures/{settle}/positions/{contract} | Get single position -[**get_price_triggered_order**](FuturesApi.md#get_price_triggered_order) | **GET** /futures/{settle}/price_orders/{order_id} | Get a single order -[**list_futures_account_book**](FuturesApi.md#list_futures_account_book) | **GET** /futures/{settle}/account_book | Query account book -[**list_futures_accounts**](FuturesApi.md#list_futures_accounts) | **GET** /futures/{settle}/accounts | Query futures account +[**list_futures_order_book**](FuturesApi.md#list_futures_order_book) | **GET** /futures/{settle}/order_book | Futures order book +[**list_futures_trades**](FuturesApi.md#list_futures_trades) | **GET** /futures/{settle}/trades | Futures trading history [**list_futures_candlesticks**](FuturesApi.md#list_futures_candlesticks) | **GET** /futures/{settle}/candlesticks | Get futures candlesticks -[**list_futures_contracts**](FuturesApi.md#list_futures_contracts) | **GET** /futures/{settle}/contracts | List all futures contracts +[**list_futures_tickers**](FuturesApi.md#list_futures_tickers) | **GET** /futures/{settle}/tickers | List futures tickers [**list_futures_funding_rate_history**](FuturesApi.md#list_futures_funding_rate_history) | **GET** /futures/{settle}/funding_rate | Funding rate history [**list_futures_insurance_ledger**](FuturesApi.md#list_futures_insurance_ledger) | **GET** /futures/{settle}/insurance | Futures insurance balance history -[**list_futures_order_book**](FuturesApi.md#list_futures_order_book) | **GET** /futures/{settle}/order_book | Futures order book -[**list_futures_orders**](FuturesApi.md#list_futures_orders) | **GET** /futures/{settle}/orders | List futures orders -[**list_futures_tickers**](FuturesApi.md#list_futures_tickers) | **GET** /futures/{settle}/tickers | List futures tickers -[**list_futures_trades**](FuturesApi.md#list_futures_trades) | **GET** /futures/{settle}/trades | Futures trading history -[**list_liquidates**](FuturesApi.md#list_liquidates) | **GET** /futures/{settle}/liquidates | List liquidation history -[**list_position_close**](FuturesApi.md#list_position_close) | **GET** /futures/{settle}/position_close | List position close history +[**list_futures_accounts**](FuturesApi.md#list_futures_accounts) | **GET** /futures/{settle}/accounts | Query futures account +[**list_futures_account_book**](FuturesApi.md#list_futures_account_book) | **GET** /futures/{settle}/account_book | Query account book [**list_positions**](FuturesApi.md#list_positions) | **GET** /futures/{settle}/positions | List all positions of a user -[**list_price_triggered_orders**](FuturesApi.md#list_price_triggered_orders) | **GET** /futures/{settle}/price_orders | List all auto orders -[**update_position_leverage**](FuturesApi.md#update_position_leverage) | **POST** /futures/{settle}/positions/{contract}/leverage | Update position leverage +[**get_position**](FuturesApi.md#get_position) | **GET** /futures/{settle}/positions/{contract} | Get single position [**update_position_margin**](FuturesApi.md#update_position_margin) | **POST** /futures/{settle}/positions/{contract}/margin | Update position margin +[**update_position_leverage**](FuturesApi.md#update_position_leverage) | **POST** /futures/{settle}/positions/{contract}/leverage | Update position leverage [**update_position_risk_limit**](FuturesApi.md#update_position_risk_limit) | **POST** /futures/{settle}/positions/{contract}/risk_limit | Update position risk limit +[**list_futures_orders**](FuturesApi.md#list_futures_orders) | **GET** /futures/{settle}/orders | List futures orders +[**create_futures_order**](FuturesApi.md#create_futures_order) | **POST** /futures/{settle}/orders | Create a futures order +[**cancel_futures_orders**](FuturesApi.md#cancel_futures_orders) | **DELETE** /futures/{settle}/orders | Cancel all `open` orders matched +[**get_futures_order**](FuturesApi.md#get_futures_order) | **GET** /futures/{settle}/orders/{order_id} | Get a single order +[**cancel_futures_order**](FuturesApi.md#cancel_futures_order) | **DELETE** /futures/{settle}/orders/{order_id} | Cancel a single order +[**get_my_trades**](FuturesApi.md#get_my_trades) | **GET** /futures/{settle}/my_trades | List personal trading history +[**list_position_close**](FuturesApi.md#list_position_close) | **GET** /futures/{settle}/position_close | List position close history +[**list_liquidates**](FuturesApi.md#list_liquidates) | **GET** /futures/{settle}/liquidates | List liquidation history +[**list_price_triggered_orders**](FuturesApi.md#list_price_triggered_orders) | **GET** /futures/{settle}/price_orders | List all auto orders +[**create_price_triggered_order**](FuturesApi.md#create_price_triggered_order) | **POST** /futures/{settle}/price_orders | Create a price-triggered order +[**cancel_price_triggered_order_list**](FuturesApi.md#cancel_price_triggered_order_list) | **DELETE** /futures/{settle}/price_orders | Cancel all open orders +[**get_price_triggered_order**](FuturesApi.md#get_price_triggered_order) | **GET** /futures/{settle}/price_orders/{order_id} | Get a single order +[**cancel_price_triggered_order**](FuturesApi.md#cancel_price_triggered_order) | **DELETE** /futures/{settle}/price_orders/{order_id} | Cancel a single order -# **cancel_futures_order** -> FuturesOrder cancel_futures_order(settle, order_id) +# **list_futures_contracts** +> list[Contract] list_futures_contracts(settle) -Cancel a single order +List all futures contracts ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -order_id = '12345' # str | ID returned on order successfully being created try: - # Cancel a single order - api_response = api_instance.cancel_futures_order(settle, order_id) + # List all futures contracts + api_response = api_instance.list_futures_contracts(settle) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->cancel_futures_order: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_contracts: %s\n" % e) ``` ### Parameters @@ -68,53 +69,56 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**FuturesOrder**](FuturesOrder.md) +[**list[Contract]**](Contract.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | -# **cancel_futures_orders** -> list[FuturesOrder] cancel_futures_orders(settle, contract, side=side) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Cancel all `open` orders matched +# **get_futures_contract** +> Contract get_futures_contract(settle, contract) -Zero-fill order cannot be retrieved 60 seconds after cancellation +Get a single contract ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract -side = 'ask' # str | All bids or asks. Both included in not specified (optional) try: - # Cancel all `open` orders matched - api_response = api_instance.cancel_futures_orders(settle, contract, side=side) + # Get a single contract + api_response = api_instance.get_futures_contract(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->cancel_futures_orders: %s\n" % e) + print("Exception when calling FuturesApi->get_futures_contract: %s\n" % e) ``` ### Parameters @@ -123,50 +127,60 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | - **side** | **str**| All bids or asks. Both included in not specified | [optional] ### Return type -[**list[FuturesOrder]**](FuturesOrder.md) +[**Contract**](Contract.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Contract information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_price_triggered_order** -> FuturesPriceTriggeredOrder cancel_price_triggered_order(settle, order_id) +# **list_futures_order_book** +> FuturesOrderBook list_futures_order_book(settle, contract, interval=interval, limit=limit) -Cancel a single order +Futures order book + +Bids will be sorted by price from high to low, while asks sorted reversely ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -order_id = 'order_id_example' # str | ID returned on order successfully being created +contract = 'BTC_USD' # str | Futures contract +interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') +limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) try: - # Cancel a single order - api_response = api_instance.cancel_price_triggered_order(settle, order_id) + # Futures order book + api_response = api_instance.list_futures_order_book(settle, contract, interval=interval, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->cancel_price_triggered_order: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_order_book: %s\n" % e) ``` ### Parameters @@ -174,50 +188,63 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **order_id** | **str**| ID returned on order successfully being created | + **contract** | **str**| Futures contract | + **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] + **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] ### Return type -[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) +[**FuturesOrderBook**](FuturesOrderBook.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order book retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_price_triggered_order_list** -> list[FuturesPriceTriggeredOrder] cancel_price_triggered_order_list(settle, contract) +# **list_futures_trades** +> list[FuturesTrade] list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) -Cancel all open orders +Futures trading history ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +last_id = '12345' # str | Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range (optional) +_from = 1546905600 # int | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. (optional) +to = 1546935600 # int | Specify end time in Unix seconds, default to current time (optional) try: - # Cancel all open orders - api_response = api_instance.cancel_price_triggered_order_list(settle, contract) + # 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 ApiException as e: - print("Exception when calling FuturesApi->cancel_price_triggered_order_list: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_trades: %s\n" % e) ``` ### Parameters @@ -226,51 +253,66 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **last_id** | **str**| Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range | [optional] + **_from** | **int**| Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. | [optional] + **to** | **int**| Specify end time in Unix seconds, default to current time | [optional] ### Return type -[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) +[**list[FuturesTrade]**](FuturesTrade.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_futures_order** -> FuturesOrder create_futures_order(settle, futures_order) +# **list_futures_candlesticks** +> list[FuturesCandlestick] list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) -Create a futures order +Get futures candlesticks -Zero-fill order cannot be retrieved 60 seconds after cancellation +Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -futures_order = gate_api.FuturesOrder() # FuturesOrder | +contract = 'BTC_USD' # str | Futures contract +_from = 1546905600 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) +to = 1546935600 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) +limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) +interval = '5m' # str | Interval time between data points (optional) (default to '5m') try: - # Create a futures order - api_response = api_instance.create_futures_order(settle, futures_order) + # Get futures candlesticks + api_response = api_instance.list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->create_futures_order: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_candlesticks: %s\n" % e) ``` ### Parameters @@ -278,50 +320,61 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **futures_order** | [**FuturesOrder**](FuturesOrder.md)| | + **contract** | **str**| Futures contract | + **_from** | **int**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] + **to** | **int**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] + **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] + **interval** | **str**| Interval time between data points | [optional] [default to '5m'] ### Return type -[**FuturesOrder**](FuturesOrder.md) +[**list[FuturesCandlestick]**](FuturesCandlestick.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_price_triggered_order** -> TriggerOrderResponse create_price_triggered_order(settle, futures_price_triggered_order) +# **list_futures_tickers** +> list[FuturesTicker] list_futures_tickers(settle, contract=contract) -Create a price-triggered order +List futures tickers ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -futures_price_triggered_order = gate_api.FuturesPriceTriggeredOrder() # FuturesPriceTriggeredOrder | +contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) try: - # Create a price-triggered order - api_response = api_instance.create_price_triggered_order(settle, futures_price_triggered_order) + # List futures tickers + api_response = api_instance.list_futures_tickers(settle, contract=contract) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->create_price_triggered_order: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_tickers: %s\n" % e) ``` ### Parameters @@ -329,46 +382,58 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **futures_price_triggered_order** | [**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md)| | + **contract** | **str**| Futures contract, return related data only if specified | [optional] ### Return type -[**TriggerOrderResponse**](TriggerOrderResponse.md) +[**list[FuturesTicker]**](FuturesTicker.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_futures_contract** -> Contract get_futures_contract(settle, contract) +# **list_futures_funding_rate_history** +> list[FundingRateRecord] list_futures_funding_rate_history(settle, contract, limit=limit) -Get a single contract +Funding rate history ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) try: - # Get a single contract - api_response = api_instance.get_futures_contract(settle, contract) + # Funding rate history + api_response = api_instance.list_futures_funding_rate_history(settle, contract, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->get_futures_contract: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_funding_rate_history: %s\n" % e) ``` ### Parameters @@ -377,10 +442,11 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] ### Return type -[**Contract**](Contract.md) +[**list[FundingRateRecord]**](FundingRateRecord.md) ### Authorization @@ -391,93 +457,42 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_futures_order** -> FuturesOrder get_futures_order(settle, order_id) - -Get a single order - -Zero-fill order cannot be retrieved 60 seconds after cancellation - -### Example - -```python -from __future__ import print_function -import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) -settle = 'btc' # str | Settle currency (default to 'btc') -order_id = '12345' # str | ID returned on order successfully being created - -try: - # Get a single order - api_response = api_instance.get_futures_order(settle, order_id) - print(api_response) -except ApiException as e: - print("Exception when calling FuturesApi->get_futures_order: %s\n" % e) -``` - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **settle** | **str**| Settle currency | [default to 'btc'] - **order_id** | **str**| ID returned on order successfully being created | - -### Return type - -[**FuturesOrder**](FuturesOrder.md) - -### Authorization - -Authentication with API key and secret is required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | History retrieved | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_my_trades** -> list[MyFuturesTrade] get_my_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) +# **list_futures_insurance_ledger** +> list[InsuranceRecord] list_futures_insurance_ledger(settle, limit=limit) -List personal trading history +Futures insurance balance history ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) -order = 12345 # int | Futures order ID, return related data only if specified (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -offset = 0 # int | List offset, starting from 0 (optional) (default to 0) -last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) -count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) 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) + # Futures insurance balance history + api_response = api_instance.list_futures_insurance_ledger(settle, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->get_my_trades: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_insurance_ledger: %s\n" % e) ``` ### Parameters @@ -485,55 +500,65 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract, return related data only if specified | [optional] - **order** | **int**| Futures order ID, return related data only if specified | [optional] **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] - **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] - **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] ### Return type -[**list[MyFuturesTrade]**](MyFuturesTrade.md) +[**list[InsuranceRecord]**](InsuranceRecord.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_position** -> Position get_position(settle, contract) +# **list_futures_accounts** +> FuturesAccount list_futures_accounts(settle) -Get single position +Query futures account ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract try: - # Get single position - api_response = api_instance.get_position(settle, contract) + # Query futures account + api_response = api_instance.list_futures_accounts(settle) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->get_position: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_accounts: %s\n" % e) ``` ### Parameters @@ -541,50 +566,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract | ### Return type -[**Position**](Position.md) +[**FuturesAccount**](FuturesAccount.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_price_triggered_order** -> FuturesPriceTriggeredOrder get_price_triggered_order(settle, order_id) +# **list_futures_account_book** +> list[FuturesAccountBook] list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type) -Get a single order +Query account book ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -order_id = 'order_id_example' # str | ID returned on order successfully being created +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +_from = 1547706332 # int | Start timestamp (optional) +to = 1547706332 # int | End timestamp (optional) +type = 'dnw' # str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate (optional) try: - # Get a single order - api_response = api_instance.get_price_triggered_order(settle, order_id) + # Query account book + api_response = api_instance.list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->get_price_triggered_order: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_account_book: %s\n" % e) ``` ### Parameters @@ -592,53 +635,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **order_id** | **str**| ID returned on order successfully being created | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **_from** | **int**| Start timestamp | [optional] + **to** | **int**| End timestamp | [optional] + **type** | **str**| Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate | [optional] ### Return type -[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) +[**list[FuturesAccountBook]**](FuturesAccountBook.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_account_book** -> list[FuturesAccountBook] list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type) +# **list_positions** +> list[Position] list_positions(settle) -Query account book +List all positions of a user ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -_from = 1547706332 # int | Start timestamp (optional) -to = 1547706332 # int | End timestamp (optional) -type = 'dnw' # str | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate (optional) try: - # Query account book - api_response = api_instance.list_futures_account_book(settle, limit=limit, _from=_from, to=to, type=type) + # List all positions of a user + api_response = api_instance.list_positions(settle) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_account_book: %s\n" % e) + print("Exception when calling FuturesApi->list_positions: %s\n" % e) ``` ### Parameters @@ -646,52 +704,65 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **_from** | **int**| Start timestamp | [optional] - **to** | **int**| End timestamp | [optional] - **type** | **str**| Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate | [optional] ### Return type -[**list[FuturesAccountBook]**](FuturesAccountBook.md) +[**list[Position]**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_accounts** -> FuturesAccount list_futures_accounts(settle) +# **get_position** +> Position get_position(settle, contract) -Query futures account +Get single position ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') +contract = 'BTC_USD' # str | Futures contract try: - # Query futures account - api_response = api_instance.list_futures_accounts(settle) + # Get single position + api_response = api_instance.get_position(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_accounts: %s\n" % e) + print("Exception when calling FuturesApi->get_position: %s\n" % e) ``` ### Parameters @@ -699,51 +770,67 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] + **contract** | **str**| Futures contract | ### Return type -[**FuturesAccount**](FuturesAccount.md) +[**Position**](Position.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | -# **list_futures_candlesticks** -> list[FuturesCandlestick] list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Get futures candlesticks +# **update_position_margin** +> Position update_position_margin(settle, contract, change) -Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` +Update position margin ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract -_from = 1546905600 # float | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) -to = 1546935600 # float | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) -limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) -interval = '5m' # str | Interval time between data points (optional) (default to '5m') +change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise. try: - # Get futures candlesticks - api_response = api_instance.list_futures_candlesticks(settle, contract, _from=_from, to=to, limit=limit, interval=interval) + # Update position margin + api_response = api_instance.update_position_margin(settle, contract, change) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_candlesticks: %s\n" % e) + print("Exception when calling FuturesApi->update_position_margin: %s\n" % e) ``` ### Parameters @@ -752,48 +839,67 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | - **_from** | **float**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] - **to** | **float**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] - **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] - **interval** | **str**| Interval time between data points | [optional] [default to '5m'] + **change** | **str**| Margin change. Use positive number to increase margin, negative number otherwise. | ### Return type -[**list[FuturesCandlestick]**](FuturesCandlestick.md) +[**Position**](Position.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_contracts** -> list[Contract] list_futures_contracts(settle) +# **update_position_leverage** +> Position update_position_leverage(settle, contract, leverage) -List all futures contracts +Update position leverage ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') +contract = 'BTC_USD' # str | Futures contract +leverage = '10' # str | New position leverage try: - # List all futures contracts - api_response = api_instance.list_futures_contracts(settle) + # Update position leverage + api_response = api_instance.update_position_leverage(settle, contract, leverage) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_contracts: %s\n" % e) + print("Exception when calling FuturesApi->update_position_leverage: %s\n" % e) ``` ### Parameters @@ -801,46 +907,68 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] + **contract** | **str**| Futures contract | + **leverage** | **str**| New position leverage | ### Return type -[**list[Contract]**](Contract.md) +[**Position**](Position.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_funding_rate_history** -> list[FundingRateRecord] list_futures_funding_rate_history(settle, contract, limit=limit) +# **update_position_risk_limit** +> Position update_position_risk_limit(settle, contract, risk_limit) -Funding rate history +Update position risk limit ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +risk_limit = '10' # str | New position risk limit try: - # Funding rate history - api_response = api_instance.list_futures_funding_rate_history(settle, contract, limit=limit) + # Update position risk limit + api_response = api_instance.update_position_risk_limit(settle, contract, risk_limit) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_funding_rate_history: %s\n" % e) + print("Exception when calling FuturesApi->update_position_risk_limit: %s\n" % e) ``` ### Parameters @@ -849,46 +977,73 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **risk_limit** | **str**| New position risk limit | ### Return type -[**list[FundingRateRecord]**](FundingRateRecord.md) +[**Position**](Position.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Position information | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_insurance_ledger** -> list[InsuranceRecord] list_futures_insurance_ledger(settle, limit=limit) +# **list_futures_orders** +> list[FuturesOrder] list_futures_orders(settle, contract, status, limit=limit, offset=offset, last_id=last_id, count_total=count_total) -Futures insurance balance history +List futures orders + +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') +contract = 'BTC_USD' # str | Futures contract +status = 'open' # str | List orders based on status limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +offset = 0 # int | List offset, starting from 0 (optional) (default to 0) +last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) +count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) try: - # Futures insurance balance history - api_response = api_instance.list_futures_insurance_ledger(settle, limit=limit) + # 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 ApiException as e: - print("Exception when calling FuturesApi->list_futures_insurance_ledger: %s\n" % e) + print("Exception when calling FuturesApi->list_futures_orders: %s\n" % e) ``` ### Parameters @@ -896,50 +1051,73 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] + **contract** | **str**| Futures contract | + **status** | **str**| List orders based on status | **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] + **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] + **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] ### Return type -[**list[InsuranceRecord]**](InsuranceRecord.md) +[**list[FuturesOrder]**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | * X-Pagination-Limit - Request limit specified
* X-Pagination-Offset - Request offset specified
* X-Pagination-Total - Total number matched. Only returned on `count_total` set to 1
| + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_order_book** -> FuturesOrderBook list_futures_order_book(settle, contract, interval=interval, limit=limit) +# **create_futures_order** +> FuturesOrder create_futures_order(settle, futures_order) -Futures order book +Create a futures order -Bids will be sorted by price from high to low, while asks sorted reversely +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract -interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') -limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) +futures_order = gate_api.FuturesOrder() # FuturesOrder | try: - # Futures order book - api_response = api_instance.list_futures_order_book(settle, contract, interval=interval, limit=limit) + # Create a futures order + api_response = api_instance.create_futures_order(settle, futures_order) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_order_book: %s\n" % e) + print("Exception when calling FuturesApi->create_futures_order: %s\n" % e) ``` ### Parameters @@ -947,59 +1125,69 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract | - **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] - **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] + **futures_order** | [**FuturesOrder**](FuturesOrder.md)| | ### Return type -[**FuturesOrderBook**](FuturesOrderBook.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Order details | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_orders** -> list[FuturesOrder] list_futures_orders(settle, contract, status, limit=limit, offset=offset, last_id=last_id, count_total=count_total) +# **cancel_futures_orders** +> list[FuturesOrder] cancel_futures_orders(settle, contract, side=side) -List futures orders +Cancel all `open` orders matched Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract -status = 'open' # str | List orders based on status -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -offset = 0 # int | List offset, starting from 0 (optional) (default to 0) -last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) -count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) +side = 'ask' # str | All bids or asks. Both included in not specified (optional) 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) + # Cancel all `open` orders matched + api_response = api_instance.cancel_futures_orders(settle, contract, side=side) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_orders: %s\n" % e) + print("Exception when calling FuturesApi->cancel_futures_orders: %s\n" % e) ``` ### Parameters @@ -1008,11 +1196,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | - **status** | **str**| List orders based on status | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] - **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] - **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] + **side** | **str**| All bids or asks. Both included in not specified | [optional] ### Return type @@ -1020,38 +1204,60 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | All orders matched cancelled | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_tickers** -> list[FuturesTicker] list_futures_tickers(settle, contract=contract) +# **get_futures_order** +> FuturesOrder get_futures_order(settle, order_id) -List futures tickers +Get a single order + +Zero-fill order cannot be retrieved 60 seconds after cancellation ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) +order_id = '12345' # str | ID returned on order successfully being created try: - # List futures tickers - api_response = api_instance.list_futures_tickers(settle, contract=contract) + # Get a single order + api_response = api_instance.get_futures_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_tickers: %s\n" % e) + print("Exception when calling FuturesApi->get_futures_order: %s\n" % e) ``` ### Parameters @@ -1059,50 +1265,66 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract, return related data only if specified | [optional] + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**list[FuturesTicker]**](FuturesTicker.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order details | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_futures_trades** -> list[FuturesTrade] list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) +# **cancel_futures_order** +> FuturesOrder cancel_futures_order(settle, order_id) -Futures trading history +Cancel a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.FuturesApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -last_id = '12345' # str | Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range (optional) -_from = 1546905600 # float | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. (optional) -to = 1546935600 # float | Specify end time in Unix seconds, default to current time (optional) +order_id = '12345' # str | ID returned on order successfully being created try: - # Futures trading history - api_response = api_instance.list_futures_trades(settle, contract, limit=limit, last_id=last_id, _from=_from, to=to) + # Cancel a single order + api_response = api_instance.cancel_futures_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_futures_trades: %s\n" % e) + print("Exception when calling FuturesApi->cancel_futures_order: %s\n" % e) ``` ### Parameters @@ -1110,56 +1332,71 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **last_id** | **str**| Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range | [optional] - **_from** | **float**| Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. | [optional] - **to** | **float**| Specify end time in Unix seconds, default to current time | [optional] + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**list[FuturesTrade]**](FuturesTrade.md) +[**FuturesOrder**](FuturesOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order details | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_liquidates** -> list[FuturesLiquidate] list_liquidates(settle, contract=contract, limit=limit, at=at) +# **get_my_trades** +> list[MyFuturesTrade] get_my_trades(settle, contract=contract, order=order, limit=limit, offset=offset, last_id=last_id, count_total=count_total) -List liquidation history +List personal trading history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) +order = 12345 # int | Futures order ID, return related data only if specified (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -at = 0 # int | Specify a liquidation timestamp (optional) (default to 0) +offset = 0 # int | List offset, starting from 0 (optional) (default to 0) +last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) +count_total = 0 # int | Whether to return total number matched. Default to 0(no return) (optional) (default to 0) try: - # List liquidation history - api_response = api_instance.list_liquidates(settle, contract=contract, limit=limit, at=at) + # 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 ApiException as e: - print("Exception when calling FuturesApi->list_liquidates: %s\n" % e) + print("Exception when calling FuturesApi->get_my_trades: %s\n" % e) ``` ### Parameters @@ -1168,22 +1405,30 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract, return related data only if specified | [optional] + **order** | **int**| Futures order ID, return related data only if specified | [optional] **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **at** | **int**| Specify a liquidation timestamp | [optional] [default to 0] + **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] + **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] + **count_total** | **int**| Whether to return total number matched. Default to 0(no return) | [optional] [default to 0] ### Return type -[**list[FuturesLiquidate]**](FuturesLiquidate.md) +[**list[MyFuturesTrade]**](MyFuturesTrade.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | * X-Pagination-Limit - Request limit specified
* X-Pagination-Offset - Request offset specified
* X-Pagination-Total - Total number matched. Only returned on `count_total` set to 1
| + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **list_position_close** @@ -1193,17 +1438,28 @@ List position close history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) @@ -1230,41 +1486,60 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_positions** -> list[Position] list_positions(settle) +# **list_liquidates** +> list[FuturesLiquidate] list_liquidates(settle, contract=contract, limit=limit, at=at) -List all positions of a user +List liquidation history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') +contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +at = 0 # int | Specify a liquidation timestamp (optional) (default to 0) try: - # List all positions of a user - api_response = api_instance.list_positions(settle) + # List liquidation history + api_response = api_instance.list_liquidates(settle, contract=contract, limit=limit, at=at) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->list_positions: %s\n" % e) + print("Exception when calling FuturesApi->list_liquidates: %s\n" % e) ``` ### Parameters @@ -1272,20 +1547,28 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] + **contract** | **str**| Futures contract, return related data only if specified | [optional] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **at** | **int**| Specify a liquidation timestamp | [optional] [default to 0] ### Return type -[**list[Position]**](Position.md) +[**list[FuturesLiquidate]**](FuturesLiquidate.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **list_price_triggered_orders** @@ -1295,17 +1578,28 @@ List all auto orders ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') status = 'status_example' # str | List orders based on status contract = 'BTC_USD' # str | Futures contract, return related data only if specified (optional) @@ -1336,43 +1630,125 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_position_leverage** -> Position update_position_leverage(settle, contract, leverage) +# **create_price_triggered_order** +> TriggerOrderResponse create_price_triggered_order(settle, futures_price_triggered_order) -Update position leverage +Create a price-triggered order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) +settle = 'btc' # str | Settle currency (default to 'btc') +futures_price_triggered_order = gate_api.FuturesPriceTriggeredOrder() # FuturesPriceTriggeredOrder | + +try: + # Create a price-triggered order + api_response = api_instance.create_price_triggered_order(settle, futures_price_triggered_order) + print(api_response) +except ApiException as e: + print("Exception when calling FuturesApi->create_price_triggered_order: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **settle** | **str**| Settle currency | [default to 'btc'] + **futures_price_triggered_order** | [**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md)| | + +### Return type + +[**TriggerOrderResponse**](TriggerOrderResponse.md) + +### Authorization + +[apiv4](../README.md#apiv4) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Order created | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **cancel_price_triggered_order_list** +> list[FuturesPriceTriggeredOrder] cancel_price_triggered_order_list(settle, contract) + +Cancel all open orders -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' +### Example -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +* Api Key Authentication (apiv4): +```python +from __future__ import print_function +import gate_api +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') contract = 'BTC_USD' # str | Futures contract -leverage = '10' # str | New position leverage try: - # Update position leverage - api_response = api_instance.update_position_leverage(settle, contract, leverage) + # Cancel all open orders + api_response = api_instance.cancel_price_triggered_order_list(settle, contract) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->update_position_leverage: %s\n" % e) + print("Exception when calling FuturesApi->cancel_price_triggered_order_list: %s\n" % e) ``` ### Parameters @@ -1381,51 +1757,65 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] **contract** | **str**| Futures contract | - **leverage** | **str**| New position leverage | ### Return type -[**Position**](Position.md) +[**list[FuturesPriceTriggeredOrder]**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Batch cancellation request accepted. Query order status by listing orders | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_position_margin** -> Position update_position_margin(settle, contract, change) +# **get_price_triggered_order** +> FuturesPriceTriggeredOrder get_price_triggered_order(settle, order_id) -Update position margin +Get a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract -change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise. +order_id = 'order_id_example' # str | ID returned on order successfully being created try: - # Update position margin - api_response = api_instance.update_position_margin(settle, contract, change) + # Get a single order + api_response = api_instance.get_price_triggered_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->update_position_margin: %s\n" % e) + print("Exception when calling FuturesApi->get_price_triggered_order: %s\n" % e) ``` ### Parameters @@ -1433,52 +1823,66 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract | - **change** | **str**| Margin change. Use positive number to increase margin, negative number otherwise. | + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**Position**](Position.md) +[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Auto order detail | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **update_position_risk_limit** -> Position update_position_risk_limit(settle, contract, risk_limit) +# **cancel_price_triggered_order** +> FuturesPriceTriggeredOrder cancel_price_triggered_order(settle, order_id) -Update position risk limit +Cancel a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.FuturesApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.FuturesApi(api_client) settle = 'btc' # str | Settle currency (default to 'btc') -contract = 'BTC_USD' # str | Futures contract -risk_limit = '10' # str | New position risk limit +order_id = 'order_id_example' # str | ID returned on order successfully being created try: - # Update position risk limit - api_response = api_instance.update_position_risk_limit(settle, contract, risk_limit) + # Cancel a single order + api_response = api_instance.cancel_price_triggered_order(settle, order_id) print(api_response) except ApiException as e: - print("Exception when calling FuturesApi->update_position_risk_limit: %s\n" % e) + print("Exception when calling FuturesApi->cancel_price_triggered_order: %s\n" % e) ``` ### Parameters @@ -1486,21 +1890,25 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **settle** | **str**| Settle currency | [default to 'btc'] - **contract** | **str**| Futures contract | - **risk_limit** | **str**| New position risk limit | + **order_id** | **str**| ID returned on order successfully being created | ### Return type -[**Position**](Position.md) +[**FuturesPriceTriggeredOrder**](FuturesPriceTriggeredOrder.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Auto order detail | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/FuturesCandlestick.md b/docs/FuturesCandlestick.md index 9602dfb..5d73a6b 100644 --- a/docs/FuturesCandlestick.md +++ b/docs/FuturesCandlestick.md @@ -1,5 +1,6 @@ # FuturesCandlestick +data point in every timestamp ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/FuturesErrorResponse.md b/docs/FuturesErrorResponse.md deleted file mode 100644 index e8fe220..0000000 --- a/docs/FuturesErrorResponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# FuturesErrorResponse - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**label** | **str** | 错误标识符,错误描述如下: 请求参数或格式问题: - INVALID_PARAM_VALUE: 参数输入值无效 - INVALID_REQUEST_BODY: 无效请求体 - MISSING_REQUIRED_PARAM: 缺少必选参数 - DUPLICATE_REQUEST: 请求过于频繁 认证相关: - INVALID_CREDENTIALS: 认证接口缺少用户认证信息 - NO_FUTURES_ACCOUNT: 用户无期货账户 业务相关: - NO_MATCHING: 没有匹配的对手单 - NO_MARKING_PRICE: 合约当前无标记价格 - CONTRACT_NOT_FOUND: 合约未找到 - NOT_FOUND: 请求路径不存在 - RISK_LIMIT_EXCEEDED: 委托超出风险限额 - INSUFFICIENT_BALANCE: 余额不足 - POTENTIAL_LIQUIDATION: 操作可能导致爆仓 - LEVERAGE_TOO_HIGH: 杠杆倍数设置过高 - LEVERAGE_TOO_LOW: 杠杆倍数设置过低 - ORDER_NOT_FOUND: 委托不存在 - ORDER_FINISHED: 订单已结束 - TOO_MANY_ORDERS: 过多未交易的挂单 - POSITION_NOT_FOUND: 合约无头寸信息 - POSITION_CROSS_MARGIN: 全仓不支持更新保证金 - POSITION_LOCKED: 头寸当前被锁定 - TOO_MUCH_CHANGE: 保证金超过可调范围 - RISK_LIMIT_NOT_MULTIPLE: 风险限额未按照步长调整 - RISK_LIMIT_TOO_HIGH: 超出最大风险限额 - RISK_LIMIT_TOO_lOW: 风险限额设置过低 - PRICE_TOO_DEVIATED: 下单价与标记价格相差过大 - SIZE_TOO_LARGE: 下单数量超过上限 - SIZE_TOO_SMALL: 下单数量不足下限 - LIQUIDATION_PRICE_EXCEEDED: 补仓时价格不能超过平仓价 - POSITION_IN_CLOSE: 仓位正在平仓 - POTENTIAL_BANKRUPTCY: 下单若成交,保证金无法弥补损失 服务异常: - SERVER_ERROR: 内部错误 - TOO_BUSY: 服务当前忙 | [optional] -**message** | **str** | 详细错误描述。如果指定了 `Accept-Language` 请求头部,且支持指定语言,则描述信息会返回对应的语言 | [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/FuturesInitialOrder.md b/docs/FuturesInitialOrder.md index e40508e..07521e7 100644 --- a/docs/FuturesInitialOrder.md +++ b/docs/FuturesInitialOrder.md @@ -10,8 +10,8 @@ Name | Type | Description | Notes **tif** | **str** | Time in force. If using market price, only `ioc` is supported. - gtc: GoodTillCancelled - ioc: ImmediateOrCancelled | [optional] [default to 'gtc'] **text** | **str** | How the order is created. Possible values are: web, api and app | [optional] **reduce_only** | **bool** | Set to true to create an reduce-only order | [optional] [default to False] -**is_reduce_only** | **bool** | Is the order reduce-only | [optional] -**is_close** | **bool** | Is the order to close position | [optional] +**is_reduce_only** | **bool** | Is the order reduce-only | [optional] [readonly] +**is_close** | **bool** | Is the order to close position | [optional] [readonly] [[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/FuturesLiquidate.md b/docs/FuturesLiquidate.md index da65736..fc66f59 100644 --- a/docs/FuturesLiquidate.md +++ b/docs/FuturesLiquidate.md @@ -3,18 +3,18 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**time** | **int** | Liquidation time | [optional] -**contract** | **str** | Futures contract | [optional] -**leverage** | **str** | Position leverage | [optional] -**size** | **int** | Position size | [optional] -**margin** | **str** | Position margin | [optional] -**entry_price** | **str** | Average entry price | [optional] -**liq_price** | **str** | Liquidation price | [optional] -**mark_price** | **str** | Mark price | [optional] -**order_id** | **int** | Liquidation order ID | [optional] -**order_price** | **str** | Liquidation order price | [optional] -**fill_price** | **str** | Liquidation order average taker price | [optional] -**left** | **int** | Liquidation order maker size | [optional] +**time** | **int** | Liquidation time | [optional] [readonly] +**contract** | **str** | Futures contract | [optional] [readonly] +**leverage** | **str** | Position leverage | [optional] [readonly] +**size** | **int** | Position size | [optional] [readonly] +**margin** | **str** | Position margin | [optional] [readonly] +**entry_price** | **str** | Average entry price | [optional] [readonly] +**liq_price** | **str** | Liquidation price | [optional] [readonly] +**mark_price** | **str** | Mark price | [optional] [readonly] +**order_id** | **int** | Liquidation order ID | [optional] [readonly] +**order_price** | **str** | Liquidation order price | [optional] [readonly] +**fill_price** | **str** | Liquidation order average taker price | [optional] [readonly] +**left** | **int** | Liquidation order maker size | [optional] [readonly] [[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/FuturesOrder.md b/docs/FuturesOrder.md index a58fc57..9953129 100644 --- a/docs/FuturesOrder.md +++ b/docs/FuturesOrder.md @@ -1,30 +1,31 @@ # FuturesOrder +Futures order details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **int** | Futures order ID | [optional] -**user** | **int** | User ID | [optional] -**create_time** | **float** | Order creation time | [optional] -**finish_time** | **float** | Order finished time. Not returned if order is open | [optional] -**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] -**status** | **str** | Order status - `open`: waiting to be traded - `finished`: finished | [optional] +**id** | **int** | Futures order ID | [optional] [readonly] +**user** | **int** | User ID | [optional] [readonly] +**create_time** | **float** | Order creation time | [optional] [readonly] +**finish_time** | **float** | Order finished time. Not returned if order is open | [optional] [readonly] +**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] **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] -**is_close** | **bool** | Is the order to close position | [optional] +**is_close** | **bool** | Is the order to close position | [optional] [readonly] **reduce_only** | **bool** | Set as `true` to be reduce-only order | [optional] [default to False] -**is_reduce_only** | **bool** | Is the order reduce-only | [optional] -**is_liq** | **bool** | Is the order for liquidation | [optional] +**is_reduce_only** | **bool** | Is the order reduce-only | [optional] [readonly] +**is_liq** | **bool** | Is the order for liquidation | [optional] [readonly] **tif** | **str** | Time in force - gtc: GoodTillCancelled - ioc: ImmediateOrCancelled, taker only - poc: PendingOrCancelled, reduce-only | [optional] [default to 'gtc'] -**left** | **int** | Size left to be traded | [optional] -**fill_price** | **str** | Fill price of the order | [optional] -**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance | [optional] -**tkfr** | **str** | Taker fee | [optional] -**mkfr** | **str** | Maker fee | [optional] -**refu** | **int** | Reference user ID | [optional] +**left** | **int** | Size left to be traded | [optional] [readonly] +**fill_price** | **str** | Fill price of the order | [optional] [readonly] +**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance | [optional] +**tkfr** | **str** | Taker fee | [optional] [readonly] +**mkfr** | **str** | Maker fee | [optional] [readonly] +**refu** | **int** | Reference user ID | [optional] [readonly] [[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/FuturesPriceTriggeredOrder.md b/docs/FuturesPriceTriggeredOrder.md index 308b196..f018dc7 100644 --- a/docs/FuturesPriceTriggeredOrder.md +++ b/docs/FuturesPriceTriggeredOrder.md @@ -1,18 +1,19 @@ # FuturesPriceTriggeredOrder +Futures order details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **initial** | [**FuturesInitialOrder**](FuturesInitialOrder.md) | | **trigger** | [**FuturesPriceTrigger**](FuturesPriceTrigger.md) | | -**id** | **int** | Auto order ID | [optional] -**user** | **int** | User ID | [optional] -**create_time** | **float** | Creation time | [optional] -**finish_time** | **float** | Finished time | [optional] -**trade_id** | **int** | ID of the newly created order on condition triggered | [optional] -**status** | **str** | Order status. | [optional] -**finish_as** | **str** | How order is finished | [optional] -**reason** | **str** | Extra messages of how order is finished | [optional] +**id** | **int** | Auto order ID | [optional] [readonly] +**user** | **int** | User ID | [optional] [readonly] +**create_time** | **float** | Creation time | [optional] [readonly] +**finish_time** | **float** | Finished time | [optional] [readonly] +**trade_id** | **int** | ID of the newly created order on condition triggered | [optional] [readonly] +**status** | **str** | Order status. | [optional] [readonly] +**finish_as** | **str** | How order is finished | [optional] [readonly] +**reason** | **str** | Extra messages of how order is finished | [optional] [readonly] [[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/LedgerRecord.md b/docs/LedgerRecord.md index a5ba712..b584342 100644 --- a/docs/LedgerRecord.md +++ b/docs/LedgerRecord.md @@ -3,14 +3,14 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | Record ID | [optional] -**txid** | **str** | Hash record of the withdrawal | [optional] -**timestamp** | **str** | Record time | [optional] +**id** | **str** | Record ID | [optional] [readonly] +**txid** | **str** | Hash record of the withdrawal | [optional] [readonly] +**timestamp** | **str** | Record time | [optional] [readonly] **amount** | **str** | Trade amount | **currency** | **str** | Record currency | **address** | **str** | Withdrawal address. Required for withdrawals | [optional] **memo** | **str** | Extra withdrawal memo | [optional] -**status** | **str** | Record status. - DONE: done - CANCEL: cancelled - REQUEST: requesting - MANUAL: waiting for manual approval - BCODE: GateCode operation | [optional] +**status** | **str** | Record status. - DONE: done - CANCEL: cancelled - REQUEST: requesting - MANUAL: waiting for manual approval - BCODE: GateCode operation | [optional] [readonly] [[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/Loan.md b/docs/Loan.md index 00afde2..6b291a6 100644 --- a/docs/Loan.md +++ b/docs/Loan.md @@ -1,12 +1,13 @@ # Loan +Margin loan details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | Loan ID | [optional] -**create_time** | **str** | Creation time | [optional] -**expire_time** | **str** | Repay time of the loan. No value will be returned for lending loan | [optional] -**status** | **str** | Loan status open - not fully loaned loaned - all loaned out for lending loan; loaned in for borrowing side finished - loan is finished, either being all repaid or cancelled by the lender auto_repaid - automatically repaid by the system | [optional] +**id** | **str** | Loan ID | [optional] [readonly] +**create_time** | **str** | Creation time | [optional] [readonly] +**expire_time** | **str** | Repay time of the loan. No value will be returned for lending loan | [optional] [readonly] +**status** | **str** | Loan status open - not fully loaned loaned - all loaned out for lending loan; loaned in for borrowing side finished - loan is finished, either being all repaid or cancelled by the lender auto_repaid - automatically repaid by the system | [optional] [readonly] **side** | **str** | Loan side | **currency** | **str** | Loan currency | **rate** | **str** | Loan rate. Only rates in [0.0002, 0.002] are supported. Not required in lending. Market rate calculated from recent rates will be used if not set | [optional] @@ -14,10 +15,10 @@ Name | Type | Description | Notes **days** | **int** | Loan days | **auto_renew** | **bool** | Auto renew the loan on expiration | [optional] [default to False] **currency_pair** | **str** | Currency pair. Required for borrowing side | [optional] -**left** | **str** | Amount not lending out | [optional] -**repaid** | **str** | Repaid amount | [optional] -**paid_interest** | **str** | Repaid interest | [optional] -**unpaid_interest** | **str** | Interest not repaid | [optional] +**left** | **str** | Amount not lending out | [optional] [readonly] +**repaid** | **str** | Repaid amount | [optional] [readonly] +**paid_interest** | **str** | Repaid interest | [optional] [readonly] +**unpaid_interest** | **str** | Interest not repaid | [optional] [readonly] **fee_rate** | **str** | Loan fee rate | [optional] **orig_id** | **str** | Original loan ID if the loan is auto-renewed. Equal to `id` if not | [optional] diff --git a/docs/LoanRecord.md b/docs/LoanRecord.md index 370ebb6..fe8214b 100644 --- a/docs/LoanRecord.md +++ b/docs/LoanRecord.md @@ -1,5 +1,6 @@ # LoanRecord +Margin loaned record details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- @@ -15,8 +16,8 @@ Name | Type | Description | Notes **days** | **int** | Loan days | [optional] **auto_renew** | **bool** | Whether the record will auto renew on expiration | [optional] [default to False] **repaid** | **str** | Repaid amount | [optional] -**paid_interest** | **str** | Repaid interest | [optional] -**unpaid_interest** | **str** | Interest not repaid | [optional] +**paid_interest** | **str** | Repaid interest | [optional] [readonly] +**unpaid_interest** | **str** | Interest not repaid | [optional] [readonly] [[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/MarginAccount.md b/docs/MarginAccount.md index 945e489..313e1b2 100644 --- a/docs/MarginAccount.md +++ b/docs/MarginAccount.md @@ -1,5 +1,6 @@ # MarginAccount +Margin account detail. `base` refers to base currency, while `quotes to quote currency ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/MarginAccountBook.md b/docs/MarginAccountBook.md new file mode 100644 index 0000000..e745b7b --- /dev/null +++ b/docs/MarginAccountBook.md @@ -0,0 +1,15 @@ +# MarginAccountBook + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | Balance change record ID | [optional] +**time** | **str** | Balance changed timestamp | [optional] +**currency** | **str** | Currency changed | [optional] +**currency_pair** | **str** | Account currency pair | [optional] +**change** | **str** | Amount changed. Positive value means transferring in, while negative out | [optional] +**balance** | **str** | Balance after change | [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/MarginAccountCurrency.md b/docs/MarginAccountCurrency.md index 56c4e2f..74f3224 100644 --- a/docs/MarginAccountCurrency.md +++ b/docs/MarginAccountCurrency.md @@ -1,5 +1,6 @@ # MarginAccountCurrency +Account currency detail ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/MarginApi.md b/docs/MarginApi.md index cb34ef5..8c24d0c 100644 --- a/docs/MarginApi.md +++ b/docs/MarginApi.md @@ -4,225 +4,272 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- -[**cancel_loan**](MarginApi.md#cancel_loan) | **DELETE** /margin/loans/{loan_id} | Cancel lending loan -[**create_loan**](MarginApi.md#create_loan) | **POST** /margin/loans | Lend or borrow -[**get_loan**](MarginApi.md#get_loan) | **GET** /margin/loans/{loan_id} | Retrieve one single loan detail -[**get_loan_record**](MarginApi.md#get_loan_record) | **GET** /margin/loan_records/{loan_record_id} | Get one single loan record -[**list_funding_accounts**](MarginApi.md#list_funding_accounts) | **GET** /margin/funding_accounts | Funding account list +[**list_margin_currency_pairs**](MarginApi.md#list_margin_currency_pairs) | **GET** /margin/currency_pairs | List all supported currency pairs supported in margin trading [**list_funding_book**](MarginApi.md#list_funding_book) | **GET** /margin/funding_book | Order book of lending loans -[**list_loan_records**](MarginApi.md#list_loan_records) | **GET** /margin/loan_records | List repayment records of specified loan -[**list_loan_repayments**](MarginApi.md#list_loan_repayments) | **GET** /margin/loans/{loan_id}/repayment | List loan repayment records -[**list_loans**](MarginApi.md#list_loans) | **GET** /margin/loans | List all loans [**list_margin_accounts**](MarginApi.md#list_margin_accounts) | **GET** /margin/accounts | Margin account list -[**list_margin_currency_pairs**](MarginApi.md#list_margin_currency_pairs) | **GET** /margin/currency_pairs | List all supported currency pairs supported in margin trading +[**list_margin_account_book**](MarginApi.md#list_margin_account_book) | **GET** /margin/account_book | List margin account balance change history +[**list_funding_accounts**](MarginApi.md#list_funding_accounts) | **GET** /margin/funding_accounts | Funding account list +[**list_loans**](MarginApi.md#list_loans) | **GET** /margin/loans | List all loans +[**create_loan**](MarginApi.md#create_loan) | **POST** /margin/loans | Lend or borrow [**merge_loans**](MarginApi.md#merge_loans) | **POST** /margin/merged_loans | Merge multiple lending loans -[**repay_loan**](MarginApi.md#repay_loan) | **POST** /margin/loans/{loan_id}/repayment | Repay a loan +[**get_loan**](MarginApi.md#get_loan) | **GET** /margin/loans/{loan_id} | Retrieve one single loan detail +[**cancel_loan**](MarginApi.md#cancel_loan) | **DELETE** /margin/loans/{loan_id} | Cancel lending loan [**update_loan**](MarginApi.md#update_loan) | **PATCH** /margin/loans/{loan_id} | Modify a loan +[**list_loan_repayments**](MarginApi.md#list_loan_repayments) | **GET** /margin/loans/{loan_id}/repayment | List loan repayment records +[**repay_loan**](MarginApi.md#repay_loan) | **POST** /margin/loans/{loan_id}/repayment | Repay a loan +[**list_loan_records**](MarginApi.md#list_loan_records) | **GET** /margin/loan_records | List repayment records of specified loan +[**get_loan_record**](MarginApi.md#get_loan_record) | **GET** /margin/loan_records/{loan_record_id} | Get one single loan record [**update_loan_record**](MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record -# **cancel_loan** -> Loan cancel_loan(loan_id, currency) - -Cancel lending loan +# **list_margin_currency_pairs** +> list[MarginCurrencyPair] list_margin_currency_pairs() -Only lending loans can be cancelled +List all supported currency pairs supported in margin trading ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan_id = '12345' # str | Loan ID -currency = 'BTC' # str | Retrieved specified currency related data +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) try: - # Cancel lending loan - api_response = api_instance.cancel_loan(loan_id, currency) + # List all supported currency pairs supported in margin trading + api_response = api_instance.list_margin_currency_pairs() print(api_response) except ApiException as e: - print("Exception when calling MarginApi->cancel_loan: %s\n" % e) + print("Exception when calling MarginApi->list_margin_currency_pairs: %s\n" % e) ``` ### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **loan_id** | **str**| Loan ID | - **currency** | **str**| Retrieved specified currency related data | +This endpoint does not need any parameter. ### Return type -[**Loan**](Loan.md) +[**list[MarginCurrencyPair]**](MarginCurrencyPair.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_loan** -> Loan create_loan(loan) +# **list_funding_book** +> list[FundingBookItem] list_funding_book(currency) -Lend or borrow +Order book of lending loans ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan = gate_api.Loan() # Loan | +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +currency = 'BTC' # str | Retrieved specified currency related data try: - # Lend or borrow - api_response = api_instance.create_loan(loan) + # Order book of lending loans + api_response = api_instance.list_funding_book(currency) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->create_loan: %s\n" % e) + print("Exception when calling MarginApi->list_funding_book: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **loan** | [**Loan**](Loan.md)| | + **currency** | **str**| Retrieved specified currency related data | ### Return type -[**Loan**](Loan.md) +[**list[FundingBookItem]**](FundingBookItem.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order book retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_loan** -> Loan get_loan(loan_id, side) +# **list_margin_accounts** +> list[MarginAccount] list_margin_accounts(currency_pair=currency_pair) -Retrieve one single loan detail +Margin account list ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan_id = '12345' # str | Loan ID -side = 'lend' # str | Lend or borrow +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +currency_pair = 'BTC_USDT' # str | Currency pair (optional) try: - # Retrieve one single loan detail - api_response = api_instance.get_loan(loan_id, side) + # Margin account list + api_response = api_instance.list_margin_accounts(currency_pair=currency_pair) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->get_loan: %s\n" % e) + print("Exception when calling MarginApi->list_margin_accounts: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **loan_id** | **str**| Loan ID | - **side** | **str**| Lend or borrow | + **currency_pair** | **str**| Currency pair | [optional] ### Return type -[**Loan**](Loan.md) +[**list[MarginAccount]**](MarginAccount.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_loan_record** -> LoanRecord get_loan_record(loan_record_id, loan_id) +# **list_margin_account_book** +> list[MarginAccountBook] list_margin_account_book(currency=currency, currency_pair=currency_pair, _from=_from, to=to, page=page, limit=limit) -Get one single loan record +List margin account balance change history + +Only transferring from or to margin account are provided for now. Time range allows 30 days at most ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan_record_id = '12345' # str | Loan record ID -loan_id = '12345' # str | Loan ID +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +currency = 'currency_example' # str | List records related to specified currency only. If specified, `currency_pair` is also required. (optional) +currency_pair = 'currency_pair_example' # str | List records related to specified currency pair. Used in combination with `currency`. Ignored if `currency` is not provided (optional) +_from = 56 # int | Time range beginning, default to 7 days before current time (optional) +to = 56 # int | Time range ending, default to current time (optional) +page = 1 # int | Page number (optional) (default to 1) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) try: - # Get one single loan record - api_response = api_instance.get_loan_record(loan_record_id, loan_id) + # 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 ApiException as e: - print("Exception when calling MarginApi->get_loan_record: %s\n" % e) + print("Exception when calling MarginApi->list_margin_account_book: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **loan_record_id** | **str**| Loan record ID | - **loan_id** | **str**| Loan ID | + **currency** | **str**| List records related to specified currency only. If specified, `currency_pair` is also required. | [optional] + **currency_pair** | **str**| List records related to specified currency pair. Used in combination with `currency`. Ignored if `currency` is not provided | [optional] + **_from** | **int**| Time range beginning, default to 7 days before current time | [optional] + **to** | **int**| Time range ending, default to current time | [optional] + **page** | **int**| Page number | [optional] [default to 1] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] ### Return type -[**LoanRecord**](LoanRecord.md) +[**list[MarginAccountBook]**](MarginAccountBook.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **list_funding_accounts** @@ -232,17 +279,28 @@ Funding account list ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) currency = 'BTC' # str | Retrieved specified currency related data (optional) try: @@ -265,366 +323,499 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_funding_book** -> list[FundingBookItem] list_funding_book(currency) +# **list_loans** +> list[Loan] list_loans(status, side, currency=currency, currency_pair=currency_pair, sort_by=sort_by, reverse_sort=reverse_sort, page=page, limit=limit) -Order book of lending loans +List all loans ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.MarginApi() -currency = 'BTC' # str | Retrieved specified currency related data +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +status = 'open' # str | Loan status +side = 'lend' # str | Lend or borrow +currency = 'BTC' # str | Retrieved specified currency related data (optional) +currency_pair = 'BTC_USDT' # str | Currency pair (optional) +sort_by = 'rate' # str | Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` (optional) +reverse_sort = false # bool | Whether to sort in descending order. Default to `true` (optional) +page = 1 # int | Page number (optional) (default to 1) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) try: - # Order book of lending loans - api_response = api_instance.list_funding_book(currency) + # 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 ApiException as e: - print("Exception when calling MarginApi->list_funding_book: %s\n" % e) + print("Exception when calling MarginApi->list_loans: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency** | **str**| Retrieved specified currency related data | + **status** | **str**| Loan status | + **side** | **str**| Lend or borrow | + **currency** | **str**| Retrieved specified currency related data | [optional] + **currency_pair** | **str**| Currency pair | [optional] + **sort_by** | **str**| Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` | [optional] + **reverse_sort** | **bool**| Whether to sort in descending order. Default to `true` | [optional] + **page** | **int**| Page number | [optional] [default to 1] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] ### Return type -[**list[FundingBookItem]**](FundingBookItem.md) +[**list[Loan]**](Loan.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_loan_records** -> list[LoanRecord] list_loan_records(loan_id, status=status, page=page, limit=limit) +# **create_loan** +> Loan create_loan(loan) -List repayment records of specified loan +Lend or borrow ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan_id = '12345' # str | Loan ID -status = 'loaned' # str | Loan record status (optional) -page = 1 # int | Page number (optional) (default to 1) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan = gate_api.Loan() # Loan | try: - # List repayment records of specified loan - api_response = api_instance.list_loan_records(loan_id, status=status, page=page, limit=limit) + # Lend or borrow + api_response = api_instance.create_loan(loan) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->list_loan_records: %s\n" % e) + print("Exception when calling MarginApi->create_loan: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **loan_id** | **str**| Loan ID | - **status** | **str**| Loan record status | [optional] - **page** | **int**| Page number | [optional] [default to 1] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **loan** | [**Loan**](Loan.md)| | ### Return type -[**list[LoanRecord]**](LoanRecord.md) +[**Loan**](Loan.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Loan created | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_loan_repayments** -> list[Repayment] list_loan_repayments(loan_id) +# **merge_loans** +> Loan merge_loans(currency, ids) -List loan repayment records +Merge multiple lending loans ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -loan_id = '12345' # str | Loan ID +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +currency = 'BTC' # str | Retrieved specified currency related data +ids = '123,234,345' # str | Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request try: - # List loan repayment records - api_response = api_instance.list_loan_repayments(loan_id) + # Merge multiple lending loans + api_response = api_instance.merge_loans(currency, ids) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->list_loan_repayments: %s\n" % e) + print("Exception when calling MarginApi->merge_loans: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **loan_id** | **str**| Loan ID | + **currency** | **str**| Retrieved specified currency related data | + **ids** | **str**| Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request | ### Return type -[**list[Repayment]**](Repayment.md) +[**Loan**](Loan.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Loans merged | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_loans** -> list[Loan] list_loans(status, side, currency=currency, currency_pair=currency_pair, sort_by=sort_by, reverse_sort=reverse_sort, page=page, limit=limit) +# **get_loan** +> Loan get_loan(loan_id, side) -List all loans +Retrieve one single loan detail ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -status = 'open' # str | Loan status +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_id = '12345' # str | Loan ID side = 'lend' # str | Lend or borrow -currency = 'BTC' # str | Retrieved specified currency related data (optional) -currency_pair = 'BTC_USDT' # str | Currency pair (optional) -sort_by = 'rate' # str | Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` (optional) -reverse_sort = True # bool | Whether to sort in descending order. Default to `true` (optional) -page = 1 # int | Page number (optional) (default to 1) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) 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) + # Retrieve one single loan detail + api_response = api_instance.get_loan(loan_id, side) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->list_loans: %s\n" % e) + print("Exception when calling MarginApi->get_loan: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **status** | **str**| Loan status | + **loan_id** | **str**| Loan ID | **side** | **str**| Lend or borrow | - **currency** | **str**| Retrieved specified currency related data | [optional] - **currency_pair** | **str**| Currency pair | [optional] - **sort_by** | **str**| Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` | [optional] - **reverse_sort** | **bool**| Whether to sort in descending order. Default to `true` | [optional] - **page** | **int**| Page number | [optional] [default to 1] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] ### Return type -[**list[Loan]**](Loan.md) +[**Loan**](Loan.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_margin_accounts** -> list[MarginAccount] list_margin_accounts(currency_pair=currency_pair) +# **cancel_loan** +> Loan cancel_loan(loan_id, currency) -Margin account list +Cancel lending loan + +Only lending loans can be cancelled ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -currency_pair = 'BTC_USDT' # str | Currency pair (optional) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_id = '12345' # str | Loan ID +currency = 'BTC' # str | Retrieved specified currency related data try: - # Margin account list - api_response = api_instance.list_margin_accounts(currency_pair=currency_pair) + # Cancel lending loan + api_response = api_instance.cancel_loan(loan_id, currency) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->list_margin_accounts: %s\n" % e) + print("Exception when calling MarginApi->cancel_loan: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency_pair** | **str**| Currency pair | [optional] + **loan_id** | **str**| Loan ID | + **currency** | **str**| Retrieved specified currency related data | ### Return type -[**list[MarginAccount]**](MarginAccount.md) +[**Loan**](Loan.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order cancelled | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_margin_currency_pairs** -> list[MarginCurrencyPair] list_margin_currency_pairs() +# **update_loan** +> Loan update_loan(loan_id, loan_patch) -List all supported currency pairs supported in margin trading +Modify a loan + +Only `auto_renew` modification is supported currently ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.MarginApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_id = '12345' # str | Loan ID +loan_patch = gate_api.LoanPatch() # LoanPatch | try: - # List all supported currency pairs supported in margin trading - api_response = api_instance.list_margin_currency_pairs() + # Modify a loan + api_response = api_instance.update_loan(loan_id, loan_patch) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->list_margin_currency_pairs: %s\n" % e) + print("Exception when calling MarginApi->update_loan: %s\n" % e) ``` ### Parameters -This endpoint does not need any parameter. + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **loan_id** | **str**| Loan ID | + **loan_patch** | [**LoanPatch**](LoanPatch.md)| | ### Return type -[**list[MarginCurrencyPair]**](MarginCurrencyPair.md) +[**Loan**](Loan.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Updated | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **merge_loans** -> Loan merge_loans(currency, ids) +# **list_loan_repayments** +> list[Repayment] list_loan_repayments(loan_id) -Merge multiple lending loans +List loan repayment records ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) -currency = 'BTC' # str | Retrieved specified currency related data -ids = '123,234,345' # str | Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_id = '12345' # str | Loan ID try: - # Merge multiple lending loans - api_response = api_instance.merge_loans(currency, ids) + # List loan repayment records + api_response = api_instance.list_loan_repayments(loan_id) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->merge_loans: %s\n" % e) + print("Exception when calling MarginApi->list_loan_repayments: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency** | **str**| Retrieved specified currency related data | - **ids** | **str**| Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request | + **loan_id** | **str**| Loan ID | ### Return type -[**Loan**](Loan.md) +[**list[Repayment]**](Repayment.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **repay_loan** @@ -634,17 +825,28 @@ Repay a loan ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) loan_id = '12345' # str | Loan ID repay_request = gate_api.RepayRequest() # RepayRequest | @@ -669,66 +871,156 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Loan repaid | - | -# **update_loan** -> Loan update_loan(loan_id, loan_patch) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Modify a loan +# **list_loan_records** +> list[LoanRecord] list_loan_records(loan_id, status=status, page=page, limit=limit) -Only `auto_renew` modification is supported currently +List repayment records of specified loan ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_id = '12345' # str | Loan ID +status = 'loaned' # str | Loan record status (optional) +page = 1 # int | Page number (optional) (default to 1) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) + +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 ApiException as e: + print("Exception when calling MarginApi->list_loan_records: %s\n" % e) +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **loan_id** | **str**| Loan ID | + **status** | **str**| Loan record status | [optional] + **page** | **int**| Page number | [optional] [default to 1] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + +### Return type + +[**list[LoanRecord]**](LoanRecord.md) + +### Authorization + +[apiv4](../README.md#apiv4) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_loan_record** +> LoanRecord get_loan_record(loan_record_id, loan_id) -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' +Get one single loan record + +### Example -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) +* Api Key Authentication (apiv4): +```python +from __future__ import print_function +import gate_api +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) +loan_record_id = '12345' # str | Loan record ID loan_id = '12345' # str | Loan ID -loan_patch = gate_api.LoanPatch() # LoanPatch | try: - # Modify a loan - api_response = api_instance.update_loan(loan_id, loan_patch) + # Get one single loan record + api_response = api_instance.get_loan_record(loan_record_id, loan_id) print(api_response) except ApiException as e: - print("Exception when calling MarginApi->update_loan: %s\n" % e) + print("Exception when calling MarginApi->get_loan_record: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- + **loan_record_id** | **str**| Loan record ID | **loan_id** | **str**| Loan ID | - **loan_patch** | [**LoanPatch**](LoanPatch.md)| | ### Return type -[**Loan**](Loan.md) +[**LoanRecord**](LoanRecord.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Detail retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **update_loan_record** @@ -740,17 +1032,28 @@ Only `auto_renew` modification is supported currently ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.MarginApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.MarginApi(api_client) loan_record_id = '12345' # str | Loan record ID loan_patch = gate_api.LoanPatch() # LoanPatch | @@ -775,12 +1078,17 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Loan record updated | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/GateErrorResponse.md b/docs/OpenOrders.md similarity index 57% rename from docs/GateErrorResponse.md rename to docs/OpenOrders.md index 9cb36b0..e57cbf6 100644 --- a/docs/GateErrorResponse.md +++ b/docs/OpenOrders.md @@ -1,10 +1,11 @@ -# GateErrorResponse +# OpenOrders ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**label** | **str** | Error label | [optional] -**message** | **str** | Detailed error message | [optional] +**currency_pair** | **str** | Currency pair | [optional] +**total** | **int** | Total open orders in this currency pair | [optional] +**orders** | [**list[Order]**](Order.md) | | [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/Order.md b/docs/Order.md index 5994852..5a4b242 100644 --- a/docs/Order.md +++ b/docs/Order.md @@ -1,13 +1,14 @@ # Order +Spot order details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | Order ID | [optional] -**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) | [optional] -**create_time** | **str** | Order creation time | [optional] -**update_time** | **str** | Order last modification time | [optional] -**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] +**id** | **str** | Order ID | [optional] [readonly] +**text** | **str** | User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) | [optional] +**create_time** | **str** | Order creation time | [optional] [readonly] +**update_time** | **str** | Order last modification time | [optional] [readonly] +**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] [readonly] **currency_pair** | **str** | Currency pair | **type** | **str** | Order type. limit - limit order | [optional] [default to 'limit'] **account** | **str** | Account type. spot - use spot account; margin - use margin account | [optional] [default to 'spot'] @@ -16,16 +17,16 @@ Name | Type | Description | Notes **price** | **str** | Order price | **time_in_force** | **str** | Time in force - gtc: GoodTillCancelled - ioc: ImmediateOrCancelled, taker only - poc: PendingOrCancelled, makes a post-only order that always enjoys a maker fee | [optional] [default to 'gtc'] **auto_borrow** | **bool** | Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. | [optional] -**left** | **str** | Amount left to fill | [optional] -**fill_price** | **str** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] -**filled_total** | **str** | Total filled in quote currency | [optional] -**fee** | **str** | Fee deducted | [optional] -**fee_currency** | **str** | Fee currency unit | [optional] -**point_fee** | **str** | Point used to deduct fee | [optional] -**gt_fee** | **str** | GT used to deduct fee | [optional] -**gt_discount** | **bool** | Whether GT fee discount is used | [optional] -**rebated_fee** | **str** | Rebated fee | [optional] -**rebated_fee_currency** | **str** | Rebated fee currency unit | [optional] +**left** | **str** | Amount left to fill | [optional] [readonly] +**fill_price** | **str** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] [readonly] +**filled_total** | **str** | Total filled in quote currency | [optional] [readonly] +**fee** | **str** | Fee deducted | [optional] [readonly] +**fee_currency** | **str** | Fee currency unit | [optional] [readonly] +**point_fee** | **str** | Point used to deduct fee | [optional] [readonly] +**gt_fee** | **str** | GT used to deduct fee | [optional] [readonly] +**gt_discount** | **bool** | Whether GT fee discount is used | [optional] [readonly] +**rebated_fee** | **str** | Rebated fee | [optional] [readonly] +**rebated_fee_currency** | **str** | Rebated fee currency unit | [optional] [readonly] [[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/Position.md b/docs/Position.md index e35007d..5ca6ba6 100644 --- a/docs/Position.md +++ b/docs/Position.md @@ -1,28 +1,29 @@ # Position +Futures position details ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**user** | **int** | User ID | [optional] -**contract** | **str** | Futures contract | [optional] -**size** | **int** | Position size | [optional] +**user** | **int** | User ID | [optional] [readonly] +**contract** | **str** | Futures contract | [optional] [readonly] +**size** | **int** | Position size | [optional] [readonly] **leverage** | **str** | Position leverage. 0 means cross margin; positive number means isolated margin | [optional] **risk_limit** | **str** | Position risk limit | [optional] -**leverage_max** | **str** | Maximum leverage under current risk limit | [optional] -**maintenance_rate** | **str** | Maintenance rate under current risk limit | [optional] -**value** | **str** | Position value calculated in settlement currency | [optional] +**leverage_max** | **str** | Maximum leverage under current risk limit | [optional] [readonly] +**maintenance_rate** | **str** | Maintenance rate under current risk limit | [optional] [readonly] +**value** | **str** | Position value calculated in settlement currency | [optional] [readonly] **margin** | **str** | Position margin | [optional] -**entry_price** | **str** | Entry price | [optional] -**liq_price** | **str** | Liquidation price | [optional] -**mark_price** | **str** | Current mark price | [optional] -**unrealised_pnl** | **str** | Unrealized PNL | [optional] -**realised_pnl** | **str** | Realized PNL | [optional] -**history_pnl** | **str** | History realized PNL | [optional] -**last_close_pnl** | **str** | PNL of last position close | [optional] -**realised_point** | **str** | Realized POINT PNL | [optional] -**history_point** | **str** | History realized POINT PNL | [optional] -**adl_ranking** | **int** | ADL ranking, range from 1 to 5 | [optional] -**pending_orders** | **int** | Current open orders | [optional] +**entry_price** | **str** | Entry price | [optional] [readonly] +**liq_price** | **str** | Liquidation price | [optional] [readonly] +**mark_price** | **str** | Current mark price | [optional] [readonly] +**unrealised_pnl** | **str** | Unrealized PNL | [optional] [readonly] +**realised_pnl** | **str** | Realized PNL | [optional] [readonly] +**history_pnl** | **str** | History realized PNL | [optional] [readonly] +**last_close_pnl** | **str** | PNL of last position close | [optional] [readonly] +**realised_point** | **str** | Realized POINT PNL | [optional] [readonly] +**history_point** | **str** | History realized POINT PNL | [optional] [readonly] +**adl_ranking** | **int** | ADL ranking, range from 1 to 5 | [optional] [readonly] +**pending_orders** | **int** | Current open orders | [optional] [readonly] **close_order** | [**PositionCloseOrder**](PositionCloseOrder.md) | | [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/PositionClose.md b/docs/PositionClose.md index 0641a31..2573f6b 100644 --- a/docs/PositionClose.md +++ b/docs/PositionClose.md @@ -3,11 +3,11 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**time** | **float** | Position close time | [optional] -**contract** | **str** | Futures contract | [optional] -**side** | **str** | Position side, long or short | [optional] -**pnl** | **str** | PNL | [optional] -**text** | **str** | Text of close order | [optional] +**time** | **float** | Position close time | [optional] [readonly] +**contract** | **str** | Futures contract | [optional] [readonly] +**side** | **str** | Position side, long or short | [optional] [readonly] +**pnl** | **str** | PNL | [optional] [readonly] +**text** | **str** | Text of close order | [optional] [readonly] [[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/PositionCloseOrder.md b/docs/PositionCloseOrder.md index 43883ed..6f5540d 100644 --- a/docs/PositionCloseOrder.md +++ b/docs/PositionCloseOrder.md @@ -1,5 +1,6 @@ # PositionCloseOrder +Current close order if any, or `null` ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/SpotApi.md b/docs/SpotApi.md index d78b256..4cf4fa0 100644 --- a/docs/SpotApi.md +++ b/docs/SpotApi.md @@ -4,300 +4,347 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- -[**cancel_batch_orders**](SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list -[**cancel_order**](SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order -[**cancel_orders**](SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair +[**list_currency_pairs**](SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported +[**get_currency_pair**](SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order +[**list_tickers**](SpotApi.md#list_tickers) | **GET** /spot/tickers | Retrieve ticker information +[**list_order_book**](SpotApi.md#list_order_book) | **GET** /spot/order_book | Retrieve order book +[**list_trades**](SpotApi.md#list_trades) | **GET** /spot/trades | Retrieve market trades +[**list_candlesticks**](SpotApi.md#list_candlesticks) | **GET** /spot/candlesticks | Market candlesticks +[**get_fee**](SpotApi.md#get_fee) | **GET** /spot/fee | Query user trading fee rates +[**list_spot_accounts**](SpotApi.md#list_spot_accounts) | **GET** /spot/accounts | List spot accounts [**create_batch_orders**](SpotApi.md#create_batch_orders) | **POST** /spot/batch_orders | Create a batch of orders +[**list_all_open_orders**](SpotApi.md#list_all_open_orders) | **GET** /spot/open_orders | List all open orders +[**list_orders**](SpotApi.md#list_orders) | **GET** /spot/orders | List orders [**create_order**](SpotApi.md#create_order) | **POST** /spot/orders | Create an order -[**get_currency_pair**](SpotApi.md#get_currency_pair) | **GET** /spot/currency_pairs/{currency_pair} | Get detail of one single order +[**cancel_orders**](SpotApi.md#cancel_orders) | **DELETE** /spot/orders | Cancel all `open` orders in specified currency pair +[**cancel_batch_orders**](SpotApi.md#cancel_batch_orders) | **POST** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list [**get_order**](SpotApi.md#get_order) | **GET** /spot/orders/{order_id} | Get a single order -[**list_candlesticks**](SpotApi.md#list_candlesticks) | **GET** /spot/candlesticks | Market candlesticks -[**list_currency_pairs**](SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported +[**cancel_order**](SpotApi.md#cancel_order) | **DELETE** /spot/orders/{order_id} | Cancel a single order [**list_my_trades**](SpotApi.md#list_my_trades) | **GET** /spot/my_trades | List personal trading history -[**list_order_book**](SpotApi.md#list_order_book) | **GET** /spot/order_book | Retrieve order book -[**list_orders**](SpotApi.md#list_orders) | **GET** /spot/orders | List orders -[**list_spot_accounts**](SpotApi.md#list_spot_accounts) | **GET** /spot/accounts | List spot accounts -[**list_tickers**](SpotApi.md#list_tickers) | **GET** /spot/tickers | Retrieve ticker information -[**list_trades**](SpotApi.md#list_trades) | **GET** /spot/trades | Retrieve market trades -# **cancel_batch_orders** -> list[CancelOrderResult] cancel_batch_orders(cancel_order) - -Cancel a batch of orders with an ID list +# **list_currency_pairs** +> list[CurrencyPair] list_currency_pairs() -Multiple currency pairs can be specified, but maximum 20 orders are allowed per request +List all currency pairs supported ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -cancel_order = [gate_api.CancelOrder()] # list[CancelOrder] | +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) try: - # Cancel a batch of orders with an ID list - api_response = api_instance.cancel_batch_orders(cancel_order) + # List all currency pairs supported + api_response = api_instance.list_currency_pairs() print(api_response) except ApiException as e: - print("Exception when calling SpotApi->cancel_batch_orders: %s\n" % e) + print("Exception when calling SpotApi->list_currency_pairs: %s\n" % e) ``` ### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **cancel_order** | [**list[CancelOrder]**](CancelOrder.md)| | +This endpoint does not need any parameter. ### Return type -[**list[CancelOrderResult]**](CancelOrderResult.md) +[**list[CurrencyPair]**](CurrencyPair.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | All currency pairs retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_order** -> Order cancel_order(order_id, currency_pair) +# **get_currency_pair** +> CurrencyPair get_currency_pair(currency_pair) -Cancel a single order +Get detail of one single order ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -order_id = '12345' # str | ID returned on order successfully being created -currency_pair = 'BTC_USDT' # str | Currency pair +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'ETH_BTC' # str | Currency pair try: - # Cancel a single order - api_response = api_instance.cancel_order(order_id, currency_pair) + # Get detail of one single order + api_response = api_instance.get_currency_pair(currency_pair) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->cancel_order: %s\n" % e) + print("Exception when calling SpotApi->get_currency_pair: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order_id** | **str**| ID returned on order successfully being created | **currency_pair** | **str**| Currency pair | ### Return type -[**Order**](Order.md) +[**CurrencyPair**](CurrencyPair.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **cancel_orders** -> list[Order] cancel_orders(currency_pair, side=side, account=account) +# **list_tickers** +> list[Ticker] list_tickers(currency_pair=currency_pair) -Cancel all `open` orders in specified currency pair +Retrieve ticker information + +Return only related data if `currency_pair` is specified; otherwise return all of them ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -currency_pair = 'BTC_USDT' # str | Currency pair -side = 'sell' # str | All bids or asks. Both included in not specified (optional) -account = 'spot' # str | Specify account type. Default to all account types being included (optional) +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'BTC_USDT' # str | Currency pair (optional) try: - # Cancel all `open` orders in specified currency pair - api_response = api_instance.cancel_orders(currency_pair, side=side, account=account) + # Retrieve ticker information + api_response = api_instance.list_tickers(currency_pair=currency_pair) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->cancel_orders: %s\n" % e) + print("Exception when calling SpotApi->list_tickers: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency_pair** | **str**| Currency pair | - **side** | **str**| All bids or asks. Both included in not specified | [optional] - **account** | **str**| Specify account type. Default to all account types being included | [optional] + **currency_pair** | **str**| Currency pair | [optional] ### Return type -[**list[Order]**](Order.md) +[**list[Ticker]**](Ticker.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_batch_orders** -> list[BatchOrder] create_batch_orders(order) +# **list_order_book** +> OrderBook list_order_book(currency_pair, interval=interval, limit=limit) -Create a batch of orders +Retrieve order book -Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders +Order book will be sorted by price from high to low on bids; reversed on asks ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -order = [gate_api.Order()] # list[Order] | +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'BTC_USDT' # str | Currency pair +interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') +limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) try: - # Create a batch of orders - api_response = api_instance.create_batch_orders(order) + # Retrieve order book + api_response = api_instance.list_order_book(currency_pair, interval=interval, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->create_batch_orders: %s\n" % e) + print("Exception when calling SpotApi->list_order_book: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**list[Order]**](Order.md)| | + **currency_pair** | **str**| Currency pair | + **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] + **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] ### Return type -[**list[BatchOrder]**](BatchOrder.md) +[**OrderBook**](OrderBook.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **create_order** -> Order create_order(order) +# **list_trades** +> list[Trade] list_trades(currency_pair, limit=limit, last_id=last_id) -Create an order +Retrieve market trades ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -order = gate_api.Order() # Order | +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'BTC_USDT' # str | Currency pair +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) try: - # Create an order - api_response = api_instance.create_order(order) + # Retrieve market trades + api_response = api_instance.list_trades(currency_pair, limit=limit, last_id=last_id) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->create_order: %s\n" % e) + print("Exception when calling SpotApi->list_trades: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order** | [**Order**](Order.md)| | + **currency_pair** | **str**| Currency pair | + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] ### Return type -[**Order**](Order.md) +[**list[Trade]**](Trade.md) ### Authorization -Authentication with API key and secret is required +No authorization required ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_currency_pair** -> CurrencyPair get_currency_pair(currency_pair) +# **list_candlesticks** +> list[list[str]] list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval) -Get detail of one single order +Market candlesticks + +Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` ### Example ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() -currency_pair = 'ETH_BTC' # str | Currency pair +from gate_api.exceptions import ApiException +# 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( + host = "https://api.gateio.ws/api/v4" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'BTC_USDT' # str | Currency pair +limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) +_from = 1546905600 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) +to = 1546935600 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) +interval = '30m' # str | Interval time between data points (optional) (default to '30m') try: - # Get detail of one single order - api_response = api_instance.get_currency_pair(currency_pair) + # Market candlesticks + api_response = api_instance.list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->get_currency_pair: %s\n" % e) + print("Exception when calling SpotApi->list_candlesticks: %s\n" % e) ``` ### Parameters @@ -305,10 +352,14 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **currency_pair** | **str**| Currency pair | + **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] + **_from** | **int**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] + **to** | **int**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] + **interval** | **str**| Interval time between data points | [optional] [default to '30m'] ### Return type -[**CurrencyPair**](CurrencyPair.md) +**list[list[str]]** ### Authorization @@ -319,236 +370,319 @@ No authorization required - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **get_order** -> Order get_order(order_id, currency_pair) +# **get_fee** +> TradeFee get_fee(currency_pair=currency_pair) -Get a single order +Query user trading fee rates ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -order_id = '12345' # str | ID returned on order successfully being created -currency_pair = 'BTC_USDT' # str | Currency pair +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency_pair = 'BTC_USDT' # str | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs (optional) try: - # Get a single order - api_response = api_instance.get_order(order_id, currency_pair) + # Query user trading fee rates + api_response = api_instance.get_fee(currency_pair=currency_pair) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->get_order: %s\n" % e) + print("Exception when calling SpotApi->get_fee: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **order_id** | **str**| ID returned on order successfully being created | - **currency_pair** | **str**| Currency pair | + **currency_pair** | **str**| Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs | [optional] ### Return type -[**Order**](Order.md) +[**TradeFee**](TradeFee.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successfully retrieved | - | -# **list_candlesticks** -> list[list[str]] list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Market candlesticks +# **list_spot_accounts** +> list[SpotAccount] list_spot_accounts(currency=currency) -Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` +List spot accounts ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() -currency_pair = 'BTC_USDT' # str | Currency pair -limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100) -_from = 1546905600 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional) -to = 1546935600 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional) -interval = '30m' # str | Interval time between data points (optional) (default to '30m') +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +currency = 'BTC' # str | Retrieved specified currency related data (optional) try: - # Market candlesticks - api_response = api_instance.list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval) + # List spot accounts + api_response = api_instance.list_spot_accounts(currency=currency) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_candlesticks: %s\n" % e) + print("Exception when calling SpotApi->list_spot_accounts: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency_pair** | **str**| Currency pair | - **limit** | **int**| Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] - **_from** | **int**| Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] - **to** | **int**| End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] - **interval** | **str**| Interval time between data points | [optional] [default to '30m'] + **currency** | **str**| Retrieved specified currency related data | [optional] ### Return type -**list[list[str]]** +[**list[SpotAccount]**](SpotAccount.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_currency_pairs** -> list[CurrencyPair] list_currency_pairs() +# **create_batch_orders** +> list[BatchOrder] create_batch_orders(order) -List all currency pairs supported +Create a batch of orders + +Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +order = [gate_api.Order()] # list[Order] | try: - # List all currency pairs supported - api_response = api_instance.list_currency_pairs() + # Create a batch of orders + api_response = api_instance.create_batch_orders(order) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_currency_pairs: %s\n" % e) + print("Exception when calling SpotApi->create_batch_orders: %s\n" % e) ``` ### Parameters -This endpoint does not need any parameter. + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**list[Order]**](Order.md)| | ### Return type -[**list[CurrencyPair]**](CurrencyPair.md) +[**list[BatchOrder]**](BatchOrder.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined + - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Request is completed | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_my_trades** -> list[Trade] list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id) +# **list_all_open_orders** +> list[OpenOrders] list_all_open_orders(page=page, limit=limit) -List personal trading history +List all open orders + +List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -currency_pair = 'BTC_USDT' # str | Currency pair -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) page = 1 # int | Page number (optional) (default to 1) -order_id = '12345' # str | List all trades of specified order (optional) +limit = 100 # int | Maximum number of records returned in one page in each currency pair (optional) (default to 100) try: - # List personal trading history - api_response = api_instance.list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id) + # List all open orders + api_response = api_instance.list_all_open_orders(page=page, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_my_trades: %s\n" % e) + print("Exception when calling SpotApi->list_all_open_orders: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency_pair** | **str**| Currency pair | - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] **page** | **int**| Page number | [optional] [default to 1] - **order_id** | **str**| List all trades of specified order | [optional] + **limit** | **int**| Maximum number of records returned in one page in each currency pair | [optional] [default to 100] ### Return type -[**list[Trade]**](Trade.md) +[**list[OpenOrders]**](OpenOrders.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | -# **list_order_book** -> OrderBook list_order_book(currency_pair, interval=interval, limit=limit) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Retrieve order book +# **list_orders** +> list[Order] list_orders(currency_pair, status, page=page, limit=limit) -Order book will be sorted by price from high to low on bids; reversed on asks +List orders ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) currency_pair = 'BTC_USDT' # str | Currency pair -interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0') -limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10) +status = 'open' # str | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled +page = 1 # int | Page number (optional) (default to 1) +limit = 100 # int | Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 (optional) (default to 100) try: - # Retrieve order book - api_response = api_instance.list_order_book(currency_pair, interval=interval, limit=limit) + # List orders + api_response = api_instance.list_orders(currency_pair, status, page=page, limit=limit) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_order_book: %s\n" % e) + print("Exception when calling SpotApi->list_orders: %s\n" % e) ``` ### Parameters @@ -556,53 +690,134 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **currency_pair** | **str**| Currency pair | - **interval** | **str**| Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] - **limit** | **int**| Maximum number of order depth data in asks or bids | [optional] [default to 10] + **status** | **str**| List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled | + **page** | **int**| Page number | [optional] [default to 1] + **limit** | **int**| Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 | [optional] [default to 100] ### Return type -[**OrderBook**](OrderBook.md) +[**list[Order]**](Order.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_orders** -> list[Order] list_orders(currency_pair, status, page=page, limit=limit) +# **create_order** +> Order create_order(order) -List orders +Create an order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +order = gate_api.Order() # Order | + +try: + # Create an order + api_response = api_instance.create_order(order) + print(api_response) +except ApiException as e: + print("Exception when calling SpotApi->create_order: %s\n" % e) +``` + +### Parameters -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order** | [**Order**](Order.md)| | + +### Return type + +[**Order**](Order.md) -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) +### Authorization + +[apiv4](../README.md#apiv4) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Order created. | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **cancel_orders** +> list[Order] cancel_orders(currency_pair, side=side, account=account) + +Cancel all `open` orders in specified currency pair + +### Example + +* Api Key Authentication (apiv4): +```python +from __future__ import print_function +import gate_api +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) currency_pair = 'BTC_USDT' # str | Currency pair -status = 'open' # str | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled -page = 1 # int | Page number (optional) (default to 1) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +side = 'sell' # str | All bids or asks. Both included in not specified (optional) +account = 'spot' # str | Specify account type. Default to all account types being included (optional) try: - # List orders - api_response = api_instance.list_orders(currency_pair, status, page=page, limit=limit) + # Cancel all `open` orders in specified currency pair + api_response = api_instance.cancel_orders(currency_pair, side=side, account=account) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_orders: %s\n" % e) + print("Exception when calling SpotApi->cancel_orders: %s\n" % e) ``` ### Parameters @@ -610,9 +825,8 @@ except ApiException as e: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **currency_pair** | **str**| Currency pair | - **status** | **str**| List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled | - **page** | **int**| Page number | [optional] [default to 1] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **side** | **str**| All bids or asks. Both included in not specified | [optional] + **account** | **str**| Specify account type. Default to all account types being included | [optional] ### Return type @@ -620,135 +834,261 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Batch cancellation request accepted. Query order status by listing orders | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_spot_accounts** -> list[SpotAccount] list_spot_accounts(currency=currency) +# **cancel_batch_orders** +> list[CancelOrderResult] cancel_batch_orders(cancel_order) -List spot accounts +Cancel a batch of orders with an ID list + +Multiple currency pairs can be specified, but maximum 20 orders are allowed per request ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +cancel_order = [gate_api.CancelOrder()] # list[CancelOrder] | -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' +try: + # Cancel a batch of orders with an ID list + api_response = api_instance.cancel_batch_orders(cancel_order) + print(api_response) +except ApiException as e: + print("Exception when calling SpotApi->cancel_batch_orders: %s\n" % e) +``` -# create an instance of the API class -api_instance = gate_api.SpotApi(gate_api.ApiClient(configuration)) -currency = 'BTC' # str | Retrieved specified currency related data (optional) +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **cancel_order** | [**list[CancelOrder]**](CancelOrder.md)| | + +### Return type + +[**list[CancelOrderResult]**](CancelOrderResult.md) + +### Authorization + +[apiv4](../README.md#apiv4) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Batch cancellation completed | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_order** +> Order get_order(order_id, currency_pair) + +Get a single order + +### Example + +* Api Key Authentication (apiv4): +```python +from __future__ import print_function +import gate_api +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +order_id = '12345' # str | ID returned on order successfully being created +currency_pair = 'BTC_USDT' # str | Currency pair try: - # List spot accounts - api_response = api_instance.list_spot_accounts(currency=currency) + # Get a single order + api_response = api_instance.get_order(order_id, currency_pair) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_spot_accounts: %s\n" % e) + print("Exception when calling SpotApi->get_order: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency** | **str**| Retrieved specified currency related data | [optional] + **order_id** | **str**| ID returned on order successfully being created | + **currency_pair** | **str**| Currency pair | ### Return type -[**list[SpotAccount]**](SpotAccount.md) +[**Order**](Order.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Detail retrieved | - | -# **list_tickers** -> list[Ticker] list_tickers(currency_pair=currency_pair) +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -Retrieve ticker information +# **cancel_order** +> Order cancel_order(order_id, currency_pair) -Return only related data if `currency_pair` is specified; otherwise return all of them +Cancel a single order ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() -currency_pair = 'BTC_USDT' # str | Currency pair (optional) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) +order_id = '12345' # str | ID returned on order successfully being created +currency_pair = 'BTC_USDT' # str | Currency pair try: - # Retrieve ticker information - api_response = api_instance.list_tickers(currency_pair=currency_pair) + # Cancel a single order + api_response = api_instance.cancel_order(order_id, currency_pair) print(api_response) except ApiException as e: - print("Exception when calling SpotApi->list_tickers: %s\n" % e) + print("Exception when calling SpotApi->cancel_order: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency_pair** | **str**| Currency pair | [optional] + **order_id** | **str**| ID returned on order successfully being created | + **currency_pair** | **str**| Currency pair | ### Return type -[**list[Ticker]**](Ticker.md) +[**Order**](Order.md) ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Order cancelled | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_trades** -> list[Trade] list_trades(currency_pair, limit=limit, last_id=last_id) +# **list_my_trades** +> list[Trade] list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id) -Retrieve market trades +List personal trading history ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -# create an instance of the API class -api_instance = gate_api.SpotApi() +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.SpotApi(api_client) currency_pair = 'BTC_USDT' # str | Currency pair limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional) +page = 1 # int | Page number (optional) (default to 1) +order_id = '12345' # str | List all trades of specified order (optional) try: - # Retrieve market trades - api_response = api_instance.list_trades(currency_pair, limit=limit, last_id=last_id) + # 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 ApiException as e: - print("Exception when calling SpotApi->list_trades: %s\n" % e) + print("Exception when calling SpotApi->list_my_trades: %s\n" % e) ``` ### Parameters @@ -757,7 +1097,8 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **currency_pair** | **str**| Currency pair | **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **last_id** | **str**| Specify list staring point using the `id` of last record in previous list-query results | [optional] + **page** | **int**| Page number | [optional] [default to 1] + **order_id** | **str**| List all trades of specified order | [optional] ### Return type @@ -765,12 +1106,17 @@ Name | Type | Description | Notes ### Authorization -No authorization required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/SubAccountTransfer.md b/docs/SubAccountTransfer.md index 7c772d5..36a35d8 100644 --- a/docs/SubAccountTransfer.md +++ b/docs/SubAccountTransfer.md @@ -7,9 +7,9 @@ Name | Type | Description | Notes **sub_account** | **str** | Sub account user ID | **direction** | **str** | Transfer direction. to - transfer into sub account; from - transfer out from sub account | **amount** | **str** | Transfer amount | -**uid** | **str** | Main account user ID | [optional] -**timest** | **str** | Transfer timestamp | [optional] -**source** | **str** | Where the operation is initiated from | [optional] +**uid** | **str** | Main account user ID | [optional] [readonly] +**timest** | **str** | Transfer timestamp | [optional] [readonly] +**source** | **str** | Where the operation is initiated from | [optional] [readonly] [[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/TradeFee.md b/docs/TradeFee.md new file mode 100644 index 0000000..15ddaf0 --- /dev/null +++ b/docs/TradeFee.md @@ -0,0 +1,16 @@ +# TradeFee + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**user_id** | **int** | User ID | [optional] +**taker_fee** | **str** | taker fee rate | [optional] +**maker_fee** | **str** | maker fee rate | [optional] +**gt_discount** | **bool** | Is GT deduction is enabled | [optional] +**gt_taker_fee** | **str** | Taker fee rate if using GT deduction. It will be 0 if GT deduction is disabled | [optional] +**gt_maker_fee** | **str** | Maker fee rate if using GT deduction. It will be 0 if GT deduction is disabled | [optional] +**loan_fee** | **str** | Loan fee rate of margin lending | [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/Transfer.md b/docs/Transfer.md index d01aac0..2c7e018 100644 --- a/docs/Transfer.md +++ b/docs/Transfer.md @@ -1,5 +1,6 @@ # Transfer +Accounts available to transfer: - `spot`: spot account - `margin`: margin account - `futures`: perpetual futures account - `delivery`: delivery futures account ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- diff --git a/docs/WalletApi.md b/docs/WalletApi.md index 70af80e..21f5474 100644 --- a/docs/WalletApi.md +++ b/docs/WalletApi.md @@ -5,10 +5,10 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- [**get_deposit_address**](WalletApi.md#get_deposit_address) | **GET** /wallet/deposit_address | Generate currency deposit address +[**list_withdrawals**](WalletApi.md#list_withdrawals) | **GET** /wallet/withdrawals | Retrieve withdrawal records [**list_deposits**](WalletApi.md#list_deposits) | **GET** /wallet/deposits | Retrieve deposit records +[**transfer**](WalletApi.md#transfer) | **POST** /wallet/transfers | Transfer between trading accounts [**list_sub_account_transfers**](WalletApi.md#list_sub_account_transfers) | **GET** /wallet/sub_account_transfers | Transfer records between main and sub accounts -[**list_withdrawals**](WalletApi.md#list_withdrawals) | **GET** /wallet/withdrawals | Retrieve withdrawal records -[**transfer**](WalletApi.md#transfer) | **POST** /wallet/transfers | Transfer between accounts [**transfer_with_sub_account**](WalletApi.md#transfer_with_sub_account) | **POST** /wallet/sub_account_transfers | Transfer between main and sub accounts @@ -19,17 +19,28 @@ Generate currency deposit address ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) currency = 'currency_example' # str | Currency name try: @@ -52,35 +63,51 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Address successfully generated | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_deposits** -> list[LedgerRecord] list_deposits(currency=currency, _from=_from, to=to, limit=limit, offset=offset) +# **list_withdrawals** +> list[LedgerRecord] list_withdrawals(currency=currency, _from=_from, to=to, limit=limit, offset=offset) -Retrieve deposit records +Retrieve withdrawal records Record time range cannot exceed 30 days ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) currency = 'BTC' # str | Filter by currency. Return all currency records if not specified (optional) _from = 56 # int | Time range beginning, default to 7 days before current time (optional) to = 56 # int | Time range ending, default to current time (optional) @@ -88,11 +115,11 @@ limit = 100 # int | Maximum number of records returned in one list (optional) (d offset = 0 # int | List offset, starting from 0 (optional) (default to 0) try: - # Retrieve deposit records - api_response = api_instance.list_deposits(currency=currency, _from=_from, to=to, limit=limit, offset=offset) + # Retrieve withdrawal records + api_response = api_instance.list_withdrawals(currency=currency, _from=_from, to=to, limit=limit, offset=offset) print(api_response) except ApiException as e: - print("Exception when calling WalletApi->list_deposits: %s\n" % e) + print("Exception when calling WalletApi->list_withdrawals: %s\n" % e) ``` ### Parameters @@ -111,54 +138,70 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_sub_account_transfers** -> list[SubAccountTransfer] list_sub_account_transfers(sub_uid=sub_uid, _from=_from, to=to, limit=limit, offset=offset) +# **list_deposits** +> list[LedgerRecord] list_deposits(currency=currency, _from=_from, to=to, limit=limit, offset=offset) -Transfer records between main and sub accounts +Retrieve deposit records -Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved +Record time range cannot exceed 30 days ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) -sub_uid = '10003' # str | Sub account user ID. Return records related to all sub accounts if not specified (optional) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) +currency = 'BTC' # str | Filter by currency. Return all currency records if not specified (optional) _from = 56 # int | Time range beginning, default to 7 days before current time (optional) to = 56 # int | Time range ending, default to current time (optional) limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) offset = 0 # int | List offset, starting from 0 (optional) (default to 0) 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) + # Retrieve deposit records + api_response = api_instance.list_deposits(currency=currency, _from=_from, to=to, limit=limit, offset=offset) print(api_response) except ApiException as e: - print("Exception when calling WalletApi->list_sub_account_transfers: %s\n" % e) + print("Exception when calling WalletApi->list_deposits: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **sub_uid** | **str**| Sub account user ID. Return records related to all sub accounts if not specified | [optional] + **currency** | **str**| Filter by currency. Return all currency records if not specified | [optional] **_from** | **int**| Time range beginning, default to 7 days before current time | [optional] **to** | **int**| Time range ending, default to current time | [optional] **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] @@ -166,125 +209,162 @@ Name | Type | Description | Notes ### Return type -[**list[SubAccountTransfer]**](SubAccountTransfer.md) +[**list[LedgerRecord]**](LedgerRecord.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: Not defined - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **list_withdrawals** -> list[LedgerRecord] list_withdrawals(currency=currency, _from=_from, to=to, limit=limit, offset=offset) +# **transfer** +> transfer(transfer) -Retrieve withdrawal records +Transfer between trading accounts -Record time range cannot exceed 30 days +Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) -currency = 'BTC' # str | Filter by currency. Return all currency records if not specified (optional) -_from = 56 # int | Time range beginning, default to 7 days before current time (optional) -to = 56 # int | Time range ending, default to current time (optional) -limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) -offset = 0 # int | List offset, starting from 0 (optional) (default to 0) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) +transfer = gate_api.Transfer() # Transfer | try: - # Retrieve withdrawal records - api_response = api_instance.list_withdrawals(currency=currency, _from=_from, to=to, limit=limit, offset=offset) - print(api_response) + # Transfer between trading accounts + api_instance.transfer(transfer) except ApiException as e: - print("Exception when calling WalletApi->list_withdrawals: %s\n" % e) + print("Exception when calling WalletApi->transfer: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **currency** | **str**| Filter by currency. Return all currency records if not specified | [optional] - **_from** | **int**| Time range beginning, default to 7 days before current time | [optional] - **to** | **int**| Time range ending, default to current time | [optional] - **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] - **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] + **transfer** | [**Transfer**](Transfer.md)| | ### Return type -[**list[LedgerRecord]**](LedgerRecord.md) +void (empty response body) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: Not defined - - **Accept**: application/json + - **Content-Type**: application/json + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Balance transferred | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **transfer** -> transfer(transfer) +# **list_sub_account_transfers** +> list[SubAccountTransfer] list_sub_account_transfers(sub_uid=sub_uid, _from=_from, to=to, limit=limit, offset=offset) -Transfer between accounts +Transfer records between main and sub accounts -Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 2. spot - delivery +Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) -transfer = gate_api.Transfer() # Transfer | +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) +sub_uid = '10003' # str | Sub account user ID. Return records related to all sub accounts if not specified (optional) +_from = 56 # int | Time range beginning, default to 7 days before current time (optional) +to = 56 # int | Time range ending, default to current time (optional) +limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100) +offset = 0 # int | List offset, starting from 0 (optional) (default to 0) try: - # Transfer between accounts - api_instance.transfer(transfer) + # 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 ApiException as e: - print("Exception when calling WalletApi->transfer: %s\n" % e) + print("Exception when calling WalletApi->list_sub_account_transfers: %s\n" % e) ``` ### Parameters Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **transfer** | [**Transfer**](Transfer.md)| | + **sub_uid** | **str**| Sub account user ID. Return records related to all sub accounts if not specified | [optional] + **_from** | **int**| Time range beginning, default to 7 days before current time | [optional] + **to** | **int**| Time range ending, default to current time | [optional] + **limit** | **int**| Maximum number of records returned in one list | [optional] [default to 100] + **offset** | **int**| List offset, starting from 0 | [optional] [default to 0] ### Return type -void (empty response body) +[**list[SubAccountTransfer]**](SubAccountTransfer.md) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - - **Content-Type**: application/json - - **Accept**: Not defined + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | List retrieved | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -295,17 +375,28 @@ Transfer between main and sub accounts ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WalletApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WalletApi(api_client) sub_account_transfer = gate_api.SubAccountTransfer() # SubAccountTransfer | try: @@ -327,12 +418,17 @@ void (empty response body) ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: application/json - **Accept**: Not defined +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**204** | Balance transferred | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/WithdrawalApi.md b/docs/WithdrawalApi.md index 0d71702..a45ac37 100644 --- a/docs/WithdrawalApi.md +++ b/docs/WithdrawalApi.md @@ -14,17 +14,28 @@ Withdraw ### Example +* Api Key Authentication (apiv4): ```python from __future__ import print_function import gate_api -from gate_api.rest import ApiException - -configuration = gate_api.Configuration() -configuration.key = 'YOUR_API_KEY' -configuration.secret = 'YOUR_API_SECRET' - -# create an instance of the API class -api_instance = gate_api.WithdrawalApi(gate_api.ApiClient(configuration)) +from gate_api.exceptions import ApiException +# 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 +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure APIv4 key authorization +configuration = gate_api.Configuration( + host = "https://api.gateio.ws/api/v4", + key = "YOU_API_KEY", + secret = "YOUR_API_SECRET" +) + +api_client = gate_api.ApiClient(configuration) +# Create an instance of the API class +api_instance = gate_api.WithdrawalApi(api_client) ledger_record = gate_api.LedgerRecord() # LedgerRecord | try: @@ -47,12 +58,17 @@ Name | Type | Description | Notes ### Authorization -Authentication with API key and secret is required +[apiv4](../README.md#apiv4) ### HTTP request headers - **Content-Type**: application/json - **Accept**: application/json +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | Withdraw request is accepted. Refer to withdrawal records for status | - | + [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/gate_api/__init__.py b/gate_api/__init__.py index 5f3a376..02e4168 100644 --- a/gate_api/__init__.py +++ b/gate_api/__init__.py @@ -14,7 +14,7 @@ from __future__ import absolute_import -__version__ = "4.14.0" +__version__ = "4.15.2" # import apis into sdk package from gate_api.api.delivery_api import DeliveryApi @@ -27,6 +27,12 @@ # import ApiClient from gate_api.api_client import ApiClient from gate_api.configuration import Configuration +from gate_api.exceptions import OpenApiException +from gate_api.exceptions import ApiTypeError +from gate_api.exceptions import ApiValueError +from gate_api.exceptions import ApiKeyError +from gate_api.exceptions import ApiException + # import models into sdk package from gate_api.models.batch_order import BatchOrder from gate_api.models.cancel_order import CancelOrder @@ -51,16 +57,17 @@ from gate_api.models.futures_price_triggered_order import FuturesPriceTriggeredOrder from gate_api.models.futures_ticker import FuturesTicker from gate_api.models.futures_trade import FuturesTrade -from gate_api.models.gate_error_response import GateErrorResponse from gate_api.models.insurance_record import InsuranceRecord from gate_api.models.ledger_record import LedgerRecord from gate_api.models.loan import Loan from gate_api.models.loan_patch import LoanPatch from gate_api.models.loan_record import LoanRecord from gate_api.models.margin_account import MarginAccount +from gate_api.models.margin_account_book import MarginAccountBook from gate_api.models.margin_account_currency import MarginAccountCurrency from gate_api.models.margin_currency_pair import MarginCurrencyPair from gate_api.models.my_futures_trade import MyFuturesTrade +from gate_api.models.open_orders import OpenOrders from gate_api.models.order import Order from gate_api.models.order_book import OrderBook from gate_api.models.position import Position @@ -72,5 +79,6 @@ from gate_api.models.sub_account_transfer import SubAccountTransfer from gate_api.models.ticker import Ticker from gate_api.models.trade import Trade +from gate_api.models.trade_fee import TradeFee from gate_api.models.transfer import Transfer from gate_api.models.trigger_order_response import TriggerOrderResponse diff --git a/gate_api/api/delivery_api.py b/gate_api/api/delivery_api.py index b97f488..275389e 100644 --- a/gate_api/api/delivery_api.py +++ b/gate_api/api/delivery_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class DeliveryApi(object): @@ -32,76 +33,77 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def cancel_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_delivery_contracts(self, settle, **kwargs): # noqa: E501 + """List all futures contracts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_delivery_order(settle, order_id, async_req=True) + >>> thread = api.list_delivery_contracts(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.DeliveryContract] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.cancel_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_delivery_contracts_with_http_info(settle, **kwargs) # noqa: E501 - def cancel_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_delivery_contracts_with_http_info(self, settle, **kwargs): # noqa: E501 + """List all futures contracts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_delivery_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_delivery_contracts_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.DeliveryContract], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_delivery_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_contracts" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_delivery_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `cancel_delivery_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_contracts`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] @@ -112,106 +114,113 @@ def cancel_delivery_order_with_http_info(self, settle, order_id, **kwargs): # n body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/orders/{order_id}', 'DELETE', + '/delivery/{settle}/contracts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='list[DeliveryContract]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_delivery_orders(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all `open` orders matched # noqa: E501 + def get_delivery_contract(self, settle, contract, **kwargs): # noqa: E501 + """Get a single contract # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_delivery_orders(settle, contract, async_req=True) + >>> thread = api.get_delivery_contract(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str side: All bids or asks. Both included in not specified - :return: list[FuturesOrder] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.DeliveryContract + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_delivery_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.cancel_delivery_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.get_delivery_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_delivery_orders_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all `open` orders matched # noqa: E501 + def get_delivery_contract_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get a single contract # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_delivery_orders_with_http_info(settle, contract, async_req=True) + >>> thread = api.get_delivery_contract_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str side: All bids or asks. Both included in not specified - :return: list[FuturesOrder] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.DeliveryContract, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'side'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_delivery_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_delivery_contract" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_delivery_orders`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_delivery_contract`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `cancel_delivery_orders`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `get_delivery_contract`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'side' in local_var_params: - query_params.append(('side', local_var_params['side'])) # noqa: E501 header_params = {} @@ -220,100 +229,137 @@ def cancel_delivery_orders_with_http_info(self, settle, contract, **kwargs): # body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/orders', 'DELETE', + '/delivery/{settle}/contracts/{contract}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesOrder]', # noqa: E501 + response_type='DeliveryContract', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_price_triggered_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_delivery_order_book(self, settle, contract, **kwargs): # noqa: E501 + """Futures order book # noqa: E501 + Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_delivery_order(settle, order_id, async_req=True) + >>> thread = api.list_delivery_order_book(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrderBook + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.cancel_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_delivery_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_price_triggered_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_delivery_order_book_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Futures order book # noqa: E501 + Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_delivery_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_delivery_order_book_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrderBook, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'interval', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_price_triggered_delivery_order" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_order_book" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_price_triggered_delivery_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `cancel_price_triggered_delivery_order`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_order_book`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_delivery_order_book`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 20 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_order_book`, must be a value less than or equal to `20`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_order_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -322,91 +368,124 @@ def cancel_price_triggered_delivery_order_with_http_info(self, settle, order_id, body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/price_orders/{order_id}', 'DELETE', + '/delivery/{settle}/order_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesPriceTriggeredOrder', # noqa: E501 + response_type='FuturesOrderBook', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_price_triggered_delivery_order_list(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all open orders # noqa: E501 + def list_delivery_trades(self, settle, contract, **kwargs): # noqa: E501 + """Futures trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_delivery_order_list(settle, contract, async_req=True) + >>> thread = api.list_delivery_trades(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range + :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. + :param float to: Specify end time in Unix seconds, default to current time + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesTrade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_price_triggered_delivery_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.cancel_price_triggered_delivery_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_delivery_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_price_triggered_delivery_order_list_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all open orders # noqa: E501 + def list_delivery_trades_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Futures trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_delivery_order_list_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_delivery_trades_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range + :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. + :param float to: Specify end time in Unix seconds, default to current time + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesTrade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit', 'last_id', '_from', 'to'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_price_triggered_delivery_order_list" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_price_triggered_delivery_order_list`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_trades`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `cancel_price_triggered_delivery_order_list`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_delivery_trades`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -414,8 +493,16 @@ def cancel_price_triggered_delivery_order_list_with_http_info(self, settle, cont path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 header_params = {} @@ -424,93 +511,122 @@ def cancel_price_triggered_delivery_order_list_with_http_info(self, settle, cont body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/price_orders', 'DELETE', + '/delivery/{settle}/trades', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 + response_type='list[FuturesTrade]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_delivery_order(self, settle, futures_order, **kwargs): # noqa: E501 - """Create a futures order # noqa: E501 + def list_delivery_candlesticks(self, settle, contract, **kwargs): # noqa: E501 + """Get futures candlesticks # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 + Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_delivery_order(settle, futures_order, async_req=True) + >>> thread = api.list_delivery_candlesticks(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesOrder futures_order: (required) - :return: FuturesOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param str interval: Interval time between data points + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesCandlestick] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_delivery_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - else: - (data) = self.create_delivery_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - return data + return self.list_delivery_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - def create_delivery_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501 - """Create a futures order # noqa: E501 + def list_delivery_candlesticks_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get futures candlesticks # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 + Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_delivery_order_with_http_info(settle, futures_order, async_req=True) + >>> thread = api.list_delivery_candlesticks_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesOrder futures_order: (required) - :return: FuturesOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param str interval: Interval time between data points + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesCandlestick], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'futures_order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_delivery_order" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_candlesticks" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `create_delivery_order`") # noqa: E501 - # verify the required parameter 'futures_order' is set - if ('futures_order' not in local_var_params or - local_var_params['futures_order'] is None): - raise ValueError("Missing the required parameter `futures_order` when calling `create_delivery_order`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_candlesticks`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_delivery_candlesticks`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 2000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_candlesticks`, must be a value less than or equal to `2000`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -518,6 +634,16 @@ def create_delivery_order_with_http_info(self, settle, futures_order, **kwargs): path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 header_params = {} @@ -525,97 +651,97 @@ def create_delivery_order_with_http_info(self, settle, futures_order, **kwargs): local_var_files = {} body_params = None - if 'futures_order' in local_var_params: - body_params = local_var_params['futures_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/orders', 'POST', + '/delivery/{settle}/candlesticks', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='list[FuturesCandlestick]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_price_triggered_delivery_order(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 - """Create a price-triggered order # noqa: E501 + def list_delivery_tickers(self, settle, **kwargs): # noqa: E501 + """List futures tickers # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_price_triggered_delivery_order(settle, futures_price_triggered_order, async_req=True) + >>> thread = api.list_delivery_tickers(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) - :return: TriggerOrderResponse - If the method is called asynchronously, + :param str contract: Futures contract + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesTicker] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_price_triggered_delivery_order_with_http_info(settle, futures_price_triggered_order, **kwargs) # noqa: E501 - else: - (data) = self.create_price_triggered_delivery_order_with_http_info(settle, futures_price_triggered_order, **kwargs) # noqa: E501 - return data + return self.list_delivery_tickers_with_http_info(settle, **kwargs) # noqa: E501 - def create_price_triggered_delivery_order_with_http_info(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 - """Create a price-triggered order # noqa: E501 + def list_delivery_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 + """List futures tickers # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_price_triggered_delivery_order_with_http_info(settle, futures_price_triggered_order, async_req=True) + >>> thread = api.list_delivery_tickers_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) - :return: TriggerOrderResponse - If the method is called asynchronously, + :param str contract: Futures contract + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesTicker], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'futures_price_triggered_order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_price_triggered_delivery_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_tickers" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `create_price_triggered_delivery_order`") # noqa: E501 - # verify the required parameter 'futures_price_triggered_order' is set - if ('futures_price_triggered_order' not in local_var_params or - local_var_params['futures_price_triggered_order'] is None): - raise ValueError("Missing the required parameter `futures_price_triggered_order` when calling `create_price_triggered_delivery_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_tickers`" + ) # noqa: E501 collection_formats = {} @@ -624,6 +750,8 @@ def create_price_triggered_delivery_order_with_http_info(self, settle, futures_p path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 header_params = {} @@ -631,107 +759,121 @@ def create_price_triggered_delivery_order_with_http_info(self, settle, futures_p local_var_files = {} body_params = None - if 'futures_price_triggered_order' in local_var_params: - body_params = local_var_params['futures_price_triggered_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/price_orders', 'POST', + '/delivery/{settle}/tickers', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='TriggerOrderResponse', # noqa: E501 + response_type='list[FuturesTicker]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_delivery_contract(self, settle, contract, **kwargs): # noqa: E501 - """Get a single contract # noqa: E501 + def list_delivery_insurance_ledger(self, settle, **kwargs): # noqa: E501 + """Futures insurance balance history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_contract(settle, contract, async_req=True) + >>> thread = api.list_delivery_insurance_ledger(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: DeliveryContract - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.InsuranceRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_delivery_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.get_delivery_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_delivery_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - def get_delivery_contract_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get a single contract # noqa: E501 + def list_delivery_insurance_ledger_with_http_info(self, settle, **kwargs): # noqa: E501 + """Futures insurance balance history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_contract_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_delivery_insurance_ledger_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: DeliveryContract - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.InsuranceRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_delivery_contract" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_insurance_ledger" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_delivery_contract`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `get_delivery_contract`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_insurance_ledger`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_insurance_ledger`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_insurance_ledger`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -740,100 +882,100 @@ def get_delivery_contract_with_http_info(self, settle, contract, **kwargs): # n body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/contracts/{contract}', 'GET', + '/delivery/{settle}/insurance', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='DeliveryContract', # noqa: E501 + response_type='list[InsuranceRecord]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_delivery_accounts(self, settle, **kwargs): # noqa: E501 + """Query futures account # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_order(settle, order_id, async_req=True) + >>> thread = api.list_delivery_accounts(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesAccount + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.get_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_delivery_accounts_with_http_info(settle, **kwargs) # noqa: E501 - def get_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_delivery_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 + """Query futures account # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_delivery_accounts_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesAccount, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_delivery_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_accounts" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_delivery_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `get_delivery_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_accounts`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] @@ -844,100 +986,132 @@ def get_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/orders/{order_id}', 'GET', + '/delivery/{settle}/accounts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='FuturesAccount', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_delivery_position(self, settle, contract, **kwargs): # noqa: E501 - """Get single position # noqa: E501 + def list_delivery_account_book(self, settle, **kwargs): # noqa: E501 + """Query account book # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_position(settle, contract, async_req=True) + >>> thread = api.list_delivery_account_book(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: Position - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int _from: Start timestamp + :param int to: End timestamp + :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesAccountBook] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_delivery_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.get_delivery_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_delivery_account_book_with_http_info(settle, **kwargs) # noqa: E501 - def get_delivery_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get single position # noqa: E501 + def list_delivery_account_book_with_http_info(self, settle, **kwargs): # noqa: E501 + """Query account book # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_delivery_position_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_delivery_account_book_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: Position - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int _from: Start timestamp + :param int to: End timestamp + :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesAccountBook], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'limit', '_from', 'to', 'type'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_delivery_position" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_account_book" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_delivery_position`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `get_delivery_position`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_account_book`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_account_book`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_account_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'type' in local_var_params and local_var_params['type'] is not None: # noqa: E501 + query_params.append(('type', local_var_params['type'])) # noqa: E501 header_params = {} @@ -946,103 +1120,95 @@ def get_delivery_position_with_http_info(self, settle, contract, **kwargs): # n body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/positions/{contract}', 'GET', + '/delivery/{settle}/account_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='list[FuturesAccountBook]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_my_delivery_trades(self, settle, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def list_delivery_positions(self, settle, **kwargs): # noqa: E501 + """List all positions of a user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_my_delivery_trades(settle, async_req=True) + >>> thread = api.list_delivery_positions(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract - :param int order: Futures order ID, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[MyFuturesTrade] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Position] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_my_delivery_trades_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.get_my_delivery_trades_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_delivery_positions_with_http_info(settle, **kwargs) # noqa: E501 - def get_my_delivery_trades_with_http_info(self, settle, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def list_delivery_positions_with_http_info(self, settle, **kwargs): # noqa: E501 + """List all positions of a user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_my_delivery_trades_with_http_info(settle, async_req=True) + >>> thread = api.list_delivery_positions_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract - :param int order: Futures order ID, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[MyFuturesTrade] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'order', 'limit', 'offset', 'last_id', 'count_total'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_my_delivery_trades" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_positions" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_my_delivery_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `get_my_delivery_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `get_my_delivery_trades`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `get_my_delivery_trades`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_positions`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -1050,18 +1216,6 @@ def get_my_delivery_trades_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'order' in local_var_params: - query_params.append(('order', local_var_params['order'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if 'count_total' in local_var_params: - query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -1070,98 +1224,111 @@ def get_my_delivery_trades_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/my_trades', 'GET', + '/delivery/{settle}/positions', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[MyFuturesTrade]', # noqa: E501 + response_type='list[Position]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_price_triggered_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def get_delivery_position(self, settle, contract, **kwargs): # noqa: E501 + """Get single position # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_price_triggered_delivery_order(settle, order_id, async_req=True) + >>> thread = api.get_delivery_position(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.get_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.get_delivery_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - def get_price_triggered_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def get_delivery_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get single position # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_price_triggered_delivery_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.get_delivery_position_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_price_triggered_delivery_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_delivery_position" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_price_triggered_delivery_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `get_price_triggered_delivery_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_delivery_position`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `get_delivery_position`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] @@ -1172,112 +1339,126 @@ def get_price_triggered_delivery_order_with_http_info(self, settle, order_id, ** body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/price_orders/{order_id}', 'GET', + '/delivery/{settle}/positions/{contract}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesPriceTriggeredOrder', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_account_book(self, settle, **kwargs): # noqa: E501 - """Query account book # noqa: E501 + def update_delivery_position_margin(self, settle, contract, change, **kwargs): # noqa: E501 + """Update position margin # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_account_book(settle, async_req=True) + >>> thread = api.update_delivery_position_margin(settle, contract, change, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :param int _from: Start timestamp - :param int to: End timestamp - :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate - :return: list[FuturesAccountBook] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_account_book_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_account_book_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.update_delivery_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - def list_delivery_account_book_with_http_info(self, settle, **kwargs): # noqa: E501 - """Query account book # noqa: E501 + def update_delivery_position_margin_with_http_info(self, settle, contract, change, **kwargs): # noqa: E501 + """Update position margin # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_account_book_with_http_info(settle, async_req=True) + >>> thread = api.update_delivery_position_margin_with_http_info(settle, contract, change, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :param int _from: Start timestamp - :param int to: End timestamp - :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate - :return: list[FuturesAccountBook] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'limit', '_from', 'to', 'type'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'change'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_account_book" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method update_delivery_position_margin" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_account_book`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_account_book`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_account_book`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_delivery_position_margin`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_delivery_position_margin`" + ) # noqa: E501 + # verify the required parameter 'change' is set + if self.api_client.client_side_validation and ( + 'change' not in local_var_params or local_var_params['change'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `change` when calling `update_delivery_position_margin`" + ) # noqa: E501 + collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'type' in local_var_params: - query_params.append(('type', local_var_params['type'])) # noqa: E501 + if 'change' in local_var_params and local_var_params['change'] is not None: # noqa: E501 + query_params.append(('change', local_var_params['change'])) # noqa: E501 header_params = {} @@ -1286,92 +1467,126 @@ def list_delivery_account_book_with_http_info(self, settle, **kwargs): # noqa: body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/account_book', 'GET', + '/delivery/{settle}/positions/{contract}/margin', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesAccountBook]', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_accounts(self, settle, **kwargs): # noqa: E501 - """Query futures account # noqa: E501 + def update_delivery_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501 + """Update position leverage # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_accounts(settle, async_req=True) + >>> thread = api.update_delivery_position_leverage(settle, contract, leverage, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: FuturesAccount - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str leverage: New position leverage (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_accounts_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_accounts_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.update_delivery_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - def list_delivery_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 - """Query futures account # noqa: E501 + def update_delivery_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501 + """Update position leverage # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_accounts_with_http_info(settle, async_req=True) + >>> thread = api.update_delivery_position_leverage_with_http_info(settle, contract, leverage, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: FuturesAccount - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str leverage: New position leverage (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'leverage'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_accounts" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method update_delivery_position_leverage" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_accounts`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_delivery_position_leverage`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_delivery_position_leverage`" + ) # noqa: E501 + # verify the required parameter 'leverage' is set + if self.api_client.client_side_validation and ( + 'leverage' not in local_var_params or local_var_params['leverage'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `leverage` when calling `update_delivery_position_leverage`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'leverage' in local_var_params and local_var_params['leverage'] is not None: # noqa: E501 + query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501 header_params = {} @@ -1380,120 +1595,128 @@ def list_delivery_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/accounts', 'GET', + '/delivery/{settle}/positions/{contract}/leverage', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesAccount', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_candlesticks(self, settle, contract, **kwargs): # noqa: E501 - """Get futures candlesticks # noqa: E501 + def update_delivery_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501 + """Update position risk limit # noqa: E501 - Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_candlesticks(settle, contract, async_req=True) + >>> thread = api.update_delivery_position_risk_limit(settle, contract, risk_limit, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param str interval: Interval time between data points - :return: list[FuturesCandlestick] - If the method is called asynchronously, + :param str risk_limit: New position risk limit (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.update_delivery_position_risk_limit_with_http_info( + settle, contract, risk_limit, **kwargs + ) # noqa: E501 - def list_delivery_candlesticks_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get futures candlesticks # noqa: E501 + def update_delivery_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501 + """Update position risk limit # noqa: E501 - Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_candlesticks_with_http_info(settle, contract, async_req=True) + >>> thread = api.update_delivery_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param str interval: Interval time between data points - :return: list[FuturesCandlestick] - If the method is called asynchronously, + :param str risk_limit: New position risk limit (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'risk_limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_candlesticks" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method update_delivery_position_risk_limit" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_candlesticks`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_delivery_position_risk_limit`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_delivery_candlesticks`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_delivery_position_risk_limit`" + ) # noqa: E501 + # verify the required parameter 'risk_limit' is set + if self.api_client.client_side_validation and ( + 'risk_limit' not in local_var_params or local_var_params['risk_limit'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `risk_limit` when calling `update_delivery_position_risk_limit`" + ) # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 2000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_candlesticks`, must be a value less than or equal to `2000`") # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + if 'risk_limit' in local_var_params and local_var_params['risk_limit'] is not None: # noqa: E501 + query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501 header_params = {} @@ -1502,85 +1725,134 @@ def list_delivery_candlesticks_with_http_info(self, settle, contract, **kwargs): body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/candlesticks', 'GET', + '/delivery/{settle}/positions/{contract}/risk_limit', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesCandlestick]', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_contracts(self, settle, **kwargs): # noqa: E501 - """List all futures contracts # noqa: E501 + def list_delivery_orders(self, settle, status, **kwargs): # noqa: E501 + """List futures orders # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_contracts(settle, async_req=True) + >>> thread = api.list_delivery_orders(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[DeliveryContract] - If the method is called asynchronously, + :param str status: List orders based on status (required) + :param str contract: Futures contract + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_contracts_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_contracts_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - def list_delivery_contracts_with_http_info(self, settle, **kwargs): # noqa: E501 - """List all futures contracts # noqa: E501 + def list_delivery_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 + """List futures orders # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_contracts_with_http_info(settle, async_req=True) + >>> thread = api.list_delivery_orders_with_http_info(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[DeliveryContract] - If the method is called asynchronously, + :param str status: List orders based on status (required) + :param str contract: Futures contract + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'status', 'contract', 'limit', 'offset', 'last_id', 'count_total'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_contracts" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_delivery_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_contracts`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_orders`" + ) # noqa: E501 + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `status` when calling `list_delivery_orders`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_orders`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_delivery_orders`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -1588,6 +1860,18 @@ def list_delivery_contracts_with_http_info(self, settle, **kwargs): # noqa: E50 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if 'count_total' in local_var_params and local_var_params['count_total'] is not None: # noqa: E501 + query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -1596,91 +1880,106 @@ def list_delivery_contracts_with_http_info(self, settle, **kwargs): # noqa: E50 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/contracts', 'GET', + '/delivery/{settle}/orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[DeliveryContract]', # noqa: E501 + response_type='list[FuturesOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_insurance_ledger(self, settle, **kwargs): # noqa: E501 - """Futures insurance balance history # noqa: E501 + def create_delivery_order(self, settle, futures_order, **kwargs): # noqa: E501 + """Create a futures order # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_insurance_ledger(settle, async_req=True) + >>> thread = api.create_delivery_order(settle, futures_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :return: list[InsuranceRecord] - If the method is called asynchronously, + :param FuturesOrder futures_order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.create_delivery_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - def list_delivery_insurance_ledger_with_http_info(self, settle, **kwargs): # noqa: E501 - """Futures insurance balance history # noqa: E501 + def create_delivery_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501 + """Create a futures order # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_insurance_ledger_with_http_info(settle, async_req=True) + >>> thread = api.create_delivery_order_with_http_info(settle, futures_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :return: list[InsuranceRecord] - If the method is called asynchronously, + :param FuturesOrder futures_order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'futures_order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_insurance_ledger" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_delivery_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_insurance_ledger`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_insurance_ledger`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_insurance_ledger`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `create_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'futures_order' is set + if self.api_client.client_side_validation and ( + 'futures_order' not in local_var_params or local_var_params['futures_order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `futures_order` when calling `create_delivery_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -1688,8 +1987,6 @@ def list_delivery_insurance_ledger_with_http_info(self, settle, **kwargs): # no path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -1697,96 +1994,116 @@ def list_delivery_insurance_ledger_with_http_info(self, settle, **kwargs): # no local_var_files = {} body_params = None + if 'futures_order' in local_var_params: + body_params = local_var_params['futures_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/insurance', 'GET', + '/delivery/{settle}/orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[InsuranceRecord]', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_liquidates(self, settle, **kwargs): # noqa: E501 - """List liquidation history # noqa: E501 + def cancel_delivery_orders(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all `open` orders matched # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_liquidates(settle, async_req=True) + >>> thread = api.cancel_delivery_orders(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract - :param int limit: Maximum number of records returned in one list - :param int at: Specify a liquidation timestamp - :return: list[FuturesLiquidate] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str side: All bids or asks. Both included in not specified + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.cancel_delivery_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - def list_delivery_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 - """List liquidation history # noqa: E501 + def cancel_delivery_orders_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all `open` orders matched # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_liquidates_with_http_info(settle, async_req=True) + >>> thread = api.cancel_delivery_orders_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract - :param int limit: Maximum number of records returned in one list - :param int at: Specify a liquidation timestamp - :return: list[FuturesLiquidate] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str side: All bids or asks. Both included in not specified + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit', 'at'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'side'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_liquidates" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_delivery_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_liquidates`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_liquidates`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_liquidates`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_delivery_orders`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `cancel_delivery_orders`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -1794,12 +2111,10 @@ def list_delivery_liquidates_with_http_info(self, settle, **kwargs): # noqa: E5 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'at' in local_var_params: - query_params.append(('at', local_var_params['at'])) # noqa: E501 + if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501 + query_params.append(('side', local_var_params['side'])) # noqa: E501 header_params = {} @@ -1808,114 +2123,115 @@ def list_delivery_liquidates_with_http_info(self, settle, **kwargs): # noqa: E5 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/liquidates', 'GET', + '/delivery/{settle}/orders', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesLiquidate]', # noqa: E501 + response_type='list[FuturesOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_order_book(self, settle, contract, **kwargs): # noqa: E501 - """Futures order book # noqa: E501 + def get_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 - Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_order_book(settle, contract, async_req=True) + >>> thread = api.get_delivery_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: FuturesOrderBook - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.get_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def list_delivery_order_book_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Futures order book # noqa: E501 + def get_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 - Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_order_book_with_http_info(settle, contract, async_req=True) + >>> thread = api.get_delivery_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: FuturesOrderBook - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'interval', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_order_book" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_delivery_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_order_book`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_delivery_order_book`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 20: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_order_book`, must be a value less than or equal to `20`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_order_book`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `get_delivery_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -1924,129 +2240,114 @@ def list_delivery_order_book_with_http_info(self, settle, contract, **kwargs): body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/order_book', 'GET', + '/delivery/{settle}/orders/{order_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrderBook', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_orders(self, settle, status, **kwargs): # noqa: E501 - """List futures orders # noqa: E501 + def cancel_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_orders(settle, status, async_req=True) + >>> thread = api.cancel_delivery_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[FuturesOrder] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - return data + return self.cancel_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def list_delivery_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 - """List futures orders # noqa: E501 + def cancel_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_orders_with_http_info(settle, status, async_req=True) + >>> thread = api.cancel_delivery_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[FuturesOrder] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'status', 'contract', 'limit', 'offset', 'last_id', 'count_total'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_delivery_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_orders`") # noqa: E501 - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_delivery_orders`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_orders`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_orders`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_delivery_orders`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `cancel_delivery_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 + + query_params = [] - query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if 'count_total' in local_var_params: - query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 - header_params = {} form_params = [] @@ -2054,93 +2355,125 @@ def list_delivery_orders_with_http_info(self, settle, status, **kwargs): # noqa body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/orders', 'GET', + '/delivery/{settle}/orders/{order_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesOrder]', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_position_close(self, settle, **kwargs): # noqa: E501 - """List position close history # noqa: E501 + def get_my_delivery_trades(self, settle, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_position_close(settle, async_req=True) + >>> thread = api.get_my_delivery_trades(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract + :param int order: Futures order ID, return related data only if specified :param int limit: Maximum number of records returned in one list - :return: list[PositionClose] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.MyFuturesTrade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_position_close_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_position_close_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.get_my_delivery_trades_with_http_info(settle, **kwargs) # noqa: E501 - def list_delivery_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 - """List position close history # noqa: E501 + def get_my_delivery_trades_with_http_info(self, settle, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_position_close_with_http_info(settle, async_req=True) + >>> thread = api.get_my_delivery_trades_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract + :param int order: Futures order ID, return related data only if specified :param int limit: Maximum number of records returned in one list - :return: list[PositionClose] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.MyFuturesTrade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'order', 'limit', 'offset', 'last_id', 'count_total'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_position_close" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_my_delivery_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_position_close`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_position_close`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_position_close`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_my_delivery_trades`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `get_my_delivery_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `get_my_delivery_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `get_my_delivery_trades`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2148,10 +2481,18 @@ def list_delivery_position_close_with_http_info(self, settle, **kwargs): # noqa path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'order' in local_var_params and local_var_params['order'] is not None: # noqa: E501 + query_params.append(('order', local_var_params['order'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if 'count_total' in local_var_params and local_var_params['count_total'] is not None: # noqa: E501 + query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -2160,85 +2501,113 @@ def list_delivery_position_close_with_http_info(self, settle, **kwargs): # noqa body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/position_close', 'GET', + '/delivery/{settle}/my_trades', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[PositionClose]', # noqa: E501 + response_type='list[MyFuturesTrade]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_positions(self, settle, **kwargs): # noqa: E501 - """List all positions of a user # noqa: E501 + def list_delivery_position_close(self, settle, **kwargs): # noqa: E501 + """List position close history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_positions(settle, async_req=True) + >>> thread = api.list_delivery_position_close(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Position] - If the method is called asynchronously, + :param str contract: Futures contract + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.PositionClose] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_positions_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_positions_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_delivery_position_close_with_http_info(settle, **kwargs) # noqa: E501 - def list_delivery_positions_with_http_info(self, settle, **kwargs): # noqa: E501 - """List all positions of a user # noqa: E501 + def list_delivery_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 + """List position close history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_positions_with_http_info(settle, async_req=True) + >>> thread = api.list_delivery_position_close_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Position] - If the method is called asynchronously, + :param str contract: Futures contract + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.PositionClose], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_positions" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_position_close" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_positions`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_position_close`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_position_close`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_position_close`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2246,6 +2615,10 @@ def list_delivery_positions_with_http_info(self, settle, **kwargs): # noqa: E50 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -2254,95 +2627,115 @@ def list_delivery_positions_with_http_info(self, settle, **kwargs): # noqa: E50 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/positions', 'GET', + '/delivery/{settle}/position_close', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Position]', # noqa: E501 + response_type='list[PositionClose]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_settlements(self, settle, **kwargs): # noqa: E501 - """List settlement history # noqa: E501 + def list_delivery_liquidates(self, settle, **kwargs): # noqa: E501 + """List liquidation history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_settlements(settle, async_req=True) + >>> thread = api.list_delivery_liquidates(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract :param int limit: Maximum number of records returned in one list - :param int at: Specify a settlement timestamp - :return: list[DeliverySettlement] - If the method is called asynchronously, + :param int at: Specify a liquidation timestamp + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesLiquidate] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_settlements_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_settlements_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_delivery_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - def list_delivery_settlements_with_http_info(self, settle, **kwargs): # noqa: E501 - """List settlement history # noqa: E501 + def list_delivery_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 + """List liquidation history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_settlements_with_http_info(settle, async_req=True) + >>> thread = api.list_delivery_liquidates_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract :param int limit: Maximum number of records returned in one list - :param int at: Specify a settlement timestamp - :return: list[DeliverySettlement] - If the method is called asynchronously, + :param int at: Specify a liquidation timestamp + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesLiquidate], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit', 'at'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit', 'at'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_settlements" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_liquidates" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_settlements`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_settlements`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_settlements`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_liquidates`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_liquidates`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_liquidates`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2350,11 +2743,11 @@ def list_delivery_settlements_with_http_info(self, settle, **kwargs): # noqa: E path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'at' in local_var_params: + if 'at' in local_var_params and local_var_params['at'] is not None: # noqa: E501 query_params.append(('at', local_var_params['at'])) # noqa: E501 header_params = {} @@ -2364,87 +2757,115 @@ def list_delivery_settlements_with_http_info(self, settle, **kwargs): # noqa: E body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/settlements', 'GET', + '/delivery/{settle}/liquidates', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[DeliverySettlement]', # noqa: E501 + response_type='list[FuturesLiquidate]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_tickers(self, settle, **kwargs): # noqa: E501 - """List futures tickers # noqa: E501 + def list_delivery_settlements(self, settle, **kwargs): # noqa: E501 + """List settlement history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_tickers(settle, async_req=True) + >>> thread = api.list_delivery_settlements(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract - :return: list[FuturesTicker] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int at: Specify a settlement timestamp + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.DeliverySettlement] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_tickers_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_tickers_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_delivery_settlements_with_http_info(settle, **kwargs) # noqa: E501 - def list_delivery_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 - """List futures tickers # noqa: E501 + def list_delivery_settlements_with_http_info(self, settle, **kwargs): # noqa: E501 + """List settlement history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_tickers_with_http_info(settle, async_req=True) + >>> thread = api.list_delivery_settlements_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract - :return: list[FuturesTicker] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int at: Specify a settlement timestamp + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.DeliverySettlement], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit', 'at'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_tickers" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_delivery_settlements" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_tickers`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_delivery_settlements`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_settlements`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_delivery_settlements`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2452,8 +2873,12 @@ def list_delivery_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'at' in local_var_params and local_var_params['at'] is not None: # noqa: E501 + query_params.append(('at', local_var_params['at'])) # noqa: E501 header_params = {} @@ -2462,103 +2887,130 @@ def list_delivery_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/tickers', 'GET', + '/delivery/{settle}/settlements', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesTicker]', # noqa: E501 + response_type='list[DeliverySettlement]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_delivery_trades(self, settle, contract, **kwargs): # noqa: E501 - """Futures trading history # noqa: E501 + def list_price_triggered_delivery_orders(self, settle, status, **kwargs): # noqa: E501 + """List all auto orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_trades(settle, contract, async_req=True) + >>> thread = api.list_price_triggered_delivery_orders(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) + :param str status: List orders based on status (required) + :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range - :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. - :param float to: Specify end time in Unix seconds, default to current time - :return: list[FuturesTrade] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesPriceTriggeredOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_delivery_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_delivery_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_price_triggered_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - def list_delivery_trades_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Futures trading history # noqa: E501 + def list_price_triggered_delivery_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 + """List all auto orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_delivery_trades_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_price_triggered_delivery_orders_with_http_info(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) + :param str status: List orders based on status (required) + :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range - :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. - :param float to: Specify end time in Unix seconds, default to current time - :return: list[FuturesTrade] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit', 'last_id', '_from', 'to'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'status', 'contract', 'limit', 'offset'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_delivery_trades" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_price_triggered_delivery_orders" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_delivery_trades`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_delivery_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_delivery_trades`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_price_triggered_delivery_orders`" + ) # noqa: E501 + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `status` when calling `list_price_triggered_delivery_orders`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_price_triggered_delivery_orders`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_price_triggered_delivery_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_price_triggered_delivery_orders`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2566,16 +3018,14 @@ def list_delivery_trades_with_http_info(self, settle, contract, **kwargs): # no path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -2584,103 +3034,111 @@ def list_delivery_trades_with_http_info(self, settle, contract, **kwargs): # no body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/trades', 'GET', + '/delivery/{settle}/price_orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesTrade]', # noqa: E501 + response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_price_triggered_delivery_orders(self, settle, status, **kwargs): # noqa: E501 - """List all auto orders # noqa: E501 + def create_price_triggered_delivery_order(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 + """Create a price-triggered order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_price_triggered_delivery_orders(settle, status, async_req=True) + >>> thread = api.create_price_triggered_delivery_order(settle, futures_price_triggered_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.TriggerOrderResponse + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_price_triggered_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - else: - (data) = self.list_price_triggered_delivery_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - return data + return self.create_price_triggered_delivery_order_with_http_info( + settle, futures_price_triggered_order, **kwargs + ) # noqa: E501 - def list_price_triggered_delivery_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 - """List all auto orders # noqa: E501 + def create_price_triggered_delivery_order_with_http_info( + self, settle, futures_price_triggered_order, **kwargs + ): # noqa: E501 + """Create a price-triggered order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_price_triggered_delivery_orders_with_http_info(settle, status, async_req=True) + >>> thread = api.create_price_triggered_delivery_order_with_http_info(settle, futures_price_triggered_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.TriggerOrderResponse, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'status', 'contract', 'limit', 'offset'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'futures_price_triggered_order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_price_triggered_delivery_orders" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method create_price_triggered_delivery_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_price_triggered_delivery_orders`") # noqa: E501 - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_price_triggered_delivery_orders`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_price_triggered_delivery_orders`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_price_triggered_delivery_orders`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_price_triggered_delivery_orders`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `create_price_triggered_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'futures_price_triggered_order' is set + if self.api_client.client_side_validation and ( + 'futures_price_triggered_order' not in local_var_params + or local_var_params['futures_price_triggered_order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `futures_price_triggered_order` when calling `create_price_triggered_delivery_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -2688,14 +3146,6 @@ def list_price_triggered_delivery_orders_with_http_info(self, settle, status, ** path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -2703,109 +3153,124 @@ def list_price_triggered_delivery_orders_with_http_info(self, settle, status, ** local_var_files = {} body_params = None + if 'futures_price_triggered_order' in local_var_params: + body_params = local_var_params['futures_price_triggered_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/price_orders', 'GET', + '/delivery/{settle}/price_orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 + response_type='TriggerOrderResponse', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_delivery_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501 - """Update position leverage # noqa: E501 + def cancel_price_triggered_delivery_order_list(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all open orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_leverage(settle, contract, leverage, async_req=True) + >>> thread = api.cancel_price_triggered_delivery_order_list(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str leverage: New position leverage (required) - :return: Position - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesPriceTriggeredOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_delivery_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - else: - (data) = self.update_delivery_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - return data + return self.cancel_price_triggered_delivery_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - def update_delivery_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501 - """Update position leverage # noqa: E501 + def cancel_price_triggered_delivery_order_list_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all open orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_leverage_with_http_info(settle, contract, leverage, async_req=True) + >>> thread = api.cancel_price_triggered_delivery_order_list_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str leverage: New position leverage (required) - :return: Position - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'leverage'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( + raise ApiTypeError( "Got an unexpected keyword argument '%s'" - " to method update_delivery_position_leverage" % key + " to method cancel_price_triggered_delivery_order_list" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_delivery_position_leverage`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_price_triggered_delivery_order_list`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_delivery_position_leverage`") # noqa: E501 - # verify the required parameter 'leverage' is set - if ('leverage' not in local_var_params or - local_var_params['leverage'] is None): - raise ValueError("Missing the required parameter `leverage` when calling `update_delivery_position_leverage`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `cancel_price_triggered_delivery_order_list`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'leverage' in local_var_params: - query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501 + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 header_params = {} @@ -2814,108 +3279,115 @@ def update_delivery_position_leverage_with_http_info(self, settle, contract, lev body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/positions/{contract}/leverage', 'POST', + '/delivery/{settle}/price_orders', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_delivery_position_margin(self, settle, contract, change, **kwargs): # noqa: E501 - """Update position margin # noqa: E501 + def get_price_triggered_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_margin(settle, contract, change, async_req=True) + >>> thread = api.get_price_triggered_delivery_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesPriceTriggeredOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_delivery_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - else: - (data) = self.update_delivery_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - return data + return self.get_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def update_delivery_position_margin_with_http_info(self, settle, contract, change, **kwargs): # noqa: E501 - """Update position margin # noqa: E501 + def get_price_triggered_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_margin_with_http_info(settle, contract, change, async_req=True) + >>> thread = api.get_price_triggered_delivery_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'change'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_delivery_position_margin" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method get_price_triggered_delivery_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_delivery_position_margin`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_delivery_position_margin`") # noqa: E501 - # verify the required parameter 'change' is set - if ('change' not in local_var_params or - local_var_params['change'] is None): - raise ValueError("Missing the required parameter `change` when calling `update_delivery_position_margin`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_price_triggered_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `get_price_triggered_delivery_order`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'change' in local_var_params: - query_params.append(('change', local_var_params['change'])) # noqa: E501 header_params = {} @@ -2924,108 +3396,115 @@ def update_delivery_position_margin_with_http_info(self, settle, contract, chang body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/positions/{contract}/margin', 'POST', + '/delivery/{settle}/price_orders/{order_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='FuturesPriceTriggeredOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_delivery_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501 - """Update position risk limit # noqa: E501 + def cancel_price_triggered_delivery_order(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_risk_limit(settle, contract, risk_limit, async_req=True) + >>> thread = api.cancel_price_triggered_delivery_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str risk_limit: New position risk limit (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesPriceTriggeredOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_delivery_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501 - else: - (data) = self.update_delivery_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501 - return data + return self.cancel_price_triggered_delivery_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def update_delivery_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501 - """Update position risk limit # noqa: E501 + def cancel_price_triggered_delivery_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_delivery_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True) + >>> thread = api.cancel_price_triggered_delivery_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str risk_limit: New position risk limit (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'risk_limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_delivery_position_risk_limit" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method cancel_price_triggered_delivery_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_delivery_position_risk_limit`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_delivery_position_risk_limit`") # noqa: E501 - # verify the required parameter 'risk_limit' is set - if ('risk_limit' not in local_var_params or - local_var_params['risk_limit'] is None): - raise ValueError("Missing the required parameter `risk_limit` when calling `update_delivery_position_risk_limit`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_price_triggered_delivery_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `cancel_price_triggered_delivery_order`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'risk_limit' in local_var_params: - query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501 header_params = {} @@ -3034,24 +3513,25 @@ def update_delivery_position_risk_limit_with_http_info(self, settle, contract, r body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/delivery/{settle}/positions/{contract}/risk_limit', 'POST', + '/delivery/{settle}/price_orders/{order_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='FuturesPriceTriggeredOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api/futures_api.py b/gate_api/api/futures_api.py index 6f43c28..d3d255c 100644 --- a/gate_api/api/futures_api.py +++ b/gate_api/api/futures_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class FuturesApi(object): @@ -32,76 +33,77 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def cancel_futures_order(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_futures_contracts(self, settle, **kwargs): # noqa: E501 + """List all futures contracts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_futures_order(settle, order_id, async_req=True) + >>> thread = api.list_futures_contracts(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Contract] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.cancel_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_futures_contracts_with_http_info(settle, **kwargs) # noqa: E501 - def cancel_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_futures_contracts_with_http_info(self, settle, **kwargs): # noqa: E501 + """List all futures contracts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_futures_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_futures_contracts_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Contract], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_futures_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_contracts" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_futures_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `cancel_futures_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_contracts`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] @@ -112,106 +114,113 @@ def cancel_futures_order_with_http_info(self, settle, order_id, **kwargs): # no body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/orders/{order_id}', 'DELETE', + '/futures/{settle}/contracts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='list[Contract]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_futures_orders(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all `open` orders matched # noqa: E501 + def get_futures_contract(self, settle, contract, **kwargs): # noqa: E501 + """Get a single contract # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_futures_orders(settle, contract, async_req=True) + >>> thread = api.get_futures_contract(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str side: All bids or asks. Both included in not specified - :return: list[FuturesOrder] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Contract + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_futures_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.cancel_futures_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.get_futures_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_futures_orders_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all `open` orders matched # noqa: E501 + def get_futures_contract_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get a single contract # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_futures_orders_with_http_info(settle, contract, async_req=True) + >>> thread = api.get_futures_contract_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str side: All bids or asks. Both included in not specified - :return: list[FuturesOrder] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Contract, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'side'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_futures_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_futures_contract" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_futures_orders`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_futures_contract`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `cancel_futures_orders`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `get_futures_contract`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'side' in local_var_params: - query_params.append(('side', local_var_params['side'])) # noqa: E501 header_params = {} @@ -220,100 +229,135 @@ def cancel_futures_orders_with_http_info(self, settle, contract, **kwargs): # n body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/orders', 'DELETE', + '/futures/{settle}/contracts/{contract}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesOrder]', # noqa: E501 + response_type='Contract', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_futures_order_book(self, settle, contract, **kwargs): # noqa: E501 + """Futures order book # noqa: E501 + Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_order(settle, order_id, async_req=True) + >>> thread = api.list_futures_order_book(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrderBook + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.cancel_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_futures_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def list_futures_order_book_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Futures order book # noqa: E501 + Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_futures_order_book_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrderBook, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'interval', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_price_triggered_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_order_book" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_price_triggered_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `cancel_price_triggered_order`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_order_book`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_futures_order_book`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 20 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value less than or equal to `20`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -322,91 +366,124 @@ def cancel_price_triggered_order_with_http_info(self, settle, order_id, **kwargs body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/price_orders/{order_id}', 'DELETE', + '/futures/{settle}/order_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesPriceTriggeredOrder', # noqa: E501 + response_type='FuturesOrderBook', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_price_triggered_order_list(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all open orders # noqa: E501 + def list_futures_trades(self, settle, contract, **kwargs): # noqa: E501 + """Futures trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_order_list(settle, contract, async_req=True) + >>> thread = api.list_futures_trades(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range + :param int _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. + :param int to: Specify end time in Unix seconds, default to current time + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesTrade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_price_triggered_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.cancel_price_triggered_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_futures_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - def cancel_price_triggered_order_list_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Cancel all open orders # noqa: E501 + def list_futures_trades_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Futures trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_price_triggered_order_list_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_futures_trades_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range + :param int _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. + :param int to: Specify end time in Unix seconds, default to current time + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesTrade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit', 'last_id', '_from', 'to'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_price_triggered_order_list" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `cancel_price_triggered_order_list`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_trades`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `cancel_price_triggered_order_list`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_futures_trades`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -414,8 +491,16 @@ def cancel_price_triggered_order_list_with_http_info(self, settle, contract, **k path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 header_params = {} @@ -424,93 +509,122 @@ def cancel_price_triggered_order_list_with_http_info(self, settle, contract, **k body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/price_orders', 'DELETE', + '/futures/{settle}/trades', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 + response_type='list[FuturesTrade]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_futures_order(self, settle, futures_order, **kwargs): # noqa: E501 - """Create a futures order # noqa: E501 + def list_futures_candlesticks(self, settle, contract, **kwargs): # noqa: E501 + """Get futures candlesticks # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 + Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_futures_order(settle, futures_order, async_req=True) + >>> thread = api.list_futures_candlesticks(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesOrder futures_order: (required) - :return: FuturesOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param str interval: Interval time between data points + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesCandlestick] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - else: - (data) = self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - return data + return self.list_futures_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - def create_futures_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501 - """Create a futures order # noqa: E501 + def list_futures_candlesticks_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get futures candlesticks # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 + Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_futures_order_with_http_info(settle, futures_order, async_req=True) + >>> thread = api.list_futures_candlesticks_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesOrder futures_order: (required) - :return: FuturesOrder - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param str interval: Interval time between data points + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesCandlestick], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'futures_order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_futures_order" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_futures_candlesticks" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `create_futures_order`") # noqa: E501 - # verify the required parameter 'futures_order' is set - if ('futures_order' not in local_var_params or - local_var_params['futures_order'] is None): - raise ValueError("Missing the required parameter `futures_order` when calling `create_futures_order`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_candlesticks`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_futures_candlesticks`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 2000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_candlesticks`, must be a value less than or equal to `2000`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -518,6 +632,16 @@ def create_futures_order_with_http_info(self, settle, futures_order, **kwargs): path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 header_params = {} @@ -525,97 +649,97 @@ def create_futures_order_with_http_info(self, settle, futures_order, **kwargs): local_var_files = {} body_params = None - if 'futures_order' in local_var_params: - body_params = local_var_params['futures_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/orders', 'POST', + '/futures/{settle}/candlesticks', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='list[FuturesCandlestick]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_price_triggered_order(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 - """Create a price-triggered order # noqa: E501 + def list_futures_tickers(self, settle, **kwargs): # noqa: E501 + """List futures tickers # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_price_triggered_order(settle, futures_price_triggered_order, async_req=True) + >>> thread = api.list_futures_tickers(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) - :return: TriggerOrderResponse - If the method is called asynchronously, + :param str contract: Futures contract, return related data only if specified + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesTicker] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_price_triggered_order_with_http_info(settle, futures_price_triggered_order, **kwargs) # noqa: E501 - else: - (data) = self.create_price_triggered_order_with_http_info(settle, futures_price_triggered_order, **kwargs) # noqa: E501 - return data + return self.list_futures_tickers_with_http_info(settle, **kwargs) # noqa: E501 - def create_price_triggered_order_with_http_info(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 - """Create a price-triggered order # noqa: E501 + def list_futures_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 + """List futures tickers # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_price_triggered_order_with_http_info(settle, futures_price_triggered_order, async_req=True) + >>> thread = api.list_futures_tickers_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) - :return: TriggerOrderResponse - If the method is called asynchronously, + :param str contract: Futures contract, return related data only if specified + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesTicker], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'futures_price_triggered_order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_price_triggered_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_tickers" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `create_price_triggered_order`") # noqa: E501 - # verify the required parameter 'futures_price_triggered_order' is set - if ('futures_price_triggered_order' not in local_var_params or - local_var_params['futures_price_triggered_order'] is None): - raise ValueError("Missing the required parameter `futures_price_triggered_order` when calling `create_price_triggered_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_tickers`" + ) # noqa: E501 collection_formats = {} @@ -624,6 +748,8 @@ def create_price_triggered_order_with_http_info(self, settle, futures_price_trig path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 header_params = {} @@ -631,107 +757,132 @@ def create_price_triggered_order_with_http_info(self, settle, futures_price_trig local_var_files = {} body_params = None - if 'futures_price_triggered_order' in local_var_params: - body_params = local_var_params['futures_price_triggered_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/price_orders', 'POST', + '/futures/{settle}/tickers', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='TriggerOrderResponse', # noqa: E501 + response_type='list[FuturesTicker]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_futures_contract(self, settle, contract, **kwargs): # noqa: E501 - """Get a single contract # noqa: E501 + def list_futures_funding_rate_history(self, settle, contract, **kwargs): # noqa: E501 + """Funding rate history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_futures_contract(settle, contract, async_req=True) + >>> thread = api.list_futures_funding_rate_history(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: Contract - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FundingRateRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_futures_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.get_futures_contract_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_futures_funding_rate_history_with_http_info(settle, contract, **kwargs) # noqa: E501 - def get_futures_contract_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get a single contract # noqa: E501 + def list_futures_funding_rate_history_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Funding rate history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_futures_contract_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_futures_funding_rate_history_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :return: Contract - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FundingRateRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_futures_contract" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_futures_funding_rate_history" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_futures_contract`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_funding_rate_history`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `get_futures_contract`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_futures_funding_rate_history`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -740,102 +891,120 @@ def get_futures_contract_with_http_info(self, settle, contract, **kwargs): # no body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/contracts/{contract}', 'GET', + '/futures/{settle}/funding_rate', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Contract', # noqa: E501 + response_type='list[FundingRateRecord]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_futures_order(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_futures_insurance_ledger(self, settle, **kwargs): # noqa: E501 + """Futures insurance balance history # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_futures_order(settle, order_id, async_req=True) + >>> thread = api.list_futures_insurance_ledger(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.InsuranceRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.get_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_futures_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - def get_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_futures_insurance_ledger_with_http_info(self, settle, **kwargs): # noqa: E501 + """Futures insurance balance history # noqa: E501 - Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_futures_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_futures_insurance_ledger_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesOrder - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.InsuranceRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_futures_order" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_futures_insurance_ledger" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_futures_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `get_futures_order`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_insurance_ledger`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -844,103 +1013,95 @@ def get_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/orders/{order_id}', 'GET', + '/futures/{settle}/insurance', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrder', # noqa: E501 + response_type='list[InsuranceRecord]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_my_trades(self, settle, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def list_futures_accounts(self, settle, **kwargs): # noqa: E501 + """Query futures account # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_my_trades(settle, async_req=True) + >>> thread = api.list_futures_accounts(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract, return related data only if specified - :param int order: Futures order ID, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[MyFuturesTrade] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesAccount + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_my_trades_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.get_my_trades_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_futures_accounts_with_http_info(settle, **kwargs) # noqa: E501 - def get_my_trades_with_http_info(self, settle, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def list_futures_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 + """Query futures account # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_my_trades_with_http_info(settle, async_req=True) + >>> thread = api.list_futures_accounts_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract, return related data only if specified - :param int order: Futures order ID, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[MyFuturesTrade] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesAccount, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'order', 'limit', 'offset', 'last_id', 'count_total'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_my_trades" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_accounts" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_my_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `get_my_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `get_my_trades`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `get_my_trades`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_accounts`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -948,18 +1109,6 @@ def get_my_trades_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'order' in local_var_params: - query_params.append(('order', local_var_params['order'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if 'count_total' in local_var_params: - query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -968,100 +1117,132 @@ def get_my_trades_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/my_trades', 'GET', + '/futures/{settle}/accounts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[MyFuturesTrade]', # noqa: E501 + response_type='FuturesAccount', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_position(self, settle, contract, **kwargs): # noqa: E501 - """Get single position # noqa: E501 + def list_futures_account_book(self, settle, **kwargs): # noqa: E501 + """Query account book # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_position(settle, contract, async_req=True) + >>> thread = api.list_futures_account_book(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: Position - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int _from: Start timestamp + :param int to: End timestamp + :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesAccountBook] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.get_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_futures_account_book_with_http_info(settle, **kwargs) # noqa: E501 - def get_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get single position # noqa: E501 + def list_futures_account_book_with_http_info(self, settle, **kwargs): # noqa: E501 + """Query account book # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_position_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_futures_account_book_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :return: Position - If the method is called asynchronously, + :param int limit: Maximum number of records returned in one list + :param int _from: Start timestamp + :param int to: End timestamp + :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesAccountBook], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'limit', '_from', 'to', 'type'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_position" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_futures_account_book" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_position`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `get_position`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_account_book`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'type' in local_var_params and local_var_params['type'] is not None: # noqa: E501 + query_params.append(('type', local_var_params['type'])) # noqa: E501 header_params = {} @@ -1070,98 +1251,98 @@ def get_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/positions/{contract}', 'GET', + '/futures/{settle}/account_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='list[FuturesAccountBook]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_positions(self, settle, **kwargs): # noqa: E501 + """List all positions of a user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_price_triggered_order(settle, order_id, async_req=True) + >>> thread = api.list_positions(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Position] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - else: - (data) = self.get_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - return data + return self.list_positions_with_http_info(settle, **kwargs) # noqa: E501 - def get_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def list_positions_with_http_info(self, settle, **kwargs): # noqa: E501 + """List all positions of a user # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_price_triggered_order_with_http_info(settle, order_id, async_req=True) + >>> thread = api.list_positions_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str order_id: ID returned on order successfully being created (required) - :return: FuturesPriceTriggeredOrder - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Position], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_price_triggered_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_positions" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `get_price_triggered_order`") # noqa: E501 - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `get_price_triggered_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `settle` when calling `list_positions`") # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] @@ -1172,112 +1353,109 @@ def get_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/price_orders/{order_id}', 'GET', + '/futures/{settle}/positions', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesPriceTriggeredOrder', # noqa: E501 + response_type='list[Position]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_account_book(self, settle, **kwargs): # noqa: E501 - """Query account book # noqa: E501 + def get_position(self, settle, contract, **kwargs): # noqa: E501 + """Get single position # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_account_book(settle, async_req=True) + >>> thread = api.get_position(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :param int _from: Start timestamp - :param int to: End timestamp - :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate - :return: list[FuturesAccountBook] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_account_book_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_account_book_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.get_position_with_http_info(settle, contract, **kwargs) # noqa: E501 - def list_futures_account_book_with_http_info(self, settle, **kwargs): # noqa: E501 - """Query account book # noqa: E501 + def get_position_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Get single position # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_account_book_with_http_info(settle, async_req=True) + >>> thread = api.get_position_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :param int _from: Start timestamp - :param int to: End timestamp - :param str type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate - :return: list[FuturesAccountBook] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'limit', '_from', 'to', 'type'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_account_book" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_position" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_account_book`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_account_book`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `settle` when calling `get_position`") # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `contract` when calling `get_position`") # noqa: E501 + collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'type' in local_var_params: - query_params.append(('type', local_var_params['type'])) # noqa: E501 header_params = {} @@ -1286,92 +1464,124 @@ def list_futures_account_book_with_http_info(self, settle, **kwargs): # noqa: E body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/account_book', 'GET', + '/futures/{settle}/positions/{contract}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesAccountBook]', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_accounts(self, settle, **kwargs): # noqa: E501 - """Query futures account # noqa: E501 + def update_position_margin(self, settle, contract, change, **kwargs): # noqa: E501 + """Update position margin # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_accounts(settle, async_req=True) + >>> thread = api.update_position_margin(settle, contract, change, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: FuturesAccount - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_accounts_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_accounts_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.update_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - def list_futures_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 - """Query futures account # noqa: E501 + def update_position_margin_with_http_info(self, settle, contract, change, **kwargs): # noqa: E501 + """Update position margin # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_accounts_with_http_info(settle, async_req=True) + >>> thread = api.update_position_margin_with_http_info(settle, contract, change, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: FuturesAccount - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'change'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_accounts" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_position_margin" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_accounts`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_position_margin`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_position_margin`" + ) # noqa: E501 + # verify the required parameter 'change' is set + if self.api_client.client_side_validation and ( + 'change' not in local_var_params or local_var_params['change'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `change` when calling `update_position_margin`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'change' in local_var_params and local_var_params['change'] is not None: # noqa: E501 + query_params.append(('change', local_var_params['change'])) # noqa: E501 header_params = {} @@ -1380,120 +1590,126 @@ def list_futures_accounts_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/accounts', 'GET', + '/futures/{settle}/positions/{contract}/margin', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesAccount', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_candlesticks(self, settle, contract, **kwargs): # noqa: E501 - """Get futures candlesticks # noqa: E501 + def update_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501 + """Update position leverage # noqa: E501 - Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_candlesticks(settle, contract, async_req=True) + >>> thread = api.update_position_leverage(settle, contract, leverage, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param str interval: Interval time between data points - :return: list[FuturesCandlestick] - If the method is called asynchronously, + :param str leverage: New position leverage (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_candlesticks_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.update_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - def list_futures_candlesticks_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Get futures candlesticks # noqa: E501 + def update_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501 + """Update position leverage # noqa: E501 - Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract's mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_candlesticks_with_http_info(settle, contract, async_req=True) + >>> thread = api.update_position_leverage_with_http_info(settle, contract, leverage, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param float _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param float to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param str interval: Interval time between data points - :return: list[FuturesCandlestick] - If the method is called asynchronously, + :param str leverage: New position leverage (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', '_from', 'to', 'limit', 'interval'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'leverage'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_candlesticks" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method update_position_leverage" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_candlesticks`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_position_leverage`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_futures_candlesticks`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_position_leverage`" + ) # noqa: E501 + # verify the required parameter 'leverage' is set + if self.api_client.client_side_validation and ( + 'leverage' not in local_var_params or local_var_params['leverage'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `leverage` when calling `update_position_leverage`" + ) # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 2000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_candlesticks`, must be a value less than or equal to `2000`") # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + if 'leverage' in local_var_params and local_var_params['leverage'] is not None: # noqa: E501 + query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501 header_params = {} @@ -1502,92 +1718,126 @@ def list_futures_candlesticks_with_http_info(self, settle, contract, **kwargs): body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/candlesticks', 'GET', + '/futures/{settle}/positions/{contract}/leverage', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesCandlestick]', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_contracts(self, settle, **kwargs): # noqa: E501 - """List all futures contracts # noqa: E501 + def update_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501 + """Update position risk limit # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_contracts(settle, async_req=True) + >>> thread = api.update_position_risk_limit(settle, contract, risk_limit, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Contract] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str risk_limit: New position risk limit (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Position + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_contracts_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_contracts_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.update_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501 - def list_futures_contracts_with_http_info(self, settle, **kwargs): # noqa: E501 - """List all futures contracts # noqa: E501 + def update_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501 + """Update position risk limit # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_contracts_with_http_info(settle, async_req=True) + >>> thread = api.update_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Contract] - If the method is called asynchronously, + :param str contract: Futures contract (required) + :param str risk_limit: New position risk limit (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Position, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'risk_limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_contracts" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method update_position_risk_limit" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_contracts`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `update_position_risk_limit`" + ) # noqa: E501 + # verify the required parameter 'contract' is set + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `update_position_risk_limit`" + ) # noqa: E501 + # verify the required parameter 'risk_limit' is set + if self.api_client.client_side_validation and ( + 'risk_limit' not in local_var_params or local_var_params['risk_limit'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `risk_limit` when calling `update_position_risk_limit`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'contract' in local_var_params: + path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] + if 'risk_limit' in local_var_params and local_var_params['risk_limit'] is not None: # noqa: E501 + query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501 header_params = {} @@ -1596,97 +1846,141 @@ def list_futures_contracts_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/contracts', 'GET', + '/futures/{settle}/positions/{contract}/risk_limit', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Contract]', # noqa: E501 + response_type='Position', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_funding_rate_history(self, settle, contract, **kwargs): # noqa: E501 - """Funding rate history # noqa: E501 + def list_futures_orders(self, settle, contract, status, **kwargs): # noqa: E501 + """List futures orders # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_funding_rate_history(settle, contract, async_req=True) + >>> thread = api.list_futures_orders(settle, contract, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) + :param str status: List orders based on status (required) :param int limit: Maximum number of records returned in one list - :return: list[FundingRateRecord] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_funding_rate_history_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_funding_rate_history_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.list_futures_orders_with_http_info(settle, contract, status, **kwargs) # noqa: E501 - def list_futures_funding_rate_history_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Funding rate history # noqa: E501 + def list_futures_orders_with_http_info(self, settle, contract, status, **kwargs): # noqa: E501 + """List futures orders # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_funding_rate_history_with_http_info(settle, contract, async_req=True) + >>> thread = api.list_futures_orders_with_http_info(settle, contract, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) + :param str status: List orders based on status (required) :param int limit: Maximum number of records returned in one list - :return: list[FundingRateRecord] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'status', 'limit', 'offset', 'last_id', 'count_total'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_funding_rate_history" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_futures_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_funding_rate_history`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_futures_orders`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_futures_funding_rate_history`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_funding_rate_history`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `list_futures_orders`" + ) # noqa: E501 + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `status` when calling `list_futures_orders`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_futures_orders`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -1694,10 +1988,18 @@ def list_futures_funding_rate_history_with_http_info(self, settle, contract, **k path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if 'count_total' in local_var_params and local_var_params['count_total'] is not None: # noqa: E501 + query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -1706,91 +2008,106 @@ def list_futures_funding_rate_history_with_http_info(self, settle, contract, **k body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/funding_rate', 'GET', + '/futures/{settle}/orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FundingRateRecord]', # noqa: E501 + response_type='list[FuturesOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_insurance_ledger(self, settle, **kwargs): # noqa: E501 - """Futures insurance balance history # noqa: E501 + def create_futures_order(self, settle, futures_order, **kwargs): # noqa: E501 + """Create a futures order # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_insurance_ledger(settle, async_req=True) + >>> thread = api.create_futures_order(settle, futures_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :return: list[InsuranceRecord] - If the method is called asynchronously, + :param FuturesOrder futures_order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_insurance_ledger_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.create_futures_order_with_http_info(settle, futures_order, **kwargs) # noqa: E501 - def list_futures_insurance_ledger_with_http_info(self, settle, **kwargs): # noqa: E501 - """Futures insurance balance history # noqa: E501 + def create_futures_order_with_http_info(self, settle, futures_order, **kwargs): # noqa: E501 + """Create a futures order # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_insurance_ledger_with_http_info(settle, async_req=True) + >>> thread = api.create_futures_order_with_http_info(settle, futures_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param int limit: Maximum number of records returned in one list - :return: list[InsuranceRecord] - If the method is called asynchronously, + :param FuturesOrder futures_order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'futures_order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_insurance_ledger" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_futures_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_insurance_ledger`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_insurance_ledger`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `create_futures_order`" + ) # noqa: E501 + # verify the required parameter 'futures_order' is set + if self.api_client.client_side_validation and ( + 'futures_order' not in local_var_params or local_var_params['futures_order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `futures_order` when calling `create_futures_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -1798,8 +2115,6 @@ def list_futures_insurance_ledger_with_http_info(self, settle, **kwargs): # noq path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -1807,102 +2122,116 @@ def list_futures_insurance_ledger_with_http_info(self, settle, **kwargs): # noq local_var_files = {} body_params = None + if 'futures_order' in local_var_params: + body_params = local_var_params['futures_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/insurance', 'GET', + '/futures/{settle}/orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[InsuranceRecord]', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_order_book(self, settle, contract, **kwargs): # noqa: E501 - """Futures order book # noqa: E501 + def cancel_futures_orders(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all `open` orders matched # noqa: E501 - Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_order_book(settle, contract, async_req=True) + >>> thread = api.cancel_futures_orders(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: FuturesOrderBook - If the method is called asynchronously, + :param str side: All bids or asks. Both included in not specified + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_order_book_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.cancel_futures_orders_with_http_info(settle, contract, **kwargs) # noqa: E501 - def list_futures_order_book_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Futures order book # noqa: E501 + def cancel_futures_orders_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all `open` orders matched # noqa: E501 - Bids will be sorted by price from high to low, while asks sorted reversely # noqa: E501 + Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_order_book_with_http_info(settle, contract, async_req=True) + >>> thread = api.cancel_futures_orders_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: FuturesOrderBook - If the method is called asynchronously, + :param str side: All bids or asks. Both included in not specified + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'interval', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'side'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_order_book" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_futures_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_order_book`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_futures_orders`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_futures_order_book`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 20: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value less than or equal to `20`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_order_book`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `cancel_futures_orders`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -1910,12 +2239,10 @@ def list_futures_order_book_with_http_info(self, settle, contract, **kwargs): # path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501 + query_params.append(('side', local_var_params['side'])) # noqa: E501 header_params = {} @@ -1924,132 +2251,115 @@ def list_futures_order_book_with_http_info(self, settle, contract, **kwargs): # body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/order_book', 'GET', + '/futures/{settle}/orders', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='FuturesOrderBook', # noqa: E501 + response_type='list[FuturesOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_orders(self, settle, contract, status, **kwargs): # noqa: E501 - """List futures orders # noqa: E501 + def get_futures_order(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_orders(settle, contract, status, async_req=True) + >>> thread = api.get_futures_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str status: List orders based on status (required) - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[FuturesOrder] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_orders_with_http_info(settle, contract, status, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_orders_with_http_info(settle, contract, status, **kwargs) # noqa: E501 - return data + return self.get_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def list_futures_orders_with_http_info(self, settle, contract, status, **kwargs): # noqa: E501 - """List futures orders # noqa: E501 + def get_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 Zero-fill order cannot be retrieved 60 seconds after cancellation # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_orders_with_http_info(settle, contract, status, async_req=True) + >>> thread = api.get_futures_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str status: List orders based on status (required) - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :param int count_total: Whether to return total number matched. Default to 0(no return) - :return: list[FuturesOrder] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'status', 'limit', 'offset', 'last_id', 'count_total'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_futures_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_orders`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_futures_orders`") # noqa: E501 - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_futures_orders`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_orders`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_futures_orders`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_futures_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `get_futures_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if 'count_total' in local_var_params: - query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -2058,96 +2368,113 @@ def list_futures_orders_with_http_info(self, settle, contract, status, **kwargs) body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/orders', 'GET', + '/futures/{settle}/orders/{order_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesOrder]', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_tickers(self, settle, **kwargs): # noqa: E501 - """List futures tickers # noqa: E501 + def cancel_futures_order(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_tickers(settle, async_req=True) + >>> thread = api.cancel_futures_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract, return related data only if specified - :return: list[FuturesTicker] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_tickers_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_tickers_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.cancel_futures_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def list_futures_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 - """List futures tickers # noqa: E501 + def cancel_futures_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_tickers_with_http_info(settle, async_req=True) + >>> thread = api.cancel_futures_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract, return related data only if specified - :return: list[FuturesTicker] - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_tickers" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_futures_order" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_tickers`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_futures_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `cancel_futures_order`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 header_params = {} @@ -2156,103 +2483,123 @@ def list_futures_tickers_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/tickers', 'GET', + '/futures/{settle}/orders/{order_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesTicker]', # noqa: E501 + response_type='FuturesOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_futures_trades(self, settle, contract, **kwargs): # noqa: E501 - """Futures trading history # noqa: E501 + def get_my_trades(self, settle, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_trades(settle, contract, async_req=True) + >>> thread = api.get_my_trades(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) + :param str contract: Futures contract, return related data only if specified + :param int order: Futures order ID, return related data only if specified :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range - :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. - :param float to: Specify end time in Unix seconds, default to current time - :return: list[FuturesTrade] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.MyFuturesTrade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_futures_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - else: - (data) = self.list_futures_trades_with_http_info(settle, contract, **kwargs) # noqa: E501 - return data + return self.get_my_trades_with_http_info(settle, **kwargs) # noqa: E501 - def list_futures_trades_with_http_info(self, settle, contract, **kwargs): # noqa: E501 - """Futures trading history # noqa: E501 + def get_my_trades_with_http_info(self, settle, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_futures_trades_with_http_info(settle, contract, async_req=True) + >>> thread = api.get_my_trades_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) + :param str contract: Futures contract, return related data only if specified + :param int order: Futures order ID, return related data only if specified :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the id of last record in previous list-query results This parameter is deprecated. Use `from` and `to` instead to limit time range - :param float _from: Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. - :param float to: Specify end time in Unix seconds, default to current time - :return: list[FuturesTrade] - If the method is called asynchronously, + :param int offset: List offset, starting from 0 + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param int count_total: Whether to return total number matched. Default to 0(no return) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.MyFuturesTrade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit', 'last_id', '_from', 'to'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'order', 'limit', 'offset', 'last_id', 'count_total'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_futures_trades" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_my_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_futures_trades`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `list_futures_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_futures_trades`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `settle` when calling `get_my_trades`") # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `get_my_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `get_my_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `get_my_trades`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2260,16 +2607,18 @@ def list_futures_trades_with_http_info(self, settle, contract, **kwargs): # noq path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'order' in local_var_params and local_var_params['order'] is not None: # noqa: E501 + query_params.append(('order', local_var_params['order'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'last_id' in local_var_params: + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'count_total' in local_var_params and local_var_params['count_total'] is not None: # noqa: E501 + query_params.append(('count_total', local_var_params['count_total'])) # noqa: E501 header_params = {} @@ -2278,95 +2627,111 @@ def list_futures_trades_with_http_info(self, settle, contract, **kwargs): # noq body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/trades', 'GET', + '/futures/{settle}/my_trades', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesTrade]', # noqa: E501 + response_type='list[MyFuturesTrade]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_liquidates(self, settle, **kwargs): # noqa: E501 - """List liquidation history # noqa: E501 + def list_position_close(self, settle, **kwargs): # noqa: E501 + """List position close history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_liquidates(settle, async_req=True) + >>> thread = api.list_position_close(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :param int at: Specify a liquidation timestamp - :return: list[FuturesLiquidate] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.PositionClose] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_position_close_with_http_info(settle, **kwargs) # noqa: E501 - def list_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 - """List liquidation history # noqa: E501 + def list_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 + """List position close history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_liquidates_with_http_info(settle, async_req=True) + >>> thread = api.list_position_close_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :param int at: Specify a liquidation timestamp - :return: list[FuturesLiquidate] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.PositionClose], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit', 'at'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_liquidates" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_position_close" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_liquidates`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_liquidates`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_liquidates`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_position_close`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_position_close`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_position_close`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2374,12 +2739,10 @@ def list_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'at' in local_var_params: - query_params.append(('at', local_var_params['at'])) # noqa: E501 header_params = {} @@ -2388,93 +2751,111 @@ def list_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/liquidates', 'GET', + '/futures/{settle}/position_close', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesLiquidate]', # noqa: E501 + response_type='list[PositionClose]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_position_close(self, settle, **kwargs): # noqa: E501 - """List position close history # noqa: E501 + def list_liquidates(self, settle, **kwargs): # noqa: E501 + """List liquidation history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_position_close(settle, async_req=True) + >>> thread = api.list_liquidates(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :return: list[PositionClose] - If the method is called asynchronously, + :param int at: Specify a liquidation timestamp + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesLiquidate] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_position_close_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_position_close_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_liquidates_with_http_info(settle, **kwargs) # noqa: E501 - def list_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 - """List position close history # noqa: E501 + def list_liquidates_with_http_info(self, settle, **kwargs): # noqa: E501 + """List liquidation history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_position_close_with_http_info(settle, async_req=True) + >>> thread = api.list_liquidates_with_http_info(settle, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract, return related data only if specified :param int limit: Maximum number of records returned in one list - :return: list[PositionClose] - If the method is called asynchronously, + :param int at: Specify a liquidation timestamp + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesLiquidate], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract', 'limit', 'at'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_position_close" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_liquidates" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_position_close`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_position_close`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_position_close`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `settle` when calling `list_liquidates`") # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_liquidates`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_liquidates`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2482,10 +2863,12 @@ def list_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'contract' in local_var_params: + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'at' in local_var_params and local_var_params['at'] is not None: # noqa: E501 + query_params.append(('at', local_var_params['at'])) # noqa: E501 header_params = {} @@ -2494,85 +2877,130 @@ def list_position_close_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/position_close', 'GET', + '/futures/{settle}/liquidates', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[PositionClose]', # noqa: E501 + response_type='list[FuturesLiquidate]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_positions(self, settle, **kwargs): # noqa: E501 - """List all positions of a user # noqa: E501 + def list_price_triggered_orders(self, settle, status, **kwargs): # noqa: E501 + """List all auto orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_positions(settle, async_req=True) + >>> thread = api.list_price_triggered_orders(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Position] - If the method is called asynchronously, + :param str status: List orders based on status (required) + :param str contract: Futures contract, return related data only if specified + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesPriceTriggeredOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_positions_with_http_info(settle, **kwargs) # noqa: E501 - else: - (data) = self.list_positions_with_http_info(settle, **kwargs) # noqa: E501 - return data + return self.list_price_triggered_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - def list_positions_with_http_info(self, settle, **kwargs): # noqa: E501 - """List all positions of a user # noqa: E501 + def list_price_triggered_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 + """List all auto orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_positions_with_http_info(settle, async_req=True) + >>> thread = api.list_price_triggered_orders_with_http_info(settle, status, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :return: list[Position] - If the method is called asynchronously, + :param str status: List orders based on status (required) + :param str contract: Futures contract, return related data only if specified + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'status', 'contract', 'limit', 'offset'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_positions" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_price_triggered_orders" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_positions`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `list_price_triggered_orders`" + ) # noqa: E501 + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `status` when calling `list_price_triggered_orders`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_price_triggered_orders`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} @@ -2580,6 +3008,14 @@ def list_positions_with_http_info(self, settle, **kwargs): # noqa: E501 path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -2588,103 +3024,111 @@ def list_positions_with_http_info(self, settle, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/positions', 'GET', + '/futures/{settle}/price_orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Position]', # noqa: E501 + response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_price_triggered_orders(self, settle, status, **kwargs): # noqa: E501 - """List all auto orders # noqa: E501 + def create_price_triggered_order(self, settle, futures_price_triggered_order, **kwargs): # noqa: E501 + """Create a price-triggered order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_price_triggered_orders(settle, status, async_req=True) + >>> thread = api.create_price_triggered_order(settle, futures_price_triggered_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.TriggerOrderResponse + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_price_triggered_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - else: - (data) = self.list_price_triggered_orders_with_http_info(settle, status, **kwargs) # noqa: E501 - return data + return self.create_price_triggered_order_with_http_info( + settle, futures_price_triggered_order, **kwargs + ) # noqa: E501 - def list_price_triggered_orders_with_http_info(self, settle, status, **kwargs): # noqa: E501 - """List all auto orders # noqa: E501 + def create_price_triggered_order_with_http_info( + self, settle, futures_price_triggered_order, **kwargs + ): # noqa: E501 + """Create a price-triggered order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_price_triggered_orders_with_http_info(settle, status, async_req=True) + >>> thread = api.create_price_triggered_order_with_http_info(settle, futures_price_triggered_order, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str status: List orders based on status (required) - :param str contract: Futures contract, return related data only if specified - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[FuturesPriceTriggeredOrder] - If the method is called asynchronously, + :param FuturesPriceTriggeredOrder futures_price_triggered_order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.TriggerOrderResponse, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'status', 'contract', 'limit', 'offset'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'futures_price_triggered_order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_price_triggered_orders" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method create_price_triggered_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `list_price_triggered_orders`") # noqa: E501 - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_price_triggered_orders`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_price_triggered_orders`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_price_triggered_orders`, must be a value greater than or equal to `0`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `create_price_triggered_order`" + ) # noqa: E501 + # verify the required parameter 'futures_price_triggered_order' is set + if self.api_client.client_side_validation and ( + 'futures_price_triggered_order' not in local_var_params + or local_var_params['futures_price_triggered_order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `futures_price_triggered_order` when calling `create_price_triggered_order`" + ) # noqa: E501 + collection_formats = {} path_params = {} @@ -2692,14 +3136,6 @@ def list_price_triggered_orders_with_http_info(self, settle, status, **kwargs): path_params['settle'] = local_var_params['settle'] # noqa: E501 query_params = [] - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'contract' in local_var_params: - query_params.append(('contract', local_var_params['contract'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -2707,109 +3143,123 @@ def list_price_triggered_orders_with_http_info(self, settle, status, **kwargs): local_var_files = {} body_params = None + if 'futures_price_triggered_order' in local_var_params: + body_params = local_var_params['futures_price_triggered_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/price_orders', 'GET', + '/futures/{settle}/price_orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 + response_type='TriggerOrderResponse', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_position_leverage(self, settle, contract, leverage, **kwargs): # noqa: E501 - """Update position leverage # noqa: E501 + def cancel_price_triggered_order_list(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all open orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_leverage(settle, contract, leverage, async_req=True) + >>> thread = api.cancel_price_triggered_order_list(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str leverage: New position leverage (required) - :return: Position - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FuturesPriceTriggeredOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - else: - (data) = self.update_position_leverage_with_http_info(settle, contract, leverage, **kwargs) # noqa: E501 - return data + return self.cancel_price_triggered_order_list_with_http_info(settle, contract, **kwargs) # noqa: E501 - def update_position_leverage_with_http_info(self, settle, contract, leverage, **kwargs): # noqa: E501 - """Update position leverage # noqa: E501 + def cancel_price_triggered_order_list_with_http_info(self, settle, contract, **kwargs): # noqa: E501 + """Cancel all open orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_leverage_with_http_info(settle, contract, leverage, async_req=True) + >>> thread = api.cancel_price_triggered_order_list_with_http_info(settle, contract, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) :param str contract: Futures contract (required) - :param str leverage: New position leverage (required) - :return: Position - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FuturesPriceTriggeredOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'leverage'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'contract'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_position_leverage" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method cancel_price_triggered_order_list" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_position_leverage`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_price_triggered_order_list`" + ) # noqa: E501 # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_position_leverage`") # noqa: E501 - # verify the required parameter 'leverage' is set - if ('leverage' not in local_var_params or - local_var_params['leverage'] is None): - raise ValueError("Missing the required parameter `leverage` when calling `update_position_leverage`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'contract' not in local_var_params or local_var_params['contract'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `contract` when calling `cancel_price_triggered_order_list`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 query_params = [] - if 'leverage' in local_var_params: - query_params.append(('leverage', local_var_params['leverage'])) # noqa: E501 + if 'contract' in local_var_params and local_var_params['contract'] is not None: # noqa: E501 + query_params.append(('contract', local_var_params['contract'])) # noqa: E501 header_params = {} @@ -2818,108 +3268,115 @@ def update_position_leverage_with_http_info(self, settle, contract, leverage, ** body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/positions/{contract}/leverage', 'POST', + '/futures/{settle}/price_orders', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='list[FuturesPriceTriggeredOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_position_margin(self, settle, contract, change, **kwargs): # noqa: E501 - """Update position margin # noqa: E501 + def get_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_margin(settle, contract, change, async_req=True) + >>> thread = api.get_price_triggered_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesPriceTriggeredOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - else: - (data) = self.update_position_margin_with_http_info(settle, contract, change, **kwargs) # noqa: E501 - return data + return self.get_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def update_position_margin_with_http_info(self, settle, contract, change, **kwargs): # noqa: E501 - """Update position margin # noqa: E501 + def get_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_margin_with_http_info(settle, contract, change, async_req=True) + >>> thread = api.get_price_triggered_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str change: Margin change. Use positive number to increase margin, negative number otherwise. (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'change'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_position_margin" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method get_price_triggered_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_position_margin`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_position_margin`") # noqa: E501 - # verify the required parameter 'change' is set - if ('change' not in local_var_params or - local_var_params['change'] is None): - raise ValueError("Missing the required parameter `change` when calling `update_position_margin`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `get_price_triggered_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `get_price_triggered_order`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'change' in local_var_params: - query_params.append(('change', local_var_params['change'])) # noqa: E501 header_params = {} @@ -2928,108 +3385,115 @@ def update_position_margin_with_http_info(self, settle, contract, change, **kwar body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/positions/{contract}/margin', 'POST', + '/futures/{settle}/price_orders/{order_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='FuturesPriceTriggeredOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_position_risk_limit(self, settle, contract, risk_limit, **kwargs): # noqa: E501 - """Update position risk limit # noqa: E501 + def cancel_price_triggered_order(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_risk_limit(settle, contract, risk_limit, async_req=True) + >>> thread = api.cancel_price_triggered_order(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str risk_limit: New position risk limit (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.FuturesPriceTriggeredOrder + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501 - else: - (data) = self.update_position_risk_limit_with_http_info(settle, contract, risk_limit, **kwargs) # noqa: E501 - return data + return self.cancel_price_triggered_order_with_http_info(settle, order_id, **kwargs) # noqa: E501 - def update_position_risk_limit_with_http_info(self, settle, contract, risk_limit, **kwargs): # noqa: E501 - """Update position risk limit # noqa: E501 + def cancel_price_triggered_order_with_http_info(self, settle, order_id, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_position_risk_limit_with_http_info(settle, contract, risk_limit, async_req=True) + >>> thread = api.cancel_price_triggered_order_with_http_info(settle, order_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str settle: Settle currency (required) - :param str contract: Futures contract (required) - :param str risk_limit: New position risk limit (required) - :return: Position - If the method is called asynchronously, + :param str order_id: ID returned on order successfully being created (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.FuturesPriceTriggeredOrder, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['settle', 'contract', 'risk_limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['settle', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_position_risk_limit" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method cancel_price_triggered_order" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'settle' is set - if ('settle' not in local_var_params or - local_var_params['settle'] is None): - raise ValueError("Missing the required parameter `settle` when calling `update_position_risk_limit`") # noqa: E501 - # verify the required parameter 'contract' is set - if ('contract' not in local_var_params or - local_var_params['contract'] is None): - raise ValueError("Missing the required parameter `contract` when calling `update_position_risk_limit`") # noqa: E501 - # verify the required parameter 'risk_limit' is set - if ('risk_limit' not in local_var_params or - local_var_params['risk_limit'] is None): - raise ValueError("Missing the required parameter `risk_limit` when calling `update_position_risk_limit`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'settle' not in local_var_params or local_var_params['settle'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `settle` when calling `cancel_price_triggered_order`" + ) # noqa: E501 + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order_id` when calling `cancel_price_triggered_order`" + ) # noqa: E501 collection_formats = {} path_params = {} if 'settle' in local_var_params: path_params['settle'] = local_var_params['settle'] # noqa: E501 - if 'contract' in local_var_params: - path_params['contract'] = local_var_params['contract'] # noqa: E501 + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'risk_limit' in local_var_params: - query_params.append(('risk_limit', local_var_params['risk_limit'])) # noqa: E501 header_params = {} @@ -3038,24 +3502,25 @@ def update_position_risk_limit_with_http_info(self, settle, contract, risk_limit body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/futures/{settle}/positions/{contract}/risk_limit', 'POST', + '/futures/{settle}/price_orders/{order_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Position', # noqa: E501 + response_type='FuturesPriceTriggeredOrder', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api/margin_api.py b/gate_api/api/margin_api.py index 64f178a..b8cb615 100644 --- a/gate_api/api/margin_api.py +++ b/gate_api/api/margin_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class MarginApi(object): @@ -32,80 +33,70 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def cancel_loan(self, loan_id, currency, **kwargs): # noqa: E501 - """Cancel lending loan # noqa: E501 + def list_margin_currency_pairs(self, **kwargs): # noqa: E501 + """List all supported currency pairs supported in margin trading # noqa: E501 - Only lending loans can be cancelled # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_loan(loan_id, currency, async_req=True) + >>> thread = api.list_margin_currency_pairs(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str currency: Retrieved specified currency related data (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.MarginCurrencyPair] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_loan_with_http_info(loan_id, currency, **kwargs) # noqa: E501 - else: - (data) = self.cancel_loan_with_http_info(loan_id, currency, **kwargs) # noqa: E501 - return data + return self.list_margin_currency_pairs_with_http_info(**kwargs) # noqa: E501 - def cancel_loan_with_http_info(self, loan_id, currency, **kwargs): # noqa: E501 - """Cancel lending loan # noqa: E501 + def list_margin_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 + """List all supported currency pairs supported in margin trading # noqa: E501 - Only lending loans can be cancelled # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_loan_with_http_info(loan_id, currency, async_req=True) + >>> thread = api.list_margin_currency_pairs_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str currency: Retrieved specified currency related data (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.MarginCurrencyPair], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id', 'currency'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = [] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_loan" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_margin_currency_pairs" % key ) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `cancel_loan`") # noqa: E501 - # verify the required parameter 'currency' is set - if ('currency' not in local_var_params or - local_var_params['currency'] is None): - raise ValueError("Missing the required parameter `currency` when calling `cancel_loan`") # noqa: E501 collection_formats = {} path_params = {} - if 'loan_id' in local_var_params: - path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] - if 'currency' in local_var_params: - query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -114,90 +105,102 @@ def cancel_loan_with_http_info(self, loan_id, currency, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/margin/loans/{loan_id}', 'DELETE', + '/margin/currency_pairs', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Loan', # noqa: E501 + response_type='list[MarginCurrencyPair]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_loan(self, loan, **kwargs): # noqa: E501 - """Lend or borrow # noqa: E501 + def list_funding_book(self, currency, **kwargs): # noqa: E501 + """Order book of lending loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_loan(loan, async_req=True) + >>> thread = api.list_funding_book(currency, async_req=True) >>> result = thread.get() - :param async_req bool - :param Loan loan: (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FundingBookItem] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_loan_with_http_info(loan, **kwargs) # noqa: E501 - else: - (data) = self.create_loan_with_http_info(loan, **kwargs) # noqa: E501 - return data + return self.list_funding_book_with_http_info(currency, **kwargs) # noqa: E501 - def create_loan_with_http_info(self, loan, **kwargs): # noqa: E501 - """Lend or borrow # noqa: E501 + def list_funding_book_with_http_info(self, currency, **kwargs): # noqa: E501 + """Order book of lending loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_loan_with_http_info(loan, async_req=True) + >>> thread = api.list_funding_book_with_http_info(currency, async_req=True) >>> result = thread.get() - :param async_req bool - :param Loan loan: (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FundingBookItem], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_loan" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_funding_book" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan' is set - if ('loan' not in local_var_params or - local_var_params['loan'] is None): - raise ValueError("Missing the required parameter `loan` when calling `create_loan`") # noqa: E501 + # verify the required parameter 'currency' is set + if self.api_client.client_side_validation and ( + 'currency' not in local_var_params or local_var_params['currency'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency` when calling `list_funding_book`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -205,107 +208,96 @@ def create_loan_with_http_info(self, loan, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'loan' in local_var_params: - body_params = local_var_params['loan'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/margin/loans', 'POST', + '/margin/funding_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Loan', # noqa: E501 + response_type='list[FundingBookItem]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_loan(self, loan_id, side, **kwargs): # noqa: E501 - """Retrieve one single loan detail # noqa: E501 + def list_margin_accounts(self, **kwargs): # noqa: E501 + """Margin account list # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_loan(loan_id, side, async_req=True) + >>> thread = api.list_margin_accounts(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str side: Lend or borrow (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.MarginAccount] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_loan_with_http_info(loan_id, side, **kwargs) # noqa: E501 - else: - (data) = self.get_loan_with_http_info(loan_id, side, **kwargs) # noqa: E501 - return data + return self.list_margin_accounts_with_http_info(**kwargs) # noqa: E501 - def get_loan_with_http_info(self, loan_id, side, **kwargs): # noqa: E501 - """Retrieve one single loan detail # noqa: E501 + def list_margin_accounts_with_http_info(self, **kwargs): # noqa: E501 + """Margin account list # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_loan_with_http_info(loan_id, side, async_req=True) + >>> thread = api.list_margin_accounts_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str side: Lend or borrow (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.MarginAccount], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id', 'side'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_loan" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_margin_accounts" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `get_loan`") # noqa: E501 - # verify the required parameter 'side' is set - if ('side' not in local_var_params or - local_var_params['side'] is None): - raise ValueError("Missing the required parameter `side` when calling `get_loan`") # noqa: E501 collection_formats = {} path_params = {} - if 'loan_id' in local_var_params: - path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] - if 'side' in local_var_params: - query_params.append(('side', local_var_params['side'])) # noqa: E501 + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 header_params = {} @@ -314,100 +306,137 @@ def get_loan_with_http_info(self, loan_id, side, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loans/{loan_id}', 'GET', + '/margin/accounts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Loan', # noqa: E501 + response_type='list[MarginAccount]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_loan_record(self, loan_record_id, loan_id, **kwargs): # noqa: E501 - """Get one single loan record # noqa: E501 + def list_margin_account_book(self, **kwargs): # noqa: E501 + """List margin account balance change history # noqa: E501 + Only transferring from or to margin account are provided for now. Time range allows 30 days at most # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_loan_record(loan_record_id, loan_id, async_req=True) + >>> thread = api.list_margin_account_book(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_record_id: Loan record ID (required) - :param str loan_id: Loan ID (required) - :return: LoanRecord - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: List records related to specified currency only. If specified, `currency_pair` is also required. + :param str currency_pair: List records related to specified currency pair. Used in combination with `currency`. Ignored if `currency` is not provided + :param int _from: Time range beginning, default to 7 days before current time + :param int to: Time range ending, default to current time + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.MarginAccountBook] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_loan_record_with_http_info(loan_record_id, loan_id, **kwargs) # noqa: E501 - else: - (data) = self.get_loan_record_with_http_info(loan_record_id, loan_id, **kwargs) # noqa: E501 - return data + return self.list_margin_account_book_with_http_info(**kwargs) # noqa: E501 - def get_loan_record_with_http_info(self, loan_record_id, loan_id, **kwargs): # noqa: E501 - """Get one single loan record # noqa: E501 + def list_margin_account_book_with_http_info(self, **kwargs): # noqa: E501 + """List margin account balance change history # noqa: E501 + Only transferring from or to margin account are provided for now. Time range allows 30 days at most # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_loan_record_with_http_info(loan_record_id, loan_id, async_req=True) + >>> thread = api.list_margin_account_book_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_record_id: Loan record ID (required) - :param str loan_id: Loan ID (required) - :return: LoanRecord - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: List records related to specified currency only. If specified, `currency_pair` is also required. + :param str currency_pair: List records related to specified currency pair. Used in combination with `currency`. Ignored if `currency` is not provided + :param int _from: Time range beginning, default to 7 days before current time + :param int to: Time range ending, default to current time + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.MarginAccountBook], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_record_id', 'loan_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency', 'currency_pair', '_from', 'to', 'page', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_loan_record" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_margin_account_book" % key ) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan_record_id' is set - if ('loan_record_id' not in local_var_params or - local_var_params['loan_record_id'] is None): - raise ValueError("Missing the required parameter `loan_record_id` when calling `get_loan_record`") # noqa: E501 - # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `get_loan_record`") # noqa: E501 + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_margin_account_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 500 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_margin_account_book`, must be a value less than or equal to `500`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_margin_account_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'loan_record_id' in local_var_params: - path_params['loan_record_id'] = local_var_params['loan_record_id'] # noqa: E501 query_params = [] - if 'loan_id' in local_var_params: - query_params.append(('loan_id', local_var_params['loan_id'])) # noqa: E501 + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -416,27 +445,28 @@ def get_loan_record_with_http_info(self, loan_record_id, loan_id, **kwargs): # body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loan_records/{loan_record_id}', 'GET', + '/margin/account_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='LoanRecord', # noqa: E501 + response_type='list[MarginAccountBook]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) def list_funding_accounts(self, **kwargs): # noqa: E501 """Funding account list # noqa: E501 @@ -446,18 +476,21 @@ def list_funding_accounts(self, **kwargs): # noqa: E501 >>> thread = api.list_funding_accounts(async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Retrieved specified currency related data - :return: list[FundingAccount] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.FundingAccount] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_funding_accounts_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_funding_accounts_with_http_info(**kwargs) # noqa: E501 - return data + return self.list_funding_accounts_with_http_info(**kwargs) # noqa: E501 def list_funding_accounts_with_http_info(self, **kwargs): # noqa: E501 """Funding account list # noqa: E501 @@ -467,27 +500,30 @@ def list_funding_accounts_with_http_info(self, **kwargs): # noqa: E501 >>> thread = api.list_funding_accounts_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Retrieved specified currency related data - :return: list[FundingAccount] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.FundingAccount], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_funding_accounts" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_funding_accounts" % key) local_var_params[key] = val del local_var_params['kwargs'] @@ -496,7 +532,7 @@ def list_funding_accounts_with_http_info(self, **kwargs): # noqa: E501 path_params = {} query_params = [] - if 'currency' in local_var_params: + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -506,14 +542,14 @@ def list_funding_accounts_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/funding_accounts', 'GET', + '/margin/funding_accounts', + 'GET', path_params, query_params, header_params, @@ -526,72 +562,131 @@ def list_funding_accounts_with_http_info(self, **kwargs): # noqa: E501 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_funding_book(self, currency, **kwargs): # noqa: E501 - """Order book of lending loans # noqa: E501 + def list_loans(self, status, side, **kwargs): # noqa: E501 + """List all loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_funding_book(currency, async_req=True) + >>> thread = api.list_loans(status, side, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data (required) - :return: list[FundingBookItem] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str status: Loan status (required) + :param str side: Lend or borrow (required) + :param str currency: Retrieved specified currency related data + :param str currency_pair: Currency pair + :param str sort_by: Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` + :param bool reverse_sort: Whether to sort in descending order. Default to `true` + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Loan] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_funding_book_with_http_info(currency, **kwargs) # noqa: E501 - else: - (data) = self.list_funding_book_with_http_info(currency, **kwargs) # noqa: E501 - return data + return self.list_loans_with_http_info(status, side, **kwargs) # noqa: E501 - def list_funding_book_with_http_info(self, currency, **kwargs): # noqa: E501 - """Order book of lending loans # noqa: E501 + def list_loans_with_http_info(self, status, side, **kwargs): # noqa: E501 + """List all loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_funding_book_with_http_info(currency, async_req=True) + >>> thread = api.list_loans_with_http_info(status, side, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data (required) - :return: list[FundingBookItem] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str status: Loan status (required) + :param str side: Lend or borrow (required) + :param str currency: Retrieved specified currency related data + :param str currency_pair: Currency pair + :param str sort_by: Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` + :param bool reverse_sort: Whether to sort in descending order. Default to `true` + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Loan], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['status', 'side', 'currency', 'currency_pair', 'sort_by', 'reverse_sort', 'page', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_funding_book" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_loans" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency' is set - if ('currency' not in local_var_params or - local_var_params['currency'] is None): - raise ValueError("Missing the required parameter `currency` when calling `list_funding_book`") # noqa: E501 - + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `status` when calling `list_loans`") # noqa: E501 + # verify the required parameter 'side' is set + if self.api_client.client_side_validation and ( + 'side' not in local_var_params or local_var_params['side'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `side` when calling `list_loans`") # noqa: E501 + + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_loans`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_loans`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_loans`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency' in local_var_params: + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501 + query_params.append(('side', local_var_params['side'])) # noqa: E501 + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 query_params.append(('currency', local_var_params['currency'])) # noqa: E501 + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if 'sort_by' in local_var_params and local_var_params['sort_by'] is not None: # noqa: E501 + query_params.append(('sort_by', local_var_params['sort_by'])) # noqa: E501 + if 'reverse_sort' in local_var_params and local_var_params['reverse_sort'] is not None: # noqa: E501 + query_params.append(('reverse_sort', local_var_params['reverse_sort'])) # noqa: E501 + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -600,110 +695,98 @@ def list_funding_book_with_http_info(self, currency, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/funding_book', 'GET', + '/margin/loans', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[FundingBookItem]', # noqa: E501 + response_type='list[Loan]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_loan_records(self, loan_id, **kwargs): # noqa: E501 - """List repayment records of specified loan # noqa: E501 + def create_loan(self, loan, **kwargs): # noqa: E501 + """Lend or borrow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loan_records(loan_id, async_req=True) + >>> thread = api.create_loan(loan, async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str status: Loan record status - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[LoanRecord] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Loan loan: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_loan_records_with_http_info(loan_id, **kwargs) # noqa: E501 - else: - (data) = self.list_loan_records_with_http_info(loan_id, **kwargs) # noqa: E501 - return data + return self.create_loan_with_http_info(loan, **kwargs) # noqa: E501 - def list_loan_records_with_http_info(self, loan_id, **kwargs): # noqa: E501 - """List repayment records of specified loan # noqa: E501 + def create_loan_with_http_info(self, loan, **kwargs): # noqa: E501 + """Lend or borrow # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loan_records_with_http_info(loan_id, async_req=True) + >>> thread = api.create_loan_with_http_info(loan, async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :param str status: Loan record status - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[LoanRecord] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Loan loan: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id', 'status', 'page', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_loan_records" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_loan" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `list_loan_records`") # noqa: E501 - - if 'page' in local_var_params and local_var_params['page'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `page` when calling `list_loan_records`, must be a value greater than or equal to `1`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_loan_records`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_loan_records`, must be a value greater than or equal to `1`") # noqa: E501 + # verify the required parameter 'loan' is set + if self.api_client.client_side_validation and ( + 'loan' not in local_var_params or local_var_params['loan'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan` when calling `create_loan`") # noqa: E501 + collection_formats = {} path_params = {} query_params = [] - if 'loan_id' in local_var_params: - query_params.append(('loan_id', local_var_params['loan_id'])) # noqa: E501 - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -711,93 +794,117 @@ def list_loan_records_with_http_info(self, loan_id, **kwargs): # noqa: E501 local_var_files = {} body_params = None + if 'loan' in local_var_params: + body_params = local_var_params['loan'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loan_records', 'GET', + '/margin/loans', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[LoanRecord]', # noqa: E501 + response_type='Loan', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_loan_repayments(self, loan_id, **kwargs): # noqa: E501 - """List loan repayment records # noqa: E501 + def merge_loans(self, currency, ids, **kwargs): # noqa: E501 + """Merge multiple lending loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loan_repayments(loan_id, async_req=True) + >>> thread = api.merge_loans(currency, ids, async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :return: list[Repayment] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data (required) + :param str ids: Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_loan_repayments_with_http_info(loan_id, **kwargs) # noqa: E501 - else: - (data) = self.list_loan_repayments_with_http_info(loan_id, **kwargs) # noqa: E501 - return data + return self.merge_loans_with_http_info(currency, ids, **kwargs) # noqa: E501 - def list_loan_repayments_with_http_info(self, loan_id, **kwargs): # noqa: E501 - """List loan repayment records # noqa: E501 + def merge_loans_with_http_info(self, currency, ids, **kwargs): # noqa: E501 + """Merge multiple lending loans # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loan_repayments_with_http_info(loan_id, async_req=True) + >>> thread = api.merge_loans_with_http_info(currency, ids, async_req=True) >>> result = thread.get() - :param async_req bool - :param str loan_id: Loan ID (required) - :return: list[Repayment] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data (required) + :param str ids: Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency', 'ids'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_loan_repayments" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method merge_loans" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `list_loan_repayments`") # noqa: E501 + # verify the required parameter 'currency' is set + if self.api_client.client_side_validation and ( + 'currency' not in local_var_params or local_var_params['currency'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `currency` when calling `merge_loans`") # noqa: E501 + # verify the required parameter 'ids' is set + if self.api_client.client_side_validation and ( + 'ids' not in local_var_params or local_var_params['ids'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `ids` when calling `merge_loans`") # noqa: E501 collection_formats = {} path_params = {} - if 'loan_id' in local_var_params: - path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 + if 'ids' in local_var_params and local_var_params['ids'] is not None: # noqa: E501 + query_params.append(('ids', local_var_params['ids'])) # noqa: E501 header_params = {} @@ -806,130 +913,109 @@ def list_loan_repayments_with_http_info(self, loan_id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loans/{loan_id}/repayment', 'GET', + '/margin/merged_loans', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Repayment]', # noqa: E501 + response_type='Loan', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_loans(self, status, side, **kwargs): # noqa: E501 - """List all loans # noqa: E501 + def get_loan(self, loan_id, side, **kwargs): # noqa: E501 + """Retrieve one single loan detail # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loans(status, side, async_req=True) + >>> thread = api.get_loan(loan_id, side, async_req=True) >>> result = thread.get() - :param async_req bool - :param str status: Loan status (required) + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) :param str side: Lend or borrow (required) - :param str currency: Retrieved specified currency related data - :param str currency_pair: Currency pair - :param str sort_by: Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` - :param bool reverse_sort: Whether to sort in descending order. Default to `true` - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[Loan] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_loans_with_http_info(status, side, **kwargs) # noqa: E501 - else: - (data) = self.list_loans_with_http_info(status, side, **kwargs) # noqa: E501 - return data + return self.get_loan_with_http_info(loan_id, side, **kwargs) # noqa: E501 - def list_loans_with_http_info(self, status, side, **kwargs): # noqa: E501 - """List all loans # noqa: E501 + def get_loan_with_http_info(self, loan_id, side, **kwargs): # noqa: E501 + """Retrieve one single loan detail # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_loans_with_http_info(status, side, async_req=True) + >>> thread = api.get_loan_with_http_info(loan_id, side, async_req=True) >>> result = thread.get() - :param async_req bool - :param str status: Loan status (required) + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) :param str side: Lend or borrow (required) - :param str currency: Retrieved specified currency related data - :param str currency_pair: Currency pair - :param str sort_by: Specify which field is used to sort. `create_time` or `rate` is supported. Default to `create_time` - :param bool reverse_sort: Whether to sort in descending order. Default to `true` - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[Loan] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['status', 'side', 'currency', 'currency_pair', 'sort_by', 'reverse_sort', 'page', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id', 'side'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_loans" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_loan" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_loans`") # noqa: E501 + # verify the required parameter 'loan_id' is set + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_id` when calling `get_loan`") # noqa: E501 # verify the required parameter 'side' is set - if ('side' not in local_var_params or - local_var_params['side'] is None): - raise ValueError("Missing the required parameter `side` when calling `list_loans`") # noqa: E501 - - if 'page' in local_var_params and local_var_params['page'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `page` when calling `list_loans`, must be a value greater than or equal to `1`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_loans`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_loans`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'side' not in local_var_params or local_var_params['side'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `side` when calling `get_loan`") # noqa: E501 + collection_formats = {} path_params = {} + if 'loan_id' in local_var_params: + path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'side' in local_var_params: + if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501 query_params.append(('side', local_var_params['side'])) # noqa: E501 - if 'currency' in local_var_params: - query_params.append(('currency', local_var_params['currency'])) # noqa: E501 - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'sort_by' in local_var_params: - query_params.append(('sort_by', local_var_params['sort_by'])) # noqa: E501 - if 'reverse_sort' in local_var_params: - query_params.append(('reverse_sort', local_var_params['reverse_sort'])) # noqa: E501 - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -938,88 +1024,111 @@ def list_loans_with_http_info(self, status, side, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loans', 'GET', + '/margin/loans/{loan_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Loan]', # noqa: E501 + response_type='Loan', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_margin_accounts(self, **kwargs): # noqa: E501 - """Margin account list # noqa: E501 + def cancel_loan(self, loan_id, currency, **kwargs): # noqa: E501 + """Cancel lending loan # noqa: E501 + Only lending loans can be cancelled # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_margin_accounts(async_req=True) + >>> thread = api.cancel_loan(loan_id, currency, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair - :return: list[MarginAccount] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param str currency: Retrieved specified currency related data (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_margin_accounts_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_margin_accounts_with_http_info(**kwargs) # noqa: E501 - return data + return self.cancel_loan_with_http_info(loan_id, currency, **kwargs) # noqa: E501 - def list_margin_accounts_with_http_info(self, **kwargs): # noqa: E501 - """Margin account list # noqa: E501 + def cancel_loan_with_http_info(self, loan_id, currency, **kwargs): # noqa: E501 + """Cancel lending loan # noqa: E501 + Only lending loans can be cancelled # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_margin_accounts_with_http_info(async_req=True) + >>> thread = api.cancel_loan_with_http_info(loan_id, currency, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair - :return: list[MarginAccount] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param str currency: Retrieved specified currency related data (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id', 'currency'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_margin_accounts" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_loan" % key) local_var_params[key] = val del local_var_params['kwargs'] + # verify the required parameter 'loan_id' is set + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_id` when calling `cancel_loan`") # noqa: E501 + # verify the required parameter 'currency' is set + if self.api_client.client_side_validation and ( + 'currency' not in local_var_params or local_var_params['currency'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `currency` when calling `cancel_loan`") # noqa: E501 collection_formats = {} path_params = {} + if 'loan_id' in local_var_params: + path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -1028,82 +1137,107 @@ def list_margin_accounts_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/accounts', 'GET', + '/margin/loans/{loan_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[MarginAccount]', # noqa: E501 + response_type='Loan', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_margin_currency_pairs(self, **kwargs): # noqa: E501 - """List all supported currency pairs supported in margin trading # noqa: E501 + def update_loan(self, loan_id, loan_patch, **kwargs): # noqa: E501 + """Modify a loan # noqa: E501 + Only `auto_renew` modification is supported currently # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_margin_currency_pairs(async_req=True) + >>> thread = api.update_loan(loan_id, loan_patch, async_req=True) >>> result = thread.get() - :param async_req bool - :return: list[MarginCurrencyPair] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param LoanPatch loan_patch: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_margin_currency_pairs_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_margin_currency_pairs_with_http_info(**kwargs) # noqa: E501 - return data + return self.update_loan_with_http_info(loan_id, loan_patch, **kwargs) # noqa: E501 - def list_margin_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 - """List all supported currency pairs supported in margin trading # noqa: E501 + def update_loan_with_http_info(self, loan_id, loan_patch, **kwargs): # noqa: E501 + """Modify a loan # noqa: E501 + Only `auto_renew` modification is supported currently # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_margin_currency_pairs_with_http_info(async_req=True) + >>> thread = api.update_loan_with_http_info(loan_id, loan_patch, async_req=True) >>> result = thread.get() - :param async_req bool - :return: list[MarginCurrencyPair] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param LoanPatch loan_patch: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = [] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id', 'loan_patch'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_margin_currency_pairs" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_loan" % key) local_var_params[key] = val del local_var_params['kwargs'] + # verify the required parameter 'loan_id' is set + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_id` when calling `update_loan`") # noqa: E501 + # verify the required parameter 'loan_patch' is set + if self.api_client.client_side_validation and ( + 'loan_patch' not in local_var_params or local_var_params['loan_patch'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_patch` when calling `update_loan`") # noqa: E501 collection_formats = {} path_params = {} + if 'loan_id' in local_var_params: + path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] @@ -1113,101 +1247,110 @@ def list_margin_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None + if 'loan_patch' in local_var_params: + body_params = local_var_params['loan_patch'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/currency_pairs', 'GET', + '/margin/loans/{loan_id}', + 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[MarginCurrencyPair]', # noqa: E501 + response_type='Loan', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def merge_loans(self, currency, ids, **kwargs): # noqa: E501 - """Merge multiple lending loans # noqa: E501 + def list_loan_repayments(self, loan_id, **kwargs): # noqa: E501 + """List loan repayment records # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.merge_loans(currency, ids, async_req=True) + >>> thread = api.list_loan_repayments(loan_id, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data (required) - :param str ids: Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Repayment] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.merge_loans_with_http_info(currency, ids, **kwargs) # noqa: E501 - else: - (data) = self.merge_loans_with_http_info(currency, ids, **kwargs) # noqa: E501 - return data + return self.list_loan_repayments_with_http_info(loan_id, **kwargs) # noqa: E501 - def merge_loans_with_http_info(self, currency, ids, **kwargs): # noqa: E501 - """Merge multiple lending loans # noqa: E501 + def list_loan_repayments_with_http_info(self, loan_id, **kwargs): # noqa: E501 + """List loan repayment records # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.merge_loans_with_http_info(currency, ids, async_req=True) + >>> thread = api.list_loan_repayments_with_http_info(loan_id, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data (required) - :param str ids: Lending loan ID list separated by `,`. Maximum of 20 IDs are allowed in one request (required) - :return: Loan - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str loan_id: Loan ID (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Repayment], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency', 'ids'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method merge_loans" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_loan_repayments" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency' is set - if ('currency' not in local_var_params or - local_var_params['currency'] is None): - raise ValueError("Missing the required parameter `currency` when calling `merge_loans`") # noqa: E501 - # verify the required parameter 'ids' is set - if ('ids' not in local_var_params or - local_var_params['ids'] is None): - raise ValueError("Missing the required parameter `ids` when calling `merge_loans`") # noqa: E501 + # verify the required parameter 'loan_id' is set + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `loan_id` when calling `list_loan_repayments`" + ) # noqa: E501 collection_formats = {} path_params = {} + if 'loan_id' in local_var_params: + path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] - if 'currency' in local_var_params: - query_params.append(('currency', local_var_params['currency'])) # noqa: E501 - if 'ids' in local_var_params: - query_params.append(('ids', local_var_params['ids'])) # noqa: E501 header_params = {} @@ -1216,27 +1359,28 @@ def merge_loans_with_http_info(self, currency, ids, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/merged_loans', 'POST', + '/margin/loans/{loan_id}/repayment', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Loan', # noqa: E501 + response_type='list[Repayment]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) def repay_loan(self, loan_id, repay_request, **kwargs): # noqa: E501 """Repay a loan # noqa: E501 @@ -1246,19 +1390,22 @@ def repay_loan(self, loan_id, repay_request, **kwargs): # noqa: E501 >>> thread = api.repay_loan(loan_id, repay_request, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_id: Loan ID (required) :param RepayRequest repay_request: (required) - :return: Loan - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Loan + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.repay_loan_with_http_info(loan_id, repay_request, **kwargs) # noqa: E501 - else: - (data) = self.repay_loan_with_http_info(loan_id, repay_request, **kwargs) # noqa: E501 - return data + return self.repay_loan_with_http_info(loan_id, repay_request, **kwargs) # noqa: E501 def repay_loan_with_http_info(self, loan_id, repay_request, **kwargs): # noqa: E501 """Repay a loan # noqa: E501 @@ -1268,38 +1415,45 @@ def repay_loan_with_http_info(self, loan_id, repay_request, **kwargs): # noqa: >>> thread = api.repay_loan_with_http_info(loan_id, repay_request, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_id: Loan ID (required) :param RepayRequest repay_request: (required) - :return: Loan - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Loan, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id', 'repay_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id', 'repay_request'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method repay_loan" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method repay_loan" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `repay_loan`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_id` when calling `repay_loan`") # noqa: E501 # verify the required parameter 'repay_request' is set - if ('repay_request' not in local_var_params or - local_var_params['repay_request'] is None): - raise ValueError("Missing the required parameter `repay_request` when calling `repay_loan`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'repay_request' not in local_var_params or local_var_params['repay_request'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `repay_request` when calling `repay_loan`" + ) # noqa: E501 collection_formats = {} @@ -1318,18 +1472,19 @@ def repay_loan_with_http_info(self, loan_id, repay_request, **kwargs): # noqa: if 'repay_request' in local_var_params: body_params = local_var_params['repay_request'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loans/{loan_id}/repayment', 'POST', + '/margin/loans/{loan_id}/repayment', + 'POST', path_params, query_params, header_params, @@ -1342,80 +1497,112 @@ def repay_loan_with_http_info(self, loan_id, repay_request, **kwargs): # noqa: _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def update_loan(self, loan_id, loan_patch, **kwargs): # noqa: E501 - """Modify a loan # noqa: E501 + def list_loan_records(self, loan_id, **kwargs): # noqa: E501 + """List repayment records of specified loan # noqa: E501 - Only `auto_renew` modification is supported currently # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_loan(loan_id, loan_patch, async_req=True) + >>> thread = api.list_loan_records(loan_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_id: Loan ID (required) - :param LoanPatch loan_patch: (required) - :return: Loan - If the method is called asynchronously, + :param str status: Loan record status + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.LoanRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_loan_with_http_info(loan_id, loan_patch, **kwargs) # noqa: E501 - else: - (data) = self.update_loan_with_http_info(loan_id, loan_patch, **kwargs) # noqa: E501 - return data + return self.list_loan_records_with_http_info(loan_id, **kwargs) # noqa: E501 - def update_loan_with_http_info(self, loan_id, loan_patch, **kwargs): # noqa: E501 - """Modify a loan # noqa: E501 + def list_loan_records_with_http_info(self, loan_id, **kwargs): # noqa: E501 + """List repayment records of specified loan # noqa: E501 - Only `auto_renew` modification is supported currently # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.update_loan_with_http_info(loan_id, loan_patch, async_req=True) + >>> thread = api.list_loan_records_with_http_info(loan_id, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_id: Loan ID (required) - :param LoanPatch loan_patch: (required) - :return: Loan - If the method is called asynchronously, + :param str status: Loan record status + :param int page: Page number + :param int limit: Maximum number of records returned in one list + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.LoanRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_id', 'loan_patch'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_id', 'status', 'page', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_loan" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_loan_records" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'loan_id' is set - if ('loan_id' not in local_var_params or - local_var_params['loan_id'] is None): - raise ValueError("Missing the required parameter `loan_id` when calling `update_loan`") # noqa: E501 - # verify the required parameter 'loan_patch' is set - if ('loan_patch' not in local_var_params or - local_var_params['loan_patch'] is None): - raise ValueError("Missing the required parameter `loan_patch` when calling `update_loan`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `loan_id` when calling `list_loan_records`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_loan_records`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_loan_records`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_loan_records`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'loan_id' in local_var_params: - path_params['loan_id'] = local_var_params['loan_id'] # noqa: E501 query_params = [] + if 'loan_id' in local_var_params and local_var_params['loan_id'] is not None: # noqa: E501 + query_params.append(('loan_id', local_var_params['loan_id'])) # noqa: E501 + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -1423,34 +1610,142 @@ def update_loan_with_http_info(self, loan_id, loan_patch, **kwargs): # noqa: E5 local_var_files = {} body_params = None - if 'loan_patch' in local_var_params: - body_params = local_var_params['loan_patch'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + # Authentication setting + auth_settings = ['apiv4'] # noqa: E501 + + return self.api_client.call_api( + '/margin/loan_records', + 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[LoanRecord]', # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats, + ) + + def get_loan_record(self, loan_record_id, loan_id, **kwargs): # noqa: E501 + """Get one single loan record # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_loan_record(loan_record_id, loan_id, async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str loan_record_id: Loan record ID (required) + :param str loan_id: Loan ID (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.LoanRecord + :return: If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + return self.get_loan_record_with_http_info(loan_record_id, loan_id, **kwargs) # noqa: E501 + + def get_loan_record_with_http_info(self, loan_record_id, loan_id, **kwargs): # noqa: E501 + """Get one single loan record # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.get_loan_record_with_http_info(loan_record_id, loan_id, async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str loan_record_id: Loan record ID (required) + :param str loan_id: Loan ID (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.LoanRecord, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ['loan_record_id', 'loan_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_loan_record" % key) + local_var_params[key] = val + del local_var_params['kwargs'] + # verify the required parameter 'loan_record_id' is set + if self.api_client.client_side_validation and ( + 'loan_record_id' not in local_var_params or local_var_params['loan_record_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `loan_record_id` when calling `get_loan_record`" + ) # noqa: E501 + # verify the required parameter 'loan_id' is set + if self.api_client.client_side_validation and ( + 'loan_id' not in local_var_params or local_var_params['loan_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `loan_id` when calling `get_loan_record`") # noqa: E501 + + collection_formats = {} + + path_params = {} + if 'loan_record_id' in local_var_params: + path_params['loan_record_id'] = local_var_params['loan_record_id'] # noqa: E501 + + query_params = [] + if 'loan_id' in local_var_params and local_var_params['loan_id'] is not None: # noqa: E501 + query_params.append(('loan_id', local_var_params['loan_id'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loans/{loan_id}', 'PATCH', + '/margin/loan_records/{loan_record_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Loan', # noqa: E501 + response_type='LoanRecord', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) def update_loan_record(self, loan_record_id, loan_patch, **kwargs): # noqa: E501 """Modify a loan record # noqa: E501 @@ -1461,19 +1756,22 @@ def update_loan_record(self, loan_record_id, loan_patch, **kwargs): # noqa: E50 >>> thread = api.update_loan_record(loan_record_id, loan_patch, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_record_id: Loan record ID (required) :param LoanPatch loan_patch: (required) - :return: LoanRecord - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.LoanRecord + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.update_loan_record_with_http_info(loan_record_id, loan_patch, **kwargs) # noqa: E501 - else: - (data) = self.update_loan_record_with_http_info(loan_record_id, loan_patch, **kwargs) # noqa: E501 - return data + return self.update_loan_record_with_http_info(loan_record_id, loan_patch, **kwargs) # noqa: E501 def update_loan_record_with_http_info(self, loan_record_id, loan_patch, **kwargs): # noqa: E501 """Modify a loan record # noqa: E501 @@ -1484,38 +1782,47 @@ def update_loan_record_with_http_info(self, loan_record_id, loan_patch, **kwargs >>> thread = api.update_loan_record_with_http_info(loan_record_id, loan_patch, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str loan_record_id: Loan record ID (required) :param LoanPatch loan_patch: (required) - :return: LoanRecord - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.LoanRecord, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['loan_record_id', 'loan_patch'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['loan_record_id', 'loan_patch'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method update_loan_record" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method update_loan_record" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'loan_record_id' is set - if ('loan_record_id' not in local_var_params or - local_var_params['loan_record_id'] is None): - raise ValueError("Missing the required parameter `loan_record_id` when calling `update_loan_record`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'loan_record_id' not in local_var_params or local_var_params['loan_record_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `loan_record_id` when calling `update_loan_record`" + ) # noqa: E501 # verify the required parameter 'loan_patch' is set - if ('loan_patch' not in local_var_params or - local_var_params['loan_patch'] is None): - raise ValueError("Missing the required parameter `loan_patch` when calling `update_loan_record`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'loan_patch' not in local_var_params or local_var_params['loan_patch'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `loan_patch` when calling `update_loan_record`" + ) # noqa: E501 collection_formats = {} @@ -1534,18 +1841,19 @@ def update_loan_record_with_http_info(self, loan_record_id, loan_patch, **kwargs if 'loan_patch' in local_var_params: body_params = local_var_params['loan_patch'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/margin/loan_records/{loan_record_id}', 'PATCH', + '/margin/loan_records/{loan_record_id}', + 'PATCH', path_params, query_params, header_params, @@ -1558,4 +1866,5 @@ def update_loan_record_with_http_info(self, loan_record_id, loan_patch, **kwargs _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api/spot_api.py b/gate_api/api/spot_api.py index f7a95a3..94524af 100644 --- a/gate_api/api/spot_api.py +++ b/gate_api/api/spot_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class SpotApi(object): @@ -32,64 +33,62 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def cancel_batch_orders(self, cancel_order, **kwargs): # noqa: E501 - """Cancel a batch of orders with an ID list # noqa: E501 + def list_currency_pairs(self, **kwargs): # noqa: E501 + """List all currency pairs supported # noqa: E501 - Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_batch_orders(cancel_order, async_req=True) + >>> thread = api.list_currency_pairs(async_req=True) >>> result = thread.get() - :param async_req bool - :param list[CancelOrder] cancel_order: (required) - :return: list[CancelOrderResult] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.CurrencyPair] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501 - else: - (data) = self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501 - return data + return self.list_currency_pairs_with_http_info(**kwargs) # noqa: E501 - def cancel_batch_orders_with_http_info(self, cancel_order, **kwargs): # noqa: E501 - """Cancel a batch of orders with an ID list # noqa: E501 + def list_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 + """List all currency pairs supported # noqa: E501 - Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_batch_orders_with_http_info(cancel_order, async_req=True) + >>> thread = api.list_currency_pairs_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param list[CancelOrder] cancel_order: (required) - :return: list[CancelOrderResult] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.CurrencyPair], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['cancel_order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = [] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_batch_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_currency_pairs" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'cancel_order' is set - if ('cancel_order' not in local_var_params or - local_var_params['cancel_order'] is None): - raise ValueError("Missing the required parameter `cancel_order` when calling `cancel_batch_orders`") # noqa: E501 collection_formats = {} @@ -103,106 +102,201 @@ def cancel_batch_orders_with_http_info(self, cancel_order, **kwargs): # noqa: E local_var_files = {} body_params = None - if 'cancel_order' in local_var_params: - body_params = local_var_params['cancel_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/spot/cancel_batch_orders', 'POST', + '/spot/currency_pairs', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[CancelOrderResult]', # noqa: E501 + response_type='list[CurrencyPair]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_order(self, order_id, currency_pair, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def get_currency_pair(self, currency_pair, **kwargs): # noqa: E501 + """Get detail of one single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_order(order_id, currency_pair, async_req=True) + >>> thread = api.get_currency_pair(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str order_id: ID returned on order successfully being created (required) + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :return: Order - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.CurrencyPair + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.cancel_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - return data + return self.get_currency_pair_with_http_info(currency_pair, **kwargs) # noqa: E501 - def cancel_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501 - """Cancel a single order # noqa: E501 + def get_currency_pair_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """Get detail of one single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_order_with_http_info(order_id, currency_pair, async_req=True) + >>> thread = api.get_currency_pair_with_http_info(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str order_id: ID returned on order successfully being created (required) + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :return: Order - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.CurrencyPair, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['order_id', 'currency_pair'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_currency_pair" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `cancel_order`") # noqa: E501 # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `cancel_order`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `get_currency_pair`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 + if 'currency_pair' in local_var_params: + path_params['currency_pair'] = local_var_params['currency_pair'] # noqa: E501 query_params = [] - if 'currency_pair' in local_var_params: + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + '/spot/currency_pairs/{currency_pair}', + 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='CurrencyPair', # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats, + ) + + def list_tickers(self, **kwargs): # noqa: E501 + """Retrieve ticker information # noqa: E501 + + Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_tickers(async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Ticker] + :return: If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + return self.list_tickers_with_http_info(**kwargs) # noqa: E501 + + def list_tickers_with_http_info(self, **kwargs): # noqa: E501 + """Retrieve ticker information # noqa: E501 + + Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_tickers_with_http_info(async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Ticker], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ['currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_tickers" % key) + local_var_params[key] = val + del local_var_params['kwargs'] + + collection_formats = {} + + path_params = {} + + query_params = [] + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 header_params = {} @@ -212,100 +306,124 @@ def cancel_order_with_http_info(self, order_id, currency_pair, **kwargs): # noq body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/spot/orders/{order_id}', 'DELETE', + '/spot/tickers', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Order', # noqa: E501 + response_type='list[Ticker]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def cancel_orders(self, currency_pair, **kwargs): # noqa: E501 - """Cancel all `open` orders in specified currency pair # noqa: E501 + def list_order_book(self, currency_pair, **kwargs): # noqa: E501 + """Retrieve order book # noqa: E501 + Order book will be sorted by price from high to low on bids; reversed on asks # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_orders(currency_pair, async_req=True) + >>> thread = api.list_order_book(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :param str side: All bids or asks. Both included in not specified - :param str account: Specify account type. Default to all account types being included - :return: list[Order] - If the method is called asynchronously, + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.OrderBook + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.cancel_orders_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.cancel_orders_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.list_order_book_with_http_info(currency_pair, **kwargs) # noqa: E501 - def cancel_orders_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """Cancel all `open` orders in specified currency pair # noqa: E501 + def list_order_book_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """Retrieve order book # noqa: E501 + Order book will be sorted by price from high to low on bids; reversed on asks # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.cancel_orders_with_http_info(currency_pair, async_req=True) + >>> thread = api.list_order_book_with_http_info(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :param str side: All bids or asks. Both included in not specified - :param str account: Specify account type. Default to all account types being included - :return: list[Order] - If the method is called asynchronously, + :param str interval: Order depth. 0 means no aggregation is applied. default to 0 + :param int limit: Maximum number of order depth data in asks or bids + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.OrderBook, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'side', 'account'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair', 'interval', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method cancel_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_order_book" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `cancel_orders`") # noqa: E501 - + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `list_order_book`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 30 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_order_book`, must be a value less than or equal to `30`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_order_book`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'side' in local_var_params: - query_params.append(('side', local_var_params['side'])) # noqa: E501 - if 'account' in local_var_params: - query_params.append(('account', local_var_params['account'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -314,92 +432,122 @@ def cancel_orders_with_http_info(self, currency_pair, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/spot/orders', 'DELETE', + '/spot/order_book', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Order]', # noqa: E501 + response_type='OrderBook', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_batch_orders(self, order, **kwargs): # noqa: E501 - """Create a batch of orders # noqa: E501 + def list_trades(self, currency_pair, **kwargs): # noqa: E501 + """Retrieve market trades # noqa: E501 - Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_batch_orders(order, async_req=True) + >>> thread = api.list_trades(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param list[Order] order: (required) - :return: list[BatchOrder] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Trade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501 - else: - (data) = self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501 - return data + return self.list_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - def create_batch_orders_with_http_info(self, order, **kwargs): # noqa: E501 - """Create a batch of orders # noqa: E501 + def list_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """Retrieve market trades # noqa: E501 - Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_batch_orders_with_http_info(order, async_req=True) + >>> thread = api.list_trades_with_http_info(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param list[Order] order: (required) - :return: list[BatchOrder] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param int limit: Maximum number of records returned in one list + :param str last_id: Specify list staring point using the `id` of last record in previous list-query results + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Trade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair', 'limit', 'last_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_batch_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'order' is set - if ('order' not in local_var_params or - local_var_params['order'] is None): - raise ValueError("Missing the required parameter `order` when calling `create_batch_orders`") # noqa: E501 - + # verify the required parameter 'currency_pair' is set + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `list_trades`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'last_id' in local_var_params and local_var_params['last_id'] is not None: # noqa: E501 + query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 header_params = {} @@ -407,97 +555,224 @@ def create_batch_orders_with_http_info(self, order, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'order' in local_var_params: - body_params = local_var_params['order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + # Authentication setting + auth_settings = [] # noqa: E501 + + return self.api_client.call_api( + '/spot/trades', + 'GET', + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=local_var_files, + response_type='list[Trade]', # noqa: E501 + auth_settings=auth_settings, + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats, + ) + + def list_candlesticks(self, currency_pair, **kwargs): # noqa: E501 + """Market candlesticks # noqa: E501 + + Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_candlesticks(currency_pair, async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param str interval: Interval time between data points + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[list[str]] + :return: If the method is called asynchronously, + returns the request thread. + """ + kwargs['_return_http_data_only'] = True + return self.list_candlesticks_with_http_info(currency_pair, **kwargs) # noqa: E501 + + def list_candlesticks_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """Market candlesticks # noqa: E501 + + Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.list_candlesticks_with_http_info(currency_pair, async_req=True) + >>> result = thread.get() + + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. + :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified + :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time + :param str interval: Interval time between data points + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[list[str]], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, + returns the request thread. + """ + + local_var_params = locals() + + all_params = ['currency_pair', 'limit', '_from', 'to', 'interval'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) + + for key, val in six.iteritems(local_var_params['kwargs']): + if key not in all_params: + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_candlesticks" % key) + local_var_params[key] = val + del local_var_params['kwargs'] + # verify the required parameter 'currency_pair' is set + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `list_candlesticks`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_candlesticks`, must be a value less than or equal to `1000`" + ) # noqa: E501 + collection_formats = {} + + path_params = {} + + query_params = [] + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'interval' in local_var_params and local_var_params['interval'] is not None: # noqa: E501 + query_params.append(('interval', local_var_params['interval'])) # noqa: E501 + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = ['apiv4'] # noqa: E501 + auth_settings = [] # noqa: E501 return self.api_client.call_api( - '/spot/batch_orders', 'POST', + '/spot/candlesticks', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[BatchOrder]', # noqa: E501 + response_type='list[list[str]]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def create_order(self, order, **kwargs): # noqa: E501 - """Create an order # noqa: E501 + def get_fee(self, **kwargs): # noqa: E501 + """Query user trading fee rates # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_order(order, async_req=True) + >>> thread = api.get_fee(async_req=True) >>> result = thread.get() - :param async_req bool - :param Order order: (required) - :return: Order - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.TradeFee + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.create_order_with_http_info(order, **kwargs) # noqa: E501 - else: - (data) = self.create_order_with_http_info(order, **kwargs) # noqa: E501 - return data + return self.get_fee_with_http_info(**kwargs) # noqa: E501 - def create_order_with_http_info(self, order, **kwargs): # noqa: E501 - """Create an order # noqa: E501 + def get_fee_with_http_info(self, **kwargs): # noqa: E501 + """Query user trading fee rates # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_order_with_http_info(order, async_req=True) + >>> thread = api.get_fee_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param Order order: (required) - :return: Order - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.TradeFee, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['order'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method create_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_fee" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'order' is set - if ('order' not in local_var_params or - local_var_params['order'] is None): - raise ValueError("Missing the required parameter `order` when calling `create_order`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 header_params = {} @@ -505,99 +780,96 @@ def create_order_with_http_info(self, order, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'order' in local_var_params: - body_params = local_var_params['order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/orders', 'POST', + '/spot/fee', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Order', # noqa: E501 + response_type='TradeFee', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_currency_pair(self, currency_pair, **kwargs): # noqa: E501 - """Get detail of one single order # noqa: E501 + def list_spot_accounts(self, **kwargs): # noqa: E501 + """List spot accounts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_currency_pair(currency_pair, async_req=True) + >>> thread = api.list_spot_accounts(async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :return: CurrencyPair - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.SpotAccount] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_currency_pair_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.get_currency_pair_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.list_spot_accounts_with_http_info(**kwargs) # noqa: E501 - def get_currency_pair_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """Get detail of one single order # noqa: E501 + def list_spot_accounts_with_http_info(self, **kwargs): # noqa: E501 + """List spot accounts # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_currency_pair_with_http_info(currency_pair, async_req=True) + >>> thread = api.list_spot_accounts_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :return: CurrencyPair - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency: Retrieved specified currency related data + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.SpotAccount], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_currency_pair" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_spot_accounts" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `get_currency_pair`") # noqa: E501 collection_formats = {} path_params = {} - if 'currency_pair' in local_var_params: - path_params['currency_pair'] = local_var_params['currency_pair'] # noqa: E501 query_params = [] + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -606,100 +878,102 @@ def get_currency_pair_with_http_info(self, currency_pair, **kwargs): # noqa: E5 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/currency_pairs/{currency_pair}', 'GET', + '/spot/accounts', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='CurrencyPair', # noqa: E501 + response_type='list[SpotAccount]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def get_order(self, order_id, currency_pair, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def create_batch_orders(self, order, **kwargs): # noqa: E501 + """Create a batch of orders # noqa: E501 + Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_order(order_id, currency_pair, async_req=True) + >>> thread = api.create_batch_orders(order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str order_id: ID returned on order successfully being created (required) - :param str currency_pair: Currency pair (required) - :return: Order - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param list[Order] order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.BatchOrder] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.get_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - return data + return self.create_batch_orders_with_http_info(order, **kwargs) # noqa: E501 - def get_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501 - """Get a single order # noqa: E501 + def create_batch_orders_with_http_info(self, order, **kwargs): # noqa: E501 + """Create a batch of orders # noqa: E501 + Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_order_with_http_info(order_id, currency_pair, async_req=True) + >>> thread = api.create_batch_orders_with_http_info(order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str order_id: ID returned on order successfully being created (required) - :param str currency_pair: Currency pair (required) - :return: Order - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param list[Order] order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.BatchOrder], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['order_id', 'currency_pair'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_order" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_batch_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'order_id' is set - if ('order_id' not in local_var_params or - local_var_params['order_id'] is None): - raise ValueError("Missing the required parameter `order_id` when calling `get_order`") # noqa: E501 - # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `get_order`") # noqa: E501 + # verify the required parameter 'order' is set + if self.api_client.client_side_validation and ( + 'order' not in local_var_params or local_var_params['order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `order` when calling `create_batch_orders`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'order_id' in local_var_params: - path_params['order_id'] = local_var_params['order_id'] # noqa: E501 - query_params = [] - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + query_params = [] header_params = {} @@ -707,113 +981,127 @@ def get_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: local_var_files = {} body_params = None + if 'order' in local_var_params: + body_params = local_var_params['order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/orders/{order_id}', 'GET', + '/spot/batch_orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='Order', # noqa: E501 + response_type='list[BatchOrder]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_candlesticks(self, currency_pair, **kwargs): # noqa: E501 - """Market candlesticks # noqa: E501 + def list_all_open_orders(self, **kwargs): # noqa: E501 + """List all open orders # noqa: E501 - Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 + List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_candlesticks(currency_pair, async_req=True) + >>> thread = api.list_all_open_orders(async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param str interval: Interval time between data points - :return: list[list[str]] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param int page: Page number + :param int limit: Maximum number of records returned in one page in each currency pair + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.OpenOrders] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_candlesticks_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.list_candlesticks_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.list_all_open_orders_with_http_info(**kwargs) # noqa: E501 - def list_candlesticks_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """Market candlesticks # noqa: E501 + def list_all_open_orders_with_http_info(self, **kwargs): # noqa: E501 + """List all open orders # noqa: E501 - Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval` # noqa: E501 + List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_candlesticks_with_http_info(currency_pair, async_req=True) + >>> thread = api.list_all_open_orders_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param int limit: Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. - :param int _from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified - :param int to: End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time - :param str interval: Interval time between data points - :return: list[list[str]] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param int page: Page number + :param int limit: Maximum number of records returned in one page in each currency pair + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.OpenOrders], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'limit', '_from', 'to', 'interval'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['page', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_candlesticks" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_all_open_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `list_candlesticks`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_candlesticks`, must be a value less than or equal to `1000`") # noqa: E501 + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_all_open_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 100 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_all_open_orders`, must be a value less than or equal to `100`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_all_open_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'limit' in local_var_params: + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 header_params = {} @@ -822,84 +1110,137 @@ def list_candlesticks_with_http_info(self, currency_pair, **kwargs): # noqa: E5 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/candlesticks', 'GET', + '/spot/open_orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[list[str]]', # noqa: E501 + response_type='list[OpenOrders]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_currency_pairs(self, **kwargs): # noqa: E501 - """List all currency pairs supported # noqa: E501 + def list_orders(self, currency_pair, status, **kwargs): # noqa: E501 + """List orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_currency_pairs(async_req=True) + >>> thread = api.list_orders(currency_pair, status, async_req=True) >>> result = thread.get() - :param async_req bool - :return: list[CurrencyPair] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required) + :param int page: Page number + :param int limit: Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Order] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_currency_pairs_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_currency_pairs_with_http_info(**kwargs) # noqa: E501 - return data + return self.list_orders_with_http_info(currency_pair, status, **kwargs) # noqa: E501 - def list_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 - """List all currency pairs supported # noqa: E501 + def list_orders_with_http_info(self, currency_pair, status, **kwargs): # noqa: E501 + """List orders # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_currency_pairs_with_http_info(async_req=True) + >>> thread = api.list_orders_with_http_info(currency_pair, status, async_req=True) >>> result = thread.get() - :param async_req bool - :return: list[CurrencyPair] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str currency_pair: Currency pair (required) + :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required) + :param int page: Page number + :param int limit: Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Order], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = [] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair', 'status', 'page', 'limit'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_currency_pairs" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] - + # verify the required parameter 'currency_pair' is set + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `list_orders`" + ) # noqa: E501 + # verify the required parameter 'status' is set + if self.api_client.client_side_validation and ( + 'status' not in local_var_params or local_var_params['status'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `status` when calling `list_orders`") # noqa: E501 + + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_orders`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_orders`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 + if 'status' in local_var_params and local_var_params['status'] is not None: # noqa: E501 + query_params.append(('status', local_var_params['status'])) # noqa: E501 + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -908,110 +1249,98 @@ def list_currency_pairs_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/currency_pairs', 'GET', + '/spot/orders', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[CurrencyPair]', # noqa: E501 + response_type='list[Order]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_my_trades(self, currency_pair, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def create_order(self, order, **kwargs): # noqa: E501 + """Create an order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_my_trades(currency_pair, async_req=True) + >>> thread = api.create_order(order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param int limit: Maximum number of records returned in one list - :param int page: Page number - :param str order_id: List all trades of specified order - :return: list[Trade] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Order order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Order + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_my_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.list_my_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.create_order_with_http_info(order, **kwargs) # noqa: E501 - def list_my_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """List personal trading history # noqa: E501 + def create_order_with_http_info(self, order, **kwargs): # noqa: E501 + """Create an order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_my_trades_with_http_info(currency_pair, async_req=True) + >>> thread = api.create_order_with_http_info(order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param int limit: Maximum number of records returned in one list - :param int page: Page number - :param str order_id: List all trades of specified order - :return: list[Trade] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Order order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'limit', 'page', 'order_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_my_trades" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method create_order" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `list_my_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_my_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_my_trades`, must be a value greater than or equal to `1`") # noqa: E501 - if 'page' in local_var_params and local_var_params['page'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `page` when calling `list_my_trades`, must be a value greater than or equal to `1`") # noqa: E501 + # verify the required parameter 'order' is set + if self.api_client.client_side_validation and ( + 'order' not in local_var_params or local_var_params['order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `order` when calling `create_order`") # noqa: E501 + collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'order_id' in local_var_params: - query_params.append(('order_id', local_var_params['order_id'])) # noqa: E501 header_params = {} @@ -1019,107 +1348,118 @@ def list_my_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 local_var_files = {} body_params = None + if 'order' in local_var_params: + body_params = local_var_params['order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/my_trades', 'GET', + '/spot/orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Trade]', # noqa: E501 + response_type='Order', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_order_book(self, currency_pair, **kwargs): # noqa: E501 - """Retrieve order book # noqa: E501 + def cancel_orders(self, currency_pair, **kwargs): # noqa: E501 + """Cancel all `open` orders in specified currency pair # noqa: E501 - Order book will be sorted by price from high to low on bids; reversed on asks # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_order_book(currency_pair, async_req=True) + >>> thread = api.cancel_orders(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: OrderBook - If the method is called asynchronously, + :param str side: All bids or asks. Both included in not specified + :param str account: Specify account type. Default to all account types being included + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Order] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_order_book_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.list_order_book_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.cancel_orders_with_http_info(currency_pair, **kwargs) # noqa: E501 - def list_order_book_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """Retrieve order book # noqa: E501 + def cancel_orders_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """Cancel all `open` orders in specified currency pair # noqa: E501 - Order book will be sorted by price from high to low on bids; reversed on asks # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_order_book_with_http_info(currency_pair, async_req=True) + >>> thread = api.cancel_orders_with_http_info(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) - :param str interval: Order depth. 0 means no aggregation is applied. default to 0 - :param int limit: Maximum number of order depth data in asks or bids - :return: OrderBook - If the method is called asynchronously, + :param str side: All bids or asks. Both included in not specified + :param str account: Specify account type. Default to all account types being included + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Order], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'interval', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair', 'side', 'account'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_order_book" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `list_order_book`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 30: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_order_book`, must be a value less than or equal to `30`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_order_book`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `cancel_orders`" + ) # noqa: E501 + collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'interval' in local_var_params: - query_params.append(('interval', local_var_params['interval'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'side' in local_var_params and local_var_params['side'] is not None: # noqa: E501 + query_params.append(('side', local_var_params['side'])) # noqa: E501 + if 'account' in local_var_params and local_var_params['account'] is not None: # noqa: E501 + query_params.append(('account', local_var_params['account'])) # noqa: E501 header_params = {} @@ -1128,114 +1468,102 @@ def list_order_book_with_http_info(self, currency_pair, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/order_book', 'GET', + '/spot/orders', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderBook', # noqa: E501 + response_type='list[Order]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_orders(self, currency_pair, status, **kwargs): # noqa: E501 - """List orders # noqa: E501 + def cancel_batch_orders(self, cancel_order, **kwargs): # noqa: E501 + """Cancel a batch of orders with an ID list # noqa: E501 + Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_orders(currency_pair, status, async_req=True) + >>> thread = api.cancel_batch_orders(cancel_order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required) - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[Order] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param list[CancelOrder] cancel_order: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.CancelOrderResult] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_orders_with_http_info(currency_pair, status, **kwargs) # noqa: E501 - else: - (data) = self.list_orders_with_http_info(currency_pair, status, **kwargs) # noqa: E501 - return data + return self.cancel_batch_orders_with_http_info(cancel_order, **kwargs) # noqa: E501 - def list_orders_with_http_info(self, currency_pair, status, **kwargs): # noqa: E501 - """List orders # noqa: E501 + def cancel_batch_orders_with_http_info(self, cancel_order, **kwargs): # noqa: E501 + """Cancel a batch of orders with an ID list # noqa: E501 + Multiple currency pairs can be specified, but maximum 20 orders are allowed per request # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_orders_with_http_info(currency_pair, status, async_req=True) + >>> thread = api.cancel_batch_orders_with_http_info(cancel_order, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair (required) - :param str status: List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled (required) - :param int page: Page number - :param int limit: Maximum number of records returned in one list - :return: list[Order] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param list[CancelOrder] cancel_order: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.CancelOrderResult], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'status', 'page', 'limit'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['cancel_order'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_orders" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_batch_orders" % key) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `list_orders`") # noqa: E501 - # verify the required parameter 'status' is set - if ('status' not in local_var_params or - local_var_params['status'] is None): - raise ValueError("Missing the required parameter `status` when calling `list_orders`") # noqa: E501 - - if 'page' in local_var_params and local_var_params['page'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `page` when calling `list_orders`, must be a value greater than or equal to `1`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_orders`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_orders`, must be a value greater than or equal to `1`") # noqa: E501 + # verify the required parameter 'cancel_order' is set + if self.api_client.client_side_validation and ( + 'cancel_order' not in local_var_params or local_var_params['cancel_order'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `cancel_order` when calling `cancel_batch_orders`" + ) # noqa: E501 + collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: - query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'status' in local_var_params: - query_params.append(('status', local_var_params['status'])) # noqa: E501 - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 header_params = {} @@ -1243,89 +1571,117 @@ def list_orders_with_http_info(self, currency_pair, status, **kwargs): # noqa: local_var_files = {} body_params = None + if 'cancel_order' in local_var_params: + body_params = local_var_params['cancel_order'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/orders', 'GET', + '/spot/cancel_batch_orders', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Order]', # noqa: E501 + response_type='list[CancelOrderResult]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_spot_accounts(self, **kwargs): # noqa: E501 - """List spot accounts # noqa: E501 + def get_order(self, order_id, currency_pair, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_spot_accounts(async_req=True) + >>> thread = api.get_order(order_id, currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data - :return: list[SpotAccount] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str order_id: ID returned on order successfully being created (required) + :param str currency_pair: Currency pair (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Order + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_spot_accounts_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_spot_accounts_with_http_info(**kwargs) # noqa: E501 - return data + return self.get_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - def list_spot_accounts_with_http_info(self, **kwargs): # noqa: E501 - """List spot accounts # noqa: E501 + def get_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501 + """Get a single order # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_spot_accounts_with_http_info(async_req=True) + >>> thread = api.get_order_with_http_info(order_id, currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Retrieved specified currency related data - :return: list[SpotAccount] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str order_id: ID returned on order successfully being created (required) + :param str currency_pair: Currency pair (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['order_id', 'currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_spot_accounts" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_order" % key) local_var_params[key] = val del local_var_params['kwargs'] + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `order_id` when calling `get_order`") # noqa: E501 + # verify the required parameter 'currency_pair' is set + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `currency_pair` when calling `get_order`") # noqa: E501 collection_formats = {} path_params = {} + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'currency' in local_var_params: - query_params.append(('currency', local_var_params['currency'])) # noqa: E501 + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 + query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 header_params = {} @@ -1334,89 +1690,110 @@ def list_spot_accounts_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/accounts', 'GET', + '/spot/orders/{order_id}', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[SpotAccount]', # noqa: E501 + response_type='Order', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_tickers(self, **kwargs): # noqa: E501 - """Retrieve ticker information # noqa: E501 + def cancel_order(self, order_id, currency_pair, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 - Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_tickers(async_req=True) + >>> thread = api.cancel_order(order_id, currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair - :return: list[Ticker] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str order_id: ID returned on order successfully being created (required) + :param str currency_pair: Currency pair (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.Order + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_tickers_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_tickers_with_http_info(**kwargs) # noqa: E501 - return data + return self.cancel_order_with_http_info(order_id, currency_pair, **kwargs) # noqa: E501 - def list_tickers_with_http_info(self, **kwargs): # noqa: E501 - """Retrieve ticker information # noqa: E501 + def cancel_order_with_http_info(self, order_id, currency_pair, **kwargs): # noqa: E501 + """Cancel a single order # noqa: E501 - Return only related data if `currency_pair` is specified; otherwise return all of them # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_tickers_with_http_info(async_req=True) + >>> thread = api.cancel_order_with_http_info(order_id, currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency_pair: Currency pair - :return: list[Ticker] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str order_id: ID returned on order successfully being created (required) + :param str currency_pair: Currency pair (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.Order, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['order_id', 'currency_pair'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_tickers" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method cancel_order" % key) local_var_params[key] = val del local_var_params['kwargs'] + # verify the required parameter 'order_id' is set + if self.api_client.client_side_validation and ( + 'order_id' not in local_var_params or local_var_params['order_id'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `order_id` when calling `cancel_order`") # noqa: E501 + # verify the required parameter 'currency_pair' is set + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `cancel_order`" + ) # noqa: E501 collection_formats = {} path_params = {} + if 'order_id' in local_var_params: + path_params['order_id'] = local_var_params['order_id'] # noqa: E501 query_params = [] - if 'currency_pair' in local_var_params: + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 header_params = {} @@ -1426,104 +1803,132 @@ def list_tickers_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/tickers', 'GET', + '/spot/orders/{order_id}', + 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[Ticker]', # noqa: E501 + response_type='Order', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_trades(self, currency_pair, **kwargs): # noqa: E501 - """Retrieve market trades # noqa: E501 + def list_my_trades(self, currency_pair, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_trades(currency_pair, async_req=True) + >>> thread = api.list_my_trades(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :return: list[Trade] - If the method is called asynchronously, + :param int page: Page number + :param str order_id: List all trades of specified order + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.Trade] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - else: - (data) = self.list_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - return data + return self.list_my_trades_with_http_info(currency_pair, **kwargs) # noqa: E501 - def list_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 - """Retrieve market trades # noqa: E501 + def list_my_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 + """List personal trading history # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_trades_with_http_info(currency_pair, async_req=True) + >>> thread = api.list_my_trades_with_http_info(currency_pair, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency_pair: Currency pair (required) :param int limit: Maximum number of records returned in one list - :param str last_id: Specify list staring point using the `id` of last record in previous list-query results - :return: list[Trade] - If the method is called asynchronously, + :param int page: Page number + :param str order_id: List all trades of specified order + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.Trade], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency_pair', 'limit', 'last_id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency_pair', 'limit', 'page', 'order_id'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_trades" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_my_trades" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'currency_pair' is set - if ('currency_pair' not in local_var_params or - local_var_params['currency_pair'] is None): - raise ValueError("Missing the required parameter `currency_pair` when calling `list_trades`") # noqa: E501 - - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_trades`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_trades`, must be a value greater than or equal to `1`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'currency_pair' not in local_var_params or local_var_params['currency_pair'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency_pair` when calling `list_my_trades`" + ) # noqa: E501 + + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_my_trades`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_my_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'page' in local_var_params and local_var_params['page'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `page` when calling `list_my_trades`, must be a value greater than or equal to `1`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency_pair' in local_var_params: + if 'currency_pair' in local_var_params and local_var_params['currency_pair'] is not None: # noqa: E501 query_params.append(('currency_pair', local_var_params['currency_pair'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'last_id' in local_var_params: - query_params.append(('last_id', local_var_params['last_id'])) # noqa: E501 + if 'page' in local_var_params and local_var_params['page'] is not None: # noqa: E501 + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'order_id' in local_var_params and local_var_params['order_id'] is not None: # noqa: E501 + query_params.append(('order_id', local_var_params['order_id'])) # noqa: E501 header_params = {} @@ -1532,14 +1937,14 @@ def list_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting - auth_settings = [] # noqa: E501 + auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/spot/trades', 'GET', + '/spot/my_trades', + 'GET', path_params, query_params, header_params, @@ -1552,4 +1957,5 @@ def list_trades_with_http_info(self, currency_pair, **kwargs): # noqa: E501 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api/wallet_api.py b/gate_api/api/wallet_api.py index 23a062a..3d5a45e 100644 --- a/gate_api/api/wallet_api.py +++ b/gate_api/api/wallet_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class WalletApi(object): @@ -40,18 +41,21 @@ def get_deposit_address(self, currency, **kwargs): # noqa: E501 >>> thread = api.get_deposit_address(currency, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Currency name (required) - :return: DepositAddress - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.DepositAddress + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.get_deposit_address_with_http_info(currency, **kwargs) # noqa: E501 - else: - (data) = self.get_deposit_address_with_http_info(currency, **kwargs) # noqa: E501 - return data + return self.get_deposit_address_with_http_info(currency, **kwargs) # noqa: E501 def get_deposit_address_with_http_info(self, currency, **kwargs): # noqa: E501 """Generate currency deposit address # noqa: E501 @@ -61,40 +65,46 @@ def get_deposit_address_with_http_info(self, currency, **kwargs): # noqa: E501 >>> thread = api.get_deposit_address_with_http_info(currency, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Currency name (required) - :return: DepositAddress - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.DepositAddress, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method get_deposit_address" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method get_deposit_address" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'currency' is set - if ('currency' not in local_var_params or - local_var_params['currency'] is None): - raise ValueError("Missing the required parameter `currency` when calling `get_deposit_address`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'currency' not in local_var_params or local_var_params['currency'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `currency` when calling `get_deposit_address`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency' in local_var_params: + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 query_params.append(('currency', local_var_params['currency'])) # noqa: E501 header_params = {} @@ -104,14 +114,14 @@ def get_deposit_address_with_http_info(self, currency, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/deposit_address', 'GET', + '/wallet/deposit_address', + 'GET', path_params, query_params, header_params, @@ -124,91 +134,110 @@ def get_deposit_address_with_http_info(self, currency, **kwargs): # noqa: E501 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_deposits(self, **kwargs): # noqa: E501 - """Retrieve deposit records # noqa: E501 + def list_withdrawals(self, **kwargs): # noqa: E501 + """Retrieve withdrawal records # noqa: E501 Record time range cannot exceed 30 days # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_deposits(async_req=True) + >>> thread = api.list_withdrawals(async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Filter by currency. Return all currency records if not specified :param int _from: Time range beginning, default to 7 days before current time :param int to: Time range ending, default to current time :param int limit: Maximum number of records returned in one list :param int offset: List offset, starting from 0 - :return: list[LedgerRecord] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.LedgerRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_deposits_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_deposits_with_http_info(**kwargs) # noqa: E501 - return data + return self.list_withdrawals_with_http_info(**kwargs) # noqa: E501 - def list_deposits_with_http_info(self, **kwargs): # noqa: E501 - """Retrieve deposit records # noqa: E501 + def list_withdrawals_with_http_info(self, **kwargs): # noqa: E501 + """Retrieve withdrawal records # noqa: E501 Record time range cannot exceed 30 days # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_deposits_with_http_info(async_req=True) + >>> thread = api.list_withdrawals_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param str currency: Filter by currency. Return all currency records if not specified :param int _from: Time range beginning, default to 7 days before current time :param int to: Time range ending, default to current time :param int limit: Maximum number of records returned in one list :param int offset: List offset, starting from 0 - :return: list[LedgerRecord] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.LedgerRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency', '_from', 'to', 'limit', 'offset'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency', '_from', 'to', 'limit', 'offset'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_deposits" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_withdrawals" % key) local_var_params[key] = val del local_var_params['kwargs'] - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_deposits`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_deposits`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_deposits`, must be a value greater than or equal to `0`") # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_withdrawals`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_withdrawals`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_withdrawals`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency' in local_var_params: + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 query_params.append(('currency', local_var_params['currency'])) # noqa: E501 - if '_from' in local_var_params: + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -218,14 +247,14 @@ def list_deposits_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/deposits', 'GET', + '/wallet/withdrawals', + 'GET', path_params, query_params, header_params, @@ -238,91 +267,110 @@ def list_deposits_with_http_info(self, **kwargs): # noqa: E501 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_sub_account_transfers(self, **kwargs): # noqa: E501 - """Transfer records between main and sub accounts # noqa: E501 + def list_deposits(self, **kwargs): # noqa: E501 + """Retrieve deposit records # noqa: E501 - Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved # noqa: E501 + Record time range cannot exceed 30 days # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_sub_account_transfers(async_req=True) + >>> thread = api.list_deposits(async_req=True) >>> result = thread.get() - :param async_req bool - :param str sub_uid: Sub account user ID. Return records related to all sub accounts if not specified + :param bool async_req: execute request asynchronously + :param str currency: Filter by currency. Return all currency records if not specified :param int _from: Time range beginning, default to 7 days before current time :param int to: Time range ending, default to current time :param int limit: Maximum number of records returned in one list :param int offset: List offset, starting from 0 - :return: list[SubAccountTransfer] - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.LedgerRecord] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_sub_account_transfers_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_sub_account_transfers_with_http_info(**kwargs) # noqa: E501 - return data + return self.list_deposits_with_http_info(**kwargs) # noqa: E501 - def list_sub_account_transfers_with_http_info(self, **kwargs): # noqa: E501 - """Transfer records between main and sub accounts # noqa: E501 + def list_deposits_with_http_info(self, **kwargs): # noqa: E501 + """Retrieve deposit records # noqa: E501 - Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved # noqa: E501 + Record time range cannot exceed 30 days # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_sub_account_transfers_with_http_info(async_req=True) + >>> thread = api.list_deposits_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param str sub_uid: Sub account user ID. Return records related to all sub accounts if not specified + :param bool async_req: execute request asynchronously + :param str currency: Filter by currency. Return all currency records if not specified :param int _from: Time range beginning, default to 7 days before current time :param int to: Time range ending, default to current time :param int limit: Maximum number of records returned in one list :param int offset: List offset, starting from 0 - :return: list[SubAccountTransfer] - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.LedgerRecord], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['sub_uid', '_from', 'to', 'limit', 'offset'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['currency', '_from', 'to', 'limit', 'offset'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_sub_account_transfers" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method list_deposits" % key) local_var_params[key] = val del local_var_params['kwargs'] - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_sub_account_transfers`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_sub_account_transfers`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_sub_account_transfers`, must be a value greater than or equal to `0`") # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_deposits`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_deposits`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_deposits`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'sub_uid' in local_var_params: - query_params.append(('sub_uid', local_var_params['sub_uid'])) # noqa: E501 - if '_from' in local_var_params: + if 'currency' in local_var_params and local_var_params['currency'] is not None: # noqa: E501 + query_params.append(('currency', local_var_params['currency'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'limit' in local_var_params: + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -332,112 +380,100 @@ def list_sub_account_transfers_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/sub_account_transfers', 'GET', + '/wallet/deposits', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[SubAccountTransfer]', # noqa: E501 + response_type='list[LedgerRecord]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def list_withdrawals(self, **kwargs): # noqa: E501 - """Retrieve withdrawal records # noqa: E501 + def transfer(self, transfer, **kwargs): # noqa: E501 + """Transfer between trading accounts # noqa: E501 - Record time range cannot exceed 30 days # noqa: E501 + Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_withdrawals(async_req=True) + >>> thread = api.transfer(transfer, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Filter by currency. Return all currency records if not specified - :param int _from: Time range beginning, default to 7 days before current time - :param int to: Time range ending, default to current time - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[LedgerRecord] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Transfer transfer: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: None + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.list_withdrawals_with_http_info(**kwargs) # noqa: E501 - else: - (data) = self.list_withdrawals_with_http_info(**kwargs) # noqa: E501 - return data + return self.transfer_with_http_info(transfer, **kwargs) # noqa: E501 - def list_withdrawals_with_http_info(self, **kwargs): # noqa: E501 - """Retrieve withdrawal records # noqa: E501 + def transfer_with_http_info(self, transfer, **kwargs): # noqa: E501 + """Transfer between trading accounts # noqa: E501 - Record time range cannot exceed 30 days # noqa: E501 + Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.list_withdrawals_with_http_info(async_req=True) + >>> thread = api.transfer_with_http_info(transfer, async_req=True) >>> result = thread.get() - :param async_req bool - :param str currency: Filter by currency. Return all currency records if not specified - :param int _from: Time range beginning, default to 7 days before current time - :param int to: Time range ending, default to current time - :param int limit: Maximum number of records returned in one list - :param int offset: List offset, starting from 0 - :return: list[LedgerRecord] - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param Transfer transfer: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: None + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['currency', '_from', 'to', 'limit', 'offset'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['transfer'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method list_withdrawals" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method transfer" % key) local_var_params[key] = val del local_var_params['kwargs'] + # verify the required parameter 'transfer' is set + if self.api_client.client_side_validation and ( + 'transfer' not in local_var_params or local_var_params['transfer'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `transfer` when calling `transfer`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] > 1000: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_withdrawals`, must be a value less than or equal to `1000`") # noqa: E501 - if 'limit' in local_var_params and local_var_params['limit'] < 1: # noqa: E501 - raise ValueError("Invalid value for parameter `limit` when calling `list_withdrawals`, must be a value greater than or equal to `1`") # noqa: E501 - if 'offset' in local_var_params and local_var_params['offset'] < 0: # noqa: E501 - raise ValueError("Invalid value for parameter `offset` when calling `list_withdrawals`, must be a value greater than or equal to `0`") # noqa: E501 collection_formats = {} path_params = {} query_params = [] - if 'currency' in local_var_params: - query_params.append(('currency', local_var_params['currency'])) # noqa: E501 - if '_from' in local_var_params: - query_params.append(('from', local_var_params['_from'])) # noqa: E501 - if 'to' in local_var_params: - query_params.append(('to', local_var_params['to'])) # noqa: E501 - if 'limit' in local_var_params: - query_params.append(('limit', local_var_params['limit'])) # noqa: E501 - if 'offset' in local_var_params: - query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -445,93 +481,138 @@ def list_withdrawals_with_http_info(self, **kwargs): # noqa: E501 local_var_files = {} body_params = None - # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + if 'transfer' in local_var_params: + body_params = local_var_params['transfer'] + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/withdrawals', 'GET', + '/wallet/transfers', + 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='list[LedgerRecord]', # noqa: E501 + response_type=None, # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) - def transfer(self, transfer, **kwargs): # noqa: E501 - """Transfer between accounts # noqa: E501 + def list_sub_account_transfers(self, **kwargs): # noqa: E501 + """Transfer records between main and sub accounts # noqa: E501 - Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 2. spot - delivery # noqa: E501 + Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.transfer(transfer, async_req=True) + >>> thread = api.list_sub_account_transfers(async_req=True) >>> result = thread.get() - :param async_req bool - :param Transfer transfer: (required) - :return: None - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str sub_uid: Sub account user ID. Return records related to all sub accounts if not specified + :param int _from: Time range beginning, default to 7 days before current time + :param int to: Time range ending, default to current time + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: list[gate_api.SubAccountTransfer] + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.transfer_with_http_info(transfer, **kwargs) # noqa: E501 - else: - (data) = self.transfer_with_http_info(transfer, **kwargs) # noqa: E501 - return data + return self.list_sub_account_transfers_with_http_info(**kwargs) # noqa: E501 - def transfer_with_http_info(self, transfer, **kwargs): # noqa: E501 - """Transfer between accounts # noqa: E501 + def list_sub_account_transfers_with_http_info(self, **kwargs): # noqa: E501 + """Transfer records between main and sub accounts # noqa: E501 - Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 2. spot - delivery # noqa: E501 + Record time range cannot exceed 30 days > Note: only records after 2020-04-10 can be retrieved # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.transfer_with_http_info(transfer, async_req=True) + >>> thread = api.list_sub_account_transfers_with_http_info(async_req=True) >>> result = thread.get() - :param async_req bool - :param Transfer transfer: (required) - :return: None - If the method is called asynchronously, + :param bool async_req: execute request asynchronously + :param str sub_uid: Sub account user ID. Return records related to all sub accounts if not specified + :param int _from: Time range beginning, default to 7 days before current time + :param int to: Time range ending, default to current time + :param int limit: Maximum number of records returned in one list + :param int offset: List offset, starting from 0 + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(list[gate_api.SubAccountTransfer], status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['transfer'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['sub_uid', '_from', 'to', 'limit', 'offset'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method transfer" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method list_sub_account_transfers" % key ) local_var_params[key] = val del local_var_params['kwargs'] - # verify the required parameter 'transfer' is set - if ('transfer' not in local_var_params or - local_var_params['transfer'] is None): - raise ValueError("Missing the required parameter `transfer` when calling `transfer`") # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] > 1000 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_sub_account_transfers`, must be a value less than or equal to `1000`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'limit' in local_var_params and local_var_params['limit'] < 1 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `limit` when calling `list_sub_account_transfers`, must be a value greater than or equal to `1`" + ) # noqa: E501 + if ( + self.api_client.client_side_validation and 'offset' in local_var_params and local_var_params['offset'] < 0 + ): # noqa: E501 + raise ApiValueError( + "Invalid value for parameter `offset` when calling `list_sub_account_transfers`, must be a value greater than or equal to `0`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + if 'sub_uid' in local_var_params and local_var_params['sub_uid'] is not None: # noqa: E501 + query_params.append(('sub_uid', local_var_params['sub_uid'])) # noqa: E501 + if '_from' in local_var_params and local_var_params['_from'] is not None: # noqa: E501 + query_params.append(('from', local_var_params['_from'])) # noqa: E501 + if 'to' in local_var_params and local_var_params['to'] is not None: # noqa: E501 + query_params.append(('to', local_var_params['to'])) # noqa: E501 + if 'limit' in local_var_params and local_var_params['limit'] is not None: # noqa: E501 + query_params.append(('limit', local_var_params['limit'])) # noqa: E501 + if 'offset' in local_var_params and local_var_params['offset'] is not None: # noqa: E501 + query_params.append(('offset', local_var_params['offset'])) # noqa: E501 header_params = {} @@ -539,30 +620,29 @@ def transfer_with_http_info(self, transfer, **kwargs): # noqa: E501 local_var_files = {} body_params = None - if 'transfer' in local_var_params: - body_params = local_var_params['transfer'] - # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + # HTTP header `Accept` + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/transfers', 'POST', + '/wallet/sub_account_transfers', + 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type=None, # noqa: E501 + response_type='list[SubAccountTransfer]', # noqa: E501 auth_settings=auth_settings, async_req=local_var_params.get('async_req'), _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) def transfer_with_sub_account(self, sub_account_transfer, **kwargs): # noqa: E501 """Transfer between main and sub accounts # noqa: E501 @@ -572,18 +652,21 @@ def transfer_with_sub_account(self, sub_account_transfer, **kwargs): # noqa: E5 >>> thread = api.transfer_with_sub_account(sub_account_transfer, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param SubAccountTransfer sub_account_transfer: (required) - :return: None - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: None + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.transfer_with_sub_account_with_http_info(sub_account_transfer, **kwargs) # noqa: E501 - else: - (data) = self.transfer_with_sub_account_with_http_info(sub_account_transfer, **kwargs) # noqa: E501 - return data + return self.transfer_with_sub_account_with_http_info(sub_account_transfer, **kwargs) # noqa: E501 def transfer_with_sub_account_with_http_info(self, sub_account_transfer, **kwargs): # noqa: E501 """Transfer between main and sub accounts # noqa: E501 @@ -593,33 +676,42 @@ def transfer_with_sub_account_with_http_info(self, sub_account_transfer, **kwarg >>> thread = api.transfer_with_sub_account_with_http_info(sub_account_transfer, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param SubAccountTransfer sub_account_transfer: (required) - :return: None - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: None + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['sub_account_transfer'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['sub_account_transfer'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method transfer_with_sub_account" % key + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" " to method transfer_with_sub_account" % key ) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'sub_account_transfer' is set - if ('sub_account_transfer' not in local_var_params or - local_var_params['sub_account_transfer'] is None): - raise ValueError("Missing the required parameter `sub_account_transfer` when calling `transfer_with_sub_account`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'sub_account_transfer' not in local_var_params + or local_var_params['sub_account_transfer'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError( + "Missing the required parameter `sub_account_transfer` when calling `transfer_with_sub_account`" + ) # noqa: E501 collection_formats = {} @@ -637,13 +729,15 @@ def transfer_with_sub_account_with_http_info(self, sub_account_transfer, **kwarg body_params = local_var_params['sub_account_transfer'] # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/wallet/sub_account_transfers', 'POST', + '/wallet/sub_account_transfers', + 'POST', path_params, query_params, header_params, @@ -656,4 +750,5 @@ def transfer_with_sub_account_with_http_info(self, sub_account_transfer, **kwarg _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api/withdrawal_api.py b/gate_api/api/withdrawal_api.py index 30d16ec..00f241b 100644 --- a/gate_api/api/withdrawal_api.py +++ b/gate_api/api/withdrawal_api.py @@ -18,6 +18,7 @@ import six from gate_api.api_client import ApiClient +from gate_api.exceptions import ApiTypeError, ApiValueError # noqa: F401 class WithdrawalApi(object): @@ -40,18 +41,21 @@ def withdraw(self, ledger_record, **kwargs): # noqa: E501 >>> thread = api.withdraw(ledger_record, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param LedgerRecord ledger_record: (required) - :return: LedgerRecord - If the method is called asynchronously, + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: gate_api.LedgerRecord + :return: If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True - if kwargs.get('async_req'): - return self.withdraw_with_http_info(ledger_record, **kwargs) # noqa: E501 - else: - (data) = self.withdraw_with_http_info(ledger_record, **kwargs) # noqa: E501 - return data + return self.withdraw_with_http_info(ledger_record, **kwargs) # noqa: E501 def withdraw_with_http_info(self, ledger_record, **kwargs): # noqa: E501 """Withdraw # noqa: E501 @@ -61,33 +65,37 @@ def withdraw_with_http_info(self, ledger_record, **kwargs): # noqa: E501 >>> thread = api.withdraw_with_http_info(ledger_record, async_req=True) >>> result = thread.get() - :param async_req bool + :param bool async_req: execute request asynchronously :param LedgerRecord ledger_record: (required) - :return: LedgerRecord - If the method is called asynchronously, + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :rtype: tuple(gate_api.LedgerRecord, status_code(int), headers(HTTPHeaderDict)) + :return: If the method is called asynchronously, returns the request thread. """ local_var_params = locals() - all_params = ['ledger_record'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') + all_params = ['ledger_record'] + all_params.extend(['async_req', '_return_http_data_only', '_preload_content', '_request_timeout']) for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: - raise TypeError( - "Got an unexpected keyword argument '%s'" - " to method withdraw" % key - ) + raise ApiTypeError("Got an unexpected keyword argument '%s'" " to method withdraw" % key) local_var_params[key] = val del local_var_params['kwargs'] # verify the required parameter 'ledger_record' is set - if ('ledger_record' not in local_var_params or - local_var_params['ledger_record'] is None): - raise ValueError("Missing the required parameter `ledger_record` when calling `withdraw`") # noqa: E501 + if self.api_client.client_side_validation and ( + 'ledger_record' not in local_var_params or local_var_params['ledger_record'] is None # noqa: E501 + ): # noqa: E501 + raise ApiValueError("Missing the required parameter `ledger_record` when calling `withdraw`") # noqa: E501 collection_formats = {} @@ -104,18 +112,19 @@ def withdraw_with_http_info(self, ledger_record, **kwargs): # noqa: E501 if 'ledger_record' in local_var_params: body_params = local_var_params['ledger_record'] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept(['application/json']) # noqa: E501 # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + ['application/json'] + ) # noqa: E501 # Authentication setting auth_settings = ['apiv4'] # noqa: E501 return self.api_client.call_api( - '/withdrawals', 'POST', + '/withdrawals', + 'POST', path_params, query_params, header_params, @@ -128,4 +137,5 @@ def withdraw_with_http_info(self, ledger_record, **kwargs): # noqa: E501 _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 _preload_content=local_var_params.get('_preload_content', True), _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + collection_formats=collection_formats, + ) diff --git a/gate_api/api_client.py b/gate_api/api_client.py index 8645c22..a4d2c06 100644 --- a/gate_api/api_client.py +++ b/gate_api/api_client.py @@ -10,7 +10,14 @@ from __future__ import absolute_import +import atexit import datetime +import hashlib +import hmac +import time +from six.moves.urllib.parse import unquote_plus, urlencode, urlparse + +from dateutil.parser import parse import json import mimetypes from multiprocessing.pool import ThreadPool @@ -25,6 +32,7 @@ from gate_api.configuration import Configuration import gate_api.models from gate_api import rest +from gate_api.exceptions import ApiValueError, ApiException class ApiClient(object): @@ -62,10 +70,9 @@ class ApiClient(object): } _pool = None - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=None): + def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): if configuration is None: - configuration = Configuration() + configuration = Configuration.get_default_copy() self.configuration = configuration self.pool_threads = pool_threads @@ -75,13 +82,22 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/4.14.0/python' + self.user_agent = 'OpenAPI-Generator/4.15.2/python' + self.client_side_validation = configuration.client_side_validation + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() - def __del__(self): + def close(self): if self._pool: self._pool.close() self._pool.join() self._pool = None + if hasattr(atexit, 'unregister'): + atexit.unregister(self.close) @property def pool(self): @@ -89,6 +105,7 @@ def pool(self): avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: + atexit.register(self.close) self._pool = ThreadPool(self.pool_threads) return self._pool @@ -105,11 +122,23 @@ def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + _host=None, + ): config = self.configuration @@ -120,68 +149,84 @@ def __call_api( header_params['Cookie'] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) + header_params = dict(self.parameters_to_tuples(header_params, collection_formats)) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) + path_params = self.parameters_to_tuples(path_params, collection_formats) for k, v in path_params: # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) - ) + resource_path = resource_path.replace('{%s}' % k, quote(str(v), safe=config.safe_chars_for_path_param)) # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) + query_params = self.parameters_to_tuples(query_params, collection_formats) # post parameters if post_params or files: - post_params = self.prepare_post_parameters(post_params, files) + post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) - - # auth setting - # self.update_params_for_auth(header_params, query_params, auth_settings) - _auth_required = (auth_settings != []) + post_params = self.parameters_to_tuples(post_params, collection_formats) + post_params.extend(self.files_parameters(files)) # body if body: body = self.sanitize_for_serialization(body) # request url - url = self.configuration.host + resource_path + if _host is None: + url = self.configuration.host + resource_path + else: + # use server/host defined in path or operation instead + url = _host + resource_path - # perform request and return response - response_data = self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - _auth_required=_auth_required) + # auth setting + self.update_params_for_auth(method, url, header_params, query_params, body, auth_settings) + + try: + # perform request and return response + response_data = self.request( + method, + url, + query_params=query_params, + headers=header_params, + post_params=post_params, + body=body, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + ) + except ApiException as e: + e.body = e.body.decode('utf-8') if six.PY3 else e.body + raise e + + content_type = response_data.getheader('content-type') self.last_response = response_data return_data = response_data - if _preload_content: - # deserialize response data - if response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None + + if not _preload_content: + return return_data + + if six.PY3 and response_type not in ["file", "bytes"]: + match = None + if content_type is not None: + match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) + encoding = match.group(1) if match else "utf-8" + response_data.data = response_data.data.decode(encoding) + + # deserialize response data + if response_type: + return_data = self.deserialize(response_data, response_type) + else: + return_data = None if _return_http_data_only: - return (return_data) + return return_data else: - return (return_data, response_data.status, - response_data.getheaders()) + return (return_data, response_data.status, response_data.getheaders()) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. @@ -202,11 +247,9 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() @@ -218,12 +261,13 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None} + obj_dict = { + obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.openapi_types) + if getattr(obj, attr) is not None + } - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} + return {key: self.sanitize_for_serialization(val) for key, val in six.iteritems(obj_dict)} def deserialize(self, response, response_type): """Deserializes response into an object. @@ -261,13 +305,11 @@ def __deserialize(self, data, klass): if type(klass) == str: if klass.startswith('list['): sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] if klass.startswith('dict('): sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} + return {k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data)} # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -282,16 +324,29 @@ def __deserialize(self, data, klass): elif klass == datetime.date: return self.__deserialize_date(data) elif klass == datetime.datetime: - return self.__deserialize_datatime(data) + return self.__deserialize_datetime(data) else: return self.__deserialize_model(data, klass) - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None): + def call_api( + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + async_req=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + _host=None, + ): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -303,7 +358,7 @@ def call_api(self, resource_path, method, :param header_params: Header parameters to be placed in the request header. :param body: Request body. - :param dict post_params: Request post form parameters, + :param list post_params: Request post form parameters, for `application/x-www-form-urlencoded`, `multipart/form-data`. :param list auth_settings: Auth Settings names for the request. :param response_type: Response data type. @@ -321,6 +376,7 @@ def call_api(self, resource_path, method, number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. + :param _host: server/host defined in path or operation instead :return: If async_req parameter is True, the request will be called asynchronously. @@ -329,90 +385,122 @@ def call_api(self, resource_path, method, then the method will return the response directly. """ if not async_req: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout) - else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, _request_timeout)) - return thread - - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None, _auth_required=True): + return self.__call_api( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + ) + + return self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + ), + ) + + def request( + self, + method, + url, + query_params=None, + headers=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): """Makes the HTTP request using RESTClient.""" if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - _auth_required=_auth_required) + return self.rest_client.GET( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - _auth_required=_auth_required) + return self.rest_client.HEAD( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.OPTIONS( + url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + ) elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.POST( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PUT( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PATCH( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _auth_required=_auth_required, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - else: - raise ValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." + return self.rest_client.DELETE( + url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, ) + else: + raise ApiValueError("http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`.") def parameters_to_tuples(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -438,24 +526,19 @@ def parameters_to_tuples(self, params, collection_formats): delimiter = '|' else: # csv is the default delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) + new_params.append((k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params - def prepare_post_parameters(self, post_params=None, files=None): + def files_parameters(self, files=None): """Builds form parameters. - :param post_params: Normal form parameters. :param files: File parameters. :return: Form parameters with files. """ params = [] - if post_params: - params = post_params - if files: for k, v in six.iteritems(files): if not v: @@ -465,10 +548,8 @@ def prepare_post_parameters(self, post_params=None, files=None): with open(n, 'rb') as f: filename = os.path.basename(f.name) filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) + mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' + params.append(tuple([k, tuple([filename, filedata, mimetype])])) return params @@ -504,11 +585,14 @@ def select_header_content_type(self, content_types): else: return content_types[0] - def update_params_for_auth(self, headers, querys, auth_settings): + def update_params_for_auth(self, method, url, headers, querys, body, auth_settings): """Updates header and query params based on authentication setting. + :param method: Request method + :param url: Request path, host included :param headers: Header parameters dict to be updated. :param querys: Query parameters tuple list to be updated. + :param body: Request body :param auth_settings: Authentication setting identifiers list. """ if not auth_settings: @@ -517,16 +601,38 @@ def update_params_for_auth(self, headers, querys, auth_settings): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting['value']: + if auth_setting['type'] == 'apiv4': + auth_headers = self.gen_sign(method, urlparse(url).path, unquote_plus(urlencode(querys)), body) + headers.update(auth_headers) continue + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys.append((auth_setting['key'], auth_setting['value'])) else: - raise ValueError( - 'Authentication token must be in `query` or `header`' - ) + raise ApiValueError('Authentication token must be in `query` or `header`') + + def gen_sign(self, method, url, query_string=None, body=None): + """generate authentication headers + + :param method: http request method + :param url: http resource path + :param query_string: query string + :param body: request body + :return: signature headers + """ + t = time.time() + m = hashlib.sha512() + if body is not None: + if not isinstance(body, six.string_types): + body = json.dumps(body) + m.update(body.encode('utf-8')) + hashed_payload = m.hexdigest() + s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t) + sign = hmac.new(self.configuration.secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest() + return {'KEY': self.configuration.key, 'Timestamp': str(t), 'SIGN': sign} def __deserialize_file(self, response): """Deserializes body to file @@ -543,8 +649,7 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -581,17 +686,13 @@ def __deserialize_date(self, string): :return: date. """ try: - from dateutil.parser import parse return parse(string).date() except ImportError: return string except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) - ) + raise rest.ApiException(status=0, reason="Failed to parse `{0}` as date object".format(string)) - def __deserialize_datatime(self, string): + def __deserialize_datetime(self, string): """Deserializes string to datetime. The string should be in iso8601 datetime format. @@ -600,18 +701,11 @@ def __deserialize_datatime(self, string): :return: datetime. """ try: - from dateutil.parser import parse return parse(string) except ImportError: return string except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) - ) + raise rest.ApiException(status=0, reason=("Failed to parse `{0}` as datetime object".format(string))) def __deserialize_model(self, data, klass): """Deserializes list or dict to model. @@ -620,23 +714,23 @@ def __deserialize_model(self, data, klass): :param klass: class literal. :return: model object. """ + has_discriminator = False + if hasattr(klass, 'get_real_child_model') and klass.discriminator_value_class_map: + has_discriminator = True - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): + if not klass.openapi_types and has_discriminator is False: return data kwargs = {} - if klass.openapi_types is not None: + if data is not None and klass.openapi_types is not None and isinstance(data, (list, dict)): for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if klass.attribute_map[attr] in data: value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) instance = klass(**kwargs) - if hasattr(instance, 'get_real_child_model'): + if has_discriminator: klass_name = instance.get_real_child_model(data) if klass_name: instance = self.__deserialize(data, klass_name) diff --git a/gate_api/configuration.py b/gate_api/configuration.py index bfe1e0c..7850577 100644 --- a/gate_api/configuration.py +++ b/gate_api/configuration.py @@ -22,87 +22,181 @@ from six.moves import http_client as httplib -class TypeWithDefault(type): - def __init__(cls, name, bases, dct): - super(TypeWithDefault, cls).__init__(name, bases, dct) - cls._default = None - - def __call__(cls): - if cls._default is None: - cls._default = type.__call__(cls) - return copy.copy(cls._default) - - def set_default(cls, default): - cls._default = copy.copy(default) - - -class Configuration(six.with_metaclass(TypeWithDefault, object)): +class Configuration(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. + + :param host: Base url + :param key: APIv4 key + :param secret: APIv4 secret + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + + :Example: + + You can set the APIv4 key and secret like: + +conf = gate_api.Configuration( + key='example_key' + secret='example_secret' +) + + The following headers will be added to the HTTP request: + KEY: example_key + SIGN: generated_signature_using_example_secret + Timestamp: request_timestamp """ - def __init__(self): - """Constructor""" - # Default Base url - self.host = "https://api.gateio.ws/api/v4" - # Temp file folder for downloading files + _default = None + + def __init__( + self, + host="https://api.gateio.ws/api/v4", + key=None, + secret=None, + username=None, + password=None, + discard_unknown_keys=False, + ): + """Constructor + """ + self.host = host + """Default Base url + """ self.temp_folder_path = None - + """Temp file folder for downloading files + """ # Authentication Settings - # dict to store API key(s) - self.api_key = {} - # dict to store API prefix (e.g. Bearer) - self.api_key_prefix = {} - # Username for HTTP basic authentication - self.username = "" - # Password for HTTP basic authentication - self.password = "" - - # Logging Settings + # Init APIv4 authentication key and secret + self.key = key + """API key for APIv4 authentication + """ + self.secret = secret + """API secret for APIv4 authentication + """ + self.username = username + """Username for HTTP basic authentication + """ + self.password = password + """Password for HTTP basic authentication + """ + self.discard_unknown_keys = discard_unknown_keys self.logger = {} + """Logging Settings + """ self.logger["package_logger"] = logging.getLogger("gate_api") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - # Log format self.logger_format = '%(asctime)s %(levelname)s %(message)s' - # Log stream handler + """Log format + """ self.logger_stream_handler = None - # Log file handler + """Log stream handler + """ self.logger_file_handler = None - # Debug file location + """Log file handler + """ self.logger_file = None - # Debug switch + """Debug file location + """ self.debug = False + """Debug switch + """ - # SSL/TLS verification - # Set this to false to skip verifying SSL certificate when calling API - # from https server. self.verify_ssl = True - # Set this to customize the certificate file to verify the peer. + """SSL/TLS verification + Set this to false to skip verifying SSL certificate when calling API + from https server. + """ self.ssl_ca_cert = None - # client certificate file + """Set this to customize the certificate file to verify the peer. + """ self.cert_file = None - # client key file + """client certificate file + """ self.key_file = None - # Set this to True/False to enable/disable SSL hostname verification. + """client key file + """ self.assert_hostname = None + """Set this to True/False to enable/disable SSL hostname verification. + """ - # urllib3 connection pool's maximum number of connections saved - # per pool. urllib3 uses 1 connection as default value, but this is - # not the best value when you are making a lot of possibly parallel - # requests to the same host, which is often the case here. - # cpu_count * 5 is used as default value to increase performance. self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 + """urllib3 connection pool's maximum number of connections saved + per pool. urllib3 uses 1 connection as default value, but this is + not the best value when you are making a lot of possibly parallel + requests to the same host, which is often the case here. + cpu_count * 5 is used as default value to increase performance. + """ - # Proxy URL self.proxy = None - # Safe chars for path_param + """Proxy URL + """ + self.proxy_headers = None + """Proxy headers + """ self.safe_chars_for_path_param = '' + """Safe chars for path_param + """ + self.retries = None + """Adding retries to override urllib3 default value 3 + """ + # Disable client side validation + self.client_side_validation = True + + def __deepcopy__(self, memo): + cls = self.__class__ + result = cls.__new__(cls) + memo[id(self)] = result + for k, v in self.__dict__.items(): + if k not in ('logger', 'logger_file_handler'): + setattr(result, k, copy.deepcopy(v, memo)) + # shallow copy of loggers + result.logger = copy.copy(self.logger) + # use setters to configure loggers + result.logger_file = self.logger_file + result.debug = self.debug + return result + + def __setattr__(self, name, value): + object.__setattr__(self, name, value) + + @classmethod + def set_default(cls, default): + """Set default instance of configuration. + + It stores default configuration, which can be + returned by get_default_copy method. + + :param default: object of Configuration + """ + cls._default = copy.deepcopy(default) + + @classmethod + def get_default_copy(cls): + """Return new instance of configuration. - # API key and secret - self.key = "" - self.secret = "" + This method returns newly created, based on default constructor, + object of Configuration class or returns a copy of default + configuration passed by the set_default method. + + :return: The configuration object. + """ + if cls._default is not None: + return copy.deepcopy(cls._default) + return Configuration() @property def logger_file(self): @@ -111,8 +205,7 @@ def logger_file(self): If the logger_file is None, then add stream handler and remove file handler. Otherwise, add file handler and remove stream handler. - :param value: The logger_file path. - :type: str + :return: The logger_file path. """ return self.__logger_file @@ -139,8 +232,7 @@ def logger_file(self, value): def debug(self): """Debug status - :param value: The debug status, True or False. - :type: bool + :return: The debug status, True or False. """ return self.__debug @@ -172,8 +264,7 @@ def logger_format(self): The logger_formatter will be updated when sets logger_format. - :param value: The format string. - :type: str + :return: The format string. """ return self.__logger_format @@ -189,51 +280,85 @@ def logger_format(self, value): self.__logger_format = value self.logger_formatter = logging.Formatter(self.__logger_format) - def get_api_key_with_prefix(self, identifier): - """Gets API key (with prefix if set). - - :param identifier: The identifier of apiKey. - :return: The token for api key authentication. - """ - if (self.api_key.get(identifier) and - self.api_key_prefix.get(identifier)): - return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier] # noqa: E501 - elif self.api_key.get(identifier): - return self.api_key[identifier] - def get_basic_auth_token(self): """Gets HTTP basic authentication header (string). :return: The token for basic HTTP authentication. """ - return urllib3.util.make_headers( - basic_auth=self.username + ':' + self.password - ).get('authorization') + username = "" + if self.username is not None: + username = self.username + password = "" + if self.password is not None: + password = self.password + return urllib3.util.make_headers(basic_auth=username + ':' + password).get('authorization') def auth_settings(self): """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ - return { - 'apiv4': - { - 'type': 'api_key', - 'in': 'header', - 'key': 'SIGN', - 'value': self.get_api_key_with_prefix('SIGN') - }, - - } + auth = {} + if self.key is not None and self.secret is not None: + auth['apiv4'] = { + 'type': 'apiv4', + 'in': 'header', + 'key': 'SIGN', + } + return auth def to_debug_report(self): """Gets the essential information for debugging. :return: The report for debugging. """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 4.14.0\n"\ - "SDK Package Version: 4.14.0".\ - format(env=sys.platform, pyversion=sys.version) + return ( + "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) + ) + + def get_host_settings(self): + """Gets an array of host settings + + :return: An array of host settings + """ + return [ + {'url': "https://api.gateio.ws/api/v4", 'description': "Real Trading",}, + {'url': "https://fx-api-testnet.gateio.ws/api/v4", 'description': "TestNet Trading",}, + ] + + def get_host_from_settings(self, index, variables=None): + """Gets host URL based on the index and variables + :param index: array index of the host settings + :param variables: hash of variable and the corresponding value + :return: URL based on host settings + """ + variables = {} if variables is None else variables + servers = self.get_host_settings() + + try: + server = servers[index] + except IndexError: + raise ValueError( + "Invalid index {0} when selecting the host settings. " + "Must be less than {1}".format(index, len(servers)) + ) + + url = server['url'] + + # go through variables and replace placeholders + for variable_name, variable in server['variables'].items(): + used_value = variables.get(variable_name, variable['default_value']) + + if 'enum_values' in variable and used_value not in variable['enum_values']: + raise ValueError( + "The variable `{0}` in the host URL has invalid value " + "{1}. Must be {2}.".format(variable_name, variables[variable_name], variable['enum_values']) + ) + + url = url.replace("{" + variable_name + "}", used_value) + + return url diff --git a/gate_api/exceptions.py b/gate_api/exceptions.py new file mode 100644 index 0000000..697fc65 --- /dev/null +++ b/gate_api/exceptions.py @@ -0,0 +1,116 @@ +# coding: utf-8 + +""" + Gate API v4 + + APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 + + Contact: support@mail.gate.io + Generated by: https://openapi-generator.tech +""" + + +import six + + +class OpenApiException(Exception): + """The base exception class for all OpenAPIExceptions""" + + +class ApiTypeError(OpenApiException, TypeError): + def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): + """ Raises an exception for TypeErrors + + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list): a list of keys an indices to get to the + current_item + None if unset + valid_classes (tuple): the primitive classes that current item + should be an instance of + None if unset + key_type (bool): False if our value is a value in a dict + True if it is a key in a dict + False if our item is an item in a list + None if unset + """ + self.path_to_item = path_to_item + self.valid_classes = valid_classes + self.key_type = key_type + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiTypeError, self).__init__(full_msg) + + +class ApiValueError(OpenApiException, ValueError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (list) the path to the exception in the + received_data dict. None if unset + """ + + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiValueError, self).__init__(full_msg) + + +class ApiKeyError(OpenApiException, KeyError): + def __init__(self, msg, path_to_item=None): + """ + Args: + msg (str): the exception message + + Keyword Args: + path_to_item (None/list) the path to the exception in the + received_data dict + """ + self.path_to_item = path_to_item + full_msg = msg + if path_to_item: + full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) + super(ApiKeyError, self).__init__(full_msg) + + +class ApiException(OpenApiException): + def __init__(self, status=None, reason=None, http_resp=None): + if http_resp: + self.status = http_resp.status + self.reason = http_resp.reason + self.body = http_resp.data + self.headers = http_resp.getheaders() + else: + self.status = status + self.reason = reason + self.body = None + self.headers = None + + def __str__(self): + """Custom error messages for exception""" + error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + if self.headers: + error_message += "HTTP response headers: {0}\n".format(self.headers) + + if self.body: + error_message += "HTTP response body: {0}\n".format(self.body) + + return error_message + + +def render_path(path_to_item): + """Returns a string representation of a path""" + result = "" + for pth in path_to_item: + if isinstance(pth, six.integer_types): + result += "[{0}]".format(pth) + else: + result += "['{0}']".format(pth) + return result diff --git a/gate_api/models/__init__.py b/gate_api/models/__init__.py index b708d5b..ac954ad 100644 --- a/gate_api/models/__init__.py +++ b/gate_api/models/__init__.py @@ -37,16 +37,17 @@ from gate_api.models.futures_price_triggered_order import FuturesPriceTriggeredOrder from gate_api.models.futures_ticker import FuturesTicker from gate_api.models.futures_trade import FuturesTrade -from gate_api.models.gate_error_response import GateErrorResponse from gate_api.models.insurance_record import InsuranceRecord from gate_api.models.ledger_record import LedgerRecord from gate_api.models.loan import Loan from gate_api.models.loan_patch import LoanPatch from gate_api.models.loan_record import LoanRecord from gate_api.models.margin_account import MarginAccount +from gate_api.models.margin_account_book import MarginAccountBook from gate_api.models.margin_account_currency import MarginAccountCurrency from gate_api.models.margin_currency_pair import MarginCurrencyPair from gate_api.models.my_futures_trade import MyFuturesTrade +from gate_api.models.open_orders import OpenOrders from gate_api.models.order import Order from gate_api.models.order_book import OrderBook from gate_api.models.position import Position @@ -58,5 +59,6 @@ from gate_api.models.sub_account_transfer import SubAccountTransfer from gate_api.models.ticker import Ticker from gate_api.models.trade import Trade +from gate_api.models.trade_fee import TradeFee from gate_api.models.transfer import Transfer from gate_api.models.trigger_order_response import TriggerOrderResponse diff --git a/gate_api/models/batch_order.py b/gate_api/models/batch_order.py index f98f532..d819e43 100644 --- a/gate_api/models/batch_order.py +++ b/gate_api/models/batch_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class BatchOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -56,7 +58,7 @@ class BatchOrder(object): 'gt_fee': 'str', 'gt_discount': 'bool', 'rebated_fee': 'str', - 'rebated_fee_currency': 'str' + 'rebated_fee_currency': 'str', } attribute_map = { @@ -85,11 +87,44 @@ class BatchOrder(object): 'gt_fee': 'gt_fee', 'gt_discount': 'gt_discount', 'rebated_fee': 'rebated_fee', - 'rebated_fee_currency': 'rebated_fee_currency' + 'rebated_fee_currency': 'rebated_fee_currency', } - def __init__(self, text=None, succeeded=None, label=None, message=None, id=None, create_time=None, update_time=None, status=None, currency_pair=None, type='limit', account='spot', side=None, amount=None, price=None, time_in_force='gtc', auto_borrow=None, left=None, fill_price=None, filled_total=None, fee=None, fee_currency=None, point_fee=None, gt_fee=None, gt_discount=None, rebated_fee=None, rebated_fee_currency=None): # noqa: E501 + def __init__( + self, + text=None, + succeeded=None, + label=None, + message=None, + id=None, + create_time=None, + update_time=None, + status=None, + currency_pair=None, + type='limit', + account='spot', + side=None, + amount=None, + price=None, + time_in_force='gtc', + auto_borrow=None, + left=None, + fill_price=None, + filled_total=None, + fee=None, + fee_currency=None, + point_fee=None, + gt_fee=None, + gt_discount=None, + rebated_fee=None, + rebated_fee_currency=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, bool, str, str, str, str, str, str, str, str, str, str, str, str, str, bool, str, str, str, str, str, str, str, bool, str, str, Configuration) -> None """BatchOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._text = None self._succeeded = None @@ -176,7 +211,7 @@ def __init__(self, text=None, succeeded=None, label=None, message=None, id=None, def text(self): """Gets the text of this BatchOrder. # noqa: E501 - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 :return: The text of this BatchOrder. # noqa: E501 :rtype: str @@ -187,7 +222,7 @@ def text(self): def text(self, text): """Sets the text of this BatchOrder. - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 :param text: The text of this BatchOrder. # noqa: E501 :type: str @@ -354,10 +389,9 @@ def status(self, status): :type: str """ allowed_values = ["open", "closed", "cancelled"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -406,10 +440,9 @@ def type(self, type): :type: str """ allowed_values = ["limit"] # noqa: E501 - if type not in allowed_values: + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format(type, allowed_values) # noqa: E501 ) self._type = type @@ -435,10 +468,9 @@ def account(self, account): :type: str """ allowed_values = ["spot", "margin"] # noqa: E501 - if account not in allowed_values: + if self.local_vars_configuration.client_side_validation and account not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `account` ({0}), must be one of {1}" # noqa: E501 - .format(account, allowed_values) + "Invalid value for `account` ({0}), must be one of {1}".format(account, allowed_values) # noqa: E501 ) self._account = account @@ -464,10 +496,9 @@ def side(self, side): :type: str """ allowed_values = ["buy", "sell"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -539,10 +570,11 @@ def time_in_force(self, time_in_force): :type: str """ allowed_values = ["gtc", "ioc", "poc"] # noqa: E501 - if time_in_force not in allowed_values: + if self.local_vars_configuration.client_side_validation and time_in_force not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `time_in_force` ({0}), must be one of {1}" # noqa: E501 - .format(time_in_force, allowed_values) + "Invalid value for `time_in_force` ({0}), must be one of {1}".format( # noqa: E501 + time_in_force, allowed_values + ) ) self._time_in_force = time_in_force @@ -807,18 +839,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -837,8 +867,11 @@ def __eq__(self, other): if not isinstance(other, BatchOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, BatchOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/cancel_order.py b/gate_api/models/cancel_order.py index 4cad4c7..d367b76 100644 --- a/gate_api/models/cancel_order.py +++ b/gate_api/models/cancel_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class CancelOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class CancelOrder(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency_pair': 'str', - 'id': 'str' - } + openapi_types = {'currency_pair': 'str', 'id': 'str'} - attribute_map = { - 'currency_pair': 'currency_pair', - 'id': 'id' - } + attribute_map = {'currency_pair': 'currency_pair', 'id': 'id'} - def __init__(self, currency_pair=None, id=None): # noqa: E501 + def __init__(self, currency_pair=None, id=None, local_vars_configuration=None): # noqa: E501 + # type: (str, str, Configuration) -> None """CancelOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency_pair = None self._id = None @@ -70,7 +70,7 @@ def currency_pair(self, currency_pair): :param currency_pair: The currency_pair of this CancelOrder. # noqa: E501 :type: str """ - if currency_pair is None: + if self.local_vars_configuration.client_side_validation and currency_pair is None: # noqa: E501 raise ValueError("Invalid value for `currency_pair`, must not be `None`") # noqa: E501 self._currency_pair = currency_pair @@ -95,7 +95,7 @@ def id(self, id): :param id: The id of this CancelOrder. # noqa: E501 :type: str """ - if id is None: + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -107,18 +107,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -137,8 +135,11 @@ def __eq__(self, other): if not isinstance(other, CancelOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, CancelOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/cancel_order_result.py b/gate_api/models/cancel_order_result.py index 4b5ab2f..c6e715a 100644 --- a/gate_api/models/cancel_order_result.py +++ b/gate_api/models/cancel_order_result.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class CancelOrderResult(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,24 @@ class CancelOrderResult(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency_pair': 'str', - 'id': 'str', - 'succeeded': 'bool', - 'label': 'str', - 'message': 'str' - } + openapi_types = {'currency_pair': 'str', 'id': 'str', 'succeeded': 'bool', 'label': 'str', 'message': 'str'} attribute_map = { 'currency_pair': 'currency_pair', 'id': 'id', 'succeeded': 'succeeded', 'label': 'label', - 'message': 'message' + 'message': 'message', } - def __init__(self, currency_pair=None, id=None, succeeded=None, label=None, message=None): # noqa: E501 + def __init__( + self, currency_pair=None, id=None, succeeded=None, label=None, message=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, bool, str, str, Configuration) -> None """CancelOrderResult - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency_pair = None self._id = None @@ -189,18 +191,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -219,8 +219,11 @@ def __eq__(self, other): if not isinstance(other, CancelOrderResult): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, CancelOrderResult): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/contract.py b/gate_api/models/contract.py index 5958a7a..fdbf5e0 100644 --- a/gate_api/models/contract.py +++ b/gate_api/models/contract.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Contract(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -61,7 +63,7 @@ class Contract(object): 'trade_size': 'int', 'position_size': 'int', 'config_change_time': 'float', - 'in_delisting': 'bool' + 'in_delisting': 'bool', } attribute_map = { @@ -95,11 +97,49 @@ class Contract(object): 'trade_size': 'trade_size', 'position_size': 'position_size', 'config_change_time': 'config_change_time', - 'in_delisting': 'in_delisting' + 'in_delisting': 'in_delisting', } - def __init__(self, name=None, type=None, quanto_multiplier=None, leverage_min=None, leverage_max=None, maintenance_rate=None, mark_type=None, mark_price=None, index_price=None, last_price=None, maker_fee_rate=None, taker_fee_rate=None, order_price_round=None, mark_price_round=None, funding_rate=None, funding_interval=None, funding_next_apply=None, risk_limit_base=None, risk_limit_step=None, risk_limit_max=None, order_size_min=None, order_size_max=None, order_price_deviate=None, ref_discount_rate=None, ref_rebate_rate=None, orderbook_id=None, trade_id=None, trade_size=None, position_size=None, config_change_time=None, in_delisting=None): # noqa: E501 + def __init__( + self, + name=None, + type=None, + quanto_multiplier=None, + leverage_min=None, + leverage_max=None, + maintenance_rate=None, + mark_type=None, + mark_price=None, + index_price=None, + last_price=None, + maker_fee_rate=None, + taker_fee_rate=None, + order_price_round=None, + mark_price_round=None, + funding_rate=None, + funding_interval=None, + funding_next_apply=None, + risk_limit_base=None, + risk_limit_step=None, + risk_limit_max=None, + order_size_min=None, + order_size_max=None, + order_price_deviate=None, + ref_discount_rate=None, + ref_rebate_rate=None, + orderbook_id=None, + trade_id=None, + trade_size=None, + position_size=None, + config_change_time=None, + in_delisting=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 """Contract - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._name = None self._type = None @@ -241,10 +281,9 @@ def type(self, type): :type: str """ allowed_values = ["inverse", "direct"] # noqa: E501 - if type not in allowed_values: + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format(type, allowed_values) # noqa: E501 ) self._type = type @@ -362,10 +401,11 @@ def mark_type(self, mark_type): :type: str """ allowed_values = ["internal", "index"] # noqa: E501 - if mark_type not in allowed_values: + if self.local_vars_configuration.client_side_validation and mark_type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `mark_type` ({0}), must be one of {1}" # noqa: E501 - .format(mark_type, allowed_values) + "Invalid value for `mark_type` ({0}), must be one of {1}".format( # noqa: E501 + mark_type, allowed_values + ) ) self._mark_type = mark_type @@ -929,18 +969,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -959,8 +997,11 @@ def __eq__(self, other): if not isinstance(other, Contract): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Contract): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/currency_pair.py b/gate_api/models/currency_pair.py index 6152585..9e1936a 100644 --- a/gate_api/models/currency_pair.py +++ b/gate_api/models/currency_pair.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class CurrencyPair(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,7 +41,7 @@ class CurrencyPair(object): 'min_quote_amount': 'str', 'amount_precision': 'int', 'precision': 'int', - 'trade_status': 'str' + 'trade_status': 'str', } attribute_map = { @@ -51,11 +53,27 @@ class CurrencyPair(object): 'min_quote_amount': 'min_quote_amount', 'amount_precision': 'amount_precision', 'precision': 'precision', - 'trade_status': 'trade_status' + 'trade_status': 'trade_status', } - def __init__(self, id=None, base=None, quote=None, fee=None, min_base_amount=None, min_quote_amount=None, amount_precision=None, precision=None, trade_status=None): # noqa: E501 + def __init__( + self, + id=None, + base=None, + quote=None, + fee=None, + min_base_amount=None, + min_quote_amount=None, + amount_precision=None, + precision=None, + trade_status=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, int, int, str, Configuration) -> None """CurrencyPair - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._base = None @@ -292,10 +310,11 @@ def trade_status(self, trade_status): :type: str """ allowed_values = ["untradable", "buyable", "sellable", "tradable"] # noqa: E501 - if trade_status not in allowed_values: + if self.local_vars_configuration.client_side_validation and trade_status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `trade_status` ({0}), must be one of {1}" # noqa: E501 - .format(trade_status, allowed_values) + "Invalid value for `trade_status` ({0}), must be one of {1}".format( # noqa: E501 + trade_status, allowed_values + ) ) self._trade_status = trade_status @@ -307,18 +326,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -337,8 +354,11 @@ def __eq__(self, other): if not isinstance(other, CurrencyPair): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, CurrencyPair): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/delivery_contract.py b/gate_api/models/delivery_contract.py index e5b9150..5ec221d 100644 --- a/gate_api/models/delivery_contract.py +++ b/gate_api/models/delivery_contract.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class DeliveryContract(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -32,7 +34,7 @@ class DeliveryContract(object): """ openapi_types = { 'name': 'str', - 'underling': 'str', + 'underlying': 'str', 'cycle': 'str', 'type': 'str', 'quanto_multiplier': 'str', @@ -67,12 +69,12 @@ class DeliveryContract(object): 'trade_size': 'int', 'position_size': 'int', 'config_change_time': 'float', - 'in_delisting': 'bool' + 'in_delisting': 'bool', } attribute_map = { 'name': 'name', - 'underling': 'underling', + 'underlying': 'underlying', 'cycle': 'cycle', 'type': 'type', 'quanto_multiplier': 'quanto_multiplier', @@ -107,14 +109,58 @@ class DeliveryContract(object): 'trade_size': 'trade_size', 'position_size': 'position_size', 'config_change_time': 'config_change_time', - 'in_delisting': 'in_delisting' + 'in_delisting': 'in_delisting', } - def __init__(self, name=None, underling=None, cycle=None, type=None, quanto_multiplier=None, leverage_min=None, leverage_max=None, maintenance_rate=None, mark_type=None, mark_price=None, index_price=None, last_price=None, maker_fee_rate=None, taker_fee_rate=None, order_price_round=None, mark_price_round=None, basis_rate=None, basis_value=None, basis_impact_value=None, settle_price=None, settle_price_interval=None, settle_price_duration=None, expire_time=None, risk_limit_base=None, risk_limit_step=None, risk_limit_max=None, order_size_min=None, order_size_max=None, order_price_deviate=None, ref_discount_rate=None, ref_rebate_rate=None, orderbook_id=None, trade_id=None, trade_size=None, position_size=None, config_change_time=None, in_delisting=None): # noqa: E501 + def __init__( + self, + name=None, + underlying=None, + cycle=None, + type=None, + quanto_multiplier=None, + leverage_min=None, + leverage_max=None, + maintenance_rate=None, + mark_type=None, + mark_price=None, + index_price=None, + last_price=None, + maker_fee_rate=None, + taker_fee_rate=None, + order_price_round=None, + mark_price_round=None, + basis_rate=None, + basis_value=None, + basis_impact_value=None, + settle_price=None, + settle_price_interval=None, + settle_price_duration=None, + expire_time=None, + risk_limit_base=None, + risk_limit_step=None, + risk_limit_max=None, + order_size_min=None, + order_size_max=None, + order_price_deviate=None, + ref_discount_rate=None, + ref_rebate_rate=None, + orderbook_id=None, + trade_id=None, + trade_size=None, + position_size=None, + config_change_time=None, + in_delisting=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 """DeliveryContract - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._name = None - self._underling = None + self._underlying = None self._cycle = None self._type = None self._quanto_multiplier = None @@ -154,8 +200,8 @@ def __init__(self, name=None, underling=None, cycle=None, type=None, quanto_mult if name is not None: self.name = name - if underling is not None: - self.underling = underling + if underlying is not None: + self.underlying = underlying if cycle is not None: self.cycle = cycle if type is not None: @@ -251,27 +297,27 @@ def name(self, name): self._name = name @property - def underling(self): - """Gets the underling of this DeliveryContract. # noqa: E501 + def underlying(self): + """Gets the underlying of this DeliveryContract. # noqa: E501 Underlying # noqa: E501 - :return: The underling of this DeliveryContract. # noqa: E501 + :return: The underlying of this DeliveryContract. # noqa: E501 :rtype: str """ - return self._underling + return self._underlying - @underling.setter - def underling(self, underling): - """Sets the underling of this DeliveryContract. + @underlying.setter + def underlying(self, underlying): + """Sets the underlying of this DeliveryContract. Underlying # noqa: E501 - :param underling: The underling of this DeliveryContract. # noqa: E501 + :param underlying: The underlying of this DeliveryContract. # noqa: E501 :type: str """ - self._underling = underling + self._underlying = underlying @property def cycle(self): @@ -294,10 +340,9 @@ def cycle(self, cycle): :type: str """ allowed_values = ["WEEKLY", "BI-WEEKLY", "QUARTERLY", "BI-QUARTERLY"] # noqa: E501 - if cycle not in allowed_values: + if self.local_vars_configuration.client_side_validation and cycle not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `cycle` ({0}), must be one of {1}" # noqa: E501 - .format(cycle, allowed_values) + "Invalid value for `cycle` ({0}), must be one of {1}".format(cycle, allowed_values) # noqa: E501 ) self._cycle = cycle @@ -323,10 +368,9 @@ def type(self, type): :type: str """ allowed_values = ["inverse", "direct"] # noqa: E501 - if type not in allowed_values: + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format(type, allowed_values) # noqa: E501 ) self._type = type @@ -444,10 +488,11 @@ def mark_type(self, mark_type): :type: str """ allowed_values = ["internal", "index"] # noqa: E501 - if mark_type not in allowed_values: + if self.local_vars_configuration.client_side_validation and mark_type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `mark_type` ({0}), must be one of {1}" # noqa: E501 - .format(mark_type, allowed_values) + "Invalid value for `mark_type` ({0}), must be one of {1}".format( # noqa: E501 + mark_type, allowed_values + ) ) self._mark_type = mark_type @@ -1103,18 +1148,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -1133,8 +1176,11 @@ def __eq__(self, other): if not isinstance(other, DeliveryContract): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, DeliveryContract): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/delivery_settlement.py b/gate_api/models/delivery_settlement.py index d8c0c93..a273442 100644 --- a/gate_api/models/delivery_settlement.py +++ b/gate_api/models/delivery_settlement.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class DeliverySettlement(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,7 +41,7 @@ class DeliverySettlement(object): 'entry_price': 'str', 'settle_price': 'str', 'profit': 'str', - 'fee': 'str' + 'fee': 'str', } attribute_map = { @@ -51,11 +53,27 @@ class DeliverySettlement(object): 'entry_price': 'entry_price', 'settle_price': 'settle_price', 'profit': 'profit', - 'fee': 'fee' + 'fee': 'fee', } - def __init__(self, time=None, contract=None, leverage=None, size=None, margin=None, entry_price=None, settle_price=None, profit=None, fee=None): # noqa: E501 + def __init__( + self, + time=None, + contract=None, + leverage=None, + size=None, + margin=None, + entry_price=None, + settle_price=None, + profit=None, + fee=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, str, str, int, str, str, str, str, str, Configuration) -> None """DeliverySettlement - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._time = None self._contract = None @@ -301,18 +319,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -331,8 +347,11 @@ def __eq__(self, other): if not isinstance(other, DeliverySettlement): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, DeliverySettlement): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/deposit_address.py b/gate_api/models/deposit_address.py index 3b1fe25..9910068 100644 --- a/gate_api/models/deposit_address.py +++ b/gate_api/models/deposit_address.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class DepositAddress(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class DepositAddress(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency': 'str', - 'address': 'str' - } + openapi_types = {'currency': 'str', 'address': 'str'} - attribute_map = { - 'currency': 'currency', - 'address': 'address' - } + attribute_map = {'currency': 'currency', 'address': 'address'} - def __init__(self, currency=None, address=None): # noqa: E501 + def __init__(self, currency=None, address=None, local_vars_configuration=None): # noqa: E501 + # type: (str, str, Configuration) -> None """DepositAddress - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._address = None @@ -70,7 +70,7 @@ def currency(self, currency): :param currency: The currency of this DepositAddress. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -95,7 +95,7 @@ def address(self, address): :param address: The address of this DepositAddress. # noqa: E501 :type: str """ - if address is None: + if self.local_vars_configuration.client_side_validation and address is None: # noqa: E501 raise ValueError("Invalid value for `address`, must not be `None`") # noqa: E501 self._address = address @@ -107,18 +107,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -137,8 +135,11 @@ def __eq__(self, other): if not isinstance(other, DepositAddress): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, DepositAddress): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/funding_account.py b/gate_api/models/funding_account.py index a3ac1eb..9096ee9 100644 --- a/gate_api/models/funding_account.py +++ b/gate_api/models/funding_account.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FundingAccount(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,24 @@ class FundingAccount(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency': 'str', - 'available': 'str', - 'locked': 'str', - 'lent': 'str', - 'total_lent': 'str' - } + openapi_types = {'currency': 'str', 'available': 'str', 'locked': 'str', 'lent': 'str', 'total_lent': 'str'} attribute_map = { 'currency': 'currency', 'available': 'available', 'locked': 'locked', 'lent': 'lent', - 'total_lent': 'total_lent' + 'total_lent': 'total_lent', } - def __init__(self, currency=None, available=None, locked=None, lent=None, total_lent=None): # noqa: E501 + def __init__( + self, currency=None, available=None, locked=None, lent=None, total_lent=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, str, str, str, Configuration) -> None """FundingAccount - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._available = None @@ -189,18 +191,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -219,8 +219,11 @@ def __eq__(self, other): if not isinstance(other, FundingAccount): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FundingAccount): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/funding_book_item.py b/gate_api/models/funding_book_item.py index 7d5f1dc..0733f4c 100644 --- a/gate_api/models/funding_book_item.py +++ b/gate_api/models/funding_book_item.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FundingBookItem(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,20 +32,16 @@ class FundingBookItem(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'rate': 'str', - 'amount': 'str', - 'days': 'int' - } - - attribute_map = { - 'rate': 'rate', - 'amount': 'amount', - 'days': 'days' - } - - def __init__(self, rate=None, amount=None, days=None): # noqa: E501 + openapi_types = {'rate': 'str', 'amount': 'str', 'days': 'int'} + + attribute_map = {'rate': 'rate', 'amount': 'amount', 'days': 'days'} + + def __init__(self, rate=None, amount=None, days=None, local_vars_configuration=None): # noqa: E501 + # type: (str, str, int, Configuration) -> None """FundingBookItem - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._rate = None self._amount = None @@ -133,18 +131,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -163,8 +159,11 @@ def __eq__(self, other): if not isinstance(other, FundingBookItem): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FundingBookItem): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/funding_rate_history.py b/gate_api/models/funding_rate_history.py deleted file mode 100644 index fc06829..0000000 --- a/gate_api/models/funding_rate_history.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 合约接口提供了与合约交易相关的操作,包括公共接口查询合约市场行情,以及需要认证的私有接口, 实现基于 API 的自动交易。 API 文档按照 OpenAPI v3 标准制定 API 文档, 方便 API 使用者能够轻松生成需要的客户端代码,快速接入新的功能 # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FundingRateHistory(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - } - - attribute_map = { - } - - def __init__(self): # noqa: E501 - """FundingRateHistory - a model defined in OpenAPI""" # noqa: E501 - self.discriminator = None - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FundingRateHistory): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/funding_rate_history_inner.py b/gate_api/models/funding_rate_history_inner.py deleted file mode 100644 index 2aca1f4..0000000 --- a/gate_api/models/funding_rate_history_inner.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 合约接口提供了与合约交易相关的操作,包括公共接口查询合约市场行情,以及需要认证的私有接口, 实现基于 API 的自动交易。 API 文档按照 OpenAPI v3 标准制定 API 文档, 方便 API 使用者能够轻松生成需要的客户端代码,快速接入新的功能 # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FundingRateHistoryInner(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 't': 'int', - 'r': 'str' - } - - attribute_map = { - 't': 't', - 'r': 'r' - } - - def __init__(self, t=None, r=None): # noqa: E501 - """FundingRateHistoryInner - a model defined in OpenAPI""" # noqa: E501 - - self._t = None - self._r = None - self.discriminator = None - - if t is not None: - self.t = t - if r is not None: - self.r = r - - @property - def t(self): - """Gets the t of this FundingRateHistoryInner. # noqa: E501 - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :return: The t of this FundingRateHistoryInner. # noqa: E501 - :rtype: int - """ - return self._t - - @t.setter - def t(self, t): - """Sets the t of this FundingRateHistoryInner. - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :param t: The t of this FundingRateHistoryInner. # noqa: E501 - :type: int - """ - - self._t = t - - @property - def r(self): - """Gets the r of this FundingRateHistoryInner. # noqa: E501 - - 资金费率 # noqa: E501 - - :return: The r of this FundingRateHistoryInner. # noqa: E501 - :rtype: str - """ - return self._r - - @r.setter - def r(self, r): - """Sets the r of this FundingRateHistoryInner. - - 资金费率 # noqa: E501 - - :param r: The r of this FundingRateHistoryInner. # noqa: E501 - :type: str - """ - - self._r = r - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FundingRateHistoryInner): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/funding_rate_record.py b/gate_api/models/funding_rate_record.py index 8010021..a235ab3 100644 --- a/gate_api/models/funding_rate_record.py +++ b/gate_api/models/funding_rate_record.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FundingRateRecord(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class FundingRateRecord(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 't': 'int', - 'r': 'str' - } + openapi_types = {'t': 'int', 'r': 'str'} - attribute_map = { - 't': 't', - 'r': 'r' - } + attribute_map = {'t': 't', 'r': 'r'} - def __init__(self, t=None, r=None): # noqa: E501 + def __init__(self, t=None, r=None, local_vars_configuration=None): # noqa: E501 + # type: (int, str, Configuration) -> None """FundingRateRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._t = None self._r = None @@ -105,18 +105,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -135,8 +133,11 @@ def __eq__(self, other): if not isinstance(other, FundingRateRecord): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FundingRateRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_account.py b/gate_api/models/futures_account.py index 36c67cc..6852e3d 100644 --- a/gate_api/models/futures_account.py +++ b/gate_api/models/futures_account.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesAccount(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,7 +39,7 @@ class FuturesAccount(object): 'order_margin': 'str', 'available': 'str', 'point': 'str', - 'currency': 'str' + 'currency': 'str', } attribute_map = { @@ -47,11 +49,25 @@ class FuturesAccount(object): 'order_margin': 'order_margin', 'available': 'available', 'point': 'point', - 'currency': 'currency' + 'currency': 'currency', } - def __init__(self, total=None, unrealised_pnl=None, position_margin=None, order_margin=None, available=None, point=None, currency=None): # noqa: E501 + def __init__( + self, + total=None, + unrealised_pnl=None, + position_margin=None, + order_margin=None, + available=None, + point=None, + currency=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, Configuration) -> None """FuturesAccount - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._total = None self._unrealised_pnl = None @@ -245,18 +261,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -275,8 +289,11 @@ def __eq__(self, other): if not isinstance(other, FuturesAccount): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesAccount): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_account_book.py b/gate_api/models/futures_account_book.py index 58f9548..ab23a03 100644 --- a/gate_api/models/futures_account_book.py +++ b/gate_api/models/futures_account_book.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesAccountBook(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,18 @@ class FuturesAccountBook(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'time': 'float', - 'change': 'str', - 'balance': 'str', - 'type': 'str', - 'text': 'str' - } - - attribute_map = { - 'time': 'time', - 'change': 'change', - 'balance': 'balance', - 'type': 'type', - 'text': 'text' - } - - def __init__(self, time=None, change=None, balance=None, type=None, text=None): # noqa: E501 + openapi_types = {'time': 'float', 'change': 'str', 'balance': 'str', 'type': 'str', 'text': 'str'} + + attribute_map = {'time': 'time', 'change': 'change', 'balance': 'balance', 'type': 'type', 'text': 'text'} + + def __init__( + self, time=None, change=None, balance=None, type=None, text=None, local_vars_configuration=None + ): # noqa: E501 + # type: (float, str, str, str, str, Configuration) -> None """FuturesAccountBook - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._time = None self._change = None @@ -157,10 +153,9 @@ def type(self, type): :type: str """ allowed_values = ["dnw", "pnl", "fee", "refr", "fund", "point_dnw", "point_fee", "point_refr"] # noqa: E501 - if type not in allowed_values: + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format(type, allowed_values) # noqa: E501 ) self._type = type @@ -195,18 +190,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -225,8 +218,11 @@ def __eq__(self, other): if not isinstance(other, FuturesAccountBook): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesAccountBook): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_candlestick.py b/gate_api/models/futures_candlestick.py index 2b3d972..66f4508 100644 --- a/gate_api/models/futures_candlestick.py +++ b/gate_api/models/futures_candlestick.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesCandlestick(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,26 +32,16 @@ class FuturesCandlestick(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 't': 'float', - 'v': 'int', - 'c': 'str', - 'h': 'str', - 'l': 'str', - 'o': 'str' - } - - attribute_map = { - 't': 't', - 'v': 'v', - 'c': 'c', - 'h': 'h', - 'l': 'l', - 'o': 'o' - } - - def __init__(self, t=None, v=None, c=None, h=None, l=None, o=None): # noqa: E501 + openapi_types = {'t': 'float', 'v': 'int', 'c': 'str', 'h': 'str', 'l': 'str', 'o': 'str'} + + attribute_map = {'t': 't', 'v': 'v', 'c': 'c', 'h': 'h', 'l': 'l', 'o': 'o'} + + def __init__(self, t=None, v=None, c=None, h=None, l=None, o=None, local_vars_configuration=None): # noqa: E501 + # type: (float, int, str, str, str, str, Configuration) -> None """FuturesCandlestick - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._t = None self._v = None @@ -217,18 +209,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -247,8 +237,11 @@ def __eq__(self, other): if not isinstance(other, FuturesCandlestick): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesCandlestick): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_candlesticks.py b/gate_api/models/futures_candlesticks.py deleted file mode 100644 index 39e3a5d..0000000 --- a/gate_api/models/futures_candlesticks.py +++ /dev/null @@ -1,85 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 合约接口提供了与合约交易相关的操作,包括公共接口查询合约市场行情,以及需要认证的私有接口, 实现基于 API 的自动交易。 API 文档按照 OpenAPI v3 标准制定 API 文档, 方便 API 使用者能够轻松生成需要的客户端代码,快速接入新的功能 # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FuturesCandlesticks(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - } - - attribute_map = { - } - - def __init__(self): # noqa: E501 - """FuturesCandlesticks - a model defined in OpenAPI""" # noqa: E501 - self.discriminator = None - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FuturesCandlesticks): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/futures_candlesticks_inner.py b/gate_api/models/futures_candlesticks_inner.py deleted file mode 100644 index b62eb39..0000000 --- a/gate_api/models/futures_candlesticks_inner.py +++ /dev/null @@ -1,255 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 合约接口提供了与合约交易相关的操作,包括公共接口查询合约市场行情,以及需要认证的私有接口, 实现基于 API 的自动交易。 API 文档按照 OpenAPI v3 标准制定 API 文档, 方便 API 使用者能够轻松生成需要的客户端代码,快速接入新的功能 # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FuturesCandlesticksInner(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 't': 'float', - 'v': 'int', - 'c': 'str', - 'h': 'str', - 'l': 'str', - 'o': 'str' - } - - attribute_map = { - 't': 't', - 'v': 'v', - 'c': 'c', - 'h': 'h', - 'l': 'l', - 'o': 'o' - } - - def __init__(self, t=None, v=None, c=None, h=None, l=None, o=None): # noqa: E501 - """FuturesCandlesticksInner - a model defined in OpenAPI""" # noqa: E501 - - self._t = None - self._v = None - self._c = None - self._h = None - self._l = None - self._o = None - self.discriminator = None - - if t is not None: - self.t = t - if v is not None: - self.v = v - if c is not None: - self.c = c - if h is not None: - self.h = h - if l is not None: - self.l = l - if o is not None: - self.o = o - - @property - def t(self): - """Gets the t of this FuturesCandlesticksInner. # noqa: E501 - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :return: The t of this FuturesCandlesticksInner. # noqa: E501 - :rtype: float - """ - return self._t - - @t.setter - def t(self, t): - """Sets the t of this FuturesCandlesticksInner. - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :param t: The t of this FuturesCandlesticksInner. # noqa: E501 - :type: float - """ - - self._t = t - - @property - def v(self): - """Gets the v of this FuturesCandlesticksInner. # noqa: E501 - - 交易量,只有市场行情的 K 线数据里有该值 # noqa: E501 - - :return: The v of this FuturesCandlesticksInner. # noqa: E501 - :rtype: int - """ - return self._v - - @v.setter - def v(self, v): - """Sets the v of this FuturesCandlesticksInner. - - 交易量,只有市场行情的 K 线数据里有该值 # noqa: E501 - - :param v: The v of this FuturesCandlesticksInner. # noqa: E501 - :type: int - """ - - self._v = v - - @property - def c(self): - """Gets the c of this FuturesCandlesticksInner. # noqa: E501 - - 收盘价 # noqa: E501 - - :return: The c of this FuturesCandlesticksInner. # noqa: E501 - :rtype: str - """ - return self._c - - @c.setter - def c(self, c): - """Sets the c of this FuturesCandlesticksInner. - - 收盘价 # noqa: E501 - - :param c: The c of this FuturesCandlesticksInner. # noqa: E501 - :type: str - """ - - self._c = c - - @property - def h(self): - """Gets the h of this FuturesCandlesticksInner. # noqa: E501 - - 最高价 # noqa: E501 - - :return: The h of this FuturesCandlesticksInner. # noqa: E501 - :rtype: str - """ - return self._h - - @h.setter - def h(self, h): - """Sets the h of this FuturesCandlesticksInner. - - 最高价 # noqa: E501 - - :param h: The h of this FuturesCandlesticksInner. # noqa: E501 - :type: str - """ - - self._h = h - - @property - def l(self): - """Gets the l of this FuturesCandlesticksInner. # noqa: E501 - - 最低价 # noqa: E501 - - :return: The l of this FuturesCandlesticksInner. # noqa: E501 - :rtype: str - """ - return self._l - - @l.setter - def l(self, l): - """Sets the l of this FuturesCandlesticksInner. - - 最低价 # noqa: E501 - - :param l: The l of this FuturesCandlesticksInner. # noqa: E501 - :type: str - """ - - self._l = l - - @property - def o(self): - """Gets the o of this FuturesCandlesticksInner. # noqa: E501 - - 开盘价 # noqa: E501 - - :return: The o of this FuturesCandlesticksInner. # noqa: E501 - :rtype: str - """ - return self._o - - @o.setter - def o(self, o): - """Sets the o of this FuturesCandlesticksInner. - - 开盘价 # noqa: E501 - - :param o: The o of this FuturesCandlesticksInner. # noqa: E501 - :type: str - """ - - self._o = o - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FuturesCandlesticksInner): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/futures_error_response.py b/gate_api/models/futures_error_response.py deleted file mode 100644 index ac19a90..0000000 --- a/gate_api/models/futures_error_response.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 futures provides all sorts of futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FuturesErrorResponse(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 'label': 'str', - 'message': 'str' - } - - attribute_map = { - 'label': 'label', - 'message': 'message' - } - - def __init__(self, label=None, message=None): # noqa: E501 - """FuturesErrorResponse - a model defined in OpenAPI""" # noqa: E501 - - self._label = None - self._message = None - self.discriminator = None - - if label is not None: - self.label = label - if message is not None: - self.message = message - - @property - def label(self): - """Gets the label of this FuturesErrorResponse. # noqa: E501 - - 错误标识符,错误描述如下: 请求参数或格式问题: - INVALID_PARAM_VALUE: 参数输入值无效 - INVALID_REQUEST_BODY: 无效请求体 - MISSING_REQUIRED_PARAM: 缺少必选参数 - DUPLICATE_REQUEST: 请求过于频繁 认证相关: - INVALID_CREDENTIALS: 认证接口缺少用户认证信息 - NO_FUTURES_ACCOUNT: 用户无期货账户 业务相关: - NO_MATCHING: 没有匹配的对手单 - NO_MARKING_PRICE: 合约当前无标记价格 - CONTRACT_NOT_FOUND: 合约未找到 - NOT_FOUND: 请求路径不存在 - RISK_LIMIT_EXCEEDED: 委托超出风险限额 - INSUFFICIENT_BALANCE: 余额不足 - POTENTIAL_LIQUIDATION: 操作可能导致爆仓 - LEVERAGE_TOO_HIGH: 杠杆倍数设置过高 - LEVERAGE_TOO_LOW: 杠杆倍数设置过低 - ORDER_NOT_FOUND: 委托不存在 - ORDER_FINISHED: 订单已结束 - TOO_MANY_ORDERS: 过多未交易的挂单 - POSITION_NOT_FOUND: 合约无头寸信息 - POSITION_CROSS_MARGIN: 全仓不支持更新保证金 - POSITION_LOCKED: 头寸当前被锁定 - TOO_MUCH_CHANGE: 保证金超过可调范围 - RISK_LIMIT_NOT_MULTIPLE: 风险限额未按照步长调整 - RISK_LIMIT_TOO_HIGH: 超出最大风险限额 - RISK_LIMIT_TOO_lOW: 风险限额设置过低 - PRICE_TOO_DEVIATED: 下单价与标记价格相差过大 - SIZE_TOO_LARGE: 下单数量超过上限 - SIZE_TOO_SMALL: 下单数量不足下限 - LIQUIDATION_PRICE_EXCEEDED: 补仓时价格不能超过平仓价 - POSITION_IN_CLOSE: 仓位正在平仓 - POTENTIAL_BANKRUPTCY: 下单若成交,保证金无法弥补损失 服务异常: - SERVER_ERROR: 内部错误 - TOO_BUSY: 服务当前忙 # noqa: E501 - - :return: The label of this FuturesErrorResponse. # noqa: E501 - :rtype: str - """ - return self._label - - @label.setter - def label(self, label): - """Sets the label of this FuturesErrorResponse. - - 错误标识符,错误描述如下: 请求参数或格式问题: - INVALID_PARAM_VALUE: 参数输入值无效 - INVALID_REQUEST_BODY: 无效请求体 - MISSING_REQUIRED_PARAM: 缺少必选参数 - DUPLICATE_REQUEST: 请求过于频繁 认证相关: - INVALID_CREDENTIALS: 认证接口缺少用户认证信息 - NO_FUTURES_ACCOUNT: 用户无期货账户 业务相关: - NO_MATCHING: 没有匹配的对手单 - NO_MARKING_PRICE: 合约当前无标记价格 - CONTRACT_NOT_FOUND: 合约未找到 - NOT_FOUND: 请求路径不存在 - RISK_LIMIT_EXCEEDED: 委托超出风险限额 - INSUFFICIENT_BALANCE: 余额不足 - POTENTIAL_LIQUIDATION: 操作可能导致爆仓 - LEVERAGE_TOO_HIGH: 杠杆倍数设置过高 - LEVERAGE_TOO_LOW: 杠杆倍数设置过低 - ORDER_NOT_FOUND: 委托不存在 - ORDER_FINISHED: 订单已结束 - TOO_MANY_ORDERS: 过多未交易的挂单 - POSITION_NOT_FOUND: 合约无头寸信息 - POSITION_CROSS_MARGIN: 全仓不支持更新保证金 - POSITION_LOCKED: 头寸当前被锁定 - TOO_MUCH_CHANGE: 保证金超过可调范围 - RISK_LIMIT_NOT_MULTIPLE: 风险限额未按照步长调整 - RISK_LIMIT_TOO_HIGH: 超出最大风险限额 - RISK_LIMIT_TOO_lOW: 风险限额设置过低 - PRICE_TOO_DEVIATED: 下单价与标记价格相差过大 - SIZE_TOO_LARGE: 下单数量超过上限 - SIZE_TOO_SMALL: 下单数量不足下限 - LIQUIDATION_PRICE_EXCEEDED: 补仓时价格不能超过平仓价 - POSITION_IN_CLOSE: 仓位正在平仓 - POTENTIAL_BANKRUPTCY: 下单若成交,保证金无法弥补损失 服务异常: - SERVER_ERROR: 内部错误 - TOO_BUSY: 服务当前忙 # noqa: E501 - - :param label: The label of this FuturesErrorResponse. # noqa: E501 - :type: str - """ - allowed_values = ["INVALID_PARAM_VALUE", "INVALID_REQUEST_BODY", "MISSING_REQUIRED_PARAM", "INVALID_CREDENTIALS", "NO_FUTURES_ACCOUNT", "DUPLICATE_REQUEST", "NO_MATCHING", "NO_MARKING_PRICE", "CONTRACT_NOT_FOUND", "NOT_FOUND", "RISK_LIMIT_EXCEEDED", "INSUFFICIENT_BALANCE", "POTENTIAL_LIQUIDATION", "LEVERAGE_TOO_HIGH", "LEVERAGE_TOO_LOW", "ORDER_NOT_FOUND", "ORDER_FINISHED", "TOO_MANY_ORDERS", "POSITION_NOT_FOUND", "POSITION_CROSS_MARGIN", "POSITION_LOCKED", "TOO_MUCH_CHANGE", "RISK_LIMIT_NOT_MULTIPLE", "RISK_LIMIT_TOO_HIGH", "RISK_LIMIT_TOO_lOW", "PRICE_TOO_DEVIATED", "SIZE_TOO_LARGE", "SIZE_TOO_SMALL", "LIQUIDATION_PRICE_EXCEEDED", "POSITION_IN_CLOSE", "SERVER_ERROR", "TOO_BUSY"] # noqa: E501 - if label not in allowed_values: - raise ValueError( - "Invalid value for `label` ({0}), must be one of {1}" # noqa: E501 - .format(label, allowed_values) - ) - - self._label = label - - @property - def message(self): - """Gets the message of this FuturesErrorResponse. # noqa: E501 - - 详细错误描述。如果指定了 `Accept-Language` 请求头部,且支持指定语言,则描述信息会返回对应的语言 # noqa: E501 - - :return: The message of this FuturesErrorResponse. # noqa: E501 - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """Sets the message of this FuturesErrorResponse. - - 详细错误描述。如果指定了 `Accept-Language` 请求头部,且支持指定语言,则描述信息会返回对应的语言 # noqa: E501 - - :param message: The message of this FuturesErrorResponse. # noqa: E501 - :type: str - """ - - self._message = message - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FuturesErrorResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/futures_initial_order.py b/gate_api/models/futures_initial_order.py index 075628e..65416a4 100644 --- a/gate_api/models/futures_initial_order.py +++ b/gate_api/models/futures_initial_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesInitialOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,7 +41,7 @@ class FuturesInitialOrder(object): 'text': 'str', 'reduce_only': 'bool', 'is_reduce_only': 'bool', - 'is_close': 'bool' + 'is_close': 'bool', } attribute_map = { @@ -51,11 +53,27 @@ class FuturesInitialOrder(object): 'text': 'text', 'reduce_only': 'reduce_only', 'is_reduce_only': 'is_reduce_only', - 'is_close': 'is_close' + 'is_close': 'is_close', } - def __init__(self, contract=None, size=None, price=None, close=False, tif='gtc', text=None, reduce_only=False, is_reduce_only=None, is_close=None): # noqa: E501 + def __init__( + self, + contract=None, + size=None, + price=None, + close=False, + tif='gtc', + text=None, + reduce_only=False, + is_reduce_only=None, + is_close=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, int, str, bool, str, str, bool, bool, bool, Configuration) -> None """FuturesInitialOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._contract = None self._size = None @@ -105,7 +123,7 @@ def contract(self, contract): :param contract: The contract of this FuturesInitialOrder. # noqa: E501 :type: str """ - if contract is None: + if self.local_vars_configuration.client_side_validation and contract is None: # noqa: E501 raise ValueError("Invalid value for `contract`, must not be `None`") # noqa: E501 self._contract = contract @@ -153,7 +171,7 @@ def price(self, price): :param price: The price of this FuturesInitialOrder. # noqa: E501 :type: str """ - if price is None: + if self.local_vars_configuration.client_side_validation and price is None: # noqa: E501 raise ValueError("Invalid value for `price`, must not be `None`") # noqa: E501 self._price = price @@ -202,10 +220,9 @@ def tif(self, tif): :type: str """ allowed_values = ["gtc", "ioc"] # noqa: E501 - if tif not in allowed_values: + if self.local_vars_configuration.client_side_validation and tif not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `tif` ({0}), must be one of {1}" # noqa: E501 - .format(tif, allowed_values) + "Invalid value for `tif` ({0}), must be one of {1}".format(tif, allowed_values) # noqa: E501 ) self._tif = tif @@ -309,18 +326,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -339,8 +354,11 @@ def __eq__(self, other): if not isinstance(other, FuturesInitialOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesInitialOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_liquidate.py b/gate_api/models/futures_liquidate.py index d309ead..cadea9a 100644 --- a/gate_api/models/futures_liquidate.py +++ b/gate_api/models/futures_liquidate.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesLiquidate(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -42,7 +44,7 @@ class FuturesLiquidate(object): 'order_id': 'int', 'order_price': 'str', 'fill_price': 'str', - 'left': 'int' + 'left': 'int', } attribute_map = { @@ -57,11 +59,30 @@ class FuturesLiquidate(object): 'order_id': 'order_id', 'order_price': 'order_price', 'fill_price': 'fill_price', - 'left': 'left' + 'left': 'left', } - def __init__(self, time=None, contract=None, leverage=None, size=None, margin=None, entry_price=None, liq_price=None, mark_price=None, order_id=None, order_price=None, fill_price=None, left=None): # noqa: E501 + def __init__( + self, + time=None, + contract=None, + leverage=None, + size=None, + margin=None, + entry_price=None, + liq_price=None, + mark_price=None, + order_id=None, + order_price=None, + fill_price=None, + left=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, str, str, int, str, str, str, str, int, str, str, int, Configuration) -> None """FuturesLiquidate - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._time = None self._contract = None @@ -385,18 +406,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -415,8 +434,11 @@ def __eq__(self, other): if not isinstance(other, FuturesLiquidate): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesLiquidate): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_order.py b/gate_api/models/futures_order.py index 852d59c..1dccd96 100644 --- a/gate_api/models/futures_order.py +++ b/gate_api/models/futures_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -52,7 +54,7 @@ class FuturesOrder(object): 'text': 'str', 'tkfr': 'str', 'mkfr': 'str', - 'refu': 'int' + 'refu': 'int', } attribute_map = { @@ -77,11 +79,40 @@ class FuturesOrder(object): 'text': 'text', 'tkfr': 'tkfr', 'mkfr': 'mkfr', - 'refu': 'refu' + 'refu': 'refu', } - def __init__(self, id=None, user=None, create_time=None, finish_time=None, finish_as=None, status=None, contract=None, size=None, iceberg=None, price=None, close=False, is_close=None, reduce_only=False, is_reduce_only=None, is_liq=None, tif='gtc', left=None, fill_price=None, text=None, tkfr=None, mkfr=None, refu=None): # noqa: E501 + def __init__( + self, + id=None, + user=None, + create_time=None, + finish_time=None, + finish_as=None, + status=None, + contract=None, + size=None, + iceberg=None, + price=None, + close=False, + is_close=None, + reduce_only=False, + is_reduce_only=None, + is_liq=None, + tif='gtc', + left=None, + fill_price=None, + text=None, + tkfr=None, + mkfr=None, + refu=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, int, float, float, str, str, str, int, int, str, bool, bool, bool, bool, bool, str, int, str, str, str, str, int, Configuration) -> None """FuturesOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._user = None @@ -264,10 +295,11 @@ def finish_as(self, finish_as): :type: str """ allowed_values = ["filled", "cancelled", "liquidated", "ioc", "auto_deleveraged", "reduce_only"] # noqa: E501 - if finish_as not in allowed_values: + if self.local_vars_configuration.client_side_validation and finish_as not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `finish_as` ({0}), must be one of {1}" # noqa: E501 - .format(finish_as, allowed_values) + "Invalid value for `finish_as` ({0}), must be one of {1}".format( # noqa: E501 + finish_as, allowed_values + ) ) self._finish_as = finish_as @@ -293,10 +325,9 @@ def status(self, status): :type: str """ allowed_values = ["open", "finished"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -321,7 +352,7 @@ def contract(self, contract): :param contract: The contract of this FuturesOrder. # noqa: E501 :type: str """ - if contract is None: + if self.local_vars_configuration.client_side_validation and contract is None: # noqa: E501 raise ValueError("Invalid value for `contract`, must not be `None`") # noqa: E501 self._contract = contract @@ -531,10 +562,9 @@ def tif(self, tif): :type: str """ allowed_values = ["gtc", "ioc", "poc"] # noqa: E501 - if tif not in allowed_values: + if self.local_vars_configuration.client_side_validation and tif not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `tif` ({0}), must be one of {1}" # noqa: E501 - .format(tif, allowed_values) + "Invalid value for `tif` ({0}), must be one of {1}".format(tif, allowed_values) # noqa: E501 ) self._tif = tif @@ -589,7 +619,7 @@ def fill_price(self, fill_price): def text(self): """Gets the text of this FuturesOrder. # noqa: E501 - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance # noqa: E501 :return: The text of this FuturesOrder. # noqa: E501 :rtype: str @@ -600,7 +630,7 @@ def text(self): def text(self, text): """Sets the text of this FuturesOrder. - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created: - web: from web - api: from API - app: from mobile phones - auto_deleveraging: from ADL - liquidation: from liquidation - insurance: from insurance # noqa: E501 :param text: The text of this FuturesOrder. # noqa: E501 :type: str @@ -684,18 +714,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -714,8 +742,11 @@ def __eq__(self, other): if not isinstance(other, FuturesOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_order_book.py b/gate_api/models/futures_order_book.py index b765415..ad88040 100644 --- a/gate_api/models/futures_order_book.py +++ b/gate_api/models/futures_order_book.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesOrderBook(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class FuturesOrderBook(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'asks': 'list[FuturesOrderBookItem]', - 'bids': 'list[FuturesOrderBookItem]' - } + openapi_types = {'asks': 'list[FuturesOrderBookItem]', 'bids': 'list[FuturesOrderBookItem]'} - attribute_map = { - 'asks': 'asks', - 'bids': 'bids' - } + attribute_map = {'asks': 'asks', 'bids': 'bids'} - def __init__(self, asks=None, bids=None): # noqa: E501 + def __init__(self, asks=None, bids=None, local_vars_configuration=None): # noqa: E501 + # type: (list[FuturesOrderBookItem], list[FuturesOrderBookItem], Configuration) -> None """FuturesOrderBook - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._asks = None self._bids = None @@ -70,7 +70,7 @@ def asks(self, asks): :param asks: The asks of this FuturesOrderBook. # noqa: E501 :type: list[FuturesOrderBookItem] """ - if asks is None: + if self.local_vars_configuration.client_side_validation and asks is None: # noqa: E501 raise ValueError("Invalid value for `asks`, must not be `None`") # noqa: E501 self._asks = asks @@ -95,7 +95,7 @@ def bids(self, bids): :param bids: The bids of this FuturesOrderBook. # noqa: E501 :type: list[FuturesOrderBookItem] """ - if bids is None: + if self.local_vars_configuration.client_side_validation and bids is None: # noqa: E501 raise ValueError("Invalid value for `bids`, must not be `None`") # noqa: E501 self._bids = bids @@ -107,18 +107,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -137,8 +135,11 @@ def __eq__(self, other): if not isinstance(other, FuturesOrderBook): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesOrderBook): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_order_book_asks.py b/gate_api/models/futures_order_book_asks.py deleted file mode 100644 index ee466f8..0000000 --- a/gate_api/models/futures_order_book_asks.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 futures provides all sorts of futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 - - OpenAPI spec version: 1.1.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class FuturesOrderBookAsks(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 'p': 'str', - 's': 'int' - } - - attribute_map = { - 'p': 'p', - 's': 's' - } - - def __init__(self, p=None, s=None): # noqa: E501 - """FuturesOrderBookAsks - a model defined in OpenAPI""" # noqa: E501 - - self._p = None - self._s = None - self.discriminator = None - - if p is not None: - self.p = p - if s is not None: - self.s = s - - @property - def p(self): - """Gets the p of this FuturesOrderBookAsks. # noqa: E501 - - Price # noqa: E501 - - :return: The p of this FuturesOrderBookAsks. # noqa: E501 - :rtype: str - """ - return self._p - - @p.setter - def p(self, p): - """Sets the p of this FuturesOrderBookAsks. - - Price # noqa: E501 - - :param p: The p of this FuturesOrderBookAsks. # noqa: E501 - :type: str - """ - - self._p = p - - @property - def s(self): - """Gets the s of this FuturesOrderBookAsks. # noqa: E501 - - Size # noqa: E501 - - :return: The s of this FuturesOrderBookAsks. # noqa: E501 - :rtype: int - """ - return self._s - - @s.setter - def s(self, s): - """Sets the s of this FuturesOrderBookAsks. - - Size # noqa: E501 - - :param s: The s of this FuturesOrderBookAsks. # noqa: E501 - :type: int - """ - - self._s = s - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, FuturesOrderBookAsks): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/futures_order_book_item.py b/gate_api/models/futures_order_book_item.py index c04a1af..e39ddab 100644 --- a/gate_api/models/futures_order_book_item.py +++ b/gate_api/models/futures_order_book_item.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesOrderBookItem(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class FuturesOrderBookItem(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'p': 'str', - 's': 'int' - } + openapi_types = {'p': 'str', 's': 'int'} - attribute_map = { - 'p': 'p', - 's': 's' - } + attribute_map = {'p': 'p', 's': 's'} - def __init__(self, p=None, s=None): # noqa: E501 + def __init__(self, p=None, s=None, local_vars_configuration=None): # noqa: E501 + # type: (str, int, Configuration) -> None """FuturesOrderBookItem - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._p = None self._s = None @@ -105,18 +105,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -135,8 +133,11 @@ def __eq__(self, other): if not isinstance(other, FuturesOrderBookItem): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesOrderBookItem): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_price_trigger.py b/gate_api/models/futures_price_trigger.py index ea128f1..a9c988b 100644 --- a/gate_api/models/futures_price_trigger.py +++ b/gate_api/models/futures_price_trigger.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesPriceTrigger(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,24 @@ class FuturesPriceTrigger(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'strategy_type': 'int', - 'price_type': 'int', - 'price': 'str', - 'rule': 'int', - 'expiration': 'int' - } + openapi_types = {'strategy_type': 'int', 'price_type': 'int', 'price': 'str', 'rule': 'int', 'expiration': 'int'} attribute_map = { 'strategy_type': 'strategy_type', 'price_type': 'price_type', 'price': 'price', 'rule': 'rule', - 'expiration': 'expiration' + 'expiration': 'expiration', } - def __init__(self, strategy_type=None, price_type=None, price=None, rule=None, expiration=None): # noqa: E501 + def __init__( + self, strategy_type=None, price_type=None, price=None, rule=None, expiration=None, local_vars_configuration=None + ): # noqa: E501 + # type: (int, int, str, int, int, Configuration) -> None """FuturesPriceTrigger - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._strategy_type = None self._price_type = None @@ -88,10 +90,11 @@ def strategy_type(self, strategy_type): :type: int """ allowed_values = [0, 1] # noqa: E501 - if strategy_type not in allowed_values: + if self.local_vars_configuration.client_side_validation and strategy_type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `strategy_type` ({0}), must be one of {1}" # noqa: E501 - .format(strategy_type, allowed_values) + "Invalid value for `strategy_type` ({0}), must be one of {1}".format( # noqa: E501 + strategy_type, allowed_values + ) ) self._strategy_type = strategy_type @@ -117,10 +120,11 @@ def price_type(self, price_type): :type: int """ allowed_values = [0, 1, 2] # noqa: E501 - if price_type not in allowed_values: + if self.local_vars_configuration.client_side_validation and price_type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `price_type` ({0}), must be one of {1}" # noqa: E501 - .format(price_type, allowed_values) + "Invalid value for `price_type` ({0}), must be one of {1}".format( # noqa: E501 + price_type, allowed_values + ) ) self._price_type = price_type @@ -169,10 +173,9 @@ def rule(self, rule): :type: int """ allowed_values = [1, 2] # noqa: E501 - if rule not in allowed_values: + if self.local_vars_configuration.client_side_validation and rule not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `rule` ({0}), must be one of {1}" # noqa: E501 - .format(rule, allowed_values) + "Invalid value for `rule` ({0}), must be one of {1}".format(rule, allowed_values) # noqa: E501 ) self._rule = rule @@ -207,18 +210,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -237,8 +238,11 @@ def __eq__(self, other): if not isinstance(other, FuturesPriceTrigger): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesPriceTrigger): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_price_triggered_order.py b/gate_api/models/futures_price_triggered_order.py index 6066169..dd84cef 100644 --- a/gate_api/models/futures_price_triggered_order.py +++ b/gate_api/models/futures_price_triggered_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesPriceTriggeredOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -40,7 +42,7 @@ class FuturesPriceTriggeredOrder(object): 'trade_id': 'int', 'status': 'str', 'finish_as': 'str', - 'reason': 'str' + 'reason': 'str', } attribute_map = { @@ -53,11 +55,28 @@ class FuturesPriceTriggeredOrder(object): 'trade_id': 'trade_id', 'status': 'status', 'finish_as': 'finish_as', - 'reason': 'reason' + 'reason': 'reason', } - def __init__(self, initial=None, trigger=None, id=None, user=None, create_time=None, finish_time=None, trade_id=None, status=None, finish_as=None, reason=None): # noqa: E501 + def __init__( + self, + initial=None, + trigger=None, + id=None, + user=None, + create_time=None, + finish_time=None, + trade_id=None, + status=None, + finish_as=None, + reason=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (FuturesInitialOrder, FuturesPriceTrigger, int, int, float, float, int, str, str, str, Configuration) -> None """FuturesPriceTriggeredOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._initial = None self._trigger = None @@ -108,7 +127,7 @@ def initial(self, initial): :param initial: The initial of this FuturesPriceTriggeredOrder. # noqa: E501 :type: FuturesInitialOrder """ - if initial is None: + if self.local_vars_configuration.client_side_validation and initial is None: # noqa: E501 raise ValueError("Invalid value for `initial`, must not be `None`") # noqa: E501 self._initial = initial @@ -131,7 +150,7 @@ def trigger(self, trigger): :param trigger: The trigger of this FuturesPriceTriggeredOrder. # noqa: E501 :type: FuturesPriceTrigger """ - if trigger is None: + if self.local_vars_configuration.client_side_validation and trigger is None: # noqa: E501 raise ValueError("Invalid value for `trigger`, must not be `None`") # noqa: E501 self._trigger = trigger @@ -272,10 +291,9 @@ def status(self, status): :type: str """ allowed_values = ["open", "finished"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -301,10 +319,11 @@ def finish_as(self, finish_as): :type: str """ allowed_values = ["cancelled", "succeeded", "failed", "expired"] # noqa: E501 - if finish_as not in allowed_values: + if self.local_vars_configuration.client_side_validation and finish_as not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `finish_as` ({0}), must be one of {1}" # noqa: E501 - .format(finish_as, allowed_values) + "Invalid value for `finish_as` ({0}), must be one of {1}".format( # noqa: E501 + finish_as, allowed_values + ) ) self._finish_as = finish_as @@ -339,18 +358,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -369,8 +386,11 @@ def __eq__(self, other): if not isinstance(other, FuturesPriceTriggeredOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesPriceTriggeredOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_ticker.py b/gate_api/models/futures_ticker.py index 9ec67fd..503fdb9 100644 --- a/gate_api/models/futures_ticker.py +++ b/gate_api/models/futures_ticker.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesTicker(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -47,7 +49,7 @@ class FuturesTicker(object): 'funding_rate': 'str', 'funding_rate_indicative': 'str', 'index_price': 'str', - 'quanto_base_rate': 'str' + 'quanto_base_rate': 'str', } attribute_map = { @@ -67,11 +69,35 @@ class FuturesTicker(object): 'funding_rate': 'funding_rate', 'funding_rate_indicative': 'funding_rate_indicative', 'index_price': 'index_price', - 'quanto_base_rate': 'quanto_base_rate' + 'quanto_base_rate': 'quanto_base_rate', } - def __init__(self, contract=None, last=None, change_percentage=None, total_size=None, low_24h=None, high_24h=None, volume_24h=None, volume_24h_btc=None, volume_24h_usd=None, volume_24h_base=None, volume_24h_quote=None, volume_24h_settle=None, mark_price=None, funding_rate=None, funding_rate_indicative=None, index_price=None, quanto_base_rate=None): # noqa: E501 + def __init__( + self, + contract=None, + last=None, + change_percentage=None, + total_size=None, + low_24h=None, + high_24h=None, + volume_24h=None, + volume_24h_btc=None, + volume_24h_usd=None, + volume_24h_base=None, + volume_24h_quote=None, + volume_24h_settle=None, + mark_price=None, + funding_rate=None, + funding_rate_indicative=None, + index_price=None, + quanto_base_rate=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, Configuration) -> None """FuturesTicker - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._contract = None self._last = None @@ -525,18 +551,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -555,8 +579,11 @@ def __eq__(self, other): if not isinstance(other, FuturesTicker): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesTicker): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/futures_trade.py b/gate_api/models/futures_trade.py index 73684f6..1daa0fb 100644 --- a/gate_api/models/futures_trade.py +++ b/gate_api/models/futures_trade.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class FuturesTrade(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,18 @@ class FuturesTrade(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'int', - 'create_time': 'float', - 'contract': 'str', - 'size': 'int', - 'price': 'str' - } - - attribute_map = { - 'id': 'id', - 'create_time': 'create_time', - 'contract': 'contract', - 'size': 'size', - 'price': 'price' - } - - def __init__(self, id=None, create_time=None, contract=None, size=None, price=None): # noqa: E501 + openapi_types = {'id': 'int', 'create_time': 'float', 'contract': 'str', 'size': 'int', 'price': 'str'} + + attribute_map = {'id': 'id', 'create_time': 'create_time', 'contract': 'contract', 'size': 'size', 'price': 'price'} + + def __init__( + self, id=None, create_time=None, contract=None, size=None, price=None, local_vars_configuration=None + ): # noqa: E501 + # type: (int, float, str, int, str, Configuration) -> None """FuturesTrade - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._create_time = None @@ -189,18 +185,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -219,8 +213,11 @@ def __eq__(self, other): if not isinstance(other, FuturesTrade): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, FuturesTrade): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/gate_error_response.py b/gate_api/models/gate_error_response.py deleted file mode 100644 index 23f7ba6..0000000 --- a/gate_api/models/gate_error_response.py +++ /dev/null @@ -1,142 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 - - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class GateErrorResponse(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 'label': 'str', - 'message': 'str' - } - - attribute_map = { - 'label': 'label', - 'message': 'message' - } - - def __init__(self, label=None, message=None): # noqa: E501 - """GateErrorResponse - a model defined in OpenAPI""" # noqa: E501 - - self._label = None - self._message = None - self.discriminator = None - - if label is not None: - self.label = label - if message is not None: - self.message = message - - @property - def label(self): - """Gets the label of this GateErrorResponse. # noqa: E501 - - Error label # noqa: E501 - - :return: The label of this GateErrorResponse. # noqa: E501 - :rtype: str - """ - return self._label - - @label.setter - def label(self, label): - """Sets the label of this GateErrorResponse. - - Error label # noqa: E501 - - :param label: The label of this GateErrorResponse. # noqa: E501 - :type: str - """ - - self._label = label - - @property - def message(self): - """Gets the message of this GateErrorResponse. # noqa: E501 - - Detailed error message # noqa: E501 - - :return: The message of this GateErrorResponse. # noqa: E501 - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """Sets the message of this GateErrorResponse. - - Detailed error message # noqa: E501 - - :param message: The message of this GateErrorResponse. # noqa: E501 - :type: str - """ - - self._message = message - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, GateErrorResponse): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/insurance_record.py b/gate_api/models/insurance_record.py index b382472..379966d 100644 --- a/gate_api/models/insurance_record.py +++ b/gate_api/models/insurance_record.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class InsuranceRecord(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class InsuranceRecord(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 't': 'int', - 'b': 'str' - } + openapi_types = {'t': 'int', 'b': 'str'} - attribute_map = { - 't': 't', - 'b': 'b' - } + attribute_map = {'t': 't', 'b': 'b'} - def __init__(self, t=None, b=None): # noqa: E501 + def __init__(self, t=None, b=None, local_vars_configuration=None): # noqa: E501 + # type: (int, str, Configuration) -> None """InsuranceRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._t = None self._b = None @@ -105,18 +105,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -135,8 +133,11 @@ def __eq__(self, other): if not isinstance(other, InsuranceRecord): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, InsuranceRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/insurance_record_inner.py b/gate_api/models/insurance_record_inner.py deleted file mode 100644 index 1774a68..0000000 --- a/gate_api/models/insurance_record_inner.py +++ /dev/null @@ -1,143 +0,0 @@ -# coding: utf-8 - -""" - Gate API v4 - - APIv4 合约接口提供了与合约交易相关的操作,包括公共接口查询合约市场行情,以及需要认证的私有接口, 实现基于 API 的自动交易。 API 文档按照 OpenAPI v3 标准制定 API 文档, 方便 API 使用者能够轻松生成需要的客户端代码,快速接入新的功能 # noqa: E501 - - OpenAPI spec version: 1.0.0 - Contact: support@mail.gate.io - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - - -class InsuranceRecordInner(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 't': 'int', - 'b': 'str' - } - - attribute_map = { - 't': 't', - 'b': 'b' - } - - def __init__(self, t=None, b=None): # noqa: E501 - """InsuranceRecordInner - a model defined in OpenAPI""" # noqa: E501 - - self._t = None - self._b = None - self.discriminator = None - - if t is not None: - self.t = t - if b is not None: - self.b = b - - @property - def t(self): - """Gets the t of this InsuranceRecordInner. # noqa: E501 - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :return: The t of this InsuranceRecordInner. # noqa: E501 - :rtype: int - """ - return self._t - - @t.setter - def t(self, t): - """Sets the t of this InsuranceRecordInner. - - 秒 s 精度的 Unix 时间戳 # noqa: E501 - - :param t: The t of this InsuranceRecordInner. # noqa: E501 - :type: int - """ - - self._t = t - - @property - def b(self): - """Gets the b of this InsuranceRecordInner. # noqa: E501 - - 保险基金余额 # noqa: E501 - - :return: The b of this InsuranceRecordInner. # noqa: E501 - :rtype: str - """ - return self._b - - @b.setter - def b(self, b): - """Sets the b of this InsuranceRecordInner. - - 保险基金余额 # noqa: E501 - - :param b: The b of this InsuranceRecordInner. # noqa: E501 - :type: str - """ - - self._b = b - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, InsuranceRecordInner): - return False - - return self.__dict__ == other.__dict__ - - def __ne__(self, other): - """Returns true if both objects are not equal""" - return not self == other diff --git a/gate_api/models/ledger_record.py b/gate_api/models/ledger_record.py index 76ba330..a2fbdbe 100644 --- a/gate_api/models/ledger_record.py +++ b/gate_api/models/ledger_record.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class LedgerRecord(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -38,7 +40,7 @@ class LedgerRecord(object): 'currency': 'str', 'address': 'str', 'memo': 'str', - 'status': 'str' + 'status': 'str', } attribute_map = { @@ -49,11 +51,26 @@ class LedgerRecord(object): 'currency': 'currency', 'address': 'address', 'memo': 'memo', - 'status': 'status' + 'status': 'status', } - def __init__(self, id=None, txid=None, timestamp=None, amount=None, currency=None, address=None, memo=None, status=None): # noqa: E501 + def __init__( + self, + id=None, + txid=None, + timestamp=None, + amount=None, + currency=None, + address=None, + memo=None, + status=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, Configuration) -> None """LedgerRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._txid = None @@ -169,7 +186,7 @@ def amount(self, amount): :param amount: The amount of this LedgerRecord. # noqa: E501 :type: str """ - if amount is None: + if self.local_vars_configuration.client_side_validation and amount is None: # noqa: E501 raise ValueError("Invalid value for `amount`, must not be `None`") # noqa: E501 self._amount = amount @@ -194,7 +211,7 @@ def currency(self, currency): :param currency: The currency of this LedgerRecord. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -266,10 +283,9 @@ def status(self, status): :type: str """ allowed_values = ["DONE", "CANCEL", "REQUEST", "MANUAL", "BCODE"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -281,18 +297,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -311,8 +325,11 @@ def __eq__(self, other): if not isinstance(other, LedgerRecord): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, LedgerRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/loan.py b/gate_api/models/loan.py index ba77055..02b5852 100644 --- a/gate_api/models/loan.py +++ b/gate_api/models/loan.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Loan(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -47,7 +49,7 @@ class Loan(object): 'paid_interest': 'str', 'unpaid_interest': 'str', 'fee_rate': 'str', - 'orig_id': 'str' + 'orig_id': 'str', } attribute_map = { @@ -67,11 +69,35 @@ class Loan(object): 'paid_interest': 'paid_interest', 'unpaid_interest': 'unpaid_interest', 'fee_rate': 'fee_rate', - 'orig_id': 'orig_id' + 'orig_id': 'orig_id', } - def __init__(self, id=None, create_time=None, expire_time=None, status=None, side=None, currency=None, rate=None, amount=None, days=None, auto_renew=False, currency_pair=None, left=None, repaid=None, paid_interest=None, unpaid_interest=None, fee_rate=None, orig_id=None): # noqa: E501 + def __init__( + self, + id=None, + create_time=None, + expire_time=None, + status=None, + side=None, + currency=None, + rate=None, + amount=None, + days=None, + auto_renew=False, + currency_pair=None, + left=None, + repaid=None, + paid_interest=None, + unpaid_interest=None, + fee_rate=None, + orig_id=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, int, bool, str, str, str, str, str, str, str, Configuration) -> None """Loan - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._create_time = None @@ -213,10 +239,9 @@ def status(self, status): :type: str """ allowed_values = ["open", "loaned", "finished", "auto_repaid"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -241,13 +266,12 @@ def side(self, side): :param side: The side of this Loan. # noqa: E501 :type: str """ - if side is None: + if self.local_vars_configuration.client_side_validation and side is None: # noqa: E501 raise ValueError("Invalid value for `side`, must not be `None`") # noqa: E501 allowed_values = ["lend", "borrow"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -272,7 +296,7 @@ def currency(self, currency): :param currency: The currency of this Loan. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -320,7 +344,7 @@ def amount(self, amount): :param amount: The amount of this Loan. # noqa: E501 :type: str """ - if amount is None: + if self.local_vars_configuration.client_side_validation and amount is None: # noqa: E501 raise ValueError("Invalid value for `amount`, must not be `None`") # noqa: E501 self._amount = amount @@ -345,7 +369,7 @@ def days(self, days): :param days: The days of this Loan. # noqa: E501 :type: int """ - if days is None: + if self.local_vars_configuration.client_side_validation and days is None: # noqa: E501 raise ValueError("Invalid value for `days`, must not be `None`") # noqa: E501 self._days = days @@ -541,18 +565,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -571,8 +593,11 @@ def __eq__(self, other): if not isinstance(other, Loan): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Loan): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/loan_patch.py b/gate_api/models/loan_patch.py index 97db9a9..7febc66 100644 --- a/gate_api/models/loan_patch.py +++ b/gate_api/models/loan_patch.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class LoanPatch(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,24 @@ class LoanPatch(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency': 'str', - 'side': 'str', - 'auto_renew': 'bool', - 'currency_pair': 'str', - 'loan_id': 'str' - } + openapi_types = {'currency': 'str', 'side': 'str', 'auto_renew': 'bool', 'currency_pair': 'str', 'loan_id': 'str'} attribute_map = { 'currency': 'currency', 'side': 'side', 'auto_renew': 'auto_renew', 'currency_pair': 'currency_pair', - 'loan_id': 'loan_id' + 'loan_id': 'loan_id', } - def __init__(self, currency=None, side=None, auto_renew=None, currency_pair=None, loan_id=None): # noqa: E501 + def __init__( + self, currency=None, side=None, auto_renew=None, currency_pair=None, loan_id=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, bool, str, str, Configuration) -> None """LoanPatch - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._side = None @@ -84,7 +86,7 @@ def currency(self, currency): :param currency: The currency of this LoanPatch. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -109,13 +111,12 @@ def side(self, side): :param side: The side of this LoanPatch. # noqa: E501 :type: str """ - if side is None: + if self.local_vars_configuration.client_side_validation and side is None: # noqa: E501 raise ValueError("Invalid value for `side`, must not be `None`") # noqa: E501 allowed_values = ["lend", "borrow"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -140,7 +141,7 @@ def auto_renew(self, auto_renew): :param auto_renew: The auto_renew of this LoanPatch. # noqa: E501 :type: bool """ - if auto_renew is None: + if self.local_vars_configuration.client_side_validation and auto_renew is None: # noqa: E501 raise ValueError("Invalid value for `auto_renew`, must not be `None`") # noqa: E501 self._auto_renew = auto_renew @@ -198,18 +199,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -228,8 +227,11 @@ def __eq__(self, other): if not isinstance(other, LoanPatch): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, LoanPatch): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/loan_record.py b/gate_api/models/loan_record.py index 5bda380..913c546 100644 --- a/gate_api/models/loan_record.py +++ b/gate_api/models/loan_record.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class LoanRecord(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -44,7 +46,7 @@ class LoanRecord(object): 'auto_renew': 'bool', 'repaid': 'str', 'paid_interest': 'str', - 'unpaid_interest': 'str' + 'unpaid_interest': 'str', } attribute_map = { @@ -61,11 +63,32 @@ class LoanRecord(object): 'auto_renew': 'auto_renew', 'repaid': 'repaid', 'paid_interest': 'paid_interest', - 'unpaid_interest': 'unpaid_interest' + 'unpaid_interest': 'unpaid_interest', } - def __init__(self, id=None, loan_id=None, create_time=None, expire_time=None, status=None, borrow_user_id=None, currency=None, rate=None, amount=None, days=None, auto_renew=False, repaid=None, paid_interest=None, unpaid_interest=None): # noqa: E501 + def __init__( + self, + id=None, + loan_id=None, + create_time=None, + expire_time=None, + status=None, + borrow_user_id=None, + currency=None, + rate=None, + amount=None, + days=None, + auto_renew=False, + repaid=None, + paid_interest=None, + unpaid_interest=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, str, int, bool, str, str, str, Configuration) -> None """LoanRecord - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._loan_id = None @@ -225,10 +248,9 @@ def status(self, status): :type: str """ allowed_values = ["loaned", "finished"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -447,18 +469,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -477,8 +497,11 @@ def __eq__(self, other): if not isinstance(other, LoanRecord): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, LoanRecord): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/margin_account.py b/gate_api/models/margin_account.py index 9a797ff..18cc45c 100644 --- a/gate_api/models/margin_account.py +++ b/gate_api/models/margin_account.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class MarginAccount(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,20 +32,16 @@ class MarginAccount(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency_pair': 'str', - 'base': 'MarginAccountCurrency', - 'quote': 'MarginAccountCurrency' - } - - attribute_map = { - 'currency_pair': 'currency_pair', - 'base': 'base', - 'quote': 'quote' - } - - def __init__(self, currency_pair=None, base=None, quote=None): # noqa: E501 + openapi_types = {'currency_pair': 'str', 'base': 'MarginAccountCurrency', 'quote': 'MarginAccountCurrency'} + + attribute_map = {'currency_pair': 'currency_pair', 'base': 'base', 'quote': 'quote'} + + def __init__(self, currency_pair=None, base=None, quote=None, local_vars_configuration=None): # noqa: E501 + # type: (str, MarginAccountCurrency, MarginAccountCurrency, Configuration) -> None """MarginAccount - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency_pair = None self._base = None @@ -129,18 +127,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -159,8 +155,11 @@ def __eq__(self, other): if not isinstance(other, MarginAccount): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, MarginAccount): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/margin_account_book.py b/gate_api/models/margin_account_book.py new file mode 100644 index 0000000..a43f3db --- /dev/null +++ b/gate_api/models/margin_account_book.py @@ -0,0 +1,270 @@ +# coding: utf-8 + +""" + Gate API v4 + + APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 + + Contact: support@mail.gate.io + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from gate_api.configuration import Configuration + + +class MarginAccountBook(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'id': 'str', + 'time': 'str', + 'currency': 'str', + 'currency_pair': 'str', + 'change': 'str', + 'balance': 'str', + } + + attribute_map = { + 'id': 'id', + 'time': 'time', + 'currency': 'currency', + 'currency_pair': 'currency_pair', + 'change': 'change', + 'balance': 'balance', + } + + def __init__( + self, + id=None, + time=None, + currency=None, + currency_pair=None, + change=None, + balance=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, Configuration) -> None + """MarginAccountBook - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._id = None + self._time = None + self._currency = None + self._currency_pair = None + self._change = None + self._balance = None + self.discriminator = None + + if id is not None: + self.id = id + if time is not None: + self.time = time + if currency is not None: + self.currency = currency + if currency_pair is not None: + self.currency_pair = currency_pair + if change is not None: + self.change = change + if balance is not None: + self.balance = balance + + @property + def id(self): + """Gets the id of this MarginAccountBook. # noqa: E501 + + Balance change record ID # noqa: E501 + + :return: The id of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._id + + @id.setter + def id(self, id): + """Sets the id of this MarginAccountBook. + + Balance change record ID # noqa: E501 + + :param id: The id of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._id = id + + @property + def time(self): + """Gets the time of this MarginAccountBook. # noqa: E501 + + Balance changed timestamp # noqa: E501 + + :return: The time of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._time + + @time.setter + def time(self, time): + """Sets the time of this MarginAccountBook. + + Balance changed timestamp # noqa: E501 + + :param time: The time of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._time = time + + @property + def currency(self): + """Gets the currency of this MarginAccountBook. # noqa: E501 + + Currency changed # noqa: E501 + + :return: The currency of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._currency + + @currency.setter + def currency(self, currency): + """Sets the currency of this MarginAccountBook. + + Currency changed # noqa: E501 + + :param currency: The currency of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._currency = currency + + @property + def currency_pair(self): + """Gets the currency_pair of this MarginAccountBook. # noqa: E501 + + Account currency pair # noqa: E501 + + :return: The currency_pair of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._currency_pair + + @currency_pair.setter + def currency_pair(self, currency_pair): + """Sets the currency_pair of this MarginAccountBook. + + Account currency pair # noqa: E501 + + :param currency_pair: The currency_pair of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._currency_pair = currency_pair + + @property + def change(self): + """Gets the change of this MarginAccountBook. # noqa: E501 + + Amount changed. Positive value means transferring in, while negative out # noqa: E501 + + :return: The change of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._change + + @change.setter + def change(self, change): + """Sets the change of this MarginAccountBook. + + Amount changed. Positive value means transferring in, while negative out # noqa: E501 + + :param change: The change of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._change = change + + @property + def balance(self): + """Gets the balance of this MarginAccountBook. # noqa: E501 + + Balance after change # noqa: E501 + + :return: The balance of this MarginAccountBook. # noqa: E501 + :rtype: str + """ + return self._balance + + @balance.setter + def balance(self, balance): + """Sets the balance of this MarginAccountBook. + + Balance after change # noqa: E501 + + :param balance: The balance of this MarginAccountBook. # noqa: E501 + :type: str + """ + + self._balance = balance + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, MarginAccountBook): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, MarginAccountBook): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/margin_account_currency.py b/gate_api/models/margin_account_currency.py index fc19129..2b96125 100644 --- a/gate_api/models/margin_account_currency.py +++ b/gate_api/models/margin_account_currency.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class MarginAccountCurrency(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,22 +32,18 @@ class MarginAccountCurrency(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency': 'str', - 'available': 'str', - 'locked': 'str', - 'borrowed': 'str' - } - - attribute_map = { - 'currency': 'currency', - 'available': 'available', - 'locked': 'locked', - 'borrowed': 'borrowed' - } - - def __init__(self, currency=None, available=None, locked=None, borrowed=None): # noqa: E501 + openapi_types = {'currency': 'str', 'available': 'str', 'locked': 'str', 'borrowed': 'str'} + + attribute_map = {'currency': 'currency', 'available': 'available', 'locked': 'locked', 'borrowed': 'borrowed'} + + def __init__( + self, currency=None, available=None, locked=None, borrowed=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, str, str, Configuration) -> None """MarginAccountCurrency - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._available = None @@ -161,18 +159,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -191,8 +187,11 @@ def __eq__(self, other): if not isinstance(other, MarginAccountCurrency): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, MarginAccountCurrency): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/margin_currency_pair.py b/gate_api/models/margin_currency_pair.py index b310557..50fbd36 100644 --- a/gate_api/models/margin_currency_pair.py +++ b/gate_api/models/margin_currency_pair.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class MarginCurrencyPair(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,7 +39,7 @@ class MarginCurrencyPair(object): 'leverage': 'int', 'min_base_amount': 'str', 'min_quote_amount': 'str', - 'max_quote_amount': 'str' + 'max_quote_amount': 'str', } attribute_map = { @@ -47,11 +49,25 @@ class MarginCurrencyPair(object): 'leverage': 'leverage', 'min_base_amount': 'min_base_amount', 'min_quote_amount': 'min_quote_amount', - 'max_quote_amount': 'max_quote_amount' + 'max_quote_amount': 'max_quote_amount', } - def __init__(self, id=None, base=None, quote=None, leverage=None, min_base_amount=None, min_quote_amount=None, max_quote_amount=None): # noqa: E501 + def __init__( + self, + id=None, + base=None, + quote=None, + leverage=None, + min_base_amount=None, + min_quote_amount=None, + max_quote_amount=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, int, str, str, str, Configuration) -> None """MarginCurrencyPair - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._base = None @@ -245,18 +261,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -275,8 +289,11 @@ def __eq__(self, other): if not isinstance(other, MarginCurrencyPair): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, MarginCurrencyPair): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/my_futures_trade.py b/gate_api/models/my_futures_trade.py index ee1279b..ccd3672 100644 --- a/gate_api/models/my_futures_trade.py +++ b/gate_api/models/my_futures_trade.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class MyFuturesTrade(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,7 +39,7 @@ class MyFuturesTrade(object): 'order_id': 'str', 'size': 'int', 'price': 'str', - 'role': 'str' + 'role': 'str', } attribute_map = { @@ -47,11 +49,25 @@ class MyFuturesTrade(object): 'order_id': 'order_id', 'size': 'size', 'price': 'price', - 'role': 'role' + 'role': 'role', } - def __init__(self, id=None, create_time=None, contract=None, order_id=None, size=None, price=None, role=None): # noqa: E501 + def __init__( + self, + id=None, + create_time=None, + contract=None, + order_id=None, + size=None, + price=None, + role=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, float, str, str, int, str, str, Configuration) -> None """MyFuturesTrade - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._create_time = None @@ -236,10 +252,9 @@ def role(self, role): :type: str """ allowed_values = ["taker", "maker"] # noqa: E501 - if role not in allowed_values: + if self.local_vars_configuration.client_side_validation and role not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `role` ({0}), must be one of {1}" # noqa: E501 - .format(role, allowed_values) + "Invalid value for `role` ({0}), must be one of {1}".format(role, allowed_values) # noqa: E501 ) self._role = role @@ -251,18 +266,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -281,8 +294,11 @@ def __eq__(self, other): if not isinstance(other, MyFuturesTrade): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, MyFuturesTrade): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/open_orders.py b/gate_api/models/open_orders.py new file mode 100644 index 0000000..505066e --- /dev/null +++ b/gate_api/models/open_orders.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + Gate API v4 + + APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 + + Contact: support@mail.gate.io + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from gate_api.configuration import Configuration + + +class OpenOrders(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = {'currency_pair': 'str', 'total': 'int', 'orders': 'list[Order]'} + + attribute_map = {'currency_pair': 'currency_pair', 'total': 'total', 'orders': 'orders'} + + def __init__(self, currency_pair=None, total=None, orders=None, local_vars_configuration=None): # noqa: E501 + # type: (str, int, list[Order], Configuration) -> None + """OpenOrders - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._currency_pair = None + self._total = None + self._orders = None + self.discriminator = None + + if currency_pair is not None: + self.currency_pair = currency_pair + if total is not None: + self.total = total + if orders is not None: + self.orders = orders + + @property + def currency_pair(self): + """Gets the currency_pair of this OpenOrders. # noqa: E501 + + Currency pair # noqa: E501 + + :return: The currency_pair of this OpenOrders. # noqa: E501 + :rtype: str + """ + return self._currency_pair + + @currency_pair.setter + def currency_pair(self, currency_pair): + """Sets the currency_pair of this OpenOrders. + + Currency pair # noqa: E501 + + :param currency_pair: The currency_pair of this OpenOrders. # noqa: E501 + :type: str + """ + + self._currency_pair = currency_pair + + @property + def total(self): + """Gets the total of this OpenOrders. # noqa: E501 + + Total open orders in this currency pair # noqa: E501 + + :return: The total of this OpenOrders. # noqa: E501 + :rtype: int + """ + return self._total + + @total.setter + def total(self, total): + """Sets the total of this OpenOrders. + + Total open orders in this currency pair # noqa: E501 + + :param total: The total of this OpenOrders. # noqa: E501 + :type: int + """ + + self._total = total + + @property + def orders(self): + """Gets the orders of this OpenOrders. # noqa: E501 + + + :return: The orders of this OpenOrders. # noqa: E501 + :rtype: list[Order] + """ + return self._orders + + @orders.setter + def orders(self, orders): + """Sets the orders of this OpenOrders. + + + :param orders: The orders of this OpenOrders. # noqa: E501 + :type: list[Order] + """ + + self._orders = orders + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, OpenOrders): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, OpenOrders): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/order.py b/gate_api/models/order.py index 4295c75..9298d83 100644 --- a/gate_api/models/order.py +++ b/gate_api/models/order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Order(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -53,7 +55,7 @@ class Order(object): 'gt_fee': 'str', 'gt_discount': 'bool', 'rebated_fee': 'str', - 'rebated_fee_currency': 'str' + 'rebated_fee_currency': 'str', } attribute_map = { @@ -79,11 +81,41 @@ class Order(object): 'gt_fee': 'gt_fee', 'gt_discount': 'gt_discount', 'rebated_fee': 'rebated_fee', - 'rebated_fee_currency': 'rebated_fee_currency' + 'rebated_fee_currency': 'rebated_fee_currency', } - def __init__(self, id=None, text=None, create_time=None, update_time=None, status=None, currency_pair=None, type='limit', account='spot', side=None, amount=None, price=None, time_in_force='gtc', auto_borrow=None, left=None, fill_price=None, filled_total=None, fee=None, fee_currency=None, point_fee=None, gt_fee=None, gt_discount=None, rebated_fee=None, rebated_fee_currency=None): # noqa: E501 + def __init__( + self, + id=None, + text=None, + create_time=None, + update_time=None, + status=None, + currency_pair=None, + type='limit', + account='spot', + side=None, + amount=None, + price=None, + time_in_force='gtc', + auto_borrow=None, + left=None, + fill_price=None, + filled_total=None, + fee=None, + fee_currency=None, + point_fee=None, + gt_fee=None, + gt_discount=None, + rebated_fee=None, + rebated_fee_currency=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, str, str, str, str, bool, str, str, str, str, str, str, str, bool, str, str, Configuration) -> None """Order - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._text = None @@ -180,7 +212,7 @@ def id(self, id): def text(self): """Gets the text of this Order. # noqa: E501 - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 :return: The text of this Order. # noqa: E501 :rtype: str @@ -191,7 +223,7 @@ def text(self): def text(self, text): """Sets the text of this Order. - User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 16 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 + User defined information. If not empty, must follow the rules below: 1. prefixed with `t-` 2. no longer than 28 bytes without `t-` prefix 3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) # noqa: E501 :param text: The text of this Order. # noqa: E501 :type: str @@ -266,10 +298,9 @@ def status(self, status): :type: str """ allowed_values = ["open", "closed", "cancelled"] # noqa: E501 - if status not in allowed_values: + if self.local_vars_configuration.client_side_validation and status not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `status` ({0}), must be one of {1}" # noqa: E501 - .format(status, allowed_values) + "Invalid value for `status` ({0}), must be one of {1}".format(status, allowed_values) # noqa: E501 ) self._status = status @@ -294,7 +325,7 @@ def currency_pair(self, currency_pair): :param currency_pair: The currency_pair of this Order. # noqa: E501 :type: str """ - if currency_pair is None: + if self.local_vars_configuration.client_side_validation and currency_pair is None: # noqa: E501 raise ValueError("Invalid value for `currency_pair`, must not be `None`") # noqa: E501 self._currency_pair = currency_pair @@ -320,10 +351,9 @@ def type(self, type): :type: str """ allowed_values = ["limit"] # noqa: E501 - if type not in allowed_values: + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format(type, allowed_values) # noqa: E501 ) self._type = type @@ -349,10 +379,9 @@ def account(self, account): :type: str """ allowed_values = ["spot", "margin"] # noqa: E501 - if account not in allowed_values: + if self.local_vars_configuration.client_side_validation and account not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `account` ({0}), must be one of {1}" # noqa: E501 - .format(account, allowed_values) + "Invalid value for `account` ({0}), must be one of {1}".format(account, allowed_values) # noqa: E501 ) self._account = account @@ -377,13 +406,12 @@ def side(self, side): :param side: The side of this Order. # noqa: E501 :type: str """ - if side is None: + if self.local_vars_configuration.client_side_validation and side is None: # noqa: E501 raise ValueError("Invalid value for `side`, must not be `None`") # noqa: E501 allowed_values = ["buy", "sell"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -408,7 +436,7 @@ def amount(self, amount): :param amount: The amount of this Order. # noqa: E501 :type: str """ - if amount is None: + if self.local_vars_configuration.client_side_validation and amount is None: # noqa: E501 raise ValueError("Invalid value for `amount`, must not be `None`") # noqa: E501 self._amount = amount @@ -433,7 +461,7 @@ def price(self, price): :param price: The price of this Order. # noqa: E501 :type: str """ - if price is None: + if self.local_vars_configuration.client_side_validation and price is None: # noqa: E501 raise ValueError("Invalid value for `price`, must not be `None`") # noqa: E501 self._price = price @@ -459,10 +487,11 @@ def time_in_force(self, time_in_force): :type: str """ allowed_values = ["gtc", "ioc", "poc"] # noqa: E501 - if time_in_force not in allowed_values: + if self.local_vars_configuration.client_side_validation and time_in_force not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `time_in_force` ({0}), must be one of {1}" # noqa: E501 - .format(time_in_force, allowed_values) + "Invalid value for `time_in_force` ({0}), must be one of {1}".format( # noqa: E501 + time_in_force, allowed_values + ) ) self._time_in_force = time_in_force @@ -727,18 +756,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -757,8 +784,11 @@ def __eq__(self, other): if not isinstance(other, Order): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Order): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/order_book.py b/gate_api/models/order_book.py index f7e11c7..4ca9aa1 100644 --- a/gate_api/models/order_book.py +++ b/gate_api/models/order_book.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class OrderBook(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,18 +32,16 @@ class OrderBook(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'asks': 'list[list[str]]', - 'bids': 'list[list[str]]' - } + openapi_types = {'asks': 'list[list[str]]', 'bids': 'list[list[str]]'} - attribute_map = { - 'asks': 'asks', - 'bids': 'bids' - } + attribute_map = {'asks': 'asks', 'bids': 'bids'} - def __init__(self, asks=None, bids=None): # noqa: E501 + def __init__(self, asks=None, bids=None, local_vars_configuration=None): # noqa: E501 + # type: (list[list[str]], list[list[str]], Configuration) -> None """OrderBook - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._asks = None self._bids = None @@ -70,7 +70,7 @@ def asks(self, asks): :param asks: The asks of this OrderBook. # noqa: E501 :type: list[list[str]] """ - if asks is None: + if self.local_vars_configuration.client_side_validation and asks is None: # noqa: E501 raise ValueError("Invalid value for `asks`, must not be `None`") # noqa: E501 self._asks = asks @@ -95,7 +95,7 @@ def bids(self, bids): :param bids: The bids of this OrderBook. # noqa: E501 :type: list[list[str]] """ - if bids is None: + if self.local_vars_configuration.client_side_validation and bids is None: # noqa: E501 raise ValueError("Invalid value for `bids`, must not be `None`") # noqa: E501 self._bids = bids @@ -107,18 +107,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -137,8 +135,11 @@ def __eq__(self, other): if not isinstance(other, OrderBook): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, OrderBook): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/position.py b/gate_api/models/position.py index fac3a46..8b174e0 100644 --- a/gate_api/models/position.py +++ b/gate_api/models/position.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Position(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -51,7 +53,7 @@ class Position(object): 'history_point': 'str', 'adl_ranking': 'int', 'pending_orders': 'int', - 'close_order': 'PositionCloseOrder' + 'close_order': 'PositionCloseOrder', } attribute_map = { @@ -75,11 +77,39 @@ class Position(object): 'history_point': 'history_point', 'adl_ranking': 'adl_ranking', 'pending_orders': 'pending_orders', - 'close_order': 'close_order' + 'close_order': 'close_order', } - def __init__(self, user=None, contract=None, size=None, leverage=None, risk_limit=None, leverage_max=None, maintenance_rate=None, value=None, margin=None, entry_price=None, liq_price=None, mark_price=None, unrealised_pnl=None, realised_pnl=None, history_pnl=None, last_close_pnl=None, realised_point=None, history_point=None, adl_ranking=None, pending_orders=None, close_order=None): # noqa: E501 + def __init__( + self, + user=None, + contract=None, + size=None, + leverage=None, + risk_limit=None, + leverage_max=None, + maintenance_rate=None, + value=None, + margin=None, + entry_price=None, + liq_price=None, + mark_price=None, + unrealised_pnl=None, + realised_pnl=None, + history_pnl=None, + last_close_pnl=None, + realised_point=None, + history_point=None, + adl_ranking=None, + pending_orders=None, + close_order=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, str, int, str, str, str, str, str, str, str, str, str, str, str, str, str, str, str, int, int, PositionCloseOrder, Configuration) -> None """Position - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._user = None self._contract = None @@ -635,18 +665,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -665,8 +693,11 @@ def __eq__(self, other): if not isinstance(other, Position): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Position): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/position_close.py b/gate_api/models/position_close.py index 65e4100..bdd4adc 100644 --- a/gate_api/models/position_close.py +++ b/gate_api/models/position_close.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class PositionClose(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,24 +32,18 @@ class PositionClose(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'time': 'float', - 'contract': 'str', - 'side': 'str', - 'pnl': 'str', - 'text': 'str' - } - - attribute_map = { - 'time': 'time', - 'contract': 'contract', - 'side': 'side', - 'pnl': 'pnl', - 'text': 'text' - } - - def __init__(self, time=None, contract=None, side=None, pnl=None, text=None): # noqa: E501 + openapi_types = {'time': 'float', 'contract': 'str', 'side': 'str', 'pnl': 'str', 'text': 'str'} + + attribute_map = {'time': 'time', 'contract': 'contract', 'side': 'side', 'pnl': 'pnl', 'text': 'text'} + + def __init__( + self, time=None, contract=None, side=None, pnl=None, text=None, local_vars_configuration=None + ): # noqa: E501 + # type: (float, str, str, str, str, Configuration) -> None """PositionClose - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._time = None self._contract = None @@ -134,10 +130,9 @@ def side(self, side): :type: str """ allowed_values = ["long", "short"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -195,18 +190,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -225,8 +218,11 @@ def __eq__(self, other): if not isinstance(other, PositionClose): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, PositionClose): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/position_close_order.py b/gate_api/models/position_close_order.py index d9dbaed..49699de 100644 --- a/gate_api/models/position_close_order.py +++ b/gate_api/models/position_close_order.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class PositionCloseOrder(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,20 +32,16 @@ class PositionCloseOrder(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'int', - 'price': 'str', - 'is_liq': 'bool' - } - - attribute_map = { - 'id': 'id', - 'price': 'price', - 'is_liq': 'is_liq' - } - - def __init__(self, id=None, price=None, is_liq=None): # noqa: E501 + openapi_types = {'id': 'int', 'price': 'str', 'is_liq': 'bool'} + + attribute_map = {'id': 'id', 'price': 'price', 'is_liq': 'is_liq'} + + def __init__(self, id=None, price=None, is_liq=None, local_vars_configuration=None): # noqa: E501 + # type: (int, str, bool, Configuration) -> None """PositionCloseOrder - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._price = None @@ -133,18 +131,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -163,8 +159,11 @@ def __eq__(self, other): if not isinstance(other, PositionCloseOrder): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, PositionCloseOrder): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/repay_request.py b/gate_api/models/repay_request.py index a3f0d9a..c6db770 100644 --- a/gate_api/models/repay_request.py +++ b/gate_api/models/repay_request.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class RepayRequest(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,22 +32,18 @@ class RepayRequest(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency_pair': 'str', - 'currency': 'str', - 'mode': 'str', - 'amount': 'str' - } - - attribute_map = { - 'currency_pair': 'currency_pair', - 'currency': 'currency', - 'mode': 'mode', - 'amount': 'amount' - } - - def __init__(self, currency_pair=None, currency=None, mode=None, amount=None): # noqa: E501 + openapi_types = {'currency_pair': 'str', 'currency': 'str', 'mode': 'str', 'amount': 'str'} + + attribute_map = {'currency_pair': 'currency_pair', 'currency': 'currency', 'mode': 'mode', 'amount': 'amount'} + + def __init__( + self, currency_pair=None, currency=None, mode=None, amount=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, str, str, Configuration) -> None """RepayRequest - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency_pair = None self._currency = None @@ -79,7 +77,7 @@ def currency_pair(self, currency_pair): :param currency_pair: The currency_pair of this RepayRequest. # noqa: E501 :type: str """ - if currency_pair is None: + if self.local_vars_configuration.client_side_validation and currency_pair is None: # noqa: E501 raise ValueError("Invalid value for `currency_pair`, must not be `None`") # noqa: E501 self._currency_pair = currency_pair @@ -104,7 +102,7 @@ def currency(self, currency): :param currency: The currency of this RepayRequest. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -129,13 +127,12 @@ def mode(self, mode): :param mode: The mode of this RepayRequest. # noqa: E501 :type: str """ - if mode is None: + if self.local_vars_configuration.client_side_validation and mode is None: # noqa: E501 raise ValueError("Invalid value for `mode`, must not be `None`") # noqa: E501 allowed_values = ["all", "partial"] # noqa: E501 - if mode not in allowed_values: + if self.local_vars_configuration.client_side_validation and mode not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `mode` ({0}), must be one of {1}" # noqa: E501 - .format(mode, allowed_values) + "Invalid value for `mode` ({0}), must be one of {1}".format(mode, allowed_values) # noqa: E501 ) self._mode = mode @@ -170,18 +167,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -200,8 +195,11 @@ def __eq__(self, other): if not isinstance(other, RepayRequest): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, RepayRequest): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/repayment.py b/gate_api/models/repayment.py index 72769c7..9558477 100644 --- a/gate_api/models/repayment.py +++ b/gate_api/models/repayment.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Repayment(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,22 +32,18 @@ class Repayment(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'str', - 'create_time': 'str', - 'principal': 'str', - 'interest': 'str' - } - - attribute_map = { - 'id': 'id', - 'create_time': 'create_time', - 'principal': 'principal', - 'interest': 'interest' - } - - def __init__(self, id=None, create_time=None, principal=None, interest=None): # noqa: E501 + openapi_types = {'id': 'str', 'create_time': 'str', 'principal': 'str', 'interest': 'str'} + + attribute_map = {'id': 'id', 'create_time': 'create_time', 'principal': 'principal', 'interest': 'interest'} + + def __init__( + self, id=None, create_time=None, principal=None, interest=None, local_vars_configuration=None + ): # noqa: E501 + # type: (str, str, str, str, Configuration) -> None """Repayment - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._create_time = None @@ -161,18 +159,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -191,8 +187,11 @@ def __eq__(self, other): if not isinstance(other, Repayment): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Repayment): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/spot_account.py b/gate_api/models/spot_account.py index f60792e..18b5ce2 100644 --- a/gate_api/models/spot_account.py +++ b/gate_api/models/spot_account.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class SpotAccount(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,20 +32,16 @@ class SpotAccount(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'currency': 'str', - 'available': 'str', - 'locked': 'str' - } - - attribute_map = { - 'currency': 'currency', - 'available': 'available', - 'locked': 'locked' - } - - def __init__(self, currency=None, available=None, locked=None): # noqa: E501 + openapi_types = {'currency': 'str', 'available': 'str', 'locked': 'str'} + + attribute_map = {'currency': 'currency', 'available': 'available', 'locked': 'locked'} + + def __init__(self, currency=None, available=None, locked=None, local_vars_configuration=None): # noqa: E501 + # type: (str, str, str, Configuration) -> None """SpotAccount - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._available = None @@ -133,18 +131,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -163,8 +159,11 @@ def __eq__(self, other): if not isinstance(other, SpotAccount): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, SpotAccount): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/sub_account_transfer.py b/gate_api/models/sub_account_transfer.py index 88edaa4..78e03d0 100644 --- a/gate_api/models/sub_account_transfer.py +++ b/gate_api/models/sub_account_transfer.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class SubAccountTransfer(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -37,7 +39,7 @@ class SubAccountTransfer(object): 'amount': 'str', 'uid': 'str', 'timest': 'str', - 'source': 'str' + 'source': 'str', } attribute_map = { @@ -47,11 +49,25 @@ class SubAccountTransfer(object): 'amount': 'amount', 'uid': 'uid', 'timest': 'timest', - 'source': 'source' + 'source': 'source', } - def __init__(self, currency=None, sub_account=None, direction=None, amount=None, uid=None, timest=None, source=None): # noqa: E501 + def __init__( + self, + currency=None, + sub_account=None, + direction=None, + amount=None, + uid=None, + timest=None, + source=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, Configuration) -> None """SubAccountTransfer - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self._sub_account = None @@ -93,7 +109,7 @@ def currency(self, currency): :param currency: The currency of this SubAccountTransfer. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -118,7 +134,7 @@ def sub_account(self, sub_account): :param sub_account: The sub_account of this SubAccountTransfer. # noqa: E501 :type: str """ - if sub_account is None: + if self.local_vars_configuration.client_side_validation and sub_account is None: # noqa: E501 raise ValueError("Invalid value for `sub_account`, must not be `None`") # noqa: E501 self._sub_account = sub_account @@ -143,13 +159,14 @@ def direction(self, direction): :param direction: The direction of this SubAccountTransfer. # noqa: E501 :type: str """ - if direction is None: + if self.local_vars_configuration.client_side_validation and direction is None: # noqa: E501 raise ValueError("Invalid value for `direction`, must not be `None`") # noqa: E501 allowed_values = ["to", "from"] # noqa: E501 - if direction not in allowed_values: + if self.local_vars_configuration.client_side_validation and direction not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `direction` ({0}), must be one of {1}" # noqa: E501 - .format(direction, allowed_values) + "Invalid value for `direction` ({0}), must be one of {1}".format( # noqa: E501 + direction, allowed_values + ) ) self._direction = direction @@ -174,7 +191,7 @@ def amount(self, amount): :param amount: The amount of this SubAccountTransfer. # noqa: E501 :type: str """ - if amount is None: + if self.local_vars_configuration.client_side_validation and amount is None: # noqa: E501 raise ValueError("Invalid value for `amount`, must not be `None`") # noqa: E501 self._amount = amount @@ -255,18 +272,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -285,8 +300,11 @@ def __eq__(self, other): if not isinstance(other, SubAccountTransfer): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, SubAccountTransfer): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/ticker.py b/gate_api/models/ticker.py index e309979..446d3bf 100644 --- a/gate_api/models/ticker.py +++ b/gate_api/models/ticker.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Ticker(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -39,7 +41,7 @@ class Ticker(object): 'base_volume': 'str', 'quote_volume': 'str', 'high_24h': 'str', - 'low_24h': 'str' + 'low_24h': 'str', } attribute_map = { @@ -51,11 +53,27 @@ class Ticker(object): 'base_volume': 'base_volume', 'quote_volume': 'quote_volume', 'high_24h': 'high_24h', - 'low_24h': 'low_24h' + 'low_24h': 'low_24h', } - def __init__(self, currency_pair=None, last=None, lowest_ask=None, highest_bid=None, change_percentage=None, base_volume=None, quote_volume=None, high_24h=None, low_24h=None): # noqa: E501 + def __init__( + self, + currency_pair=None, + last=None, + lowest_ask=None, + highest_bid=None, + change_percentage=None, + base_volume=None, + quote_volume=None, + high_24h=None, + low_24h=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, str, Configuration) -> None """Ticker - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency_pair = None self._last = None @@ -301,18 +319,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -331,8 +347,11 @@ def __eq__(self, other): if not isinstance(other, Ticker): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Ticker): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/trade.py b/gate_api/models/trade.py index a113b3c..d006733 100644 --- a/gate_api/models/trade.py +++ b/gate_api/models/trade.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Trade(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -41,7 +43,7 @@ class Trade(object): 'fee': 'str', 'fee_currency': 'str', 'point_fee': 'str', - 'gt_fee': 'str' + 'gt_fee': 'str', } attribute_map = { @@ -55,11 +57,29 @@ class Trade(object): 'fee': 'fee', 'fee_currency': 'fee_currency', 'point_fee': 'point_fee', - 'gt_fee': 'gt_fee' + 'gt_fee': 'gt_fee', } - def __init__(self, id=None, create_time=None, side=None, role=None, amount=None, price=None, order_id=None, fee=None, fee_currency=None, point_fee=None, gt_fee=None): # noqa: E501 + def __init__( + self, + id=None, + create_time=None, + side=None, + role=None, + amount=None, + price=None, + order_id=None, + fee=None, + fee_currency=None, + point_fee=None, + gt_fee=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, str, str, str, str, str, Configuration) -> None """Trade - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self._create_time = None @@ -164,10 +184,9 @@ def side(self, side): :type: str """ allowed_values = ["buy", "sell"] # noqa: E501 - if side not in allowed_values: + if self.local_vars_configuration.client_side_validation and side not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `side` ({0}), must be one of {1}" # noqa: E501 - .format(side, allowed_values) + "Invalid value for `side` ({0}), must be one of {1}".format(side, allowed_values) # noqa: E501 ) self._side = side @@ -193,10 +212,9 @@ def role(self, role): :type: str """ allowed_values = ["taker", "maker"] # noqa: E501 - if role not in allowed_values: + if self.local_vars_configuration.client_side_validation and role not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `role` ({0}), must be one of {1}" # noqa: E501 - .format(role, allowed_values) + "Invalid value for `role` ({0}), must be one of {1}".format(role, allowed_values) # noqa: E501 ) self._role = role @@ -369,18 +387,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -399,8 +415,11 @@ def __eq__(self, other): if not isinstance(other, Trade): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Trade): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/trade_fee.py b/gate_api/models/trade_fee.py new file mode 100644 index 0000000..a9052a0 --- /dev/null +++ b/gate_api/models/trade_fee.py @@ -0,0 +1,299 @@ +# coding: utf-8 + +""" + Gate API v4 + + APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 + + Contact: support@mail.gate.io + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from gate_api.configuration import Configuration + + +class TradeFee(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'user_id': 'int', + 'taker_fee': 'str', + 'maker_fee': 'str', + 'gt_discount': 'bool', + 'gt_taker_fee': 'str', + 'gt_maker_fee': 'str', + 'loan_fee': 'str', + } + + attribute_map = { + 'user_id': 'user_id', + 'taker_fee': 'taker_fee', + 'maker_fee': 'maker_fee', + 'gt_discount': 'gt_discount', + 'gt_taker_fee': 'gt_taker_fee', + 'gt_maker_fee': 'gt_maker_fee', + 'loan_fee': 'loan_fee', + } + + def __init__( + self, + user_id=None, + taker_fee=None, + maker_fee=None, + gt_discount=None, + gt_taker_fee=None, + gt_maker_fee=None, + loan_fee=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (int, str, str, bool, str, str, str, Configuration) -> None + """TradeFee - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._user_id = None + self._taker_fee = None + self._maker_fee = None + self._gt_discount = None + self._gt_taker_fee = None + self._gt_maker_fee = None + self._loan_fee = None + self.discriminator = None + + if user_id is not None: + self.user_id = user_id + if taker_fee is not None: + self.taker_fee = taker_fee + if maker_fee is not None: + self.maker_fee = maker_fee + if gt_discount is not None: + self.gt_discount = gt_discount + if gt_taker_fee is not None: + self.gt_taker_fee = gt_taker_fee + if gt_maker_fee is not None: + self.gt_maker_fee = gt_maker_fee + if loan_fee is not None: + self.loan_fee = loan_fee + + @property + def user_id(self): + """Gets the user_id of this TradeFee. # noqa: E501 + + User ID # noqa: E501 + + :return: The user_id of this TradeFee. # noqa: E501 + :rtype: int + """ + return self._user_id + + @user_id.setter + def user_id(self, user_id): + """Sets the user_id of this TradeFee. + + User ID # noqa: E501 + + :param user_id: The user_id of this TradeFee. # noqa: E501 + :type: int + """ + + self._user_id = user_id + + @property + def taker_fee(self): + """Gets the taker_fee of this TradeFee. # noqa: E501 + + taker fee rate # noqa: E501 + + :return: The taker_fee of this TradeFee. # noqa: E501 + :rtype: str + """ + return self._taker_fee + + @taker_fee.setter + def taker_fee(self, taker_fee): + """Sets the taker_fee of this TradeFee. + + taker fee rate # noqa: E501 + + :param taker_fee: The taker_fee of this TradeFee. # noqa: E501 + :type: str + """ + + self._taker_fee = taker_fee + + @property + def maker_fee(self): + """Gets the maker_fee of this TradeFee. # noqa: E501 + + maker fee rate # noqa: E501 + + :return: The maker_fee of this TradeFee. # noqa: E501 + :rtype: str + """ + return self._maker_fee + + @maker_fee.setter + def maker_fee(self, maker_fee): + """Sets the maker_fee of this TradeFee. + + maker fee rate # noqa: E501 + + :param maker_fee: The maker_fee of this TradeFee. # noqa: E501 + :type: str + """ + + self._maker_fee = maker_fee + + @property + def gt_discount(self): + """Gets the gt_discount of this TradeFee. # noqa: E501 + + Is GT deduction is enabled # noqa: E501 + + :return: The gt_discount of this TradeFee. # noqa: E501 + :rtype: bool + """ + return self._gt_discount + + @gt_discount.setter + def gt_discount(self, gt_discount): + """Sets the gt_discount of this TradeFee. + + Is GT deduction is enabled # noqa: E501 + + :param gt_discount: The gt_discount of this TradeFee. # noqa: E501 + :type: bool + """ + + self._gt_discount = gt_discount + + @property + def gt_taker_fee(self): + """Gets the gt_taker_fee of this TradeFee. # noqa: E501 + + Taker fee rate if using GT deduction. It will be 0 if GT deduction is disabled # noqa: E501 + + :return: The gt_taker_fee of this TradeFee. # noqa: E501 + :rtype: str + """ + return self._gt_taker_fee + + @gt_taker_fee.setter + def gt_taker_fee(self, gt_taker_fee): + """Sets the gt_taker_fee of this TradeFee. + + Taker fee rate if using GT deduction. It will be 0 if GT deduction is disabled # noqa: E501 + + :param gt_taker_fee: The gt_taker_fee of this TradeFee. # noqa: E501 + :type: str + """ + + self._gt_taker_fee = gt_taker_fee + + @property + def gt_maker_fee(self): + """Gets the gt_maker_fee of this TradeFee. # noqa: E501 + + Maker fee rate if using GT deduction. It will be 0 if GT deduction is disabled # noqa: E501 + + :return: The gt_maker_fee of this TradeFee. # noqa: E501 + :rtype: str + """ + return self._gt_maker_fee + + @gt_maker_fee.setter + def gt_maker_fee(self, gt_maker_fee): + """Sets the gt_maker_fee of this TradeFee. + + Maker fee rate if using GT deduction. It will be 0 if GT deduction is disabled # noqa: E501 + + :param gt_maker_fee: The gt_maker_fee of this TradeFee. # noqa: E501 + :type: str + """ + + self._gt_maker_fee = gt_maker_fee + + @property + def loan_fee(self): + """Gets the loan_fee of this TradeFee. # noqa: E501 + + Loan fee rate of margin lending # noqa: E501 + + :return: The loan_fee of this TradeFee. # noqa: E501 + :rtype: str + """ + return self._loan_fee + + @loan_fee.setter + def loan_fee(self, loan_fee): + """Sets the loan_fee of this TradeFee. + + Loan fee rate of margin lending # noqa: E501 + + :param loan_fee: The loan_fee of this TradeFee. # noqa: E501 + :type: str + """ + + self._loan_fee = loan_fee + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, TradeFee): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, TradeFee): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/transfer.py b/gate_api/models/transfer.py index 2ad8213..b22e211 100644 --- a/gate_api/models/transfer.py +++ b/gate_api/models/transfer.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class Transfer(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -36,7 +38,7 @@ class Transfer(object): 'to': 'str', 'amount': 'str', 'currency_pair': 'str', - 'settle': 'str' + 'settle': 'str', } attribute_map = { @@ -45,11 +47,24 @@ class Transfer(object): 'to': 'to', 'amount': 'amount', 'currency_pair': 'currency_pair', - 'settle': 'settle' + 'settle': 'settle', } - def __init__(self, currency=None, _from=None, to=None, amount=None, currency_pair=None, settle=None): # noqa: E501 + def __init__( + self, + currency=None, + _from=None, + to=None, + amount=None, + currency_pair=None, + settle=None, + local_vars_configuration=None, + ): # noqa: E501 + # type: (str, str, str, str, str, str, Configuration) -> None """Transfer - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._currency = None self.__from = None @@ -88,7 +103,7 @@ def currency(self, currency): :param currency: The currency of this Transfer. # noqa: E501 :type: str """ - if currency is None: + if self.local_vars_configuration.client_side_validation and currency is None: # noqa: E501 raise ValueError("Invalid value for `currency`, must not be `None`") # noqa: E501 self._currency = currency @@ -113,13 +128,12 @@ def _from(self, _from): :param _from: The _from of this Transfer. # noqa: E501 :type: str """ - if _from is None: + if self.local_vars_configuration.client_side_validation and _from is None: # noqa: E501 raise ValueError("Invalid value for `_from`, must not be `None`") # noqa: E501 allowed_values = ["spot", "margin", "futures", "delivery"] # noqa: E501 - if _from not in allowed_values: + if self.local_vars_configuration.client_side_validation and _from not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `_from` ({0}), must be one of {1}" # noqa: E501 - .format(_from, allowed_values) + "Invalid value for `_from` ({0}), must be one of {1}".format(_from, allowed_values) # noqa: E501 ) self.__from = _from @@ -144,13 +158,12 @@ def to(self, to): :param to: The to of this Transfer. # noqa: E501 :type: str """ - if to is None: + if self.local_vars_configuration.client_side_validation and to is None: # noqa: E501 raise ValueError("Invalid value for `to`, must not be `None`") # noqa: E501 allowed_values = ["spot", "margin", "futures", "delivery"] # noqa: E501 - if to not in allowed_values: + if self.local_vars_configuration.client_side_validation and to not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `to` ({0}), must be one of {1}" # noqa: E501 - .format(to, allowed_values) + "Invalid value for `to` ({0}), must be one of {1}".format(to, allowed_values) # noqa: E501 ) self._to = to @@ -175,7 +188,7 @@ def amount(self, amount): :param amount: The amount of this Transfer. # noqa: E501 :type: str """ - if amount is None: + if self.local_vars_configuration.client_side_validation and amount is None: # noqa: E501 raise ValueError("Invalid value for `amount`, must not be `None`") # noqa: E501 self._amount = amount @@ -233,18 +246,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -263,8 +274,11 @@ def __eq__(self, other): if not isinstance(other, Transfer): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, Transfer): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/models/trigger_order_response.py b/gate_api/models/trigger_order_response.py index e571612..a5b4f7b 100644 --- a/gate_api/models/trigger_order_response.py +++ b/gate_api/models/trigger_order_response.py @@ -15,6 +15,8 @@ import six +from gate_api.configuration import Configuration + class TriggerOrderResponse(object): """NOTE: This class is auto generated by OpenAPI Generator. @@ -30,16 +32,16 @@ class TriggerOrderResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'int' - } + openapi_types = {'id': 'int'} - attribute_map = { - 'id': 'id' - } + attribute_map = {'id': 'id'} - def __init__(self, id=None): # noqa: E501 + def __init__(self, id=None, local_vars_configuration=None): # noqa: E501 + # type: (int, Configuration) -> None """TriggerOrderResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration self._id = None self.discriminator = None @@ -77,18 +79,16 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value)) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, + value.items(), + ) + ) else: result[attr] = value @@ -107,8 +107,11 @@ def __eq__(self, other): if not isinstance(other, TriggerOrderResponse): return False - return self.__dict__ == other.__dict__ + return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" - return not self == other + if not isinstance(other, TriggerOrderResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/gate_api/rest.py b/gate_api/rest.py index 4215826..2c80151 100644 --- a/gate_api/rest.py +++ b/gate_api/rest.py @@ -12,31 +12,26 @@ from __future__ import absolute_import -import hashlib -import hmac import io import json import logging import re import ssl -import time import certifi + # python 2 and python 3 compatibility library import six -from six.moves.urllib.parse import unquote_plus, urlencode +from six.moves.urllib.parse import urlencode +import urllib3 -try: - import urllib3 -except ImportError: - raise ImportError('OpenAPI Python client requires urllib3.') +from gate_api.exceptions import ApiException, ApiValueError logger = logging.getLogger(__name__) class RESTResponse(io.IOBase): - def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -53,7 +48,6 @@ def getheader(self, name, default=None): class RESTClientObject(object): - def __init__(self, configuration, pools_size=4, maxsize=None): # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 @@ -62,7 +56,6 @@ def __init__(self, configuration, pools_size=4, maxsize=None): # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 # cert_reqs - self.configuration = configuration if configuration.verify_ssl: cert_reqs = ssl.CERT_REQUIRED else: @@ -79,6 +72,9 @@ def __init__(self, configuration, pools_size=4, maxsize=None): if configuration.assert_hostname is not None: addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + if configuration.retries is not None: + addition_pool_args['retries'] = configuration.retries + if maxsize is None: if configuration.connection_pool_maxsize is not None: maxsize = configuration.connection_pool_maxsize @@ -95,6 +91,7 @@ def __init__(self, configuration, pools_size=4, maxsize=None): cert_file=configuration.cert_file, key_file=configuration.key_file, proxy_url=configuration.proxy, + proxy_headers=configuration.proxy_headers, **addition_pool_args ) else: @@ -108,28 +105,17 @@ def __init__(self, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - def gen_sign(self, method, url, query_string=None, payload_string=None): - """generate authentication headers - - :param method: http request method - :param url: http resource path - :param query_string: query string - :param payload_string: request payload in string format - :return: signature headers - """ - t = time.time() - m = hashlib.sha512() - if payload_string is not None: - m.update(payload_string.encode('utf-8')) - hashed_payload = m.hexdigest() - s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t) - sign = hmac.new(self.configuration.secret.encode('utf-8'), s.encode('utf-8'), - hashlib.sha512).hexdigest() - return {'KEY': self.configuration.key, 'Timestamp': str(t), 'SIGN': sign} - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None, _auth_required=True): + def request( + self, + method, + url, + query_params=None, + headers=None, + body=None, + post_params=None, + _preload_content=True, + _request_timeout=None, + ): """Perform requests. :param method: http request method @@ -147,84 +133,80 @@ def request(self, method, url, query_params=None, headers=None, number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. - :param _auth_required: whether authentication is required """ method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS'] if post_params and body: - raise ValueError( - "body parameter cannot be used with post_params parameter." - ) + raise ApiValueError("body parameter cannot be used with post_params parameter.") post_params = post_params or {} headers = headers or {} timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + if isinstance(_request_timeout, (int,) if six.PY3 else (int, long)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): - timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: + timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) if 'Content-Type' not in headers: headers['Content-Type'] = 'application/json' - request_body = None - if body is not None: - request_body = json.dumps(body) - if _auth_required: - resource_path = '/api/v4' + url[len(self.configuration.host):] - sign_headers = self.gen_sign(method, resource_path, unquote_plus(urlencode(query_params)), - request_body) - headers.update(sign_headers) - try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): + request_body = None + if body is not None: + request_body = json.dumps(body) r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. del headers['Content-Type'] r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form - elif isinstance(body, str): + elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -233,11 +215,9 @@ def request(self, method, url, query_params=None, headers=None, raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request(method, url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers) + r = self.pool_manager.request( + method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers + ) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) @@ -245,11 +225,6 @@ def request(self, method, url, query_params=None, headers=None, if _preload_content: r = RESTResponse(r) - # In the python 3, the response.data is bytes. - # we need to decode it to string. - if six.PY3: - r.data = r.data.decode('utf8') - # log response body logger.debug("response body: %s", r.data) @@ -258,107 +233,117 @@ def request(self, method, url, query_params=None, headers=None, return r - def GET(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None, _auth_required=True): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - _auth_required=_auth_required) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None, _auth_required=True): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - _auth_required=_auth_required) - - def OPTIONS(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None, - _auth_required=True): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def DELETE(self, url, headers=None, query_params=None, body=None, - _preload_content=True, _request_timeout=None, - _auth_required=True): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _auth_required=_auth_required, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def POST(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None, - _auth_required=True): - return self.request("POST", url, - headers=headers, - query_params=query_params, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PUT(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None, - _auth_required=True): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PATCH(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None, - _auth_required=True): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - _auth_required=_auth_required, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - -class ApiException(Exception): - - def __init__(self, status=None, reason=None, http_resp=None): - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message + def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): + return self.request( + "GET", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): + return self.request( + "HEAD", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def OPTIONS( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "OPTIONS", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def DELETE(self, url, headers=None, query_params=None, body=None, _preload_content=True, _request_timeout=None): + return self.request( + "DELETE", + url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def POST( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "POST", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PUT( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PUT", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PATCH( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PATCH", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) diff --git a/git_push.sh b/git_push.sh index 06af295..2bad2b3 100644 --- a/git_push.sh +++ b/git_push.sh @@ -1,11 +1,17 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="gateio" @@ -28,7 +34,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/requirements.txt b/requirements.txt index bafdc07..eb358ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ certifi >= 14.05.14 +future; python_version<="2.7" six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..11433ee --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[flake8] +max-line-length=99 diff --git a/setup.py b/setup.py index cde72c6..1f641dc 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "gate-api" -VERSION = "4.14.0" +VERSION = "4.15.2" # To install the library, run the following # # python setup.py install @@ -27,13 +27,15 @@ name=NAME, version=VERSION, description="Gate API v4", + author="Gate API support", author_email="support@mail.gate.io", url="", keywords=["OpenAPI", "OpenAPI-Generator", "Gate API v4"], install_requires=REQUIRES, - packages=find_packages(), + packages=find_packages(exclude=["test", "tests"]), include_package_data=True, + license="Apache License 2.0", long_description="""\ APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf. # noqa: E501 - """ + """, ) diff --git a/test-requirements.txt b/test-requirements.txt index 2702246..4ed3991 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,5 +1,3 @@ -coverage>=4.0.3 -nose>=1.3.7 -pluggy>=0.3.1 -py>=1.4.31 -randomize>=0.13 +pytest~=4.6.7 # needed for python 2.7+3.4 +pytest-cov>=2.8.1 +pytest-randomly==1.2.3 # needed for python 2.7+3.4 diff --git a/tox.ini b/tox.ini index 3d0be61..2be77d1 100644 --- a/tox.ini +++ b/tox.ini @@ -6,5 +6,4 @@ deps=-r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands= - nosetests \ - [] + pytest --cov=gate_api