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 99 commits into
base: master
Choose a base branch
from
Open

Conversation

samuael
Copy link
Collaborator

@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.

Thanks, things are looking well polished. Very close now.

exchanges/okx/okx.go Outdated Show resolved Hide resolved
exchanges/okx/okx.go Outdated Show resolved Hide resolved
if currency != "" {
params.Set("ccy", currency)
if !ccy.IsEmpty() {
params.Set("ccy", ccy.String())
}
interval := ok.GetIntervalEnum(period, false)
if interval != "" {
params.Set("period", interval)
}
var resp [][6]string
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not done like I suggested

exchanges/okx/okx.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
exchanges/okx/okx_types.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.

Comments on new changes.

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.go Outdated Show resolved Hide resolved
exchanges/okx/okx_test.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
exchanges/okx/okx_types.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.

Nothing new on new changes from me. Nice work!

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.

Changes look great. One thing left over from recent changes.

Comment on lines 3521 to 3523
// PlaceRecurringBuyOrder recurringorder.Buy.Lower()is a strategy for investing a fixed amount in crypto at order.Sell.Lower()s.
// An appropriate recurring approach in volatile markets allows you toorder.Buy.Lower()crypto at lower costs. order.Sell.Lower()re
// The API endpoints of Recurringorder.Buy.Lower()order.Sell.Lower()n.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert all these comment changes across this file for order.Buy.Lower() and order.Sell.Lower()

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.

Also tests need to be fixed

@gloriousCode
Copy link
Collaborator

gloriousCode commented Nov 11, 2024

Please also run tests with real/readonly/fake API keys. Panic on TestWsAmendOrder. Will help ensure everything is working as expected

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x40 pc=0x102f5466c]

goroutine 375 [running]:
testing.tRunner.func1.2({0x10324e4c0, 0x103803ba0})
	/Users/DOGE/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1632 +0x1bc
testing.tRunner.func1()
	/Users/DOGE/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1635 +0x334
panic({0x10324e4c0?, 0x103803ba0?})
	/Users/DOGE/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:785 +0x124
github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*OrderData).GetSCode(0x1400010e200?)
	/Users/scottg/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/okx/okx_types.go:845 +0x6c
github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*Okx).handleIncomingData(0x14000c2dd30?, 0x1400010e200, {0x103336330, 0x0})
	/Users/DOGE/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/okx/okx_websocket.go:2479 +0x26c
github.com/thrasher-corp/gocryptotrader/exchanges/okx.(*Okx).WsAmendOrder(0x103831d80, {0x103338f60, 0x103859760}, 0x140007f3e58)
	/Users/DOGE/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/okx/okx_websocket.go:1945 +0x9e8
github.com/thrasher-corp/gocryptotrader/exchanges/okx.TestWsAmendOrder(0x140007d9380)
	/Users/DOGE/go/src/github.com/thrasher-corp/gocryptotrader/exchanges/okx/okx_test.go:3547 +0x94c
testing.tRunner(0x140007d9380, 0x10332f0f0)
	/Users/DOGE/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1690 +0xe4
created by testing.(*T).Run in goroutine 1
	/Users/DOGE/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:1743 +0x314

EG like my previous comment

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 38.61893% with 1200 lines in your changes missing coverage. Please review.

Project coverage is 37.27%. Comparing base (8f9ebcb) to head (5ffd43f).

Files with missing lines Patch % Lines
exchanges/okx/okx_websocket.go 22.11% 574 Missing and 7 partials ⚠️
exchanges/okx/okx_wrapper.go 39.02% 372 Missing and 42 partials ⚠️
exchanges/okx/okx_business_websocket.go 0.00% 201 Missing ⚠️
exchanges/asset/asset.go 50.00% 2 Missing ⚠️
exchanges/collateral/collateral.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1420      +/-   ##
==========================================
+ Coverage   37.13%   37.27%   +0.13%     
==========================================
  Files         414      415       +1     
  Lines      180177   182943    +2766     
==========================================
+ Hits        66910    68188    +1278     
- Misses     105411   106898    +1487     
- Partials     7856     7857       +1     
Files with missing lines Coverage Δ
common/common.go 93.35% <ø> (-0.80%) ⬇️
database/repository/withdraw/withdraw.go 38.19% <100.00%> (ø)
exchanges/okx/okx.go 32.05% <ø> (+11.98%) ⬆️
exchanges/okx/okx_type_convert.go 37.03% <ø> (+5.40%) ⬆️
exchanges/okx/okx_types.go 45.30% <ø> (+4.85%) ⬆️
exchanges/okx/ratelimit.go 100.00% <100.00%> (ø)
exchanges/order/orders.go 91.07% <100.00%> (+0.07%) ⬆️
exchanges/asset/asset.go 92.36% <50.00%> (-1.34%) ⬇️
exchanges/collateral/collateral.go 86.04% <0.00%> (-4.20%) ⬇️
exchanges/okx/okx_business_websocket.go 0.00% <0.00%> (ø)
... and 2 more

... and 12 files with indirect coverage changes

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.

@gloriousCode
Copy link
Collaborator

gloriousCode commented Nov 13, 2024

Exchange_wrapper_standards is still having issues with the Okx authenticated requests not being set as Auth type, so they fail. Please message me if you need help

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, A test needs to be fixed here

// ClosePositionForContractrid close position when the contract grid stop type is 'keep position'.
func (ok *Okx) ClosePositionForContractrid(ctx context.Context, arg *ClosePositionParams) (*ClosePositionContractGridResponse, error) {
// ClosePositionForContractrID close position when the contract grid stop type is 'keep position'.
func (ok *Okx) ClosePositionForContractrID(ctx context.Context, arg *ClosePositionParams) (*ClosePositionContractGridResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (ok *Okx) ClosePositionForContractrID(ctx context.Context, arg *ClosePositionParams) (*ClosePositionContractGridResponse, error) {
func (ok *Okx) ClosePositionForContractID(ctx context.Context, arg *ClosePositionParams) (*ClosePositionContractGridResponse, error) {

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

Successfully merging this pull request may close these issues.

5 participants