diff --git a/README.md b/README.md index ca96e6b..6033711 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ APIv4 provides spot, margin and futures trading operations. There are public API ## Overview This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. -- API version: 4.20.2 -- Package version: 5.20.2 +- API version: 4.21.2 +- Package version: 6.21.2 - Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts) @@ -39,7 +39,7 @@ page ## Installation ```shell -go get github.com/gateio/gateapi-go/v5 +go get github.com/gateio/gateapi-go/v6 ``` ## Getting Started @@ -54,7 +54,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -169,6 +169,14 @@ Class | Method | HTTP request | Description *MarginApi* | [**UpdateLoanRecord**](docs/MarginApi.md#updateloanrecord) | **Patch** /margin/loan_records/{loan_record_id} | Modify a loan record *MarginApi* | [**GetAutoRepayStatus**](docs/MarginApi.md#getautorepaystatus) | **Get** /margin/auto_repay | Retrieve user auto repayment setting *MarginApi* | [**SetAutoRepay**](docs/MarginApi.md#setautorepay) | **Post** /margin/auto_repay | Update user's auto repayment setting +*MarginApi* | [**ListCrossMarginCurrencies**](docs/MarginApi.md#listcrossmargincurrencies) | **Get** /margin/cross/currencies | Currencies supported by cross margin. +*MarginApi* | [**GetCrossMarginCurrency**](docs/MarginApi.md#getcrossmargincurrency) | **Get** /margin/cross/currencies/{currency} | Retrieve detail of one single currency supported by cross margin +*MarginApi* | [**GetCrossMarginAccount**](docs/MarginApi.md#getcrossmarginaccount) | **Get** /margin/cross/accounts | Retrieve cross margin account +*MarginApi* | [**ListCrossMarginLoans**](docs/MarginApi.md#listcrossmarginloans) | **Get** /margin/cross/loans | List cross margin borrow history +*MarginApi* | [**CreateCrossMarginLoan**](docs/MarginApi.md#createcrossmarginloan) | **Post** /margin/cross/loans | Create a cross margin borrow loan +*MarginApi* | [**GetCrossMarginLoan**](docs/MarginApi.md#getcrossmarginloan) | **Get** /margin/cross/loans/{loan_id} | Retrieve single borrow loan detail +*MarginApi* | [**ListCrossMarginRepayments**](docs/MarginApi.md#listcrossmarginrepayments) | **Get** /margin/cross/repayments | Retrieve cross margin repayments +*MarginApi* | [**RepayCrossMarginLoan**](docs/MarginApi.md#repaycrossmarginloan) | **Post** /margin/cross/repayments | Repay cross margin loan *SpotApi* | [**ListCurrencies**](docs/SpotApi.md#listcurrencies) | **Get** /spot/currencies | List all currencies' detail *SpotApi* | [**GetCurrency**](docs/SpotApi.md#getcurrency) | **Get** /spot/currencies/{currency} | Get detail of one particular currency *SpotApi* | [**ListCurrencyPairs**](docs/SpotApi.md#listcurrencypairs) | **Get** /spot/currency_pairs | List all currency pairs supported @@ -203,6 +211,7 @@ Class | Method | HTTP request | Description *WalletApi* | [**ListSubAccountBalances**](docs/WalletApi.md#listsubaccountbalances) | **Get** /wallet/sub_account_balances | Retrieve sub account balances *WalletApi* | [**GetTradeFee**](docs/WalletApi.md#gettradefee) | **Get** /wallet/fee | Retrieve personal trading fee *WithdrawalApi* | [**Withdraw**](docs/WithdrawalApi.md#withdraw) | **Post** /withdrawals | Withdraw +*WithdrawalApi* | [**CancelWithdrawal**](docs/WithdrawalApi.md#cancelwithdrawal) | **Delete** /withdrawals/{withdrawal_id} | Cancel withdrawal with specified ID ## Documentation For Models @@ -213,6 +222,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) diff --git a/api_futures.go b/api_futures.go index 39df2bb..7677c43 100644 --- a/api_futures.go +++ b/api_futures.go @@ -1540,15 +1540,22 @@ func (a *FuturesApiService) UpdatePositionMargin(ctx context.Context, settle str return localVarReturnValue, localVarHTTPResponse, nil } +// UpdatePositionLeverageOpts Optional parameters for the method 'UpdatePositionLeverage' +type UpdatePositionLeverageOpts struct { + CrossLeverageLimit optional.String +} + /* UpdatePositionLeverage Update position leverage * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param settle Settle currency * @param contract Futures contract * @param leverage New position leverage + * @param optional nil or *UpdatePositionLeverageOpts - Optional Parameters: + * @param "CrossLeverageLimit" (optional.String) - Cross margin leverage(valid only when `leverage` is 0) @return Position */ -func (a *FuturesApiService) UpdatePositionLeverage(ctx context.Context, settle string, contract string, leverage string) (Position, *http.Response, error) { +func (a *FuturesApiService) UpdatePositionLeverage(ctx context.Context, settle string, contract string, leverage string, localVarOptionals *UpdatePositionLeverageOpts) (Position, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} @@ -1569,6 +1576,9 @@ func (a *FuturesApiService) UpdatePositionLeverage(ctx context.Context, settle s localVarFormParams := url.Values{} localVarQueryParams.Add("leverage", parameterToString(leverage, "")) + if localVarOptionals != nil && localVarOptionals.CrossLeverageLimit.IsSet() { + localVarQueryParams.Add("cross_leverage_limit", parameterToString(localVarOptionals.CrossLeverageLimit.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1930,9 +1940,10 @@ UpdateDualModePositionMargin Update position margin in dual mode * @param settle Settle currency * @param contract Futures contract * @param change Margin change. Use positive number to increase margin, negative number otherwise. + * @param dualSide Long or short position @return []Position */ -func (a *FuturesApiService) UpdateDualModePositionMargin(ctx context.Context, settle string, contract string, change string) ([]Position, *http.Response, error) { +func (a *FuturesApiService) UpdateDualModePositionMargin(ctx context.Context, settle string, contract string, change string, dualSide string) ([]Position, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} @@ -1953,6 +1964,7 @@ func (a *FuturesApiService) UpdateDualModePositionMargin(ctx context.Context, se localVarFormParams := url.Values{} localVarQueryParams.Add("change", parameterToString(change, "")) + localVarQueryParams.Add("dual_side", parameterToString(dualSide, "")) // to determine the Content-Type header localVarHTTPContentTypes := []string{} diff --git a/api_margin.go b/api_margin.go index 4ca531c..75bf393 100644 --- a/api_margin.go +++ b/api_margin.go @@ -1868,3 +1868,775 @@ func (a *MarginApiService) SetAutoRepay(ctx context.Context, status string) (Aut return localVarReturnValue, localVarHTTPResponse, nil } + +/* +ListCrossMarginCurrencies Currencies supported by cross margin. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). +@return []CrossMarginCurrency +*/ +func (a *MarginApiService) ListCrossMarginCurrencies(ctx context.Context) ([]CrossMarginCurrency, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []CrossMarginCurrency + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/currencies" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + ctx = context.WithValue(ctx, ContextPublic, true) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +GetCrossMarginCurrency Retrieve detail of one single currency supported by cross margin + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param currency Currency name +@return CrossMarginCurrency +*/ +func (a *MarginApiService) GetCrossMarginCurrency(ctx context.Context, currency string) (CrossMarginCurrency, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CrossMarginCurrency + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/currencies/{currency}" + localVarPath = strings.Replace(localVarPath, "{"+"currency"+"}", url.QueryEscape(parameterToString(currency, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + ctx = context.WithValue(ctx, ContextPublic, true) + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +GetCrossMarginAccount Retrieve cross margin account + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). +@return CrossMarginAccount +*/ +func (a *MarginApiService) GetCrossMarginAccount(ctx context.Context) (CrossMarginAccount, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CrossMarginAccount + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/accounts" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListCrossMarginLoansOpts Optional parameters for the method 'ListCrossMarginLoans' +type ListCrossMarginLoansOpts struct { + Currency optional.String + Limit optional.Int32 + Offset optional.Int32 + Reverse optional.Bool +} + +/* +ListCrossMarginLoans List cross margin borrow history +Sort by creation time in descending order by default. Set `reverse=false` to return ascending results. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param status Filter by status. Supported values are 2 and 3. + * @param optional nil or *ListCrossMarginLoansOpts - Optional Parameters: + * @param "Currency" (optional.String) - Filter by currency + * @param "Limit" (optional.Int32) - Maximum number of records returned in one list + * @param "Offset" (optional.Int32) - List offset, starting from 0 + * @param "Reverse" (optional.Bool) - Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results +@return []CrossMarginLoan +*/ +func (a *MarginApiService) ListCrossMarginLoans(ctx context.Context, status int32, localVarOptionals *ListCrossMarginLoansOpts) ([]CrossMarginLoan, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []CrossMarginLoan + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/loans" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + localVarQueryParams.Add("status", parameterToString(status, "")) + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { + localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Offset.IsSet() { + localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +CreateCrossMarginLoan Create a cross margin borrow loan +Borrow amount cannot be less than currency minimum borrow amount + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param crossMarginLoan +@return CrossMarginLoan +*/ +func (a *MarginApiService) CreateCrossMarginLoan(ctx context.Context, crossMarginLoan CrossMarginLoan) (CrossMarginLoan, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CrossMarginLoan + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/loans" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = &crossMarginLoan + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +GetCrossMarginLoan Retrieve single borrow loan detail + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param loanId Borrow loan ID +@return CrossMarginLoan +*/ +func (a *MarginApiService) GetCrossMarginLoan(ctx context.Context, loanId string) (CrossMarginLoan, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CrossMarginLoan + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/loans/{loan_id}" + localVarPath = strings.Replace(localVarPath, "{"+"loan_id"+"}", url.QueryEscape(parameterToString(loanId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListCrossMarginRepaymentsOpts Optional parameters for the method 'ListCrossMarginRepayments' +type ListCrossMarginRepaymentsOpts struct { + Currency optional.String + LoanId optional.String + Limit optional.Int32 + Offset optional.Int32 + Reverse optional.Bool +} + +/* +ListCrossMarginRepayments Retrieve cross margin repayments +Sort by creation time in descending order by default. Set `reverse=false` to return ascending results. + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *ListCrossMarginRepaymentsOpts - Optional Parameters: + * @param "Currency" (optional.String) - + * @param "LoanId" (optional.String) - + * @param "Limit" (optional.Int32) - Maximum number of records returned in one list + * @param "Offset" (optional.Int32) - List offset, starting from 0 + * @param "Reverse" (optional.Bool) - Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results +@return []CrossMarginRepayment +*/ +func (a *MarginApiService) ListCrossMarginRepayments(ctx context.Context, localVarOptionals *ListCrossMarginRepaymentsOpts) ([]CrossMarginRepayment, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []CrossMarginRepayment + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/repayments" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Currency.IsSet() { + localVarQueryParams.Add("currency", parameterToString(localVarOptionals.Currency.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.LoanId.IsSet() { + localVarQueryParams.Add("loan_id", parameterToString(localVarOptionals.LoanId.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { + localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Offset.IsSet() { + localVarQueryParams.Add("offset", parameterToString(localVarOptionals.Offset.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { + localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +/* +RepayCrossMarginLoan Repay cross margin loan + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param crossMarginRepayRequest +@return []CrossMarginLoan +*/ +func (a *MarginApiService) RepayCrossMarginLoan(ctx context.Context, crossMarginRepayRequest CrossMarginRepayRequest) ([]CrossMarginLoan, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPost + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []CrossMarginLoan + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/margin/cross/repayments" + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = &crossMarginRepayRequest + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/api_spot.go b/api_spot.go index 2295126..4a03674 100644 --- a/api_spot.go +++ b/api_spot.go @@ -1074,17 +1074,19 @@ func (a *SpotApiService) CreateBatchOrders(ctx context.Context, order []Order) ( // ListAllOpenOrdersOpts Optional parameters for the method 'ListAllOpenOrders' type ListAllOpenOrdersOpts struct { - Page optional.Int32 - Limit optional.Int32 + Page optional.Int32 + Limit optional.Int32 + Account optional.String } /* ListAllOpenOrders 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 +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. Spot and margin orders are returned by default. To list cross margin orders, `account` must be set to `cross_margin` * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param optional nil or *ListAllOpenOrdersOpts - Optional Parameters: * @param "Page" (optional.Int32) - Page number * @param "Limit" (optional.Int32) - Maximum number of records returned in one page in each currency pair + * @param "Account" (optional.String) - Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account @return []OpenOrders */ func (a *SpotApiService) ListAllOpenOrders(ctx context.Context, localVarOptionals *ListAllOpenOrdersOpts) ([]OpenOrders, *http.Response, error) { @@ -1109,6 +1111,9 @@ func (a *SpotApiService) ListAllOpenOrders(ctx context.Context, localVarOptional if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) } + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1179,18 +1184,21 @@ func (a *SpotApiService) ListAllOpenOrders(ctx context.Context, localVarOptional // ListOrdersOpts Optional parameters for the method 'ListOrders' type ListOrdersOpts struct { - Page optional.Int32 - Limit optional.Int32 + Page optional.Int32 + Limit optional.Int32 + Account optional.String } /* ListOrders List orders +Spot and margin orders are returned by default. If cross margin orders are needed, `account` must be set to `cross_margin` * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param currencyPair Currency pair * @param status List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled * @param optional nil or *ListOrdersOpts - Optional Parameters: * @param "Page" (optional.Int32) - Page number * @param "Limit" (optional.Int32) - Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 + * @param "Account" (optional.String) - Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account @return []Order */ func (a *SpotApiService) ListOrders(ctx context.Context, currencyPair string, status string, localVarOptionals *ListOrdersOpts) ([]Order, *http.Response, error) { @@ -1217,6 +1225,9 @@ func (a *SpotApiService) ListOrders(ctx context.Context, currencyPair string, st if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) } + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1287,6 +1298,7 @@ func (a *SpotApiService) ListOrders(ctx context.Context, currencyPair string, st /* CreateOrder Create an order +You can place orders with spot, margin or cross margin account through setting the `account `field. It defaults to `spot`, which means spot account is used to place orders. When margin account is used, i.e., `account` is `margin`, `auto_borrow` field can be set to `true` to enable the server to borrow the amount lacked using `POST /margin/loans` when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your **margin account**, which can be updated or queried using `/margin/auto_repay` API. When cross margin account is used, i.e., `account` is `cross_margin`, `auto_borrow` can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's `auto_repay` field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either `cancelled` or `closed`. **Order status** An order waiting to be filled is `open`, and it stays `open` until it is filled totally. If fully filled, order is finished and its status turns to `closed`.If the order is cancelled before it is totally filled, whether or not partially filled, its status is `cancelled`. **Iceberg order** `iceberg` field can be used to set the amount shown. Set to `-1` to hide totally. Note that the hidden part's fee will be charged using taker's fee rate. * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param order @return Order @@ -1385,6 +1397,7 @@ type CancelOrdersOpts struct { /* CancelOrders Cancel all `open` orders in specified currency pair +If `account` is not set, all open orders, including spot, margin and cross margin ones, will be cancelled. You can set `account` to cancel only orders within the specified account * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param currencyPair Currency pair * @param optional nil or *CancelOrdersOpts - Optional Parameters: @@ -1576,14 +1589,22 @@ func (a *SpotApiService) CancelBatchOrders(ctx context.Context, cancelOrder []Ca return localVarReturnValue, localVarHTTPResponse, nil } +// GetOrderOpts Optional parameters for the method 'GetOrder' +type GetOrderOpts struct { + Account optional.String +} + /* GetOrder Get a single order +Spot and margin orders are queried by default. If cross margin orders are needed, `account` must be set to `cross_margin` * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param orderId Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. * @param currencyPair Currency pair + * @param optional nil or *GetOrderOpts - Optional Parameters: + * @param "Account" (optional.String) - Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account @return Order */ -func (a *SpotApiService) GetOrder(ctx context.Context, orderId string, currencyPair string) (Order, *http.Response, error) { +func (a *SpotApiService) GetOrder(ctx context.Context, orderId string, currencyPair string, localVarOptionals *GetOrderOpts) (Order, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} @@ -1602,6 +1623,9 @@ func (a *SpotApiService) GetOrder(ctx context.Context, orderId string, currencyP localVarFormParams := url.Values{} localVarQueryParams.Add("currency_pair", parameterToString(currencyPair, "")) + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1670,14 +1694,22 @@ func (a *SpotApiService) GetOrder(ctx context.Context, orderId string, currencyP return localVarReturnValue, localVarHTTPResponse, nil } +// CancelOrderOpts Optional parameters for the method 'CancelOrder' +type CancelOrderOpts struct { + Account optional.String +} + /* CancelOrder Cancel a single order +Spot and margin orders are cancelled by default. If trying to cancel cross margin orders, `account` must be set to `cross_margin` * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param orderId Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. * @param currencyPair Currency pair + * @param optional nil or *CancelOrderOpts - Optional Parameters: + * @param "Account" (optional.String) - Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account @return Order */ -func (a *SpotApiService) CancelOrder(ctx context.Context, orderId string, currencyPair string) (Order, *http.Response, error) { +func (a *SpotApiService) CancelOrder(ctx context.Context, orderId string, currencyPair string, localVarOptionals *CancelOrderOpts) (Order, *http.Response, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} @@ -1696,6 +1728,9 @@ func (a *SpotApiService) CancelOrder(ctx context.Context, orderId string, curren localVarFormParams := url.Values{} localVarQueryParams.Add("currency_pair", parameterToString(currencyPair, "")) + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} @@ -1769,16 +1804,19 @@ type ListMyTradesOpts struct { Limit optional.Int32 Page optional.Int32 OrderId optional.String + Account optional.String } /* ListMyTrades List personal trading history +Spot and margin trades are queried by default. If cross margin trades are needed, `account` must be set to `cross_margin` * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param currencyPair Currency pair * @param optional nil or *ListMyTradesOpts - Optional Parameters: * @param "Limit" (optional.Int32) - Maximum number of records returned in one list * @param "Page" (optional.Int32) - Page number * @param "OrderId" (optional.String) - List all trades of specified order + * @param "Account" (optional.String) - Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account @return []Trade */ func (a *SpotApiService) ListMyTrades(ctx context.Context, currencyPair string, localVarOptionals *ListMyTradesOpts) ([]Trade, *http.Response, error) { @@ -1807,6 +1845,9 @@ func (a *SpotApiService) ListMyTrades(ctx context.Context, currencyPair string, if localVarOptionals != nil && localVarOptionals.OrderId.IsSet() { localVarQueryParams.Add("order_id", parameterToString(localVarOptionals.OrderId.Value(), "")) } + if localVarOptionals != nil && localVarOptionals.Account.IsSet() { + localVarQueryParams.Add("account", parameterToString(localVarOptionals.Account.Value(), "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} diff --git a/api_wallet.go b/api_wallet.go index 5fdf56d..6f13ae1 100644 --- a/api_wallet.go +++ b/api_wallet.go @@ -358,7 +358,7 @@ func (a *WalletApiService) ListDeposits(ctx context.Context, localVarOptionals * /* Transfer Transfer between trading accounts -Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery +Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery 4. spot - cross margin * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). * @param transfer */ diff --git a/api_withdrawal.go b/api_withdrawal.go index b621165..9adaa0f 100644 --- a/api_withdrawal.go +++ b/api_withdrawal.go @@ -14,6 +14,7 @@ import ( "io/ioutil" "net/http" "net/url" + "strings" ) // Linger please @@ -115,3 +116,95 @@ func (a *WithdrawalApiService) Withdraw(ctx context.Context, ledgerRecord Ledger return localVarReturnValue, localVarHTTPResponse, nil } + +/* +CancelWithdrawal Cancel withdrawal with specified ID + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param withdrawalId +@return LedgerRecord +*/ +func (a *WithdrawalApiService) CancelWithdrawal(ctx context.Context, withdrawalId string) (LedgerRecord, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodDelete + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue LedgerRecord + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/withdrawals/{withdrawal_id}" + localVarPath = strings.Replace(localVarPath, "{"+"withdrawal_id"+"}", url.QueryEscape(parameterToString(withdrawalId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if ctx == nil { + ctx = context.Background() + } + if ctx.Value(ContextGateAPIV4) == nil { + // for compatibility, set configuration key and secret to context if ContextGateAPIV4 value is not present + ctx = context.WithValue(ctx, ContextGateAPIV4, GateAPIV4{ + Key: a.client.cfg.Key, + Secret: a.client.cfg.Secret, + }) + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(r) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status + ", " + string(localVarBody), + } + var gateErr GateAPIError + if e := a.client.decode(&gateErr, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")); e == nil && gateErr.Label != "" { + gateErr.APIError = newErr + return localVarReturnValue, localVarHTTPResponse, gateErr + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} diff --git a/configuration.go b/configuration.go index 49d327f..91a9eb2 100644 --- a/configuration.go +++ b/configuration.go @@ -90,7 +90,7 @@ func NewConfiguration() *Configuration { cfg := &Configuration{ BasePath: "https://api.gateio.ws/api/v4", DefaultHeader: make(map[string]string), - UserAgent: "OpenAPI-Generator/5.20.2/go", + UserAgent: "OpenAPI-Generator/6.21.2/go", Debug: false, Servers: []ServerConfiguration{ { diff --git a/docs/BatchOrder.md b/docs/BatchOrder.md index 22a4a1d..d51a41b 100644 --- a/docs/BatchOrder.md +++ b/docs/BatchOrder.md @@ -16,13 +16,14 @@ Name | Type | Description | Notes **Status** | **string** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] [readonly] **CurrencyPair** | **string** | Currency pair | [optional] **Type** | **string** | Order type. limit - limit order | [optional] [default to TYPE_LIMIT] -**Account** | **string** | Account type. spot - use spot account; margin - use margin account | [optional] [default to ACCOUNT_SPOT] +**Account** | **string** | Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account | [optional] [default to ACCOUNT_SPOT] **Side** | **string** | Order side | [optional] **Amount** | **string** | Trade amount | [optional] **Price** | **string** | Order price | [optional] **TimeInForce** | **string** | 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 TIME_IN_FORCE_GTC] **Iceberg** | **string** | Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally | [optional] -**AutoBorrow** | **bool** | Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. | [optional] +**AutoBorrow** | **bool** | Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. | [optional] +**AutoRepay** | **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** | **string** | Amount left to fill | [optional] [readonly] **FillPrice** | **string** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] [readonly] **FilledTotal** | **string** | Total filled in quote currency | [optional] [readonly] diff --git a/docs/CancelOrder.md b/docs/CancelOrder.md index 5d623dc..657503a 100644 --- a/docs/CancelOrder.md +++ b/docs/CancelOrder.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **CurrencyPair** | **string** | Order currency pair | **Id** | **string** | Order ID or user custom ID. Custom ID are accepted only within 30 minutes after order creation | +**Account** | **string** | 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) diff --git a/docs/CancelOrderResult.md b/docs/CancelOrderResult.md index 8671842..8c914b7 100644 --- a/docs/CancelOrderResult.md +++ b/docs/CancelOrderResult.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **Succeeded** | **bool** | Whether cancellation succeeded | [optional] **Label** | **string** | Error label when failed to cancel the order; emtpy if succeeded | [optional] **Message** | **string** | Error message when failed to cancel the order; empty if succeeded | [optional] +**Account** | **string** | 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) diff --git a/docs/Contract.md b/docs/Contract.md index a2b61a8..9943b17 100644 --- a/docs/Contract.md +++ b/docs/Contract.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Name** | **string** | Futures contract | [optional] **Type** | **string** | Futures contract type | [optional] -**QuantoMultiplier** | **string** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional] +**QuantoMultiplier** | **string** | Multiplier used in converting from invoicing to settlement currency | [optional] **LeverageMin** | **string** | Minimum leverage | [optional] **LeverageMax** | **string** | Maximum leverage | [optional] **MaintenanceRate** | **string** | Maintenance rate of margin | [optional] diff --git a/docs/CrossMarginAccount.md b/docs/CrossMarginAccount.md new file mode 100644 index 0000000..7dca908 --- /dev/null +++ b/docs/CrossMarginAccount.md @@ -0,0 +1,17 @@ +# CrossMarginAccount + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**UserId** | **int64** | User ID | [optional] +**Locked** | **bool** | Whether account is locked | [optional] +**Balances** | [**map[string]CrossMarginBalance**](CrossMarginBalance.md) | | [optional] +**Total** | **string** | Total account value in USDT, i.e., the sum of all currencies' `(available+freeze)*price*discount` | [optional] +**Borrowed** | **string** | Total borrowed value in USDT, i.e., the sum of all currencies' `borrowed*price*discount` | [optional] +**Interest** | **string** | Total unpaid interests in USDT, i.e., the sum of all currencies' `interest*price*discount` | [optional] +**Risk** | **string** | 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) + + diff --git a/docs/CrossMarginBalance.md b/docs/CrossMarginBalance.md new file mode 100644 index 0000000..09aea27 --- /dev/null +++ b/docs/CrossMarginBalance.md @@ -0,0 +1,14 @@ +# CrossMarginBalance + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Available** | **string** | Available amount | [optional] +**Freeze** | **string** | Locked amount | [optional] +**Borrowed** | **string** | Borrowed amount | [optional] +**Interest** | **string** | 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) + + diff --git a/docs/CrossMarginCurrency.md b/docs/CrossMarginCurrency.md new file mode 100644 index 0000000..65ebece --- /dev/null +++ b/docs/CrossMarginCurrency.md @@ -0,0 +1,18 @@ +# CrossMarginCurrency + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Name** | **string** | Currency name | [optional] +**Rate** | **string** | Loan rate | [optional] +**Prec** | **string** | Currency precision | [optional] +**Discount** | **string** | Currency value discount, which is used in total value calculation | [optional] +**MinBorrowAmount** | **string** | Minimum currency borrow amount. Unit is currency itself | [optional] +**UserMaxBorrowAmount** | **string** | Maximum borrow value allowed per user, in USDT | [optional] +**TotalMaxBorrowAmount** | **string** | Maximum borrow value allowed for this currency, in USDT | [optional] +**Price** | **string** | 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) + + diff --git a/docs/CrossMarginLoan.md b/docs/CrossMarginLoan.md new file mode 100644 index 0000000..4c26f9b --- /dev/null +++ b/docs/CrossMarginLoan.md @@ -0,0 +1,20 @@ +# CrossMarginLoan + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | Borrow loan ID | [optional] [readonly] +**CreateTime** | **int64** | Creation timestamp, in milliseconds | [optional] [readonly] +**UpdateTime** | **int64** | Update timestamp, in milliseconds | [optional] [readonly] +**Currency** | **string** | Currency name | +**Amount** | **string** | Borrowed amount | +**Text** | **string** | User defined custom ID | [optional] +**Status** | **int32** | Borrow loan status, which includes: - 1: failed to borrow - 2: borrowed but not repaid - 3: repayment complete | [optional] [readonly] +**Repaid** | **string** | Repaid amount | [optional] [readonly] +**RepaidInterest** | **string** | Repaid interest | [optional] [readonly] +**UnpaidInterest** | **string** | 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/CrossMarginRepayRequest.md b/docs/CrossMarginRepayRequest.md new file mode 100644 index 0000000..ef1b59f --- /dev/null +++ b/docs/CrossMarginRepayRequest.md @@ -0,0 +1,12 @@ +# CrossMarginRepayRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Currency** | **string** | Repayment currency | +**Amount** | **string** | 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) + + diff --git a/docs/CrossMarginRepayment.md b/docs/CrossMarginRepayment.md new file mode 100644 index 0000000..bc23491 --- /dev/null +++ b/docs/CrossMarginRepayment.md @@ -0,0 +1,16 @@ +# CrossMarginRepayment + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Id** | **string** | Loan record ID | [optional] +**CreateTime** | **int64** | Repayment time | [optional] +**LoanId** | **string** | Borrow loan ID | [optional] +**Currency** | **string** | Currency name | [optional] +**Principal** | **string** | Repaid principal | [optional] +**Interest** | **string** | 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) + + diff --git a/docs/DeliveryApi.md b/docs/DeliveryApi.md index 021b126..24242b2 100644 --- a/docs/DeliveryApi.md +++ b/docs/DeliveryApi.md @@ -56,7 +56,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -120,7 +120,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -198,7 +198,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -275,7 +275,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -354,7 +354,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -427,7 +427,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -499,7 +499,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -562,7 +562,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -643,7 +643,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -712,7 +712,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -782,7 +782,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -854,7 +854,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -927,7 +927,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1000,7 +1000,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1087,7 +1087,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1160,7 +1160,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1242,7 +1242,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1315,7 +1315,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1386,7 +1386,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1470,7 +1470,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1549,7 +1549,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1629,7 +1629,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1709,7 +1709,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1790,7 +1790,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1861,7 +1861,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1932,7 +1932,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2003,7 +2003,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2074,7 +2074,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { diff --git a/docs/DeliveryContract.md b/docs/DeliveryContract.md index 8c62a33..54d3f64 100644 --- a/docs/DeliveryContract.md +++ b/docs/DeliveryContract.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **Underlying** | **string** | Underlying | [optional] **Cycle** | **string** | Cycle type, e.g. WEEKLY, QUARTERLY | [optional] **Type** | **string** | Futures contract type | [optional] -**QuantoMultiplier** | **string** | Multiplier used in converting from invoicing to settlement currency in quanto futures | [optional] +**QuantoMultiplier** | **string** | Multiplier used in converting from invoicing to settlement currency | [optional] **LeverageMin** | **string** | Minimum leverage | [optional] **LeverageMax** | **string** | Maximum leverage | [optional] **MaintenanceRate** | **string** | Maintenance rate of margin | [optional] diff --git a/docs/FuturesApi.md b/docs/FuturesApi.md index 85205ab..bc6132f 100644 --- a/docs/FuturesApi.md +++ b/docs/FuturesApi.md @@ -63,7 +63,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -127,7 +127,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -205,7 +205,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -282,7 +282,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -361,7 +361,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -434,7 +434,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -507,7 +507,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -580,7 +580,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -655,7 +655,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -733,7 +733,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -796,7 +796,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -877,7 +877,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -946,7 +946,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1016,7 +1016,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1088,7 +1088,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1139,7 +1139,7 @@ func main() { ## UpdatePositionLeverage -> Position UpdatePositionLeverage(ctx, settle, contract, leverage) +> Position UpdatePositionLeverage(ctx, settle, contract, leverage, optional) Update position leverage @@ -1151,6 +1151,15 @@ Name | Type | Description | Notes **settle** | **string**| Settle currency | **contract** | **string**| Futures contract | **leverage** | **string**| New position leverage | +**optional** | **UpdatePositionLeverageOpts** | optional parameters | nil if no parameters + +### Optional Parameters + +Optional parameters are passed through a pointer to a UpdatePositionLeverageOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**crossLeverageLimit** | **optional.String**| Cross margin leverage(valid only when `leverage` is 0) | ### Example @@ -1161,7 +1170,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1179,7 +1188,7 @@ func main() { contract := "BTC_USDT" // string - Futures contract leverage := "10" // string - New position leverage - result, _, err := client.FuturesApi.UpdatePositionLeverage(ctx, settle, contract, leverage) + result, _, err := client.FuturesApi.UpdatePositionLeverage(ctx, settle, contract, leverage, nil) if err != nil { if e, ok := err.(gateapi.GateAPIError); ok { fmt.Printf("gate api error: %s\n", e.Error()) @@ -1234,7 +1243,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1308,7 +1317,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1379,7 +1388,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1429,7 +1438,7 @@ func main() { ## UpdateDualModePositionMargin -> []Position UpdateDualModePositionMargin(ctx, settle, contract, change) +> []Position UpdateDualModePositionMargin(ctx, settle, contract, change, dualSide) Update position margin in dual mode @@ -1441,6 +1450,7 @@ Name | Type | Description | Notes **settle** | **string**| Settle currency | **contract** | **string**| Futures contract | **change** | **string**| Margin change. Use positive number to increase margin, negative number otherwise. | +**dualSide** | **string**| Long or short position | ### Example @@ -1451,7 +1461,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1468,8 +1478,9 @@ func main() { settle := "usdt" // string - Settle currency contract := "BTC_USDT" // string - Futures contract change := "0.01" // string - Margin change. Use positive number to increase margin, negative number otherwise. + dualSide := "dual_long" // string - Long or short position - result, _, err := client.FuturesApi.UpdateDualModePositionMargin(ctx, settle, contract, change) + result, _, err := client.FuturesApi.UpdateDualModePositionMargin(ctx, settle, contract, change, dualSide) if err != nil { if e, ok := err.(gateapi.GateAPIError); ok { fmt.Printf("gate api error: %s\n", e.Error()) @@ -1524,7 +1535,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1597,7 +1608,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1684,7 +1695,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1758,7 +1769,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1840,7 +1851,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1913,7 +1924,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1984,7 +1995,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2068,7 +2079,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2148,7 +2159,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2228,7 +2239,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2309,7 +2320,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2380,7 +2391,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2451,7 +2462,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2522,7 +2533,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -2593,7 +2604,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { diff --git a/docs/FuturesOrder.md b/docs/FuturesOrder.md index 3c6ce55..7700d39 100644 --- a/docs/FuturesOrder.md +++ b/docs/FuturesOrder.md @@ -8,7 +8,7 @@ Name | Type | Description | Notes **User** | **int32** | User ID | [optional] [readonly] **CreateTime** | **float64** | Order creation time | [optional] [readonly] **FinishTime** | **float64** | Order finished time. Not returned if order is open | [optional] [readonly] -**FinishAs** | **string** | 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] +**FinishAs** | **string** | 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** | **string** | Order status - `open`: waiting to be traded - `finished`: finished | [optional] [readonly] **Contract** | **string** | Futures contract | **Size** | **int64** | Order size. Specify positive number to make a bid, and negative number to ask | diff --git a/docs/MarginAccountCurrency.md b/docs/MarginAccountCurrency.md index 4fdae11..0d0203f 100644 --- a/docs/MarginAccountCurrency.md +++ b/docs/MarginAccountCurrency.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **Available** | **string** | Amount suitable for margin trading. | [optional] **Locked** | **string** | Locked amount, used in margin trading | [optional] **Borrowed** | **string** | Borrowed amount | [optional] +**Interest** | **string** | 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) diff --git a/docs/MarginApi.md b/docs/MarginApi.md index 16f8476..5234c88 100644 --- a/docs/MarginApi.md +++ b/docs/MarginApi.md @@ -23,6 +23,14 @@ Method | HTTP request | Description [**UpdateLoanRecord**](MarginApi.md#UpdateLoanRecord) | **Patch** /margin/loan_records/{loan_record_id} | Modify a loan record [**GetAutoRepayStatus**](MarginApi.md#GetAutoRepayStatus) | **Get** /margin/auto_repay | Retrieve user auto repayment setting [**SetAutoRepay**](MarginApi.md#SetAutoRepay) | **Post** /margin/auto_repay | Update user's auto repayment setting +[**ListCrossMarginCurrencies**](MarginApi.md#ListCrossMarginCurrencies) | **Get** /margin/cross/currencies | Currencies supported by cross margin. +[**GetCrossMarginCurrency**](MarginApi.md#GetCrossMarginCurrency) | **Get** /margin/cross/currencies/{currency} | Retrieve detail of one single currency supported by cross margin +[**GetCrossMarginAccount**](MarginApi.md#GetCrossMarginAccount) | **Get** /margin/cross/accounts | Retrieve cross margin account +[**ListCrossMarginLoans**](MarginApi.md#ListCrossMarginLoans) | **Get** /margin/cross/loans | List cross margin borrow history +[**CreateCrossMarginLoan**](MarginApi.md#CreateCrossMarginLoan) | **Post** /margin/cross/loans | Create a cross margin borrow loan +[**GetCrossMarginLoan**](MarginApi.md#GetCrossMarginLoan) | **Get** /margin/cross/loans/{loan_id} | Retrieve single borrow loan detail +[**ListCrossMarginRepayments**](MarginApi.md#ListCrossMarginRepayments) | **Get** /margin/cross/repayments | Retrieve cross margin repayments +[**RepayCrossMarginLoan**](MarginApi.md#RepayCrossMarginLoan) | **Post** /margin/cross/repayments | Repay cross margin loan ## ListMarginCurrencyPairs @@ -43,7 +51,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -105,7 +113,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -168,7 +176,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -239,7 +247,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -322,7 +330,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -398,7 +406,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -481,7 +489,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -551,7 +559,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -621,7 +629,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -692,7 +700,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -765,7 +773,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -838,7 +846,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -908,7 +916,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -978,7 +986,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1059,7 +1067,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1129,7 +1137,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1202,7 +1210,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1268,7 +1276,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1336,7 +1344,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1382,3 +1390,562 @@ func main() { [[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) + +## ListCrossMarginCurrencies + +> []CrossMarginCurrency ListCrossMarginCurrencies(ctx, ) + +Currencies supported by cross margin. + +### Required Parameters + + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.Background() + + result, _, err := client.MarginApi.ListCrossMarginCurrencies(ctx) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**[]CrossMarginCurrency**](CrossMarginCurrency.md) + +### Authorization + +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) + +## GetCrossMarginCurrency + +> CrossMarginCurrency GetCrossMarginCurrency(ctx, currency) + +Retrieve detail of one single currency supported by cross margin + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**currency** | **string**| Currency name | + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.Background() + currency := "BTC" // string - Currency name + + result, _, err := client.MarginApi.GetCrossMarginCurrency(ctx, currency) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**CrossMarginCurrency**](CrossMarginCurrency.md) + +### Authorization + +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) + +## GetCrossMarginAccount + +> CrossMarginAccount GetCrossMarginAccount(ctx, ) + +Retrieve cross margin account + +### Required Parameters + + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + + result, _, err := client.MarginApi.GetCrossMarginAccount(ctx) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**CrossMarginAccount**](CrossMarginAccount.md) + +### Authorization + +[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) + +## ListCrossMarginLoans + +> []CrossMarginLoan ListCrossMarginLoans(ctx, status, optional) + +List cross margin borrow history + +Sort by creation time in descending order by default. Set `reverse=false` to return ascending results. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**status** | **int32**| Filter by status. Supported values are 2 and 3. | +**optional** | **ListCrossMarginLoansOpts** | optional parameters | nil if no parameters + +### Optional Parameters + +Optional parameters are passed through a pointer to a ListCrossMarginLoansOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**currency** | **optional.String**| Filter by currency | +**limit** | **optional.Int32**| Maximum number of records returned in one list | [default to 100] +**offset** | **optional.Int32**| List offset, starting from 0 | [default to 0] +**reverse** | **optional.Bool**| Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results | [default to true] + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + status := 56 // int32 - Filter by status. Supported values are 2 and 3. + + result, _, err := client.MarginApi.ListCrossMarginLoans(ctx, status, nil) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**[]CrossMarginLoan**](CrossMarginLoan.md) + +### Authorization + +[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) + +## CreateCrossMarginLoan + +> CrossMarginLoan CreateCrossMarginLoan(ctx, crossMarginLoan) + +Create a cross margin borrow loan + +Borrow amount cannot be less than currency minimum borrow amount + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**crossMarginLoan** | [**CrossMarginLoan**](CrossMarginLoan.md)| | + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + crossMarginLoan := gateapi.CrossMarginLoan{} // CrossMarginLoan - + + result, _, err := client.MarginApi.CreateCrossMarginLoan(ctx, crossMarginLoan) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**CrossMarginLoan**](CrossMarginLoan.md) + +### Authorization + +[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) + +## GetCrossMarginLoan + +> CrossMarginLoan GetCrossMarginLoan(ctx, loanId) + +Retrieve single borrow loan detail + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**loanId** | **string**| Borrow loan ID | + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + loanId := "12345" // string - Borrow loan ID + + result, _, err := client.MarginApi.GetCrossMarginLoan(ctx, loanId) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**CrossMarginLoan**](CrossMarginLoan.md) + +### Authorization + +[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) + +## ListCrossMarginRepayments + +> []CrossMarginRepayment ListCrossMarginRepayments(ctx, optional) + +Retrieve cross margin repayments + +Sort by creation time in descending order by default. Set `reverse=false` to return ascending results. + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**optional** | **ListCrossMarginRepaymentsOpts** | optional parameters | nil if no parameters + +### Optional Parameters + +Optional parameters are passed through a pointer to a ListCrossMarginRepaymentsOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**currency** | **optional.String**| | +**loanId** | **optional.String**| | +**limit** | **optional.Int32**| Maximum number of records returned in one list | [default to 100] +**offset** | **optional.Int32**| List offset, starting from 0 | [default to 0] +**reverse** | **optional.Bool**| Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results | [default to true] + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + + result, _, err := client.MarginApi.ListCrossMarginRepayments(ctx, nil) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**[]CrossMarginRepayment**](CrossMarginRepayment.md) + +### Authorization + +[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) + +## RepayCrossMarginLoan + +> []CrossMarginLoan RepayCrossMarginLoan(ctx, crossMarginRepayRequest) + +Repay cross margin loan + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**crossMarginRepayRequest** | [**CrossMarginRepayRequest**](CrossMarginRepayRequest.md)| | + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + crossMarginRepayRequest := gateapi.CrossMarginRepayRequest{} // CrossMarginRepayRequest - + + result, _, err := client.MarginApi.RepayCrossMarginLoan(ctx, crossMarginRepayRequest) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**[]CrossMarginLoan**](CrossMarginLoan.md) + +### Authorization + +[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) diff --git a/docs/Order.md b/docs/Order.md index 579830f..0e8b549 100644 --- a/docs/Order.md +++ b/docs/Order.md @@ -13,13 +13,14 @@ Name | Type | Description | Notes **Status** | **string** | Order status - `open`: to be filled - `closed`: filled - `cancelled`: cancelled | [optional] [readonly] **CurrencyPair** | **string** | Currency pair | **Type** | **string** | Order type. limit - limit order | [optional] [default to TYPE_LIMIT] -**Account** | **string** | Account type. spot - use spot account; margin - use margin account | [optional] [default to ACCOUNT_SPOT] +**Account** | **string** | Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account | [optional] [default to ACCOUNT_SPOT] **Side** | **string** | Order side | **Amount** | **string** | Trade amount | **Price** | **string** | Order price | **TimeInForce** | **string** | 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 TIME_IN_FORCE_GTC] **Iceberg** | **string** | Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally | [optional] -**AutoBorrow** | **bool** | Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. | [optional] +**AutoBorrow** | **bool** | Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. | [optional] +**AutoRepay** | **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** | **string** | Amount left to fill | [optional] [readonly] **FillPrice** | **string** | Total filled in quote currency. Deprecated in favor of `filled_total` | [optional] [readonly] **FilledTotal** | **string** | Total filled in quote currency | [optional] [readonly] diff --git a/docs/Position.md b/docs/Position.md index a193685..73ca441 100644 --- a/docs/Position.md +++ b/docs/Position.md @@ -24,8 +24,9 @@ Name | Type | Description | Notes **HistoryPoint** | **string** | History realized POINT PNL | [optional] [readonly] **AdlRanking** | **int32** | ADL ranking, range from 1 to 5 | [optional] [readonly] **PendingOrders** | **int32** | Current open orders | [optional] [readonly] -**CloseOrder** | [**PositionCloseOrder**](Position_close_order.md) | | [optional] +**CloseOrder** | Pointer to [**PositionCloseOrder**](Position_close_order.md) | | [optional] **Mode** | **string** | Position mode, including: - `single`: dual mode is not enabled- `dual_long`: long position in dual mode- `dual_short`: short position in dual mode | [optional] +**CrossLeverageLimit** | **string** | Cross margin leverage(valid only when `leverage` is 0) | [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/SpotApi.md b/docs/SpotApi.md index eb2a2c9..42e81df 100644 --- a/docs/SpotApi.md +++ b/docs/SpotApi.md @@ -48,7 +48,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -110,7 +110,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -169,7 +169,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -231,7 +231,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -304,7 +304,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -379,7 +379,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -453,7 +453,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -530,7 +530,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -603,7 +603,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -679,7 +679,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -749,7 +749,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -802,7 +802,7 @@ func main() { 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 +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. Spot and margin orders are returned by default. To list cross margin orders, `account` must be set to `cross_margin` ### Required Parameters @@ -819,6 +819,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **page** | **optional.Int32**| Page number | [default to 1] **limit** | **optional.Int32**| Maximum number of records returned in one page in each currency pair | [default to 100] +**account** | **optional.String**| Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account | ### Example @@ -829,7 +830,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -881,6 +882,8 @@ func main() { List orders +Spot and margin orders are returned by default. If cross margin orders are needed, `account` must be set to `cross_margin` + ### Required Parameters Name | Type | Description | Notes @@ -898,6 +901,7 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **page** | **optional.Int32**| Page number | [default to 1] **limit** | **optional.Int32**| Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 | [default to 100] +**account** | **optional.String**| Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account | ### Example @@ -908,7 +912,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -962,6 +966,8 @@ func main() { Create an order +You can place orders with spot, margin or cross margin account through setting the `account `field. It defaults to `spot`, which means spot account is used to place orders. When margin account is used, i.e., `account` is `margin`, `auto_borrow` field can be set to `true` to enable the server to borrow the amount lacked using `POST /margin/loans` when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your **margin account**, which can be updated or queried using `/margin/auto_repay` API. When cross margin account is used, i.e., `account` is `cross_margin`, `auto_borrow` can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's `auto_repay` field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either `cancelled` or `closed`. **Order status** An order waiting to be filled is `open`, and it stays `open` until it is filled totally. If fully filled, order is finished and its status turns to `closed`.If the order is cancelled before it is totally filled, whether or not partially filled, its status is `cancelled`. **Iceberg order** `iceberg` field can be used to set the amount shown. Set to `-1` to hide totally. Note that the hidden part's fee will be charged using taker's fee rate. + ### Required Parameters Name | Type | Description | Notes @@ -978,7 +984,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1031,6 +1037,8 @@ func main() { Cancel all `open` orders in specified currency pair +If `account` is not set, all open orders, including spot, margin and cross margin ones, will be cancelled. You can set `account` to cancel only orders within the specified account + ### Required Parameters Name | Type | Description | Notes @@ -1057,7 +1065,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1128,7 +1136,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1177,10 +1185,12 @@ func main() { ## GetOrder -> Order GetOrder(ctx, orderId, currencyPair) +> Order GetOrder(ctx, orderId, currencyPair, optional) Get a single order +Spot and margin orders are queried by default. If cross margin orders are needed, `account` must be set to `cross_margin` + ### Required Parameters Name | Type | Description | Notes @@ -1188,6 +1198,15 @@ Name | Type | Description | Notes **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **string**| Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. | **currencyPair** | **string**| Currency pair | +**optional** | **GetOrderOpts** | optional parameters | nil if no parameters + +### Optional Parameters + +Optional parameters are passed through a pointer to a GetOrderOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**account** | **optional.String**| Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account | ### Example @@ -1198,7 +1217,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1215,7 +1234,7 @@ func main() { orderId := "12345" // string - Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. currencyPair := "BTC_USDT" // string - Currency pair - result, _, err := client.SpotApi.GetOrder(ctx, orderId, currencyPair) + result, _, err := client.SpotApi.GetOrder(ctx, orderId, currencyPair, nil) if err != nil { if e, ok := err.(gateapi.GateAPIError); ok { fmt.Printf("gate api error: %s\n", e.Error()) @@ -1248,10 +1267,12 @@ func main() { ## CancelOrder -> Order CancelOrder(ctx, orderId, currencyPair) +> Order CancelOrder(ctx, orderId, currencyPair, optional) Cancel a single order +Spot and margin orders are cancelled by default. If trying to cancel cross margin orders, `account` must be set to `cross_margin` + ### Required Parameters Name | Type | Description | Notes @@ -1259,6 +1280,15 @@ Name | Type | Description | Notes **ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. **orderId** | **string**| Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. | **currencyPair** | **string**| Currency pair | +**optional** | **CancelOrderOpts** | optional parameters | nil if no parameters + +### Optional Parameters + +Optional parameters are passed through a pointer to a CancelOrderOpts struct + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**account** | **optional.String**| Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account | ### Example @@ -1269,7 +1299,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1286,7 +1316,7 @@ func main() { orderId := "12345" // string - Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID are accepted only in the first 30 minutes after order creation.After that, only order ID is accepted. currencyPair := "BTC_USDT" // string - Currency pair - result, _, err := client.SpotApi.CancelOrder(ctx, orderId, currencyPair) + result, _, err := client.SpotApi.CancelOrder(ctx, orderId, currencyPair, nil) if err != nil { if e, ok := err.(gateapi.GateAPIError); ok { fmt.Printf("gate api error: %s\n", e.Error()) @@ -1323,6 +1353,8 @@ func main() { List personal trading history +Spot and margin trades are queried by default. If cross margin trades are needed, `account` must be set to `cross_margin` + ### Required Parameters Name | Type | Description | Notes @@ -1340,6 +1372,7 @@ Name | Type | Description | Notes **limit** | **optional.Int32**| Maximum number of records returned in one list | [default to 100] **page** | **optional.Int32**| Page number | [default to 1] **orderId** | **optional.String**| List all trades of specified order | +**account** | **optional.String**| Specify operation account. Default to spot and margin account if not specified. Set to `cross_margin` to operate against margin account | ### Example @@ -1350,7 +1383,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1431,7 +1464,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1500,7 +1533,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1578,7 +1611,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1646,7 +1679,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -1715,7 +1748,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { diff --git a/docs/WalletApi.md b/docs/WalletApi.md index 0fc1ea0..39d2a14 100644 --- a/docs/WalletApi.md +++ b/docs/WalletApi.md @@ -37,7 +37,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -120,7 +120,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -202,7 +202,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -254,7 +254,7 @@ func main() { Transfer between trading accounts -Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery +Transfer between different accounts. Currently support transfers between the following: 1. spot - margin 2. spot - futures(perpetual) 3. spot - delivery 4. spot - cross margin ### Required Parameters @@ -272,7 +272,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -355,7 +355,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -425,7 +425,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -502,7 +502,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -578,7 +578,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -642,7 +642,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { diff --git a/docs/WithdrawalApi.md b/docs/WithdrawalApi.md index da9d3b2..55be306 100644 --- a/docs/WithdrawalApi.md +++ b/docs/WithdrawalApi.md @@ -5,6 +5,7 @@ All URIs are relative to *https://api.gateio.ws/api/v4* Method | HTTP request | Description ------------- | ------------- | ------------- [**Withdraw**](WithdrawalApi.md#Withdraw) | **Post** /withdrawals | Withdraw +[**CancelWithdrawal**](WithdrawalApi.md#CancelWithdrawal) | **Delete** /withdrawals/{withdrawal_id} | Cancel withdrawal with specified ID ## Withdraw @@ -29,7 +30,7 @@ import ( "context" "fmt" - "github.com/gateio/gateapi-go/v5" + "github.com/gateio/gateapi-go/v6" ) func main() { @@ -75,3 +76,72 @@ func main() { [[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) + +## CancelWithdrawal + +> LedgerRecord CancelWithdrawal(ctx, withdrawalId) + +Cancel withdrawal with specified ID + +### Required Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**withdrawalId** | **string**| | + +### Example + +```golang +package main + +import ( + "context" + "fmt" + + "github.com/gateio/gateapi-go/v6" +) + +func main() { + client := gateapi.NewAPIClient(gateapi.NewConfiguration()) + // uncomment the next line if your are testing against testnet + // client.ChangeBasePath("https://fx-api-testnet.gateio.ws/api/v4") + ctx := context.WithValue(context.Background(), + gateapi.ContextGateAPIV4, + gateapi.GateAPIV4{ + Key: "YOUR_API_KEY", + Secret: "YOUR_API_SECRET", + } + ) + withdrawalId := "210496" // string - + + result, _, err := client.WithdrawalApi.CancelWithdrawal(ctx, withdrawalId) + if err != nil { + if e, ok := err.(gateapi.GateAPIError); ok { + fmt.Printf("gate api error: %s\n", e.Error()) + } else { + fmt.Printf("generic error: %s\n", err.Error()) + } + } else { + fmt.Println(result) + } +} +``` + + +### Return type + +[**LedgerRecord**](LedgerRecord.md) + +### Authorization + +[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) diff --git a/go.mod b/go.mod index 991a368..da363b1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/gateio/gateapi-go/v5 +module github.com/gateio/gateapi-go/v6 go 1.12 diff --git a/model_batch_order.go b/model_batch_order.go index 11e4e06..dca87d9 100644 --- a/model_batch_order.go +++ b/model_batch_order.go @@ -35,7 +35,7 @@ type BatchOrder struct { CurrencyPair string `json:"currency_pair,omitempty"` // Order type. limit - limit order Type string `json:"type,omitempty"` - // Account type. spot - use spot account; margin - use margin account + // Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account Account string `json:"account,omitempty"` // Order side Side string `json:"side,omitempty"` @@ -47,8 +47,10 @@ type BatchOrder struct { TimeInForce string `json:"time_in_force,omitempty"` // Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally Iceberg string `json:"iceberg,omitempty"` - // Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. + // Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. AutoBorrow bool `json:"auto_borrow,omitempty"` + // 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. + AutoRepay bool `json:"auto_repay,omitempty"` // Amount left to fill Left string `json:"left,omitempty"` // Total filled in quote currency. Deprecated in favor of `filled_total` diff --git a/model_cancel_order.go b/model_cancel_order.go index 3b50680..679f427 100644 --- a/model_cancel_order.go +++ b/model_cancel_order.go @@ -15,4 +15,6 @@ type CancelOrder struct { CurrencyPair string `json:"currency_pair"` // Order ID or user custom ID. Custom ID are accepted only within 30 minutes after order creation Id string `json:"id"` + // If cancelled order is cross margin order, this field must be set and can only be `cross_margin` + Account string `json:"account,omitempty"` } diff --git a/model_cancel_order_result.go b/model_cancel_order_result.go index 39d2051..ad2f83b 100644 --- a/model_cancel_order_result.go +++ b/model_cancel_order_result.go @@ -21,4 +21,6 @@ type CancelOrderResult struct { Label string `json:"label,omitempty"` // Error message when failed to cancel the order; empty if succeeded Message string `json:"message,omitempty"` + // Empty by default. If cancelled order is cross margin order, this field is set to `cross_margin` + Account string `json:"account,omitempty"` } diff --git a/model_contract.go b/model_contract.go index 67035d7..3b30bf9 100644 --- a/model_contract.go +++ b/model_contract.go @@ -15,7 +15,7 @@ type Contract struct { Name string `json:"name,omitempty"` // Futures contract type Type string `json:"type,omitempty"` - // Multiplier used in converting from invoicing to settlement currency in quanto futures + // Multiplier used in converting from invoicing to settlement currency QuantoMultiplier string `json:"quanto_multiplier,omitempty"` // Minimum leverage LeverageMin string `json:"leverage_min,omitempty"` diff --git a/model_cross_margin_account.go b/model_cross_margin_account.go new file mode 100644 index 0000000..0230cd8 --- /dev/null +++ b/model_cross_margin_account.go @@ -0,0 +1,26 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginAccount struct { + // User ID + UserId int64 `json:"user_id,omitempty"` + // Whether account is locked + Locked bool `json:"locked,omitempty"` + Balances map[string]CrossMarginBalance `json:"balances,omitempty"` + // Total account value in USDT, i.e., the sum of all currencies' `(available+freeze)*price*discount` + Total string `json:"total,omitempty"` + // Total borrowed value in USDT, i.e., the sum of all currencies' `borrowed*price*discount` + Borrowed string `json:"borrowed,omitempty"` + // Total unpaid interests in USDT, i.e., the sum of all currencies' `interest*price*discount` + Interest string `json:"interest,omitempty"` + // Risk rate. When it belows 110%, liquidation will be triggered. Calculation formula: `total / (borrowed+interest)` + Risk string `json:"risk,omitempty"` +} diff --git a/model_cross_margin_balance.go b/model_cross_margin_balance.go new file mode 100644 index 0000000..01f9de1 --- /dev/null +++ b/model_cross_margin_balance.go @@ -0,0 +1,21 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginBalance struct { + // Available amount + Available string `json:"available,omitempty"` + // Locked amount + Freeze string `json:"freeze,omitempty"` + // Borrowed amount + Borrowed string `json:"borrowed,omitempty"` + // Interests unpaid + Interest string `json:"interest,omitempty"` +} diff --git a/model_cross_margin_currency.go b/model_cross_margin_currency.go new file mode 100644 index 0000000..6528ca5 --- /dev/null +++ b/model_cross_margin_currency.go @@ -0,0 +1,29 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginCurrency struct { + // Currency name + Name string `json:"name,omitempty"` + // Loan rate + Rate string `json:"rate,omitempty"` + // Currency precision + Prec string `json:"prec,omitempty"` + // Currency value discount, which is used in total value calculation + Discount string `json:"discount,omitempty"` + // Minimum currency borrow amount. Unit is currency itself + MinBorrowAmount string `json:"min_borrow_amount,omitempty"` + // Maximum borrow value allowed per user, in USDT + UserMaxBorrowAmount string `json:"user_max_borrow_amount,omitempty"` + // Maximum borrow value allowed for this currency, in USDT + TotalMaxBorrowAmount string `json:"total_max_borrow_amount,omitempty"` + // Price change between this currency and USDT + Price string `json:"price,omitempty"` +} diff --git a/model_cross_margin_loan.go b/model_cross_margin_loan.go new file mode 100644 index 0000000..f755067 --- /dev/null +++ b/model_cross_margin_loan.go @@ -0,0 +1,33 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginLoan struct { + // Borrow loan ID + Id string `json:"id,omitempty"` + // Creation timestamp, in milliseconds + CreateTime int64 `json:"create_time,omitempty"` + // Update timestamp, in milliseconds + UpdateTime int64 `json:"update_time,omitempty"` + // Currency name + Currency string `json:"currency"` + // Borrowed amount + Amount string `json:"amount"` + // User defined custom ID + Text string `json:"text,omitempty"` + // Borrow loan status, which includes: - 1: failed to borrow - 2: borrowed but not repaid - 3: repayment complete + Status int32 `json:"status,omitempty"` + // Repaid amount + Repaid string `json:"repaid,omitempty"` + // Repaid interest + RepaidInterest string `json:"repaid_interest,omitempty"` + // Interest not repaid + UnpaidInterest string `json:"unpaid_interest,omitempty"` +} diff --git a/model_cross_margin_repay_request.go b/model_cross_margin_repay_request.go new file mode 100644 index 0000000..b0d7d6d --- /dev/null +++ b/model_cross_margin_repay_request.go @@ -0,0 +1,17 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginRepayRequest struct { + // Repayment currency + Currency string `json:"currency"` + // Repayment amount + Amount string `json:"amount"` +} diff --git a/model_cross_margin_repayment.go b/model_cross_margin_repayment.go new file mode 100644 index 0000000..f3f9118 --- /dev/null +++ b/model_cross_margin_repayment.go @@ -0,0 +1,25 @@ +/* + * Gate API v4 + * + * Welcome to Gate.io API 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. + * + * Contact: support@mail.gate.io + * Generated by: OpenAPI Generator (https://openapi-generator.tech) + */ + +package gateapi + +type CrossMarginRepayment struct { + // Loan record ID + Id string `json:"id,omitempty"` + // Repayment time + CreateTime int64 `json:"create_time,omitempty"` + // Borrow loan ID + LoanId string `json:"loan_id,omitempty"` + // Currency name + Currency string `json:"currency,omitempty"` + // Repaid principal + Principal string `json:"principal,omitempty"` + // Repaid interest + Interest string `json:"interest,omitempty"` +} diff --git a/model_delivery_contract.go b/model_delivery_contract.go index 6106a6b..0934f81 100644 --- a/model_delivery_contract.go +++ b/model_delivery_contract.go @@ -19,7 +19,7 @@ type DeliveryContract struct { Cycle string `json:"cycle,omitempty"` // Futures contract type Type string `json:"type,omitempty"` - // Multiplier used in converting from invoicing to settlement currency in quanto futures + // Multiplier used in converting from invoicing to settlement currency QuantoMultiplier string `json:"quanto_multiplier,omitempty"` // Minimum leverage LeverageMin string `json:"leverage_min,omitempty"` diff --git a/model_futures_order.go b/model_futures_order.go index 47be8d6..d280008 100644 --- a/model_futures_order.go +++ b/model_futures_order.go @@ -19,7 +19,7 @@ type FuturesOrder struct { CreateTime float64 `json:"create_time,omitempty"` // Order finished time. Not returned if order is open FinishTime float64 `json:"finish_time,omitempty"` - // 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 + // 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 FinishAs string `json:"finish_as,omitempty"` // Order status - `open`: waiting to be traded - `finished`: finished Status string `json:"status,omitempty"` diff --git a/model_margin_account_currency.go b/model_margin_account_currency.go index 85a0fb8..e6bbeb3 100644 --- a/model_margin_account_currency.go +++ b/model_margin_account_currency.go @@ -19,4 +19,6 @@ type MarginAccountCurrency struct { Locked string `json:"locked,omitempty"` // Borrowed amount Borrowed string `json:"borrowed,omitempty"` + // Interests unpaid + Interest string `json:"interest,omitempty"` } diff --git a/model_order.go b/model_order.go index 67f8e84..a072d1a 100644 --- a/model_order.go +++ b/model_order.go @@ -29,7 +29,7 @@ type Order struct { CurrencyPair string `json:"currency_pair"` // Order type. limit - limit order Type string `json:"type,omitempty"` - // Account type. spot - use spot account; margin - use margin account + // Account type. spot - use spot account; margin - use margin account; cross_margin - use cross margin account Account string `json:"account,omitempty"` // Order side Side string `json:"side"` @@ -41,8 +41,10 @@ type Order struct { TimeInForce string `json:"time_in_force,omitempty"` // Amount to display for the iceberg order. Null or 0 for normal orders. Set to -1 to hide the amount totally Iceberg string `json:"iceberg,omitempty"` - // Used in margin trading(i.e. `account` is `margin`) to allow automatic loan of insufficient part if balance is not enough. + // Used in margin or cross margin trading to allow automatic loan of insufficient amount if balance is not enough. AutoBorrow bool `json:"auto_borrow,omitempty"` + // 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. + AutoRepay bool `json:"auto_repay,omitempty"` // Amount left to fill Left string `json:"left,omitempty"` // Total filled in quote currency. Deprecated in favor of `filled_total` diff --git a/model_position.go b/model_position.go index 97ce19e..3e262d1 100644 --- a/model_position.go +++ b/model_position.go @@ -50,8 +50,10 @@ type Position struct { // ADL ranking, range from 1 to 5 AdlRanking int32 `json:"adl_ranking,omitempty"` // Current open orders - PendingOrders int32 `json:"pending_orders,omitempty"` - CloseOrder PositionCloseOrder `json:"close_order,omitempty"` + PendingOrders int32 `json:"pending_orders,omitempty"` + CloseOrder *PositionCloseOrder `json:"close_order,omitempty"` // Position mode, including: - `single`: dual mode is not enabled- `dual_long`: long position in dual mode- `dual_short`: short position in dual mode Mode string `json:"mode,omitempty"` + // Cross margin leverage(valid only when `leverage` is 0) + CrossLeverageLimit string `json:"cross_leverage_limit,omitempty"` } diff --git a/model_transfer.go b/model_transfer.go index b61e73e..20a8ae3 100644 --- a/model_transfer.go +++ b/model_transfer.go @@ -9,7 +9,7 @@ package gateapi -// Accounts available to transfer: - `spot`: spot account - `margin`: margin account - `futures`: perpetual futures account - `delivery`: delivery futures account +// Accounts available to transfer: - `spot`: spot account - `margin`: margin account - `futures`: perpetual futures account - `delivery`: delivery futures account - `cross_margin`: cross margin account type Transfer struct { // Transfer currency. For futures account, `currency` can be set to `POINT` or settle currency Currency string `json:"currency"`