[go: up one dir, main page]

Skip to content

Commit

Permalink
porfolio margin account support
Browse files Browse the repository at this point in the history
  • Loading branch information
revilwang committed Jul 15, 2022
1 parent 788776d commit 3129f42
Show file tree
Hide file tree
Showing 40 changed files with 793 additions and 47 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.24.0
- Package version: 6.24.0
- API version: 4.25.1
- Package version: 6.25.1
- Build package: org.openapitools.codegen.languages.GoClientCodegen
For more information, please visit [https://www.gate.io/page/contacts](https://www.gate.io/page/contacts)

Expand Down Expand Up @@ -114,7 +114,7 @@ Class | Method | HTTP request | Description
*DeliveryApi* | [**CreatePriceTriggeredDeliveryOrder**](docs/DeliveryApi.md#createpricetriggereddeliveryorder) | **Post** /delivery/{settle}/price_orders | Create a price-triggered order
*DeliveryApi* | [**CancelPriceTriggeredDeliveryOrderList**](docs/DeliveryApi.md#cancelpricetriggereddeliveryorderlist) | **Delete** /delivery/{settle}/price_orders | Cancel all open orders
*DeliveryApi* | [**GetPriceTriggeredDeliveryOrder**](docs/DeliveryApi.md#getpricetriggereddeliveryorder) | **Get** /delivery/{settle}/price_orders/{order_id} | Get a single order
*DeliveryApi* | [**CancelPriceTriggeredDeliveryOrder**](docs/DeliveryApi.md#cancelpricetriggereddeliveryorder) | **Delete** /delivery/{settle}/price_orders/{order_id} | Cancel a single order
*DeliveryApi* | [**CancelPriceTriggeredDeliveryOrder**](docs/DeliveryApi.md#cancelpricetriggereddeliveryorder) | **Delete** /delivery/{settle}/price_orders/{order_id} | cancel a price-triggered order
*FlashSwapApi* | [**ListFlashSwapCurrencies**](docs/FlashSwapApi.md#listflashswapcurrencies) | **Get** /flash_swap/currencies | List all supported currencies in flash swap
*FlashSwapApi* | [**ListFlashSwapOrders**](docs/FlashSwapApi.md#listflashswaporders) | **Get** /flash_swap/orders | List all flash swap orders
*FlashSwapApi* | [**CreateFlashSwapOrder**](docs/FlashSwapApi.md#createflashswaporder) | **Post** /flash_swap/orders | Create a flash swap order
Expand Down Expand Up @@ -156,7 +156,7 @@ Class | Method | HTTP request | Description
*FuturesApi* | [**CreatePriceTriggeredOrder**](docs/FuturesApi.md#createpricetriggeredorder) | **Post** /futures/{settle}/price_orders | Create a price-triggered order
*FuturesApi* | [**CancelPriceTriggeredOrderList**](docs/FuturesApi.md#cancelpricetriggeredorderlist) | **Delete** /futures/{settle}/price_orders | Cancel all open orders
*FuturesApi* | [**GetPriceTriggeredOrder**](docs/FuturesApi.md#getpricetriggeredorder) | **Get** /futures/{settle}/price_orders/{order_id} | Get a single order
*FuturesApi* | [**CancelPriceTriggeredOrder**](docs/FuturesApi.md#cancelpricetriggeredorder) | **Delete** /futures/{settle}/price_orders/{order_id} | Cancel a single order
*FuturesApi* | [**CancelPriceTriggeredOrder**](docs/FuturesApi.md#cancelpricetriggeredorder) | **Delete** /futures/{settle}/price_orders/{order_id} | cancel a price-triggered order
*MarginApi* | [**ListMarginCurrencyPairs**](docs/MarginApi.md#listmargincurrencypairs) | **Get** /margin/currency_pairs | List all supported currency pairs supported in margin trading
*MarginApi* | [**GetMarginCurrencyPair**](docs/MarginApi.md#getmargincurrencypair) | **Get** /margin/currency_pairs/{currency_pair} | Query one single margin currency pair
*MarginApi* | [**ListFundingBook**](docs/MarginApi.md#listfundingbook) | **Get** /margin/funding_book | Order book of lending loans
Expand Down Expand Up @@ -186,7 +186,7 @@ Class | Method | HTTP request | Description
*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
*MarginApi* | [**RepayCrossMarginLoan**](docs/MarginApi.md#repaycrossmarginloan) | **Post** /margin/cross/repayments | When the liquidity of the currency is insufficient and the transaction risk is high, the currency will be disabled, and funds cannot be transferred.When the available balance of cross-margin is insufficient, the balance of the spot account can be used for repayment. Please ensure that the balance of the spot account is sufficient, and system uses cross-margin account for repayment first
*MarginApi* | [**GetCrossMarginTransferable**](docs/MarginApi.md#getcrossmargintransferable) | **Get** /margin/cross/transferable | Get the max transferable amount for a specific cross margin currency
*MarginApi* | [**GetCrossMarginBorrowable**](docs/MarginApi.md#getcrossmarginborrowable) | **Get** /margin/cross/borrowable | Get the max borrowable amount for a specific cross margin currency
*OptionsApi* | [**ListOptionsUnderlyings**](docs/OptionsApi.md#listoptionsunderlyings) | **Get** /options/underlyings | List all underlyings
Expand All @@ -195,6 +195,7 @@ Class | Method | HTTP request | Description
*OptionsApi* | [**GetOptionsContract**](docs/OptionsApi.md#getoptionscontract) | **Get** /options/contracts/{contract} | Query specified contract detail
*OptionsApi* | [**ListOptionsSettlements**](docs/OptionsApi.md#listoptionssettlements) | **Get** /options/settlements | List settlement history
*OptionsApi* | [**GetOptionsSettlement**](docs/OptionsApi.md#getoptionssettlement) | **Get** /options/settlements/{contract} | Get specified contract's settlement
*OptionsApi* | [**ListMyOptionsSettlements**](docs/OptionsApi.md#listmyoptionssettlements) | **Get** /options/my_settlements | List my options settlements
*OptionsApi* | [**ListOptionsOrderBook**](docs/OptionsApi.md#listoptionsorderbook) | **Get** /options/order_book | Futures order book
*OptionsApi* | [**ListOptionsTickers**](docs/OptionsApi.md#listoptionstickers) | **Get** /options/tickers | List tickers of options contracts
*OptionsApi* | [**ListOptionsUnderlyingTickers**](docs/OptionsApi.md#listoptionsunderlyingtickers) | **Get** /options/underlying/tickers/{underlying} | Get underlying ticker
Expand Down Expand Up @@ -224,18 +225,20 @@ Class | Method | HTTP request | Description
*SpotApi* | [**ListSpotAccounts**](docs/SpotApi.md#listspotaccounts) | **Get** /spot/accounts | List spot accounts
*SpotApi* | [**CreateBatchOrders**](docs/SpotApi.md#createbatchorders) | **Post** /spot/batch_orders | Create a batch of orders
*SpotApi* | [**ListAllOpenOrders**](docs/SpotApi.md#listallopenorders) | **Get** /spot/open_orders | List all open orders
*SpotApi* | [**CreateCrossLiquidateOrder**](docs/SpotApi.md#createcrossliquidateorder) | **Post** /spot/cross_liquidate_orders | close position when cross-currency is disabled
*SpotApi* | [**ListOrders**](docs/SpotApi.md#listorders) | **Get** /spot/orders | List orders
*SpotApi* | [**CreateOrder**](docs/SpotApi.md#createorder) | **Post** /spot/orders | Create an order
*SpotApi* | [**CancelOrders**](docs/SpotApi.md#cancelorders) | **Delete** /spot/orders | Cancel all `open` orders in specified currency pair
*SpotApi* | [**CancelBatchOrders**](docs/SpotApi.md#cancelbatchorders) | **Post** /spot/cancel_batch_orders | Cancel a batch of orders with an ID list
*SpotApi* | [**GetOrder**](docs/SpotApi.md#getorder) | **Get** /spot/orders/{order_id} | Get a single order
*SpotApi* | [**CancelOrder**](docs/SpotApi.md#cancelorder) | **Delete** /spot/orders/{order_id} | Cancel a single order
*SpotApi* | [**ListMyTrades**](docs/SpotApi.md#listmytrades) | **Get** /spot/my_trades | List personal trading history
*SpotApi* | [**GetSystemTime**](docs/SpotApi.md#getsystemtime) | **Get** /spot/time | Get server current time
*SpotApi* | [**ListSpotPriceTriggeredOrders**](docs/SpotApi.md#listspotpricetriggeredorders) | **Get** /spot/price_orders | Retrieve running auto order list
*SpotApi* | [**CreateSpotPriceTriggeredOrder**](docs/SpotApi.md#createspotpricetriggeredorder) | **Post** /spot/price_orders | Create a price-triggered order
*SpotApi* | [**CancelSpotPriceTriggeredOrderList**](docs/SpotApi.md#cancelspotpricetriggeredorderlist) | **Delete** /spot/price_orders | Cancel all open orders
*SpotApi* | [**GetSpotPriceTriggeredOrder**](docs/SpotApi.md#getspotpricetriggeredorder) | **Get** /spot/price_orders/{order_id} | Get a single order
*SpotApi* | [**CancelSpotPriceTriggeredOrder**](docs/SpotApi.md#cancelspotpricetriggeredorder) | **Delete** /spot/price_orders/{order_id} | Cancel a single order
*SpotApi* | [**CancelSpotPriceTriggeredOrder**](docs/SpotApi.md#cancelspotpricetriggeredorder) | **Delete** /spot/price_orders/{order_id} | cancel a price-triggered order
*WalletApi* | [**ListCurrencyChains**](docs/WalletApi.md#listcurrencychains) | **Get** /wallet/currency_chains | List chains supported for specified currency
*WalletApi* | [**GetDepositAddress**](docs/WalletApi.md#getdepositaddress) | **Get** /wallet/deposit_address | Generate currency deposit address
*WalletApi* | [**ListWithdrawals**](docs/WalletApi.md#listwithdrawals) | **Get** /wallet/withdrawals | Retrieve withdrawal records
Expand Down Expand Up @@ -286,6 +289,7 @@ Class | Method | HTTP request | Description
- [FundingRateRecord](docs/FundingRateRecord.md)
- [FuturesAccount](docs/FuturesAccount.md)
- [FuturesAccountBook](docs/FuturesAccountBook.md)
- [FuturesAccountHistory](docs/FuturesAccountHistory.md)
- [FuturesCandlestick](docs/FuturesCandlestick.md)
- [FuturesIndexConstituents](docs/FuturesIndexConstituents.md)
- [FuturesInitialOrder](docs/FuturesInitialOrder.md)
Expand All @@ -301,6 +305,7 @@ Class | Method | HTTP request | Description
- [IndexConstituent](docs/IndexConstituent.md)
- [InsuranceRecord](docs/InsuranceRecord.md)
- [LedgerRecord](docs/LedgerRecord.md)
- [LiquidateOrder](docs/LiquidateOrder.md)
- [Loan](docs/Loan.md)
- [LoanPatch](docs/LoanPatch.md)
- [LoanRecord](docs/LoanRecord.md)
Expand All @@ -316,6 +321,7 @@ Class | Method | HTTP request | Description
- [OptionsAccount](docs/OptionsAccount.md)
- [OptionsAccountBook](docs/OptionsAccountBook.md)
- [OptionsContract](docs/OptionsContract.md)
- [OptionsMySettlements](docs/OptionsMySettlements.md)
- [OptionsMyTrade](docs/OptionsMyTrade.md)
- [OptionsOrder](docs/OptionsOrder.md)
- [OptionsPosition](docs/OptionsPosition.md)
Expand All @@ -339,6 +345,7 @@ Class | Method | HTTP request | Description
- [SubAccountFuturesBalance](docs/SubAccountFuturesBalance.md)
- [SubAccountMarginBalance](docs/SubAccountMarginBalance.md)
- [SubAccountTransfer](docs/SubAccountTransfer.md)
- [SystemTime](docs/SystemTime.md)
- [Ticker](docs/Ticker.md)
- [TotalBalance](docs/TotalBalance.md)
- [Trade](docs/Trade.md)
Expand Down
2 changes: 1 addition & 1 deletion api_delivery.go
Original file line number Diff line number Diff line change
Expand Up @@ -2790,7 +2790,7 @@ func (a *DeliveryApiService) GetPriceTriggeredDeliveryOrder(ctx context.Context,
}

/*
CancelPriceTriggeredDeliveryOrder Cancel a single order
CancelPriceTriggeredDeliveryOrder cancel a price-triggered order
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param settle Settle currency
* @param orderId Retrieve the data of the order with the specified ID
Expand Down
2 changes: 1 addition & 1 deletion api_futures.go
Original file line number Diff line number Diff line change
Expand Up @@ -3698,7 +3698,7 @@ func (a *FuturesApiService) GetPriceTriggeredOrder(ctx context.Context, settle s
}

/*
CancelPriceTriggeredOrder Cancel a single order
CancelPriceTriggeredOrder cancel a price-triggered order
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param settle Settle currency
* @param orderId Retrieve the data of the order with the specified ID
Expand Down
2 changes: 1 addition & 1 deletion api_margin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ func (a *MarginApiService) ListCrossMarginRepayments(ctx context.Context, localV
}

/*
RepayCrossMarginLoan Repay cross margin loan
RepayCrossMarginLoan When the liquidity of the currency is insufficient and the transaction risk is high, the currency will be disabled, and funds cannot be transferred.When the available balance of cross-margin is insufficient, the balance of the spot account can be used for repayment. Please ensure that the balance of the spot account is sufficient, and system uses cross-margin account for repayment first
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param crossMarginRepayRequest
@return []CrossMarginLoan
Expand Down
121 changes: 121 additions & 0 deletions api_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,127 @@ func (a *OptionsApiService) GetOptionsSettlement(ctx context.Context, contract s
return localVarReturnValue, localVarHTTPResponse, nil
}

// ListMyOptionsSettlementsOpts Optional parameters for the method 'ListMyOptionsSettlements'
type ListMyOptionsSettlementsOpts struct {
Contract optional.String
Limit optional.Int32
Offset optional.Int32
From optional.Int64
To optional.Int64
}

/*
ListMyOptionsSettlements List my options settlements
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param underlying Underlying
* @param optional nil or *ListMyOptionsSettlementsOpts - Optional Parameters:
* @param "Contract" (optional.String) - Contract name
* @param "Limit" (optional.Int32) - Maximum number of records to be returned in a single list
* @param "Offset" (optional.Int32) - List offset, starting from 0
* @param "From" (optional.Int64) - Start timestamp
* @param "To" (optional.Int64) - End timestamp
@return []OptionsMySettlements
*/
func (a *OptionsApiService) ListMyOptionsSettlements(ctx context.Context, underlying string, localVarOptionals *ListMyOptionsSettlementsOpts) ([]OptionsMySettlements, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue []OptionsMySettlements
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/options/my_settlements"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

localVarQueryParams.Add("underlying", parameterToString(underlying, ""))
if localVarOptionals != nil && localVarOptionals.Contract.IsSet() {
localVarQueryParams.Add("contract", parameterToString(localVarOptionals.Contract.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.From.IsSet() {
localVarQueryParams.Add("from", parameterToString(localVarOptionals.From.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.To.IsSet() {
localVarQueryParams.Add("to", parameterToString(localVarOptionals.To.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
}

// ListOptionsOrderBookOpts Optional parameters for the method 'ListOptionsOrderBook'
type ListOptionsOrderBookOpts struct {
Interval optional.String
Expand Down
Loading

0 comments on commit 3129f42

Please sign in to comment.