Skip to content

Commit

Permalink
add spot cross margin API
Browse files Browse the repository at this point in the history
  • Loading branch information
revilwang committed Jun 11, 2021
1 parent ccbf3a8 commit c48f2e5
Show file tree
Hide file tree
Showing 49 changed files with 3,834 additions and 83 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ APIv4 provides spot, margin and futures trading operations. There are public API

This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 4.20.1
- Package version: 4.20.1
- API version: 4.21.2
- Package version: 4.21.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)

Expand Down Expand Up @@ -189,6 +189,14 @@ Class | Method | HTTP request | Description
*MarginApi* | [**update_loan_record**](docs/MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record
*MarginApi* | [**get_auto_repay_status**](docs/MarginApi.md#get_auto_repay_status) | **GET** /margin/auto_repay | Retrieve user auto repayment setting
*MarginApi* | [**set_auto_repay**](docs/MarginApi.md#set_auto_repay) | **POST** /margin/auto_repay | Update user's auto repayment setting
*MarginApi* | [**list_cross_margin_currencies**](docs/MarginApi.md#list_cross_margin_currencies) | **GET** /margin/cross/currencies | Currencies supported by cross margin.
*MarginApi* | [**get_cross_margin_currency**](docs/MarginApi.md#get_cross_margin_currency) | **GET** /margin/cross/currencies/{currency} | Retrieve detail of one single currency supported by cross margin
*MarginApi* | [**get_cross_margin_account**](docs/MarginApi.md#get_cross_margin_account) | **GET** /margin/cross/accounts | Retrieve cross margin account
*MarginApi* | [**list_cross_margin_loans**](docs/MarginApi.md#list_cross_margin_loans) | **GET** /margin/cross/loans | List cross margin borrow history
*MarginApi* | [**create_cross_margin_loan**](docs/MarginApi.md#create_cross_margin_loan) | **POST** /margin/cross/loans | Create a cross margin borrow loan
*MarginApi* | [**get_cross_margin_loan**](docs/MarginApi.md#get_cross_margin_loan) | **GET** /margin/cross/loans/{loan_id} | Retrieve single borrow loan detail
*MarginApi* | [**list_cross_margin_repayments**](docs/MarginApi.md#list_cross_margin_repayments) | **GET** /margin/cross/repayments | Retrieve cross margin repayments
*MarginApi* | [**repay_cross_margin_loan**](docs/MarginApi.md#repay_cross_margin_loan) | **POST** /margin/cross/repayments | Repay cross margin loan
*SpotApi* | [**list_currencies**](docs/SpotApi.md#list_currencies) | **GET** /spot/currencies | List all currencies' detail
*SpotApi* | [**get_currency**](docs/SpotApi.md#get_currency) | **GET** /spot/currencies/{currency} | Get detail of one particular currency
*SpotApi* | [**list_currency_pairs**](docs/SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported
Expand Down Expand Up @@ -223,6 +231,7 @@ Class | Method | HTTP request | Description
*WalletApi* | [**list_sub_account_balances**](docs/WalletApi.md#list_sub_account_balances) | **GET** /wallet/sub_account_balances | Retrieve sub account balances
*WalletApi* | [**get_trade_fee**](docs/WalletApi.md#get_trade_fee) | **GET** /wallet/fee | Retrieve personal trading fee
*WithdrawalApi* | [**withdraw**](docs/WithdrawalApi.md#withdraw) | **POST** /withdrawals | Withdraw
*WithdrawalApi* | [**cancel_withdrawal**](docs/WithdrawalApi.md#cancel_withdrawal) | **DELETE** /withdrawals/{withdrawal_id} | Cancel withdrawal with specified ID


## Documentation For Models
Expand All @@ -233,6 +242,12 @@ Class | Method | HTTP request | Description
- [CancelOrderResult](docs/CancelOrderResult.md)
- [Contract](docs/Contract.md)
- [ContractStat](docs/ContractStat.md)
- [CrossMarginAccount](docs/CrossMarginAccount.md)
- [CrossMarginBalance](docs/CrossMarginBalance.md)
- [CrossMarginCurrency](docs/CrossMarginCurrency.md)
- [CrossMarginLoan](docs/CrossMarginLoan.md)
- [CrossMarginRepayRequest](docs/CrossMarginRepayRequest.md)
- [CrossMarginRepayment](docs/CrossMarginRepayment.md)
- [Currency](docs/Currency.md)
- [CurrencyPair](docs/CurrencyPair.md)
- [DeliveryContract](docs/DeliveryContract.md)
Expand Down
7 changes: 5 additions & 2 deletions docs/BatchOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ Name | Type | Description | Notes
**id** | **str** | Order ID | [optional] [readonly]
**create_time** | **str** | Order creation time | [optional] [readonly]
**update_time** | **str** | Order last modification time | [optional] [readonly]
**create_time_ms** | **int** | Order creation time in milliseconds | [optional] [readonly]
**update_time_ms** | **int** | Order last modification time in milliseconds | [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']
**account** | **str** | Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account | [optional] [default to 'spot']
**side** | **str** | Order side | [optional]
**amount** | **str** | Trade amount | [optional]
**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']
**iceberg** | **str** | Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally | [optional]
**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]
**auto_borrow** | **bool** | Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. | [optional]
**auto_repay** | **bool** | Enable or disable automatic repayment for automatic borrow loan generated by cross margin order. Default is disabled. Note that: 1. This field is only effective for cross margin orders. Margin account does not support setting auto repayment for orders. 2. `auto_borrow` and `auto_repay` cannot be both set to true in one order. | [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]
Expand Down
1 change: 1 addition & 0 deletions docs/CancelOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**currency_pair** | **str** | Order currency pair |
**id** | **str** | Order ID or user custom ID. Custom ID are accepted only within 30 minutes after order creation |
**account** | **str** | If cancelled order is cross margin order, this field must be set and can only be `cross_margin` | [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)

Expand Down
1 change: 1 addition & 0 deletions docs/CancelOrderResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Name | Type | Description | Notes
**succeeded** | **bool** | Whether cancellation succeeded | [optional]
**label** | **str** | Error label when failed to cancel the order; emtpy if succeeded | [optional]
**message** | **str** | Error message when failed to cancel the order; empty if succeeded | [optional]
**account** | **str** | Empty by default. If cancelled order is cross margin order, this field is set to `cross_margin` | [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)

Expand Down
2 changes: 1 addition & 1 deletion docs/Contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | Futures contract | [optional]
**type** | **str** | Futures contract type | [optional]
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional]
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency | [optional]
**leverage_min** | **str** | Minimum leverage | [optional]
**leverage_max** | **str** | Maximum leverage | [optional]
**maintenance_rate** | **str** | Maintenance rate of margin | [optional]
Expand Down
16 changes: 16 additions & 0 deletions docs/CrossMarginAccount.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CrossMarginAccount

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**user_id** | **int** | User ID | [optional]
**locked** | **bool** | Whether account is locked | [optional]
**balances** | [**dict(str, CrossMarginBalance)**](CrossMarginBalance.md) | | [optional]
**total** | **str** | Total account value in USDT, i.e., the sum of all currencies' `(available+freeze)*price*discount` | [optional]
**borrowed** | **str** | Total borrowed value in USDT, i.e., the sum of all currencies' `borrowed*price*discount` | [optional]
**interest** | **str** | Total unpaid interests in USDT, i.e., the sum of all currencies' `interest*price*discount` | [optional]
**risk** | **str** | Risk rate. When it belows 110%, liquidation will be triggered. Calculation formula: `total / (borrowed+interest)` | [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)


13 changes: 13 additions & 0 deletions docs/CrossMarginBalance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# CrossMarginBalance

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**available** | **str** | Available amount | [optional]
**freeze** | **str** | Locked amount | [optional]
**borrowed** | **str** | Borrowed amount | [optional]
**interest** | **str** | Interests unpaid | [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)


17 changes: 17 additions & 0 deletions docs/CrossMarginCurrency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CrossMarginCurrency

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **str** | Currency name | [optional]
**rate** | **str** | Loan rate | [optional]
**prec** | **str** | Currency precision | [optional]
**discount** | **str** | Currency value discount, which is used in total value calculation | [optional]
**min_borrow_amount** | **str** | Minimum currency borrow amount. Unit is currency itself | [optional]
**user_max_borrow_amount** | **str** | Maximum borrow value allowed per user, in USDT | [optional]
**total_max_borrow_amount** | **str** | Maximum borrow value allowed for this currency, in USDT | [optional]
**price** | **str** | Price change between this currency and USDT | [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)


19 changes: 19 additions & 0 deletions docs/CrossMarginLoan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CrossMarginLoan

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | Borrow loan ID | [optional] [readonly]
**create_time** | **int** | Creation timestamp, in milliseconds | [optional] [readonly]
**update_time** | **int** | Update timestamp, in milliseconds | [optional] [readonly]
**currency** | **str** | Currency name |
**amount** | **str** | Borrowed amount |
**text** | **str** | User defined custom ID | [optional]
**status** | **int** | Borrow loan status, which includes: - 1: failed to borrow - 2: borrowed but not repaid - 3: repayment complete | [optional] [readonly]
**repaid** | **str** | Repaid amount | [optional] [readonly]
**repaid_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)


11 changes: 11 additions & 0 deletions docs/CrossMarginRepayRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CrossMarginRepayRequest

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**currency** | **str** | Repayment currency |
**amount** | **str** | Repayment amount |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


15 changes: 15 additions & 0 deletions docs/CrossMarginRepayment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CrossMarginRepayment

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **str** | Loan record ID | [optional]
**create_time** | **int** | Repayment time | [optional]
**loan_id** | **str** | Borrow loan ID | [optional]
**currency** | **str** | Currency name | [optional]
**principal** | **str** | Repaid principal | [optional]
**interest** | **str** | Repaid interest | [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)


2 changes: 1 addition & 1 deletion docs/DeliveryContract.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
**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]
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency | [optional]
**leverage_min** | **str** | Minimum leverage | [optional]
**leverage_max** | **str** | Maximum leverage | [optional]
**maintenance_rate** | **str** | Maintenance rate of margin | [optional]
Expand Down
12 changes: 8 additions & 4 deletions docs/FuturesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ Name | Type | Description | Notes
[[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)
> Position update_position_leverage(settle, contract, leverage, cross_leverage_limit=cross_leverage_limit)
Update position leverage

Expand Down Expand Up @@ -1062,10 +1062,11 @@ api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
leverage = '10' # str | New position leverage
cross_leverage_limit = '10' # str | Cross margin leverage(valid only when `leverage` is 0) (optional)

try:
# Update position leverage
api_response = api_instance.update_position_leverage(settle, contract, leverage)
api_response = api_instance.update_position_leverage(settle, contract, leverage, cross_leverage_limit=cross_leverage_limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
Expand All @@ -1080,6 +1081,7 @@ Name | Type | Description | Notes
**settle** | **str**| Settle currency |
**contract** | **str**| Futures contract |
**leverage** | **str**| New position leverage |
**cross_leverage_limit** | **str**| Cross margin leverage(valid only when `leverage` is 0) | [optional]

### Return type

Expand Down Expand Up @@ -1313,7 +1315,7 @@ Name | Type | Description | Notes
[[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_dual_mode_position_margin**
> list[Position] update_dual_mode_position_margin(settle, contract, change)
> list[Position] update_dual_mode_position_margin(settle, contract, change, dual_side)
Update position margin in dual mode

Expand Down Expand Up @@ -1344,10 +1346,11 @@ api_instance = gate_api.FuturesApi(api_client)
settle = 'usdt' # str | Settle currency
contract = 'BTC_USDT' # str | Futures contract
change = '0.01' # str | Margin change. Use positive number to increase margin, negative number otherwise.
dual_side = 'dual_long' # str | Long or short position

try:
# Update position margin in dual mode
api_response = api_instance.update_dual_mode_position_margin(settle, contract, change)
api_response = api_instance.update_dual_mode_position_margin(settle, contract, change, dual_side)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
Expand All @@ -1362,6 +1365,7 @@ 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. |
**dual_side** | **str**| Long or short position |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion docs/FuturesOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Name | Type | Description | Notes
**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]
**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- position_closed: cancelled because of position close | [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 |
Expand Down
1 change: 1 addition & 0 deletions docs/MarginAccountCurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Name | Type | Description | Notes
**available** | **str** | Amount suitable for margin trading. | [optional]
**locked** | **str** | Locked amount, used in margin trading | [optional]
**borrowed** | **str** | Borrowed amount | [optional]
**interest** | **str** | Interests unpaid | [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)

Expand Down
Loading

0 comments on commit c48f2e5

Please sign in to comment.