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

fix: queue concurrent execution #551

Merged
merged 4 commits into from
Dec 9, 2022
Merged

Conversation

chrisleekr
Copy link
Owner

@chrisleekr chrisleekr commented Dec 4, 2022

Description

This PR is to address the issue with concurrency of the queue execution.

In addition, this PR includes some housekeeping tasks, which are better to be separated. Sorry.

The main changes are:

  1. Added limiter to Queue - https://github.com/chrisleekr/binance-trading-bot/pull/551/files#diff-d2d27ec2077b90c3ff7d942d5cbfb3d98c992a7c1c6ffd6eac4f6e3321ea2180R18
  2. Set the job progress - https://github.com/chrisleekr/binance-trading-bot/pull/551/files#diff-d2d27ec2077b90c3ff7d942d5cbfb3d98c992a7c1c6ffd6eac4f6e3321ea2180R33

The housekeeping tasks are:

  1. executeFor is now passing the correlation ID to make it easy to trace - https://github.com/chrisleekr/binance-trading-bot/pull/551/files#diff-d2d27ec2077b90c3ff7d942d5cbfb3d98c992a7c1c6ffd6eac4f6e3321ea2180R68
  2. Web socket handlers are now passing the correlation ID to executeFor.
  3. Added log analyser - https://github.com/chrisleekr/binance-trading-bot/pull/551/files#diff-82949b44b7b7f5152e9bb957c9b0cc676d3bd142d096878ac7cd59f7edaf8cd5R1

With the limiter setting, it should limit the job attempting to run while it's already running.
If the job is added while it's running, then it will be put in the waiting queue.

How to test

$ git pull
$ git checkout fix/queue-concurrent-execution
$ npm run docker:build
$ docker-compose -f docker-compose.server.yml up -d

Related Issue

#541

Motivation and Context

See description

How Has This Been Tested?

It's running in https://binance-trading-bot-chrisleekr.cloud.okteto.net/

Screenshots (if appropriate):

image

@chrisleekr chrisleekr added the bug Something isn't working label Dec 4, 2022
@codecov-commenter
Copy link

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (4b2d60d) compared to base (577229d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #551   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           92        92           
  Lines         3384      3400   +16     
  Branches       569       571    +2     
=========================================
+ Hits          3384      3400   +16     
Impacted Files Coverage Δ
...lingTrade/step/ensure-grid-trade-order-executed.js 100.00% <ø> (ø)
app/binance/candles.js 100.00% <100.00%> (ø)
app/binance/tickers.js 100.00% <100.00%> (ø)
app/binance/user.js 100.00% <100.00%> (ø)
app/cronjob/trailingTrade.js 100.00% <100.00%> (ø)
app/cronjob/trailingTradeHelper/queue.js 100.00% <100.00%> (ø)
app/frontend/webserver/handlers/auth.js 100.00% <100.00%> (ø)
app/frontend/websocket/configure.js 100.00% <100.00%> (ø)
app/frontend/websocket/handlers/cancel-order.js 100.00% <100.00%> (ø)
...end/websocket/handlers/manual-trade-all-symbols.js 100.00% <100.00%> (ø)
... and 8 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chrisleekr chrisleekr changed the title Fix/queue concurrent execution fix: queue concurrent execution Dec 4, 2022
@chrisleekr chrisleekr self-assigned this Dec 5, 2022
@chrisleekr chrisleekr merged commit 4c00664 into master Dec 9, 2022
guardInterval: 1000
limiter: {
max: 1,
duration: 10000,
Copy link
Contributor

Choose a reason for hiding this comment

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

@chrisleekr Isn't 10 seconds too much?

Copy link
Owner Author

Choose a reason for hiding this comment

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

@uhliksk
Oh, is it acting weird?

Copy link
Contributor

Choose a reason for hiding this comment

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

@chrisleekr
It is updating price once per 10 seconds which can skip price spikes easily. For example, if your sell trigger price here is 16897.00, you can skip an opportunity to sell silently just because you'll update before and after the spike.

image

@chrisleekr chrisleekr deleted the fix/queue-concurrent-execution branch May 4, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bot sometimes immediately forgets/removes last buy price, sells, marks it down as 100% loss
3 participants