diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a725465
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+vendor/
\ No newline at end of file
diff --git a/README.md b/README.md
index 5a57d46..3125238 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# bybit-go-api
-[](https://github.com/wuhewuhe/bybit-go-api) [](https://github.com/wuhewuhe/bybit-go-api) [](https://github.com/wuhewuhe/bybit-go-api/blob/main/LICENSE)
+[](https://github.com/mudrex/bybit-go-api) [](https://github.com/mudrex/bybit-go-api) [](https://github.com/mudrex/bybit-go-api/blob/main/LICENSE)
## Table of Contents
- [About](#about)
- [Development](#development)
@@ -41,7 +41,7 @@ require (
```
To import my package you need just to put the link to your go mode file
-**github.com/wuhewuhe/bybit.go.api**
+**github.com/mudrex/bybit.go.api**
## Usage
Note: Replace placeholders (like YOUR_API_KEY, links, or other details) with the actual information. You can also customize this template to better fit the actual state and details of your Java API.
@@ -163,7 +163,7 @@ List of other contributors
\ No newline at end of file
diff --git a/account.go b/account.go
index ccf993c..b9857fa 100644
--- a/account.go
+++ b/account.go
@@ -2,8 +2,9 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
"net/http"
+
+ "github.com/mudrex/bybit.go.api/handlers"
)
type AccountClient struct {
@@ -234,11 +235,15 @@ func (s *AccountClient) SetCollateralCoin(ctx context.Context, opts ...RequestOp
}
func (s *AccountClient) SetMarginMode(ctx context.Context, opts ...RequestOption) (res *ServerResponse, err error) {
+ if err = handlers.ValidateParams(s.params); err != nil {
+ return nil, err
+ }
r := &request{
method: http.MethodPost,
endpoint: "/v5/account/set-margin-mode",
secType: secTypeSigned,
}
+ r.setParams(s.params)
data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
diff --git a/asset.go b/asset.go
index dc08e92..f907f9c 100644
--- a/asset.go
+++ b/asset.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/broker.go b/broker.go
index a68b1c6..30f1c68 100644
--- a/broker.go
+++ b/broker.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/bybit_api_client.go b/bybit_api_client.go
index b13a9b7..fc30ee5 100644
--- a/bybit_api_client.go
+++ b/bybit_api_client.go
@@ -16,7 +16,7 @@ import (
"github.com/bitly/go-simplejson"
jsoniter "github.com/json-iterator/go"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
diff --git a/bybit_websocket.go b/bybit_websocket.go
index 99e3dd9..78d8513 100644
--- a/bybit_websocket.go
+++ b/bybit_websocket.go
@@ -46,6 +46,7 @@ type WebSocket struct {
onMessage MessageHandler
ctx context.Context
cancel context.CancelFunc
+ isPrivate bool
}
type WebsocketOption func(*WebSocket)
@@ -70,6 +71,7 @@ func NewBybitPrivateWebSocket(url, apiKey, apiSecret string, handler MessageHand
maxAliveTime: "",
pingInterval: 20,
onMessage: handler,
+ isPrivate: true,
}
// Apply the provided options
@@ -152,7 +154,8 @@ func (b *WebSocket) requiresAuthentication() bool {
b.url == WEBSOCKET_PRIVATE_TESTNET ||
b.url == V3_CONTRACT_PRIVATE ||
b.url == V3_UNIFIED_PRIVATE ||
- b.url == V3_SPOT_PRIVATE
+ b.url == V3_SPOT_PRIVATE ||
+ b.isPrivate
}
func (b *WebSocket) sendAuth() error {
diff --git a/examples/Account/get_transaction.go b/examples/Account/get_transaction.go
deleted file mode 100644
index b36271c..0000000
--- a/examples/Account/get_transaction.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package main
-
-import (
- "context"
- "fmt"
- bybit "github.com/wuhewuhe/bybit.go.api"
-)
-
-func main() {
- PlaceTrade()
-}
-
-func PlaceTrade() {
- client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
- params := map[string]interface{}{"accountType": "UNIFIED", "category": "linear"}
- accountResult, err := client.NewAccountService(params).GetTransactionLog(context.Background())
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(bybit.PrettyPrint(accountResult))
-}
diff --git a/examples/Asset/get_coin_info.go b/examples/Asset/get_coin_info.go
deleted file mode 100644
index 2875c42..0000000
--- a/examples/Asset/get_coin_info.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package main
-
-import (
- "context"
- "fmt"
- bybit "github.com/wuhewuhe/bybit.go.api"
-)
-
-func main() {
- GetCoinInfo()
-}
-
-func GetCoinInfo() {
- client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
- params := map[string]interface{}{"coin": "USDT"}
- assetResult, err := client.NewAssetService(params).GetCoinInfo(context.Background())
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(bybit.PrettyPrint(assetResult))
-}
diff --git a/examples/Asset/get_transfer_coin.go b/examples/Asset/get_transfer_coin.go
deleted file mode 100644
index 2c7c5fb..0000000
--- a/examples/Asset/get_transfer_coin.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package main
-
-import (
- "context"
- "fmt"
- bybit "github.com/wuhewuhe/bybit.go.api"
-)
-
-func main() {
- PlaceOrder()
-}
-
-func PlaceOrder() {
- client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
- params := map[string]interface{}{"fromAccountType": "UNIFIED", "toAccountType": "CONTRACT"}
- response, err := client.NewAssetService(params).GetTransferableCoin(context.Background())
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(bybit.PrettyPrint(response))
-}
diff --git a/examples/Trade/place_batch_trade.go b/examples/Trade/place_batch_trade.go
deleted file mode 100644
index bae2836..0000000
--- a/examples/Trade/place_batch_trade.go
+++ /dev/null
@@ -1,51 +0,0 @@
-package main
-
-import (
- "context"
- "fmt"
- bybit "github.com/wuhewuhe/bybit.go.api"
-)
-
-func main() {
- PlaceBatchTrade()
-}
-
-func PlaceBatchTrade() {
- client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
- params := map[string]interface{}{"category": "option",
- "request": []map[string]interface{}{
- {
- "category": "option",
- "symbol": "BTC-10FEB23-24000-C",
- "orderType": "Limit",
- "side": "Buy",
- "qty": "0.1",
- "price": "5",
- "orderIv": "0.1",
- "timeInForce": "GTC",
- "orderLinkId": "9b381bb1-401",
- "mmp": false,
- "reduceOnly": false,
- },
- {
- "category": "option",
- "symbol": "BTC-10FEB23-24000-C",
- "orderType": "Limit",
- "side": "Buy",
- "qty": "0.1",
- "price": "5",
- "orderIv": "0.1",
- "timeInForce": "GTC",
- "orderLinkId": "82ee86dd-001",
- "mmp": false,
- "reduceOnly": false,
- },
- },
- }
- orderResult, err := client.NewTradeService(params).PlaceBatchOrder(context.Background())
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(bybit.PrettyPrint(orderResult))
-}
diff --git a/examples/Trade/place_order.go b/examples/Trade/place_order.go
deleted file mode 100644
index e640850..0000000
--- a/examples/Trade/place_order.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package main
-
-import (
- "context"
- "fmt"
- bybit "github.com/wuhewuhe/bybit.go.api"
-)
-
-func main() {
- PlaceOrder()
-}
-
-func PlaceOrder() {
- client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
- orderResult, err := client.NewPlaceOrderService("linear", "XRPUSDT", "Buy", "Market", "10").Do(context.Background())
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(bybit.PrettyPrint(orderResult))
-}
diff --git a/go.mod b/go.mod
index cb1ade5..0f6bbe3 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module github.com/wuhewuhe/bybit.go.api
+module github.com/mudrex/bybit.go.api
go 1.21
@@ -16,6 +16,6 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
- golang.org/x/net v0.19.0 // indirect
+ golang.org/x/net v0.23.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index 3b3cac7..d90013a 100644
--- a/go.sum
+++ b/go.sum
@@ -10,7 +10,6 @@ github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
-github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -29,8 +28,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
-golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
+golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
+golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/lending.go b/lending.go
index 3e43085..3be4d61 100644
--- a/lending.go
+++ b/lending.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/market_service.go b/market_service.go
index a660dc1..92d055d 100644
--- a/market_service.go
+++ b/market_service.go
@@ -5,7 +5,7 @@ import (
"fmt"
"net/http"
- "github.com/wuhewuhe/bybit.go.api/models"
+ "github.com/mudrex/bybit.go.api/models"
)
// MarketKlinesService Market Kline (GET /v5/market/kline)
diff --git a/market_service_test.go b/market_service_test.go
index 5c85684..c3dd30d 100644
--- a/market_service_test.go
+++ b/market_service_test.go
@@ -4,8 +4,8 @@ import (
"net/http"
"testing"
+ "github.com/mudrex/bybit.go.api/models"
"github.com/stretchr/testify/suite"
- "github.com/wuhewuhe/bybit.go.api/models"
)
type marketTestSuite struct {
@@ -390,12 +390,11 @@ func (s *marketTestSuite) TestInstrumentsInfo() {
"status": "Trading",
"marginTrading": "both",
"lotSizeFilter": {
- "basePrecision": "0.000001",
- "quotePrecision": "0.00000001",
- "minOrderQty": "0.000048",
- "maxOrderQty": "71.73956243",
- "minOrderAmt": "1",
- "maxOrderAmt": "2000000"
+ "minOrderQty": "0.000048",
+ "maxOrderQty": "71.73956243",
+ "minNotionalValue": "5.00",
+ "maxMktOrderQty": "10.0",
+ "postOnlyMaxOrderQty": "71.73956243"
},
"priceFilter": {
"tickSize": "0.01"
@@ -446,11 +445,11 @@ func (s *marketTestSuite) TestInstrumentsInfo() {
Status: "Trading",
MarginTrading: "both",
LotSizeFilter: models.LotSizeFilter{
- BasePrecision: "0.000001",
- QuotePrecision: "0.00000001",
- MinOrderQty: "0.000048",
- MaxOrderQty: "71.73956243", MinOrderAmt: "1",
- MaxOrderAmt: "2000000",
+ MinOrderQty: "0.000048",
+ MaxOrderQty: "71.73956243",
+ MinNotionalValue: "5.00",
+ MaxMktOrderQty: "10.0",
+ PostOnlyMaxOrderQty: "71.73956243",
},
PriceFilter: models.PriceFilter{
TickSize: "0.01",
diff --git a/models/marketResponse.go b/models/marketResponse.go
index c373999..74a2fe6 100644
--- a/models/marketResponse.go
+++ b/models/marketResponse.go
@@ -87,8 +87,12 @@ type Instrument struct {
LotSizeFilter LotSizeFilter `json:"lotSizeFilter"`
UnifiedMarginTrade bool `json:"unifiedMarginTrade"`
FundingInterval int `json:"fundingInterval"`
+ UpperFundingRate string `json:"upperFundingRate"`
+ LowerFundingRate string `json:"lowerFundingRate"`
SettleCoin string `json:"settleCoin"`
CopyTrading string `json:"copyTrading"`
+ IsPreListing bool `json:"isPreListing"`
+ PreListingInfo string `json:"preListingInfo"`
}
type LeverageFilter struct {
@@ -107,18 +111,11 @@ type LotSizeFilter struct {
MaxOrderQty string `json:"maxOrderQty"`
MinOrderQty string `json:"minOrderQty"`
QtyStep string `json:"qtyStep"`
+ MaxMktOrderQty string `json:"maxMktOrderQty"`
+ MinNotionalValue string `json:"minNotionalValue"`
PostOnlyMaxOrderQty string `json:"postOnlyMaxOrderQty"`
- BasePrecision string `json:"basePrecision"`
- QuotePrecision string `json:"quotePrecision"`
- MaxOrderAmt string `json:"maxOrderAmt"`
- MinOrderAmt string `jsoN:"minOrderAmt"`
}
-// type OrderBookEntry struct {
-// Price string `json:"0"`
-// Size string `json:"1"`
-// }
-
type OrderBookEntry []string
type OrderBookInfo struct {
diff --git a/position.go b/position.go
index e331d61..f8d2a46 100644
--- a/position.go
+++ b/position.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/pre_upgrade.go b/pre_upgrade.go
index 84b2041..1d34013 100644
--- a/pre_upgrade.go
+++ b/pre_upgrade.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/spot_leverage.go b/spot_leverage.go
index 58e7fae..8061fa1 100644
--- a/spot_leverage.go
+++ b/spot_leverage.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/spot_margin.go b/spot_margin.go
index f7bb9ab..7a0b67c 100644
--- a/spot_margin.go
+++ b/spot_margin.go
@@ -3,7 +3,7 @@ package bybit_connector
import (
"context"
"errors"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)
diff --git a/trade.go b/trade.go
index 4f674bc..4a3bf81 100644
--- a/trade.go
+++ b/trade.go
@@ -2,8 +2,8 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
- "github.com/wuhewuhe/bybit.go.api/models"
+ "github.com/mudrex/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/models"
"net/http"
)
diff --git a/user.go b/user.go
index fe08604..aba4615 100644
--- a/user.go
+++ b/user.go
@@ -2,7 +2,7 @@ package bybit_connector
import (
"context"
- "github.com/wuhewuhe/bybit.go.api/handlers"
+ "github.com/mudrex/bybit.go.api/handlers"
"net/http"
)