Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
- name: Detect modified targets
id: filter
run: |
echo "Detected all clients: [\"common\"]"
echo "modified_targets=[\"common\"]" >> $GITHUB_OUTPUT
ALL_CLIENTS=$(ls -d clients/*/ | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
echo "Detected all clients: $ALL_CLIENTS"
echo "modified_targets=$ALL_CLIENTS" >> $GITHUB_OUTPUT

build-target:
needs: detect-targets
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jobs:
- name: Detect all clients
id: detect
run: |
echo "clients=[\"common\"]" >> $GITHUB_OUTPUT
ALL_CLIENTS=$(ls -d clients/*/ | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
echo "Detected all clients: $ALL_CLIENTS"
echo "clients=$ALL_CLIENTS" >> $GITHUB_OUTPUT

release:
needs: detect-clients
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,51 @@ Before using the SDK, ensure you have:
- **Go** (version 1.24 or later)
- **Go Modules** (for dependency management)

## Available SDK

- [binance-connector-algo](./clients/algo) - Algo Trading connector
- [binance-connector-c2c](./clients/c2c/) - C2
- [binance-sdk-convert](./clients/convert/) - Convert connector
- [binance-sdk-copy-trading](./clients/copy-trading/) - Copy Trading connector
- [binance-sdk-crypto-loan](./clients/crypto-loan/) - Crypto Loan connector
- [binance-sdk-derivatives-trading-coin-futures](./clients/derivatives-trading-coin-futures/) - Coin Futures Trading connector
- [binance-sdk-derivatives-trading-options](./clients/derivatives-trading-options/) - Options Trading connector
- [binance-sdk-derivatives-trading-portfolio-margin](./clients/derivatives-trading-portfolio-margin/) - Portfolio Margin Futures Trading connector
- [binance-sdk-derivatives-trading-portfolio-margin-pro](./clients/derivatives-trading-portfolio-margin-pro/) - Portfolio Margin Pro Trading connector
- [binance-sdk-derivatives-trading-usds-futures](./clients/derivatives-trading-usds-futures/) - USDs Futures Trading connector
- [binance-sdk-dual-investment](./clients/dual-investment/) - Dual Investment connector
- [binance-sdk-fiat](./clients/fiat/) - Fiat connector
- [binance-sdk-gift-card](./clients/gift-card/) - Gift Card connector
- [binance-sdk-margin-trading](./clients/margin-trading/) - Margin Trading connector
- [binance-sdk-mining](./clients/mining/) - Mining connector
- [binance-sdk-nft](./clients/nft/) - NFT connector
- [binance-sdk-pay](./clients/pay/) - Pay connector
- [binance-sdk-rebate](./clients/rebate/) - Rebate connector
- [binance-sdk-simple-earn](./clients/simple-earn/) - Simple Earn connector
- [binance-sdk-spot](./clients/spot/) - Spot Trading connector
- [binance-sdk-staking](./clients/staking/) - Staking connector
- [binance-sdk-sub-account](./clients/sub-account/) - Sub Account connector
- [binance-sdk-vip-loan](./clients/vip-loan/) - VIP Loan connector
- [binance-sdk-wallet](./clients/wallet/) - Wallet connector

## Documentation

For detailed information, refer to the [Binance API Documentation](https://developers.binance.com).

## Installation

Each connector is published as a separate Python package. You can install them via `go get`. For example:

```bash
go get github.com/binance/binance-connector-go/clients/spot
```

Or to install multiple connectors:

```bash
go get github.com/binance/binance-connector-go/clients/spot github.com/binance/binance-connector-go/clients/margintrading github.com/binance/binance-connector-go/clients/wallet
```

## Contributing

Since this repository contains auto-generated code using OpenAPI Generator, we encourage you to:
Expand All @@ -23,4 +68,4 @@ Since this repository contains auto-generated code using OpenAPI Generator, we e

## License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE.md) file for details.
This project is licensed under the MIT License - see the [LICENSE](./LICENSE.md) file for details.
3 changes: 3 additions & 0 deletions clients/algo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage.txt
*.DS_Store
.idea
3 changes: 3 additions & 0 deletions clients/algo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0 - 2025-12-15

- Initial release
21 changes: 21 additions & 0 deletions clients/algo/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Binance

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
189 changes: 189 additions & 0 deletions clients/algo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# Binance Go Algo SDK

[![Build Status](https://img.shields.io/github/actions/workflow/status/binance/binance-connector-go/ci.yaml)](https://github.com/binance/binance-connector-go/actions)
[![Open Issues](https://img.shields.io/github/issues/binance/binance-connector-go)](https://github.com/binance/binance-connector-go/issues)
[![Go Version](https://img.shields.io/github/go-mod/go-version/binance/binance-connector-go)](https://github.com/binance/binance-connector-go)
[![Known Vulnerabilities](https://img.shields.io/badge/security-scanned-brightgreen)](https://github.com/binance/binance-connector-go/security)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

This is a client library for the Binance Algo API, enabling developers to interact programmatically with Binance's Algo trading platform. The library provides tools to programmatically leverage Binance in-house algorithmic trading capability to automate order execution strategy, improve execution transparency and give users smart access to the available market liquidity through the REST API:

- [REST API](./src/restapi/rest_api.go)

## Table of Contents

- [Supported Features](#supported-features)
- [Installation](#installation)
- [Documentation](#documentation)
- [REST APIs](#rest-apis)
- [Testing](#testing)
- [Migration Guide](#migration-guide)
- [Contributing](#contributing)
- [License](#license)

## Supported Features

- REST API Endpoints:
- `/sapi/v1/algo/*`
- Inclusion of test cases and examples for quick onboarding.

## Installation

To use this library, ensure you have Go installed (version **1.22** or higher is recommended). You can install the library using the following command:

```bash
go get github.com/binance/binance-connector-go/clients/algo
```

## Documentation

For detailed information, refer to the [Binance API Documentation](https://developers.binance.com/docs/algo).

### REST APIs

All REST API endpoints are available through the [`restapi`](./src/restapi/rest_api.go) module. Note that some endpoints require authentication using your Binance API credentials.

```go
package main

import (
"context"
"encoding/json"
"log"

client "github.com/binance/binance-connector-go/clients/algo/src"
"github.com/binance/binance-connector-go/common/common"
)

func main() {
QueryHistoricalAlgoOrdersSpotAlgo()
}

func QueryHistoricalAlgoOrdersSpotAlgo() {
configuration := common.NewConfigurationRestAPI(
common.WithBasePath(common.AlgoRestApiProdUrl),
common.WithApiKey("Your API Key"),
common.WithApiSecret("Your API Secret"),
)
apiClient := client.NewBinanceAlgoClient(
client.WithRestAPI(configuration),
)
resp, err := apiClient.RestApi.SpotAlgoAPI.QueryHistoricalAlgoOrdersSpotAlgo(context.Background()).Execute()
if err != nil {
log.Println(err)
return
}

rateLimitsValue, _ := json.MarshalIndent(resp.RateLimits, "", " ")
log.Printf("Rate limits: %s\n", string(rateLimitsValue))

dataValue, _ := json.MarshalIndent(resp.Data, "", " ")
log.Printf("Response: %s\n", string(dataValue))
}
```

More examples can be found in the [`examples/restapi`](./examples/restapi/) folder.

#### Configuration Options

The REST API supports the following advanced configuration options:

- `Timeout`: Timeout for requests in milliseconds (default: 1000 ms).
- `Proxy`: Proxy configuration:
- `Host`: Proxy server hostname.
- `Port`: Proxy server port.
- `Protocol`: Proxy protocol (http or https).
- `Auth`: Proxy authentication credentials:
- `Username`: Proxy username.
- `Password`: Proxy password.
- `KeepAlive`: Enable HTTP keep-alive (default: true).
- `Compression`: Enable response compression (default: true).
- `Retries`: Number of retry attempts for failed requests (default: 3).
- `Backoff`: Delay in milliseconds between retries (default: 1000 ms).
- `HTTPSAgent`: Custom HTTPS agent for advanced TLS configuration.
- `PrivateKey`: RSA or ED25519 private key for authentication.
- `PrivateKeyPassphrase`: Passphrase for the private key, if encrypted.

##### Timeout

You can configure a timeout for requests in milliseconds. If the request exceeds the specified timeout, it will be aborted. See the [Timeout example](./docs/restapi/timeout.md) for detailed usage.

##### Proxy

The REST API supports HTTP/HTTPS proxy configurations. See the [Proxy example](./docs/restapi/proxy.md) for detailed usage.

##### Keep-Alive

Enable HTTP keep-alive for persistent connections. See the [Keep-Alive example](./docs/restapi/keep-alive.md) for detailed usage.

##### Compression

Enable or disable response compression. See the [Compression example](./docs/restapi/compression.md) for detailed usage.

##### Retries

Configure the number of retry attempts and delay in milliseconds between retries for failed requests. See the [Retries example](./docs/restapi/retries.md) for detailed usage.

##### HTTPS Agent

Customize the HTTPS agent for advanced TLS configurations. See the [HTTPS Agent example](./docs/restapi/https-agent.md) for detailed usage.

##### Key Pair Based Authentication

The REST API supports key pair-based authentication for secure communication. You can use `RSA` or `ED25519` keys for signing requests. See the [Key Pair Based Authentication example](./docs/restapi/key-pair-authentication.md) for detailed usage.

##### Certificate Pinning

To enhance security, you can use certificate pinning with the `HTTPSAgent` option in the configuration. This ensures the client only communicates with servers using specific certificates. See the [Certificate Pinning example](./docs/restapi/certificate-pinning.md) for detailed usage.

#### Error Handling

The REST API provides detailed error types to help you handle issues effectively:

- `ConnectorClientError`: General client error.
- `RequiredError`: Thrown when a required parameter is missing.
- `UnauthorizedError`: Indicates missing or invalid authentication credentials.
- `ForbiddenError`: Access to the requested resource is forbidden.
- `TooManyRequestsError`: Rate limit exceeded.
- `RateLimitBanError`: IP address banned for exceeding rate limits.
- `ServerError`: Internal server error.
- `NetworkError`: Issues with network connectivity.
- `NotFoundError`: Resource not found.
- `BadRequestError`: Invalid request.

See the [Error Handling example](./docs/restapi/error-handling.md) for detailed usage.

## Testing

To run the test cases, use the following command:

```bash
go test ./tests/...
```

The tests cover:
- REST API endpoints
- Error handling and edge cases

## Migration Guide

For information on migrating from previous versions of the Binance Go Algo SDK, please refer to the [Migration Guide](./docs/migration-guide.md).

## Contributing

Contributions are welcome!

Since this repository contains auto-generated code, we encourage you to start by opening a GitHub issue to discuss your ideas or suggest improvements. This helps ensure that changes align with the project's goals and auto-generation processes.

To contribute:

1. Open a GitHub issue describing your suggestion or the bug you've identified.
2. If it's determined that changes are necessary, the maintainers will merge the changes into the main branch.

Please ensure that all tests pass if you're making a direct contribution. Submit a pull request only after discussing and confirming the change.

Thank you for your contributions!

## License

This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
Loading