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

exchanges: Okx Update #1420

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open

Conversation

samuael
Copy link
Contributor

@samuael samuael commented Dec 11, 2023

Selam, ወንድሞች.

PR Description

This pull request incorporates modifications for the Okx exchange, encompassing changes to endpoint methods, rate limits, WebSocket subscriptions and handlers, wrapper functions, and conversion methods. Rigorous testing has been conducted on all facets of the functions to ensure their reliability. The code adheres to the GCT style standards, consistent with practices adopted by other exchanges. To enhance code quality, golangci-lint was utilized for linter testing, effectively rectifying a few errors. Furthermore, this implementation includes endpoint methods that the GCT wrapper did not initially support, ensuring compatibility for future use

The PR updated implementations for REST for trading and other endpoint methods, Web-socket streaming, and Trading through the web socket stream.

Fixes # (issue)

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/AppVeyor with my changes
  • Any dependent changes have been merged and published in downstream modules

@gloriousCode gloriousCode requested a review from a team December 11, 2023 21:08
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Legend. Just somethings I noticed.

exchanges/okx/okx.go Outdated Show resolved Hide resolved
exchanges/okx/okx.go Outdated Show resolved Hide resolved
exchanges/okx/okx.go Outdated Show resolved Hide resolved
exchanges/okx/okx.go Outdated Show resolved Hide resolved
exchanges/okx/okx_test.go Outdated Show resolved Hide resolved
exchanges/okx/okx_types.go Outdated Show resolved Hide resolved
exchanges/okx/okx_types.go Outdated Show resolved Hide resolved
Comment on lines +713 to +717
// GetSCode returns a status code value
func (a *OrderData) GetSCode() string { return a.SCode }

// GetSMsg returns a status message value
func (a *OrderData) GetSMsg() string { return a.SMessage }
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could probably RM these methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How? & Why?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I might be mistaken, but the data doesn't look like it escapes scope. Have you tested the deployment and response? Also can you please add coverage across all functions that use handleIncomingData

Comment on lines +727 to +731
// GetSCode returns a status code value
func (a *ResponseSuccess) GetSCode() string { return a.SCode }

// GetSMsg returns a status message value
func (a *ResponseSuccess) GetSMsg() string { return a.SMessage }
Copy link
Collaborator

Choose a reason for hiding this comment

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

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How? & Why?

exchanges/okx/okx_wrapper.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, Linter needs to be resolved.

Comment on lines +713 to +717
// GetSCode returns a status code value
func (a *OrderData) GetSCode() string { return a.SCode }

// GetSMsg returns a status message value
func (a *OrderData) GetSMsg() string { return a.SMessage }
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might be mistaken, but the data doesn't look like it escapes scope. Have you tested the deployment and response? Also can you please add coverage across all functions that use handleIncomingData

Copy link
Collaborator

@shazbert shazbert left a comment

Choose a reason for hiding this comment

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

Just a couple items left over.

// GetAlgoOrderDetail retrieves algo order details.
func (ok *Okx) GetAlgoOrderDetail(ctx context.Context, algoID, algoClientOrderID string) (*AlgoOrderDetail, error) {
if algoID == "" && algoClientOrderID == "" {
return nil, fmt.Errorf("%w eiither 'algoId' or 'algoClOrdId' is required", errMissingAlgoOrderID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

}

// GetSCode returns a status code value
func (a *ResponseSuccess) GetSCode() string { return a.SCode }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These methods are added to be used when we encounter such kind of response with a "code": "1" and the detailed sCode and sMsg are included in the data section.

We can not call the x.SCode and x.SMsg fields in ### handleIncomingData method. Since we give an input of different instance interfaces as ### dataHolder for the ### handleIncomingData method.

{
  "id": "1514",
  "op": "sprd-cancel-order",
  "data": [
    {
      "clOrdId": "",
      "ordId": "2510789768709120",
      "sCode": "5XXXX",
      "sMsg": "Order not exist"
    }
  ],
  "code": "1",
  "msg": ""
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Therefore, removing these GetSCode() and GetSMsg() methods is problematic.

@samuael
Copy link
Contributor Author

samuael commented Feb 19, 2024

I did add unit tests for endpoints accessing the handleIncomingData section. #1420 (comment)

  • Have I addressed what you were asking, boss?

If not, give me a short elaboration - I'll review it again tomorrow as I didn't have time to address this one bc of Deribit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority review me This pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants