Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge/adshao-master #14

Merged
merged 34 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4a82de2
Signed-off-by: one230six <723682061@qq.com> (#550)
one230six Apr 22, 2024
dc7abf8
Add functions to fetch funding rate data from market (#552)
Issengaard May 11, 2024
6d8559f
changed bool types to string in reduceOnly, closePosition, priceProte…
size12 Jun 3, 2024
5c4ac82
Implement subaccount transfer history and refactor user universal tra…
wayne163 Jun 19, 2024
5824a29
complete options module (#568)
xyq-c-cpp Jun 19, 2024
418ff24
update README.md and add the way to set up websocket proxy. (#571)
xyq-c-cpp Jun 20, 2024
1ba84a6
Optimize request error handling process (#572)
xyq-c-cpp Jun 22, 2024
c2c4643
feature: support signature key Rsa and ed25519 (#579)
xyq-c-cpp Jun 24, 2024
130172e
add: /sapi/v1/convert (#578)
nlypage Jun 24, 2024
b3a9097
fix batchOrder response and fix futures.WsUserDataEvent.Time error wh…
xyq-c-cpp Jun 24, 2024
a387a5b
fix current existly typos (#582)
xyq-c-cpp Jun 26, 2024
81cc831
complete market interfaces unimplemented in futures (#586)
xyq-c-cpp Jun 29, 2024
e328ca1
Adding uid into the account service response (#587)
yaoding16 Jul 1, 2024
91b5816
complete sub-master interface(subaccount_service.go); complete spot m…
xyq-c-cpp Jul 4, 2024
5905362
fix some problems: (#590)
xyq-c-cpp Jul 9, 2024
67095c2
implement futures orderbook history
wayne163 Jul 31, 2024
2ac2df0
add fee burn service
0x0001 Aug 2, 2024
e0bbc76
feat: added omitZeroBalances param for the GetAccountService
mdawar Aug 6, 2024
639815a
Merge pull request #599 from 0x0001/master
xyq-c-cpp Aug 7, 2024
d45dcb3
Merge pull request #603 from mdawar/balances
xyq-c-cpp Aug 7, 2024
5dd8ab3
feat: update futures service arguments
wayne163 Aug 8, 2024
6189b9c
Merge pull request #596 from Croomburg/feature/futures-history-data
xyq-c-cpp Aug 8, 2024
d2b44ab
fix: added missing fields in GetAllCoinsInfoService Network structure…
paul1319 Aug 10, 2024
29b236e
Make future order ModifyService (#605)
StiveMan1 Aug 10, 2024
3e5ad9a
fix PUT /fapi/v1/order
Aug 12, 2024
a3f8064
improve comments
Aug 12, 2024
8405251
Merge pull request #607 from lyro41/fix-modify-order-endpoint
xyq-c-cpp Aug 13, 2024
5548d1a
finish futures algo services (#608)
wayne163 Aug 19, 2024
d0c0e04
support combined futures bookticker ws event (#616)
zhouziyan Sep 6, 2024
2e3a2bd
add usds-futures convert service (#617)
0x0001 Sep 10, 2024
0a3c89e
Fixes adshao/go-binance#618 (#619)
0x0001 Sep 11, 2024
4b74da2
Fixes adshao/go-binance#612 (#620)
0x0001 Sep 13, 2024
5cd9a73
Merge remote-tracking branch 'upstream/master'
thanhpp Sep 24, 2024
71c6dae
fix: 🔧 typos.toml
thanhpp Sep 24, 2024
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
8 changes: 8 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ on:
workflow_dispatch:

jobs:
TyposCheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@v1.22.7
with:
config: ./typos.toml

UnitTest:
runs-on: ubuntu-latest
steps:
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ Name | Description | Status
[web-socket-streams.md](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md) | Details on available streams and payloads | <input type="checkbox" checked> Implemented
[user-data-stream.md](https://github.com/binance/binance-spot-api-docs/blob/master/user-data-stream.md) | Details on the dedicated account stream | <input type="checkbox" checked> Implemented
[margin-api.md](https://binance-docs.github.io/apidocs/spot/en) | Details on the Margin API (/sapi) | <input type="checkbox" checked> Implemented
[futures-api.md](https://binance-docs.github.io/apidocs/futures/en/#general-info) | Details on the Futures API (/fapi) | <input type="checkbox" checked> Partially Implemented
[delivery-api.md](https://binance-docs.github.io/apidocs/delivery/en/#general-info) | Details on the Coin-M Futures API (/dapi) | <input type="checkbox" checked> Partially Implemented
[futures-api.md](https://binance-docs.github.io/apidocs/futures/en/#general-info) | Details on the Futures API (/fapi) | <input type="checkbox" checked> Implemented
[delivery-api.md](https://binance-docs.github.io/apidocs/delivery/en/#general-info) | Details on the Coin-M Futures API (/dapi) | <input type="checkbox" checked> Implemented
[options-api.md](https://binance-docs.github.io/apidocs/voptions/en/#general-info) | Details on the Options API(/eapi) | <input type="checkbox" checked> Implemented


If you find an unimplemented interface, please submit an issue. It's great if you can open a PR to fix it.

### Installation

Expand All @@ -40,7 +44,12 @@ go get github.com/adshao/go-binance/v1

```golang
import (
// for spot and other interfaces contained in https://binance-docs.github.io/apidocs/spot/en/#change-log
"github.com/adshao/go-binance/v2"

"github.com/adshao/go-binance/v2/futures" // optional package
"github.com/adshao/go-binance/v2/delivery" // optional package
"github.com/adshao/go-binance/v2/options" // optional package
)
```

Expand Down Expand Up @@ -70,6 +79,16 @@ Simply call API in chain style. Call Do() in the end to send HTTP request.

Following are some simple examples, please refer to [godoc](https://godoc.org/github.com/adshao/go-binance) for full references.

If you have any questions, please refer to the specific version of the code for specific reference definitions or usage methods

##### Proxy Client

```
proxyUrl := "http://127.0.0.1:7890" // Please replace it with your exact proxy URL.
client := binance.NewProxiedClient(apiKey, apiSecret, proxyUrl)
```


#### Create Order

```golang
Expand Down Expand Up @@ -219,6 +238,12 @@ You don't need Client in websocket API. Just call binance.WsXxxServe(args, handl

> For delivery API you can use `delivery.WsXxxServe(args, handler, errHandler)`.

If you want to use a proxy, you can set `HTTPS_PROXY` or `HTTP_PROXY` in the environment variable, or you can call `SetWsProxyUrl` in the target packages within your code. Then you can call other websocket functions. For example:
```golang
binance.SetWsProxyUrl("http://127.0.0.1:7890")
binance.WsDepthServe("LTCBTC", wsDepthHandler, errHandler)
```

#### Depth

```golang
Expand Down
19 changes: 19 additions & 0 deletions typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[files]
ignore-files = true
ignore-hidden = false
extend-exclude = [".git/", "v2/go.mod", "v2/go.sum", "v2/go.work.sum"]


[default]
extend-ignore-re = [
"ios_54d9b18d8e7a4caf9d149573e16480ba",
"Pn",
"SIZ9",
"alo",
"ot",
"[Cc]ummulative",
"OTU",
"[Tt]ransfered",
"[Mm]arginable",
]
check-filename = true
15 changes: 14 additions & 1 deletion v2/account_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ import (

// GetAccountService get account info
type GetAccountService struct {
c *Client
c *Client
omitZeroBalances *bool
}

// OmitZeroBalances sets the omitZeroBalances parameter on the request.
// When set to true, the API will return the non-zero balances of an account.
func (s *GetAccountService) OmitZeroBalances(v bool) *GetAccountService {
s.omitZeroBalances = &v
return s
}

// Do send request
Expand All @@ -17,6 +25,10 @@ func (s *GetAccountService) Do(ctx context.Context, opts ...RequestOption) (res
endpoint: "/api/v3/account",
secType: secTypeSigned,
}
if s.omitZeroBalances != nil {
r.setParam("omitZeroBalances", *s.omitZeroBalances)
}

data, err := s.c.callAPI(ctx, r, opts...)
if err != nil {
return nil, err
Expand All @@ -43,6 +55,7 @@ type Account struct {
AccountType string `json:"accountType"`
Balances []Balance `json:"balances"`
Permissions []string `json:"permissions"`
UID int64 `json:"uid"`
}

// Balance define user balance of your account
Expand Down
14 changes: 11 additions & 3 deletions v2/account_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,22 @@ func (s *accountServiceTestSuite) TestGetAccount() {
],
"permissions": [
"SPOT"
]
],
"uid": 354937868
}`)
s.mockDo(data, nil)
defer s.assertDo()

omitZeroBalances := true

s.assertReq(func(r *request) {
e := newSignedRequest()
e := newSignedRequest().setParams(params{
"omitZeroBalances": omitZeroBalances,
})
s.assertRequestEqual(e, r)
})

res, err := s.client.NewGetAccountService().Do(newContext())
res, err := s.client.NewGetAccountService().OmitZeroBalances(omitZeroBalances).Do(newContext())
s.r().NoError(err)
e := &Account{
MakerCommission: 15,
Expand Down Expand Up @@ -85,6 +91,7 @@ func (s *accountServiceTestSuite) TestGetAccount() {
},
},
Permissions: []string{"SPOT"},
UID: 354937868,
}
s.assertAccountEqual(e, res)
}
Expand All @@ -108,6 +115,7 @@ func (s *accountServiceTestSuite) assertAccountEqual(e, a *Account) {
r.Equal(e.Balances[i].Free, a.Balances[i].Free, "Free")
r.Equal(e.Balances[i].Locked, a.Balances[i].Locked, "Locked")
}
r.Equal(e.UID, a.UID, "UID")
}

func (s *accountServiceTestSuite) TestGetAccountSnapshot() {
Expand Down
3 changes: 3 additions & 0 deletions v2/asset_detail_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ type Network struct {
WithdrawMax string `json:"withdrawMax"`
WithdrawMin string `json:"withdrawMin"`
SameAddress bool `json:"sameAddress"` // 是否需要memo
EstimatedArrivalTime int `json:"estimatedArrivalTime"`
Busy bool `json:"busy"`
ContractAddressUrl string `json:"contractAddressUrl"`
ContractAddress string `json:"contractAddress"`
}

Expand Down
16 changes: 14 additions & 2 deletions v2/asset_detail_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func (s *assetDetailServiceTestSuite) TestGetAllCoinsInfo() {
"withdrawIntegerMultiple": "0.00000001",
"withdrawMax": "9999999999.99999999",
"withdrawMin": "0.00000440",
"sameAddress": true
"sameAddress": true,
"estimatedArrivalTime": 25,
"busy": false,
"contractAddressUrl": "https://bscscan.com/token/",
"contractAddress": "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c"
},
{
"addressRegex": "^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$",
Expand All @@ -96,7 +100,11 @@ func (s *assetDetailServiceTestSuite) TestGetAllCoinsInfo() {
"withdrawIntegerMultiple": "0.00000001",
"withdrawMax": "750",
"withdrawMin": "0.00100000",
"sameAddress": false
"sameAddress": false,
"estimatedArrivalTime": 25,
"busy": false,
"contractAddressUrl": "",
"contractAddress": ""
}
],
"storage": "0.00000000",
Expand All @@ -118,6 +126,10 @@ func (s *assetDetailServiceTestSuite) TestGetAllCoinsInfo() {
s.r().NoError(err)
s.r().Equal(res[0].DepositAllEnable, true, "depositAllEnable")
s.r().Equal(res[0].NetworkList[0].WithdrawEnable, false, "withdrawEnable")
s.r().Equal(res[0].NetworkList[0].EstimatedArrivalTime, 25, "estimatedArrivalTime")
s.r().Equal(res[0].NetworkList[0].Busy, false, "busy")
s.r().Equal(res[0].NetworkList[0].ContractAddressUrl, "https://bscscan.com/token/", "contractAddressUrl")
s.r().Equal(res[0].NetworkList[0].ContractAddress, "0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c", "contractAddress")
s.r().Equal(res[0].NetworkList[1].MinConfirm, 1, "minConfirm")
}

Expand Down
Loading
Loading