Skip to content

FEATURE: [dca2] UpdateProfitStatsUntilSuccess -> UpdateProfitStatsUnt… #2032

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kbearXD
Copy link
Collaborator

@kbearXD kbearXD commented May 14, 2025

…ilDuration to avoid it infinity trying

Copy link

@Copilot 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 refactors the profit stats update functionality in the DCA strategy to avoid infinite retries by renaming the function and adding a duration-based retry mechanism with exponential backoff, while also adding extra logging.

  • Renamed UpdateProfitStatsUntilSuccessful to UpdateProfitStatsUntilDuration and adjusted backoff settings
  • Added a constant for maximum retry duration in the state file
  • Improved logging messages in both grid2 and dca2 strategy files to indicate when cancel-all orders API is used

Reviewed Changes

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

File Description
pkg/strategy/grid2/strategy.go Added logging for the cancel-all orders API usage
pkg/strategy/dca2/strategy.go Renamed and refactored profit stats update function and updated backoff settings; added logging improvements
pkg/strategy/dca2/state.go Introduced a constant for max retry duration and updated the call to profit stats update
pkg/strategy/dca2/profit_stats.go Added a comment describing the AddTrade function

@@ -980,6 +980,7 @@ func (s *Strategy) cancelAll(ctx context.Context) error {

var err error
if s.UseCancelAllOrdersApiWhenClose {
s.logger.Info("UseCancelAllOrdersApiWhenClose is set, will cancel all orders by cancel all orders API")
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider rewording the logging message for clarity. For instance, 'UseCancelAllOrdersApiWhenClose is enabled; canceling all orders using the CancelAllOrders API' may be clearer.

Copilot uses AI. Check for mistakes.

@@ -366,6 +366,7 @@ func (s *Strategy) Close(ctx context.Context) error {

var err error
if s.UseCancelAllOrdersApiWhenClose {
s.logger.Info("UseCancelAllOrdersApiWhenClose is set, will cancel all orders by cancel all orders API")
Copy link
Preview

Copilot AI May 14, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider rewording this log message for improved clarity. A suggestion is: 'UseCancelAllOrdersApiWhenClose is enabled; canceling all orders using the CancelAllOrders API'.

Copilot uses AI. Check for mistakes.

@kbearXD kbearXD force-pushed the kbearXD/dca2/update-profit-stats branch from 23fc45c to 50d6a23 Compare May 17, 2025 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants