Skip to content

Commit c48f2e5

Browse files
committed
add spot cross margin API
1 parent ccbf3a8 commit c48f2e5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3834
-83
lines changed

README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ APIv4 provides spot, margin and futures trading operations. There are public API
55

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

8-
- API version: 4.20.1
9-
- Package version: 4.20.1
8+
- API version: 4.21.2
9+
- Package version: 4.21.2
1010
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1111
For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts)
1212

@@ -189,6 +189,14 @@ Class | Method | HTTP request | Description
189189
*MarginApi* | [**update_loan_record**](docs/MarginApi.md#update_loan_record) | **PATCH** /margin/loan_records/{loan_record_id} | Modify a loan record
190190
*MarginApi* | [**get_auto_repay_status**](docs/MarginApi.md#get_auto_repay_status) | **GET** /margin/auto_repay | Retrieve user auto repayment setting
191191
*MarginApi* | [**set_auto_repay**](docs/MarginApi.md#set_auto_repay) | **POST** /margin/auto_repay | Update user's auto repayment setting
192+
*MarginApi* | [**list_cross_margin_currencies**](docs/MarginApi.md#list_cross_margin_currencies) | **GET** /margin/cross/currencies | Currencies supported by cross margin.
193+
*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
194+
*MarginApi* | [**get_cross_margin_account**](docs/MarginApi.md#get_cross_margin_account) | **GET** /margin/cross/accounts | Retrieve cross margin account
195+
*MarginApi* | [**list_cross_margin_loans**](docs/MarginApi.md#list_cross_margin_loans) | **GET** /margin/cross/loans | List cross margin borrow history
196+
*MarginApi* | [**create_cross_margin_loan**](docs/MarginApi.md#create_cross_margin_loan) | **POST** /margin/cross/loans | Create a cross margin borrow loan
197+
*MarginApi* | [**get_cross_margin_loan**](docs/MarginApi.md#get_cross_margin_loan) | **GET** /margin/cross/loans/{loan_id} | Retrieve single borrow loan detail
198+
*MarginApi* | [**list_cross_margin_repayments**](docs/MarginApi.md#list_cross_margin_repayments) | **GET** /margin/cross/repayments | Retrieve cross margin repayments
199+
*MarginApi* | [**repay_cross_margin_loan**](docs/MarginApi.md#repay_cross_margin_loan) | **POST** /margin/cross/repayments | Repay cross margin loan
192200
*SpotApi* | [**list_currencies**](docs/SpotApi.md#list_currencies) | **GET** /spot/currencies | List all currencies' detail
193201
*SpotApi* | [**get_currency**](docs/SpotApi.md#get_currency) | **GET** /spot/currencies/{currency} | Get detail of one particular currency
194202
*SpotApi* | [**list_currency_pairs**](docs/SpotApi.md#list_currency_pairs) | **GET** /spot/currency_pairs | List all currency pairs supported
@@ -223,6 +231,7 @@ Class | Method | HTTP request | Description
223231
*WalletApi* | [**list_sub_account_balances**](docs/WalletApi.md#list_sub_account_balances) | **GET** /wallet/sub_account_balances | Retrieve sub account balances
224232
*WalletApi* | [**get_trade_fee**](docs/WalletApi.md#get_trade_fee) | **GET** /wallet/fee | Retrieve personal trading fee
225233
*WithdrawalApi* | [**withdraw**](docs/WithdrawalApi.md#withdraw) | **POST** /withdrawals | Withdraw
234+
*WithdrawalApi* | [**cancel_withdrawal**](docs/WithdrawalApi.md#cancel_withdrawal) | **DELETE** /withdrawals/{withdrawal_id} | Cancel withdrawal with specified ID
226235

227236

228237
## Documentation For Models
@@ -233,6 +242,12 @@ Class | Method | HTTP request | Description
233242
- [CancelOrderResult](docs/CancelOrderResult.md)
234243
- [Contract](docs/Contract.md)
235244
- [ContractStat](docs/ContractStat.md)
245+
- [CrossMarginAccount](docs/CrossMarginAccount.md)
246+
- [CrossMarginBalance](docs/CrossMarginBalance.md)
247+
- [CrossMarginCurrency](docs/CrossMarginCurrency.md)
248+
- [CrossMarginLoan](docs/CrossMarginLoan.md)
249+
- [CrossMarginRepayRequest](docs/CrossMarginRepayRequest.md)
250+
- [CrossMarginRepayment](docs/CrossMarginRepayment.md)
236251
- [Currency](docs/Currency.md)
237252
- [CurrencyPair](docs/CurrencyPair.md)
238253
- [DeliveryContract](docs/DeliveryContract.md)

docs/BatchOrder.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ Name | Type | Description | Notes
1111
**id** | **str** | Order ID | [optional] [readonly]
1212
**create_time** | **str** | Order creation time | [optional] [readonly]
1313
**update_time** | **str** | Order last modification time | [optional] [readonly]
14+
**create_time_ms** | **int** | Order creation time in milliseconds | [optional] [readonly]
15+
**update_time_ms** | **int** | Order last modification time in milliseconds | [optional] [readonly]
1416
**status** | **str** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] [readonly]
1517
**currency_pair** | **str** | Currency pair | [optional]
1618
**type** | **str** | Order type. limit - limit order | [optional] [default to 'limit']
17-
**account** | **str** | Account type. spot - use spot account; margin - use margin account | [optional] [default to 'spot']
19+
**account** | **str** | Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account | [optional] [default to 'spot']
1820
**side** | **str** | Order side | [optional]
1921
**amount** | **str** | Trade amount | [optional]
2022
**price** | **str** | Order price | [optional]
2123
**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']
2224
**iceberg** | **str** | Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally | [optional]
23-
**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]
25+
**auto_borrow** | **bool** | Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. | [optional]
26+
**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]
2427
**left** | **str** | Amount left to fill | [optional] [readonly]
2528
**fill_price** | **str** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] [readonly]
2629
**filled_total** | **str** | Total filled in quote currency | [optional] [readonly]

docs/CancelOrder.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**currency_pair** | **str** | Order currency pair |
88
**id** | **str** | Order ID or user custom ID. Custom ID are accepted only within 30 minutes after order creation |
9+
**account** | **str** | If cancelled order is cross margin order, this field must be set and can only be `cross_margin` | [optional]
910

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

docs/CancelOrderResult.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Name | Type | Description | Notes
99
**succeeded** | **bool** | Whether cancellation succeeded | [optional]
1010
**label** | **str** | Error label when failed to cancel the order; emtpy if succeeded | [optional]
1111
**message** | **str** | Error message when failed to cancel the order; empty if succeeded | [optional]
12+
**account** | **str** | Empty by default. If cancelled order is cross margin order, this field is set to `cross_margin` | [optional]
1213

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

docs/Contract.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**name** | **str** | Futures contract | [optional]
88
**type** | **str** | Futures contract type | [optional]
9-
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional]
9+
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency | [optional]
1010
**leverage_min** | **str** | Minimum leverage | [optional]
1111
**leverage_max** | **str** | Maximum leverage | [optional]
1212
**maintenance_rate** | **str** | Maintenance rate of margin | [optional]

docs/CrossMarginAccount.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CrossMarginAccount
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**user_id** | **int** | User ID | [optional]
7+
**locked** | **bool** | Whether account is locked | [optional]
8+
**balances** | [**dict(str, CrossMarginBalance)**](CrossMarginBalance.md) | | [optional]
9+
**total** | **str** | Total account value in USDT, i.e., the sum of all currencies' `(available+freeze)*price*discount` | [optional]
10+
**borrowed** | **str** | Total borrowed value in USDT, i.e., the sum of all currencies' `borrowed*price*discount` | [optional]
11+
**interest** | **str** | Total unpaid interests in USDT, i.e., the sum of all currencies' `interest*price*discount` | [optional]
12+
**risk** | **str** | Risk rate. When it belows 110%, liquidation will be triggered. Calculation formula: `total / (borrowed+interest)` | [optional]
13+
14+
[[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+
16+

docs/CrossMarginBalance.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# CrossMarginBalance
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**available** | **str** | Available amount | [optional]
7+
**freeze** | **str** | Locked amount | [optional]
8+
**borrowed** | **str** | Borrowed amount | [optional]
9+
**interest** | **str** | Interests unpaid | [optional]
10+
11+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
12+
13+

docs/CrossMarginCurrency.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# CrossMarginCurrency
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**name** | **str** | Currency name | [optional]
7+
**rate** | **str** | Loan rate | [optional]
8+
**prec** | **str** | Currency precision | [optional]
9+
**discount** | **str** | Currency value discount, which is used in total value calculation | [optional]
10+
**min_borrow_amount** | **str** | Minimum currency borrow amount. Unit is currency itself | [optional]
11+
**user_max_borrow_amount** | **str** | Maximum borrow value allowed per user, in USDT | [optional]
12+
**total_max_borrow_amount** | **str** | Maximum borrow value allowed for this currency, in USDT | [optional]
13+
**price** | **str** | Price change between this currency and USDT | [optional]
14+
15+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
16+
17+

docs/CrossMarginLoan.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# CrossMarginLoan
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**id** | **str** | Borrow loan ID | [optional] [readonly]
7+
**create_time** | **int** | Creation timestamp, in milliseconds | [optional] [readonly]
8+
**update_time** | **int** | Update timestamp, in milliseconds | [optional] [readonly]
9+
**currency** | **str** | Currency name |
10+
**amount** | **str** | Borrowed amount |
11+
**text** | **str** | User defined custom ID | [optional]
12+
**status** | **int** | Borrow loan status, which includes: - 1: failed to borrow - 2: borrowed but not repaid - 3: repayment complete | [optional] [readonly]
13+
**repaid** | **str** | Repaid amount | [optional] [readonly]
14+
**repaid_interest** | **str** | Repaid interest | [optional] [readonly]
15+
**unpaid_interest** | **str** | Interest not repaid | [optional] [readonly]
16+
17+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
18+
19+

docs/CrossMarginRepayRequest.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CrossMarginRepayRequest
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**currency** | **str** | Repayment currency |
7+
**amount** | **str** | Repayment amount |
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+
11+

docs/CrossMarginRepayment.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# CrossMarginRepayment
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**id** | **str** | Loan record ID | [optional]
7+
**create_time** | **int** | Repayment time | [optional]
8+
**loan_id** | **str** | Borrow loan ID | [optional]
9+
**currency** | **str** | Currency name | [optional]
10+
**principal** | **str** | Repaid principal | [optional]
11+
**interest** | **str** | Repaid interest | [optional]
12+
13+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
14+
15+

docs/DeliveryContract.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Name | Type | Description | Notes
88
**underlying** | **str** | Underlying | [optional]
99
**cycle** | **str** | Cycle type, e.g. WEEKLY, QUARTERLY | [optional]
1010
**type** | **str** | Futures contract type | [optional]
11-
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional]
11+
**quanto_multiplier** | **str** | Multiplier used in converting from invoicing to settlement currency | [optional]
1212
**leverage_min** | **str** | Minimum leverage | [optional]
1313
**leverage_max** | **str** | Maximum leverage | [optional]
1414
**maintenance_rate** | **str** | Maintenance rate of margin | [optional]

docs/FuturesApi.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ Name | Type | Description | Notes
10311031
[[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)
10321032

10331033
# **update_position_leverage**
1034-
> Position update_position_leverage(settle, contract, leverage)
1034+
> Position update_position_leverage(settle, contract, leverage, cross_leverage_limit=cross_leverage_limit)
10351035
10361036
Update position leverage
10371037

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

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

10841086
### Return type
10851087

@@ -1313,7 +1315,7 @@ Name | Type | Description | Notes
13131315
[[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)
13141316

13151317
# **update_dual_mode_position_margin**
1316-
> list[Position] update_dual_mode_position_margin(settle, contract, change)
1318+
> list[Position] update_dual_mode_position_margin(settle, contract, change, dual_side)
13171319
13181320
Update position margin in dual mode
13191321

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

13481351
try:
13491352
# Update position margin in dual mode
1350-
api_response = api_instance.update_dual_mode_position_margin(settle, contract, change)
1353+
api_response = api_instance.update_dual_mode_position_margin(settle, contract, change, dual_side)
13511354
print(api_response)
13521355
except GateApiException as ex:
13531356
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
@@ -1362,6 +1365,7 @@ Name | Type | Description | Notes
13621365
**settle** | **str**| Settle currency |
13631366
**contract** | **str**| Futures contract |
13641367
**change** | **str**| Margin change. Use positive number to increase margin, negative number otherwise. |
1368+
**dual_side** | **str**| Long or short position |
13651369

13661370
### Return type
13671371

docs/FuturesOrder.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Name | Type | Description | Notes
88
**user** | **int** | User ID | [optional] [readonly]
99
**create_time** | **float** | Order creation time | [optional] [readonly]
1010
**finish_time** | **float** | Order finished time. Not returned if order is open | [optional] [readonly]
11-
**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]
11+
**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]
1212
**status** | **str** | Order status - `open`: waiting to be traded - `finished`: finished | [optional] [readonly]
1313
**contract** | **str** | Futures contract |
1414
**size** | **int** | Order size. Specify positive number to make a bid, and negative number to ask |

docs/MarginAccountCurrency.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Name | Type | Description | Notes
88
**available** | **str** | Amount suitable for margin trading. | [optional]
99
**locked** | **str** | Locked amount, used in margin trading | [optional]
1010
**borrowed** | **str** | Borrowed amount | [optional]
11+
**interest** | **str** | Interests unpaid | [optional]
1112

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

0 commit comments

Comments
 (0)