[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
1755 lines (1256 loc) · 50.4 KB

OptionsApi.md

File metadata and controls

1755 lines (1256 loc) · 50.4 KB

OptionsApi

All URIs are relative to https://api.gateio.ws/api/v4

Method HTTP request Description
ListOptionsUnderlyings Get /options/underlyings List all underlyings
ListOptionsExpirations Get /options/expirations List all expiration times
ListOptionsContracts Get /options/contracts List all the contracts with specified underlying and expiration time
GetOptionsContract Get /options/contracts/{contract} Query specified contract detail
ListOptionsSettlements Get /options/settlements List settlement history
GetOptionsSettlement Get /options/settlements/{contract} Get specified contract's settlement
ListMyOptionsSettlements Get /options/my_settlements List my options settlements
ListOptionsOrderBook Get /options/order_book Options order book
ListOptionsTickers Get /options/tickers List tickers of options contracts
ListOptionsUnderlyingTickers Get /options/underlying/tickers/{underlying} Get underlying ticker
ListOptionsCandlesticks Get /options/candlesticks Get options candlesticks
ListOptionsUnderlyingCandlesticks Get /options/underlying/candlesticks Mark price candlesticks of an underlying
ListOptionsTrades Get /options/trades Options trade history
ListOptionsAccount Get /options/accounts List options account
ListOptionsAccountBook Get /options/account_book List account changing history
ListOptionsPositions Get /options/positions List user's positions of specified underlying
GetOptionsPosition Get /options/positions/{contract} Get specified contract position
ListOptionsPositionClose Get /options/position_close List user's liquidation history of specified underlying
ListOptionsOrders Get /options/orders List options orders
CreateOptionsOrder Post /options/orders Create an options order
CancelOptionsOrders Delete /options/orders Cancel all `open` orders matched
GetOptionsOrder Get /options/orders/{order_id} Get a single order
CancelOptionsOrder Delete /options/orders/{order_id} Cancel a single order
ListMyOptionsTrades Get /options/my_trades List personal trading history

ListOptionsUnderlyings

[]OptionsUnderlying ListOptionsUnderlyings(ctx, )

List all underlyings

Required Parameters

Example

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.OptionsApi.ListOptionsUnderlyings(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

[]OptionsUnderlying

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsExpirations

[]int64 ListOptionsExpirations(ctx, underlying)

List all expiration times

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)

Example

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()
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsExpirations(ctx, underlying)
    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

[]int64

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsContracts

[]OptionsContract ListOptionsContracts(ctx, underlying, optional)

List all the contracts with specified underlying and expiration time

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListOptionsContractsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsContractsOpts struct

Name Type Description Notes
expiration optional.Int64 Unix timestamp of the expiration time

Example

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()
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsContracts(ctx, underlying, 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

[]OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetOptionsContract

OptionsContract GetOptionsContract(ctx, contract)

Query specified contract detail

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
contract string

Example

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()
    contract := "BTC_USDT-20211130-65000-C" // string - 
    
    result, _, err := client.OptionsApi.GetOptionsContract(ctx, contract)
    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

OptionsContract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsSettlements

[]OptionsSettlement ListOptionsSettlements(ctx, underlying, optional)

List settlement history

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListOptionsSettlementsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsSettlementsOpts struct

Name Type Description Notes
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp

Example

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()
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsSettlements(ctx, underlying, 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

[]OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetOptionsSettlement

OptionsSettlement GetOptionsSettlement(ctx, contract, underlying, at)

Get specified contract's settlement

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
contract string
underlying string Underlying (Obtained by listing underlying endpoint)
at int64

Example

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()
    contract := "BTC_USDT-20211130-65000-C" // string - 
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    at := 56 // int64 - 
    
    result, _, err := client.OptionsApi.GetOptionsSettlement(ctx, contract, underlying, at)
    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

OptionsSettlement

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListMyOptionsSettlements

[]OptionsMySettlements ListMyOptionsSettlements(ctx, underlying, optional)

List my options settlements

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListMyOptionsSettlementsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListMyOptionsSettlementsOpts struct

Name Type Description Notes
contract optional.String Options contract name
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp

Example

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",
                             }
                            )
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListMyOptionsSettlements(ctx, underlying, 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

[]OptionsMySettlements

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsOrderBook

FuturesOrderBook ListOptionsOrderBook(ctx, contract, optional)

Options order book

Bids will be sorted by price from high to low, while asks sorted reversely

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
contract string Options contract name
optional ListOptionsOrderBookOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsOrderBookOpts struct

Name Type Description Notes
interval optional.String Order depth. 0 means no aggregation is applied. default to 0 [default to 0]
limit optional.Int32 Maximum number of order depth data in asks or bids [default to 10]
withId optional.Bool Whether the order book update ID will be returned. This ID increases by 1 on every order book update [default to false]

Example

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()
    contract := "BTC_USDT-20210916-5000-C" // string - Options contract name
    
    result, _, err := client.OptionsApi.ListOptionsOrderBook(ctx, contract, 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

FuturesOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsTickers

[]OptionsTicker ListOptionsTickers(ctx, underlying)

List tickers of options contracts

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)

Example

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()
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsTickers(ctx, underlying)
    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

[]OptionsTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsUnderlyingTickers

OptionsUnderlyingTicker ListOptionsUnderlyingTickers(ctx, underlying)

Get underlying ticker

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying

Example

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()
    underlying := "BTC_USDT" // string - Underlying
    
    result, _, err := client.OptionsApi.ListOptionsUnderlyingTickers(ctx, underlying)
    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

OptionsUnderlyingTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsCandlesticks

[]OptionsCandlestick ListOptionsCandlesticks(ctx, contract, optional)

Get options candlesticks

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
contract string Options contract name
optional ListOptionsCandlesticksOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsCandlesticksOpts struct

Name Type Description Notes
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp
interval optional.String Interval time between data points [default to 5m]

Example

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()
    contract := "BTC_USDT-20210916-5000-C" // string - Options contract name
    
    result, _, err := client.OptionsApi.ListOptionsCandlesticks(ctx, contract, 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

[]OptionsCandlestick

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsUnderlyingCandlesticks

[]FuturesCandlestick ListOptionsUnderlyingCandlesticks(ctx, underlying, optional)

Mark price candlesticks of an underlying

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListOptionsUnderlyingCandlesticksOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsUnderlyingCandlesticksOpts struct

Name Type Description Notes
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp
interval optional.String Interval time between data points [default to 5m]

Example

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()
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsUnderlyingCandlesticks(ctx, underlying, 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

[]FuturesCandlestick

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsTrades

[]FuturesTrade ListOptionsTrades(ctx, optional)

Options trade history

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional ListOptionsTradesOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsTradesOpts struct

Name Type Description Notes
contract optional.String Options contract name
type_ optional.String `C` is call, while `P` is put
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp

Example

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.OptionsApi.ListOptionsTrades(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

[]FuturesTrade

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsAccount

OptionsAccount ListOptionsAccount(ctx, )

List options account

Required Parameters

Example

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.OptionsApi.ListOptionsAccount(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

OptionsAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsAccountBook

[]OptionsAccountBook ListOptionsAccountBook(ctx, optional)

List account changing history

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional ListOptionsAccountBookOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsAccountBookOpts struct

Name Type Description Notes
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp
type_ optional.String Changing Type: - dnw: Deposit & Withdraw - prem: Trading premium - fee: Trading fee - refr: Referrer rebate - set: settlement PNL

Example

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.OptionsApi.ListOptionsAccountBook(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

[]OptionsAccountBook

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsPositions

[]OptionsPosition ListOptionsPositions(ctx, optional)

List user's positions of specified underlying

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional ListOptionsPositionsOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsPositionsOpts struct

Name Type Description Notes
underlying optional.String Underlying

Example

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.OptionsApi.ListOptionsPositions(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

[]OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetOptionsPosition

OptionsPosition GetOptionsPosition(ctx, contract)

Get specified contract position

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
contract string

Example

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",
                             }
                            )
    contract := "BTC_USDT-20211130-65000-C" // string - 
    
    result, _, err := client.OptionsApi.GetOptionsPosition(ctx, contract)
    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

OptionsPosition

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsPositionClose

[]OptionsPositionClose ListOptionsPositionClose(ctx, underlying, optional)

List user's liquidation history of specified underlying

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListOptionsPositionCloseOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsPositionCloseOpts struct

Name Type Description Notes
contract optional.String Options contract name

Example

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",
                             }
                            )
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListOptionsPositionClose(ctx, underlying, 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

[]OptionsPositionClose

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListOptionsOrders

[]OptionsOrder ListOptionsOrders(ctx, status, optional)

List options orders

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
status string Only list the orders with this status
optional ListOptionsOrdersOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListOptionsOrdersOpts struct

Name Type Description Notes
contract optional.String Options contract name
underlying optional.String Underlying
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp

Example

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 := "open" // string - Only list the orders with this status
    
    result, _, err := client.OptionsApi.ListOptionsOrders(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

[]OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CreateOptionsOrder

OptionsOrder CreateOptionsOrder(ctx, optionsOrder)

Create an options order

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optionsOrder OptionsOrder

Example

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",
                             }
                            )
    optionsOrder := gateapi.OptionsOrder{} // OptionsOrder - 
    
    result, _, err := client.OptionsApi.CreateOptionsOrder(ctx, optionsOrder)
    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

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CancelOptionsOrders

[]OptionsOrder CancelOptionsOrders(ctx, optional)

Cancel all open orders matched

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
optional CancelOptionsOrdersOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a CancelOptionsOrdersOpts struct

Name Type Description Notes
contract optional.String Options contract name
underlying optional.String Underlying
side optional.String All bids or asks. Both included if not specified

Example

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.OptionsApi.CancelOptionsOrders(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

[]OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

GetOptionsOrder

OptionsOrder GetOptionsOrder(ctx, orderId)

Get a single order

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
orderId int64 Order ID returned on successful order creation

Example

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",
                             }
                            )
    orderId := 12345 // int64 - Order ID returned on successful order creation
    
    result, _, err := client.OptionsApi.GetOptionsOrder(ctx, orderId)
    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

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

CancelOptionsOrder

OptionsOrder CancelOptionsOrder(ctx, orderId)

Cancel a single order

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
orderId int64 Order ID returned on successful order creation

Example

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",
                             }
                            )
    orderId := 12345 // int64 - Order ID returned on successful order creation
    
    result, _, err := client.OptionsApi.CancelOptionsOrder(ctx, orderId)
    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

OptionsOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]

ListMyOptionsTrades

[]OptionsMyTrade ListMyOptionsTrades(ctx, underlying, optional)

List personal trading history

Required Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
underlying string Underlying (Obtained by listing underlying endpoint)
optional ListMyOptionsTradesOpts optional parameters nil if no parameters

Optional Parameters

Optional parameters are passed through a pointer to a ListMyOptionsTradesOpts struct

Name Type Description Notes
contract optional.String Options contract name
limit optional.Int32 Maximum number of records to be returned in a single list [default to 100]
offset optional.Int32 List offset, starting from 0 [default to 0]
from optional.Int64 Start timestamp
to optional.Int64 End timestamp

Example

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",
                             }
                            )
    underlying := "BTC_USDT" // string - Underlying (Obtained by listing underlying endpoint)
    
    result, _, err := client.OptionsApi.ListMyOptionsTrades(ctx, underlying, 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

[]OptionsMyTrade

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

[Back to top] [Back to API list] [Back to Model list] [Back to README]