Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# bybit-go-api
[![GO 1.21.0](https://img.shields.io/badge/Go-1.21.0-brightgreen.svg)](https://github.com/wuhewuhe/bybit-go-api) [![Contributor Victor](https://img.shields.io/badge/contributor-Victor-blue.svg)](https://github.com/wuhewuhe/bybit-go-api) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/wuhewuhe/bybit-go-api/blob/main/LICENSE)
[![GO 1.21.0](https://img.shields.io/badge/Go-1.21.0-brightgreen.svg)](https://github.com/mudrex/bybit-go-api) [![Contributor Victor](https://img.shields.io/badge/contributor-Victor-blue.svg)](https://github.com/mudrex/bybit-go-api) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/mudrex/bybit-go-api/blob/main/LICENSE)
## Table of Contents
- [About](#about)
- [Development](#development)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -163,16 +163,16 @@ List of other contributors
<table>
<tr>
<td align="center">
<a href="https://github.com/wuhewuhe">
<a href="https://github.com/mudrex">
<img src="https://avatars.githubusercontent.com/u/32245754?v=4" width="100px;" alt=""/>
<br />
<sub>
<b>Victor</b>
</sub>
</a>
<br />
<a href="https://github.com/wuhewuhe/bybit-java-api/commits?author=wuhewuhe" title="Code">💻</a>
<a href="https://github.com/wuhewuhe/bybit-java-api/commits?author=wuhewuhe" title="Documentation">📖</a>
<a href="https://github.com/mudrex/bybit-java-api/commits?author=mudrex" title="Code">💻</a>
<a href="https://github.com/mudrex/bybit-java-api/commits?author=mudrex" title="Documentation">📖</a>
</td>
</tr>
</table>
7 changes: 6 additions & 1 deletion account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion bybit_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion bybit_websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type WebSocket struct {
onMessage MessageHandler
ctx context.Context
cancel context.CancelFunc
isPrivate bool
}

type WebsocketOption func(*WebSocket)
Expand All @@ -70,6 +71,7 @@ func NewBybitPrivateWebSocket(url, apiKey, apiSecret string, handler MessageHand
maxAliveTime: "",
pingInterval: 20,
onMessage: handler,
isPrivate: true,
}

// Apply the provided options
Expand Down Expand Up @@ -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 {
Expand Down
22 changes: 0 additions & 22 deletions examples/Account/get_transaction.go

This file was deleted.

22 changes: 0 additions & 22 deletions examples/Asset/get_coin_info.go

This file was deleted.

22 changes: 0 additions & 22 deletions examples/Asset/get_transfer_coin.go

This file was deleted.

51 changes: 0 additions & 51 deletions examples/Trade/place_batch_trade.go

This file was deleted.

21 changes: 0 additions & 21 deletions examples/Trade/place_order.go

This file was deleted.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/wuhewuhe/bybit.go.api
module github.com/mudrex/bybit.go.api

go 1.21

Expand All @@ -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
)
5 changes: 2 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion lending.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion market_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 11 additions & 12 deletions market_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
15 changes: 6 additions & 9 deletions models/marketResponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Loading
Loading