Skip to content

Conversation

@samuael
Copy link
Collaborator

@samuael samuael commented Jan 16, 2025

Selam(πŸ•ŠοΈ) be with you, team!

This PR includes minor updates to the exchange templates used for instantiating new exchanges.

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

samuael and others added 30 commits October 29, 2023 21:28
@thrasher- thrasher- requested a review from gbjk July 7, 2025 02:22
Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

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

Good progress!

Sorry; I'd like to remove the inconsistency in the exchange method receiver naming.
Some exchanges are naming it ex *Exchange and others have e *Exchange.
It seems to be following that the original exchange receiver was 2 characters, so ex is as well, but that doesn't make any sense.
If I'm not missing any other reason, can we make it consistently e everywhere?
Note: Specifically choosing e, and not ex in this request, to be idiomatic

Once that's done, I'll have another pass to do.

@samuael
Copy link
Collaborator Author

samuael commented Jul 7, 2025

Good progress!

Sorry; I'd like to remove the inconsistency in the exchange method receiver naming. Some exchanges are naming it ex *Exchange and others have e *Exchange. It seems to be following that the original exchange receiver was 2 characters, so ex is as well, but that doesn't make any sense. If I'm not missing any other reason, can we make it consistently e everywhere? Note: Specifically choosing e, and not ex in this request, to be idiomatic

Once that's done, I'll have another pass to do.

Regarding the receivers naming, I am decision neutral(Pontius πŸ˜‰ ) on this idea of replacing two variable receivers with "ex" and with just 'e' for single variable receiver for the rest. But, regarding consistency, I think, having the consistency in the specific exchange package is enough ... may be @thrasher- could give comment on this.

@thrasher-
Copy link
Collaborator

Good progress!
Sorry; I'd like to remove the inconsistency in the exchange method receiver naming. Some exchanges are naming it ex *Exchange and others have e *Exchange. It seems to be following that the original exchange receiver was 2 characters, so ex is as well, but that doesn't make any sense. If I'm not missing any other reason, can we make it consistently e everywhere? Note: Specifically choosing e, and not ex in this request, to be idiomatic
Once that's done, I'll have another pass to do.

Regarding the receivers naming, I am decision neutral(Pontius πŸ˜‰ ) on this idea of replacing two variable receivers with "ex" and with just 'e' for single variable receiver for the rest. But, regarding consistency, I think, having the consistency in the specific exchange package is enough ... may be @thrasher- could give comment on this.

We should aim to be as consistent as possible, so in this case we can change them in the ./exchanges/ dir to be e. The original need for two letter chars was due to clashes with other template vars; e.g OKX 'so would clash with a var of o for order.X so the template tool would set OKX's reciever to ok

Copy link
Collaborator

@cranktakular cranktakular left a comment

Choose a reason for hiding this comment

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

Got some changes I need.

In general, I'd also suggest making a template for rate limiting, and finishing the checklist at the start of this PR.

fmt.Printf("Output directory: %s\n", exchangeDirectory)

exch.CapitalName = cases.Title(language.English).String(exch.Name)
exch.Variable = exch.Name[0:2]
Copy link
Collaborator

Choose a reason for hiding this comment

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

With this line being removed, do we still need checkExchangeName to have that length check? Smells like it was mostly to avoid panics here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should keep this check just because the naming should satisfy this check even-if it is not helpful for the receiver naming.

Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

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

Thanks.
Couple of new changes, and some outstanding existing changes.

@samuael samuael requested a review from gbjk July 14, 2025 19:49
Copy link
Collaborator

@cranktakular cranktakular left a comment

Choose a reason for hiding this comment

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

Got one little nit, but aside that, I can tACK.

@@ -65,18 +72,14 @@ func TestNewExchangeAndSaveConfig(t *testing.T) {
WS: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changing this to false adds a line of coverage for code you newly added, without losing any elsewhere.

If you want to keep this in case of issues, you can set up another exchange where this is false.

@samuael samuael requested a review from cranktakular July 15, 2025 05:57
Copy link
Collaborator

@cranktakular cranktakular left a comment

Choose a reason for hiding this comment

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

And that makes it a full-on tACK from me.

(At least for the exchange_template folder, I haven't reviewed the rest of the changes)

Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

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

Approved πŸ‘

Minor nits only πŸ’ and just a reminder in case you missed the suggestion that the newly private function doesn't need a comment 🦍


// Subscriber sends a websocket message to receive data from the channel
func (e *Exchange) Subscriber(_ subscription.List) error {
// Subscribe sends a websocket message to receive data from the channel
Copy link
Collaborator

Choose a reason for hiding this comment

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

πŸ’ Note: There was a change to the comment here. But in hindsight I'm not happy with that suggestion either. Just a minor update to plurarity.

Suggested change
// Subscribe sends a websocket message to receive data from the channel
// Subscribe sends websocket messages to receive data for a list of channels


// Unsubscriber sends a websocket message to stop receiving data from the channel
func (e *Exchange) Unsubscriber(_ subscription.List) error {
// Unsubscribe removes a channel subscriptions from the websocket
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
// Unsubscribe removes a channel subscriptions from the websocket
// Unsubscribe sends websocket messages to stop receiving data for a list of channels


// GenerateSubscriptions returns a list of subscriptions from the configured subscriptions feature
func (e *Exchange) GenerateSubscriptions() (subscription.List, error) {
// generateSubscriptions returns a list of subscriptions from the configured subscriptions feature
Copy link
Collaborator

Choose a reason for hiding this comment

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

🦍 In case you missed it, I'm suggesting to remove this comment

Suggested change
// generateSubscriptions returns a list of subscriptions from the configured subscriptions feature

Copy link
Collaborator

@gbjk gbjk left a comment

Choose a reason for hiding this comment

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

All good, Thanks and Great work πŸ‘

Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Last two changes and then this LGTG, thanks for addressing the feedback!

"github.com/thrasher-corp/gocryptotrader/exchanges/request"
)

// Exchange implements exchange.IBotExchange and contains additional specific api methods for interacting with {{.CapitalName}}
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
// Exchange implements exchange.IBotExchange and contains additional specific api methods for interacting with {{.CapitalName}}
// Exchange implements exchange.IBotExchange and contains additional specific API methods for interacting with {{.CapitalName}}

Name: testExchangeName,
REST: true,
WS: true,
WS: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please expand this test to also include WS enabled as well, so we test both REST only and both enabled

@samuael samuael requested a review from thrasher- July 16, 2025 10:32
Copy link
Collaborator

@thrasher- thrasher- left a comment

Choose a reason for hiding this comment

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

Changes tACK, thanks!

@thrasher- thrasher- merged commit 3f534a1 into thrasher-corp:master Jul 17, 2025
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium priority review me This pull request is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants