[go: up one dir, main page]

Skip to content

Commit

Permalink
release v6.56.0
Browse files Browse the repository at this point in the history
  • Loading branch information
revilwang committed Oct 8, 2023
1 parent a7844db commit 54757cd
Show file tree
Hide file tree
Showing 120 changed files with 6,691 additions and 113 deletions.
65 changes: 60 additions & 5 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _example/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example Application

This is a demo application using `gateapi` to show how Gate APIv4 works.
This is a demo application using `gateapi` to show how Gate APIv4 works.
Instead of running it, it is recommended to read the source code to get a general idea of
how this SDK is used. However, you can modify this code directly to implement your own logic.

Expand All @@ -15,7 +15,7 @@ mkdir gateapi-demo && cd gateapi-demo

# install required dependency
go mod init
go get github.com/gateio/gateapi-go/v6
go get github.com/gateio/gateapi-go/v5
go get github.com/shopspring/decimal

# build the demo application
Expand Down
8 changes: 3 additions & 5 deletions _example/futures.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/antihax/optional"
"github.com/gateio/gateapi-go/v6"
"github.com/gateio/gateapi-go/v5"
"github.com/shopspring/decimal"
)

Expand All @@ -24,7 +24,7 @@ func FuturesDemo(config *RunConfig) {

// update position leverage
leverage := "3"
_, _, err := client.FuturesApi.UpdatePositionLeverage(ctx, settle, contract, leverage, nil)
_, _, err := client.FuturesApi.UpdatePositionLeverage(ctx, settle, contract, leverage)
if err != nil {
panicGateError(err)
}
Expand Down Expand Up @@ -102,13 +102,11 @@ func FuturesDemo(config *RunConfig) {
From: "spot",
To: "futures",
Amount: margin.String(),
Settle: settle,
}
tx, _, err := client.WalletApi.Transfer(ctx, transfer)
_, err := client.WalletApi.Transfer(ctx, transfer)
if err != nil {
panicGateError(err)
}
logger.Printf("transferred %s %s to futures %s account, transfer ID %d\n", transfer.Amount, transfer.Currency, transfer.Settle, tx.TxId)
}

// example to cancel all open orders in contract
Expand Down
2 changes: 1 addition & 1 deletion _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"time"

"github.com/gateio/gateapi-go/v6"
"github.com/gateio/gateapi-go/v5"
)

var logger = log.New(flag.CommandLine.Output(), "", log.LstdFlags)
Expand Down
6 changes: 3 additions & 3 deletions _example/margin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/antihax/optional"
"github.com/gateio/gateapi-go/v6"
"github.com/gateio/gateapi-go/v5"
"github.com/shopspring/decimal"
)

Expand Down Expand Up @@ -116,11 +116,11 @@ func MarginDemo(config *RunConfig) {
Amount: margin.Sub(available).Round(8).String(),
CurrencyPair: currencyPair,
}
tx, _, err := client.WalletApi.Transfer(ctx, transfer)
_, err := client.WalletApi.Transfer(ctx, transfer)
if err != nil {
panicGateError(err)
}
logger.Printf("transferred %s %s to margin account, transfer ID %d\n", transfer.Amount, transfer.Currency, tx.TxId)
logger.Printf("transferred %s %s to margin account\n", transfer.Amount, transfer.Amount)
}

// borrow with minimum amount
Expand Down
12 changes: 5 additions & 7 deletions _example/spot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/antihax/optional"
"github.com/gateio/gateapi-go/v6"
"github.com/gateio/gateapi-go/v5"
"github.com/shopspring/decimal"
)

Expand Down Expand Up @@ -62,12 +62,12 @@ func SpotDemo(config *RunConfig) {
}
logger.Printf("order created with ID: %s, status: %s\n", createdOrder.Id, createdOrder.Status)
if createdOrder.Status == "open" {
order, _, err := client.SpotApi.GetOrder(ctx, createdOrder.Id, createdOrder.CurrencyPair, nil)
order, _, err := client.SpotApi.GetOrder(ctx, createdOrder.Id, createdOrder.CurrencyPair)
if err != nil {
panicGateError(err)
}
logger.Printf("order %s filled: %s, left: %s\n", order.Id, order.FilledTotal, order.Left)
result, _, err := client.SpotApi.CancelOrder(ctx, createdOrder.Id, createdOrder.CurrencyPair, nil)
result, _, err := client.SpotApi.CancelOrder(ctx, createdOrder.Id, createdOrder.CurrencyPair)
if err != nil {
panicGateError(err)
}
Expand All @@ -76,10 +76,8 @@ func SpotDemo(config *RunConfig) {
}
} else {
// order finished
trades, _, err := client.SpotApi.ListMyTrades(ctx, &gateapi.ListMyTradesOpts{
CurrencyPair: optional.NewString(createdOrder.CurrencyPair),
OrderId: optional.NewString(createdOrder.Id),
})
trades, _, err := client.SpotApi.ListMyTrades(ctx, createdOrder.CurrencyPair,
&gateapi.ListMyTradesOpts{OrderId: optional.NewString(createdOrder.Id)})
if err != nil {
panicGateError(err)
}
Expand Down

0 comments on commit 54757cd

Please sign in to comment.