Skip to content

Conversation

@samuael
Copy link
Collaborator

@samuael samuael commented May 19, 2024

PR Description

This PR updates the Binance exchange by addressing WebSocket enhancements, adding or updating endpoints, and implementing unit tests for each endpoint, along with mock records. Additionally, it introduces new endpoints under European Options and Portfolio Margin and extends WebSocket streaming support for futures and spot endpoints. The new WebSocket streaming functionality supports USDT-margined and coin-margined futures assets, establishing connections and managing incoming stream data separately. Furthermore, this PR adds a group of endpoints that utilize endpoint calls through the WebSocket stream, building on the previous Binance WebSocket update.

Requires #1968

Type of change

Please delete options that are not relevant and add an x in [] as the item is complete.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also, consider improving test coverage whilst working on a certain feature or package.

  • go test ./... -race
  • golangci-lint run
  • Test X

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on GitHub Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

samuael added 30 commits April 11, 2024 18:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR significantly updates the Binance exchange implementation with comprehensive enhancements to WebSocket functionality, new API endpoints for European Options and Portfolio Margin, and introduces new order types. The update includes:

  • WebSocket streaming support for USDT-margined and coin-margined futures
  • Addition of European Options endpoints and Portfolio Margin functionality
  • Support for new order types (LimitMaker, TakeProfitLimit, OTO, SOR)
  • Updated configuration format for improved asset type management

Reviewed Changes

Copilot reviewed 41 out of 45 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
testdata/configtest.json Updated Binance configuration with new asset types and currency pairs structure
exchanges/request/limit.go Changed Weight type from uint8 to uint32 for higher rate limits
exchanges/order/orders.go Added support for new order types and their string conversions
exchanges/order/order_types.go Defined new order type constants and string representations
exchanges/order/order_test.go Added test cases for new order types
exchanges/okx/okx_types.go Removed unused error variables
exchanges/okx/okx_test.go Updated error assertion references
exchanges/okx/okx.go Replaced deprecated error variables with standard order errors
exchanges/mock/ Refactored test code to use assert/require pattern
exchanges/mock/recording.go Improved data filtering and JSON processing with slicing limits
exchanges/kraken/kraken_wrapper.go Added time in force validation function
exchanges/kline/ Added FiveHundredMilliseconds interval support
exchanges/exchange.go Added RestOptions URL type
exchanges/binance/ New type definitions and conversion utilities

err := json.Unmarshal(data, &singlePriceChange)
if err != nil {
var resp []PriceChangeStats
err = json.Unmarshal(data, a)
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unmarshal operation is attempting to decode into the receiver a instead of the temporary variable resp. This should be err = json.Unmarshal(data, &resp) to maintain consistency with the error handling pattern.

Suggested change
err = json.Unmarshal(data, a)
err = json.Unmarshal(data, &resp)

Copilot uses AI. Check for mistakes.
switch v.(type) {
case map[string]any, []any:
checkedData, err := CheckJSON(v, excluded)
for i := range value {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop processes all elements in the slice but then applies a limit check after appending. Consider applying the limit check before processing to avoid unnecessary iterations: limit := len(value); if limit > 0 && limit > maxLimit { limit = maxLimit }; for i := 0; i < limit; i++ {

Suggested change
for i := range value {
limitToUse := len(value)
if limit > 0 && limit < limitToUse {
limitToUse = limit
}
for i := 0; i < limitToUse; i++ {

Copilot uses AI. Check for mistakes.
@thrasher-
Copy link
Collaborator

@codex please review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +2036 to +2038
var resp *WithdrawResponse
return resp.ID, e.SendAuthHTTPRequest(ctx,
exchange.RestSpot,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Dereferencing nil withdrawal response before HTTP call

The new WithdrawCrypto declares var resp *WithdrawResponse and immediately returns resp.ID alongside the result of SendAuthHTTPRequest. If the HTTP request returns an error, resp stays nil but the expression resp.ID is evaluated first, causing a panic instead of propagating the error. Initialising resp or returning an empty ID before the request succeeds would avoid the nil dereference.

Useful? React with 👍 / 👎.

@shazbert shazbert removed the nomerge requires dependency This pull request is dependent on another, so it can't be merged until the dependent one is merged label Sep 19, 2025
@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Please provide an update on the progress of this PR.

@github-actions github-actions bot added the stale label Oct 20, 2025
@github-actions github-actions bot removed the stale label Oct 27, 2025
@github-actions
Copy link

This PR is stale because it has been open 21 days with no activity. Please provide an update on the progress of this PR.

@github-actions github-actions bot added the stale label Dec 18, 2025
@github-actions github-actions bot removed the stale label Jan 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review me This pull request is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants