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

testing/loadbot: Add moving markets. #2409

Merged
merged 1 commit into from Aug 25, 2023

Conversation

JoeGruffins
Copy link
Member

@JoeGruffins JoeGruffins commented Jun 21, 2023

part of #2303

Add several tools to the loadbot to allow for sideways, trending, and volatile markets. Remove most mining as continuous mining is provided by the harnesses themselves, and this allows us to run multiple bots at once without excessive mining.

To allow for sideways and trending markets, new options for the sidestacker can be used. These are a flat increase to the rate or an automatic oscillating effect. Volatile markets can be achieved by running the ts bot separately that randomly buys, or sells, large sums moving the market violently.

The sideways market after running a bit.
image

@JoeGruffins
Copy link
Member Author

I am having a lot of trouble keeping the dcr market up while using bots. The harness freezes randomly and there's nothing to do. "something something already discreet mining". This is not a new problem and not sure the cause. So, testing on a btc/eth market mostly at the moment.

@martonp
Copy link
Contributor

martonp commented Jun 24, 2023

Haven't reviewed yet, but I've been testing with oscillate, and it's working nicely!

One thing I noticed is that it seems like it will only match orders on one side of the market for ~30 mins, then only the other side for ~30 mins. I think it would be more natural if even if it's trending in one direction, it would still ocassionally match orders in the other. Perhaps there could be a random number generated, and when the market is trending up, 75% of the time the bots would place a higher order and only 25% place a lower one, or something to that effect?

Another helpful option would be to have it stay near a certain price an oscillate in a tighter range around that. This price could be either specified by the user, or it actual current market prices could be queried. This would be helpful because the bots actually use market prices in addition to looking at the order book to make decisions.

@JoeGruffins
Copy link
Member Author

Added three new settings for the sidestacker: "randomosc", "oscinterval", and "oscstep". I hope these can add enough control to get the kind of sideways market one may want. Watching randomosc atm so see if it looks sort of natural.

@JoeGruffins
Copy link
Member Author

Seems like theres a bit too many standing orders accumulating. Maybe should cancel more.

@JoeGruffins JoeGruffins force-pushed the addloadbotprograms branch 4 times, most recently from ac561c6 to 19fc8fc Compare June 29, 2023 08:52
@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jun 29, 2023

random oscillating:
image

random oscillating with ts:
Two separate bots.

./loadbot -p sidestacker -mkt btc_eth -oscillate -ignoreerrors -trace -randomosc
./loadbot -p ts -mkt btc_eth -trace -ignoreerrors

image

@JoeGruffins JoeGruffins force-pushed the addloadbotprograms branch 2 times, most recently from 0c45ba0 to 6ae6d3e Compare June 29, 2023 12:28
@JoeGruffins JoeGruffins marked this pull request as ready for review June 29, 2023 12:28
client/webserver/site/package-lock.json Outdated Show resolved Hide resolved
dex/testing/loadbot/README.md Outdated Show resolved Hide resolved
@@ -13,17 +13,16 @@ import (
// runCompound runs the 'compound' program, consisting of 2 (5/3) unmetered
// sideStackers, a 1-order sniper, and a pingPonger.
func runCompound() {
go blockEvery2()
Copy link
Member

Choose a reason for hiding this comment

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

-- because we have miners in tmux? Makes sense, but the doge and dgb harnesses are missing miner windows. I'll make a separate issue so it doesn't hold up this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, the one block per 15 min should be sufficient. Leaving it to the harnesses so multiple bots can be run without over mining, especially since this seems to be where the dcr harness gets stuck, with mining calls happening concurrently.

I'll add, should only be a few lines each. Sorry for missing that, I assumed they all had miners now.

Copy link
Member Author

Choose a reason for hiding this comment

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

dgb was turned off, I wonder if intentional?

Copy link
Member

Choose a reason for hiding this comment

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

dgb was turned off, I wonder if intentional?

Don't recall. @dev-warrior777 is turning it back on in another PR it looks like.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but dgb will never work very well for regtest mining until dgb 8.x series which is on RC2 right now and coming to RC3 soon I am assured.

For 8.x they have a new parameter for the daemon which addresses the regtest mining weakness specifically.

Copy link
Member

@chappjc chappjc Jul 12, 2023

Choose a reason for hiding this comment

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

Oh duh that's why I disabled it. I even talked to their devs about it. easypow

Copy link
Contributor

Choose a reason for hiding this comment

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

easypow correct
I tested it today doing many loops mining 100 blocks a time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, conflicts with @dev-warrior777 If that goes in first I will rebase over it.

dex/testing/loadbot/sidestacker.go Outdated Show resolved Hide resolved
dex/testing/loadbot/sidestacker.go Outdated Show resolved Hide resolved
dex/testing/loadbot/sidestacker.go Show resolved Hide resolved
dex/testing/loadbot/sidestacker.go Show resolved Hide resolved
dex/testing/loadbot/loadbot.go Outdated Show resolved Hide resolved
dex/testing/loadbot/loadbot.go Outdated Show resolved Hide resolved
dex/testing/loadbot/loadbot.go Show resolved Hide resolved
@JoeGruffins JoeGruffins force-pushed the addloadbotprograms branch 2 times, most recently from 87e98c8 to 3045223 Compare July 11, 2023 06:49
@JoeGruffins
Copy link
Member Author

@JoeGruffins JoeGruffins force-pushed the addloadbotprograms branch 3 times, most recently from d6a2f46 to d746828 Compare July 12, 2023 01:51
@JoeGruffins
Copy link
Member Author

active -> oscillatorWrite and matching error strings for cancel orders
https://github.com/decred/dcrdex/compare/d6a2f46240ee2551c80a35e3f234af9cf3586b52..d746828003d42e65455dc22d04a330837a701e69


# Background watch mining by default:
# 'export NOMINER="1"' or uncomment this line to disable
#NOMINER="1"
Copy link
Member

Choose a reason for hiding this comment

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

As per #2434, I think this has to be set for DGB since their release version cannot mine indefinitely in simnet and it ends up grinding CPU endlessly.

When running loadbot, we'll just have to start a miner manually. Maybe we can echo something here as a reminder to the dev.

Copy link
Member Author

Choose a reason for hiding this comment

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

Uncommented and left a TODO

@@ -273,6 +277,8 @@ tmux send-keys -t $SESSION:0 C-c
tmux send-keys -t $SESSION:1 C-c
tmux send-keys -t $SESSION:2 C-c
tmux send-keys -t $SESSION:3 C-c
tmux send-keys -t $SESSION:4 C-c
Copy link
Member

Choose a reason for hiding this comment

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

This tries to kill the quit script itself. A few lines down it will remove the ctl session using tmux kill-session.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this ctrl-c.

@JoeGruffins
Copy link
Member Author

Apologies rebased onto master with those changes so cannot get a clean diff on github I think. Was two changes in the harnesses

diff
diff --git a/dex/testing/dgb/harness.sh b/dex/testing/dgb/harness.sh
index 6e90e949..5de493b1 100755
--- a/dex/testing/dgb/harness.sh
+++ b/dex/testing/dgb/harness.sh
@@ -27,7 +27,10 @@ export EXTRA_ARGS="-disabledandelion=1 -rpcbind=0.0.0.0 -rpcallowip=0.0.0.0/0 -n
 
 # Background watch mining by default:
 # 'export NOMINER="1"' or uncomment this line to disable
-#NOMINER="1"
+#
+# TODO: Cannot presently continuously mine on simnet but when we can comment
+# this out.
+NOMINER="1"
 
 # Run the harness
 ../btc/base-harness.sh
diff --git a/dex/testing/doge/harness.sh b/dex/testing/doge/harness.sh
index e84689e5..6292178b 100755
--- a/dex/testing/doge/harness.sh
+++ b/dex/testing/doge/harness.sh
@@ -277,7 +277,6 @@ tmux send-keys -t $SESSION:0 C-c
 tmux send-keys -t $SESSION:1 C-c
 tmux send-keys -t $SESSION:2 C-c
 tmux send-keys -t $SESSION:3 C-c
-tmux send-keys -t $SESSION:4 C-c
 tmux send-keys -t $SESSION:5 C-c
 tmux wait-for alpha${SYMBOL}
 tmux wait-for beta${SYMBOL}

@dev-warrior777
Copy link
Contributor

Apologies rebased onto master with those changes so cannot get a clean diff on github I think. Was two changes in the harnesses

Was my bad initially I guess ;-(

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jul 21, 2023

Was my bad initially I guess

Lets not git blame (joke)

@JoeGruffins
Copy link
Member Author

@JoeGruffins
Copy link
Member Author

The sidestaker seems to be requesting way too much eth. Something doesn't look right. Investigating...

@JoeGruffins
Copy link
Member Author

@JoeGruffins
Copy link
Member Author

JoeGruffins commented Jul 24, 2023

$ ./loadbot -p sidestacker -mkt btc_eth -oscillate -ignoreerrors -trace -randomosc
and
$ ./loadbot -p whale -whalepercent 0.5 -mkt btc_eth -ignoreerrors

The first bot was suspended for something eventually...

2023-07-24 16:19:15.296 [WRN] CORE:STACKER:0: notify: |WARNING| (notify) Server has penalized you - Penalty from DEX at 127.0.0.1:17273
last broken rule: CancellationRate
time: 2023-07-24 16:19:15.268 +0900 JST
details:
"Ordering has been suspended for this account. Post additional bond to offset violations.
Last Broken Rule Details: cancellation rate dropped below the acceptable level
excessive cancellation rate, new tier = 0"

Should do something to prevent this?

image

@dev-warrior777
Copy link
Contributor

""Ordering has been suspended for this account. Post additional bond to offset violations."

..you are a Whale .. pay up out of the slush fund ;-)

@JoeGruffins
Copy link
Member Author

I guess setting bond target tier to 1 should keep us trading automatically?

@JoeGruffins
Copy link
Member Author

Now posting bond instead of registering, which should set the tier to 1 so it will automatically keep us un-banned. Right? https://github.com/decred/dcrdex/compare/52e52eba7fcb1a8e3cd49c87de89dc66842b21c8..3cbca47a8dd11f3d1279bbe7059912a6d3d47140

@JoeGruffins
Copy link
Member Author

Maybe better if the bots don't get banned for cancels, going to try to avoid canceling orders created one epoch ago.

@JoeGruffins
Copy link
Member Author

Hmm, starting the server does say:

2023-07-28 15:01:47.632 [INF] DEX: Cancellations are NOT COUNTED (the cancellation rate threshold is ignored).

@buck54321
Copy link
Member

We really shouldn't be using freecancels for load testing. Something like this would prepare sidestacker for turning of freecancels.

@JoeGruffins
Copy link
Member Author

We really shouldn't be using freecancels for load testing. Something like this would prepare sidestacker for turning of freecancels.

Thanks! I had the same changes waiting to go but was looking at the issue of the clients not remaining bonded.

@JoeGruffins
Copy link
Member Author

@buck54321
Copy link
Member

@JoeGruffins could you please test on top of the newest version of #2449 and confirm that the bug is resolved.

@JoeGruffins
Copy link
Member Author

@buck54321 the "ghost orders" appear to be gone!

@buck54321
Copy link
Member

Can rebase now that #2449 is in. Could also try removing freecancels=1 from the server simnet harness config.

Add several tools to the loadbot to allow for sideways, trending, and
volatile markets. Remove most mining as continuous mining is provided by
the harnesses themselves, and this allows us to run multiple bots at
once without excessive mining.

To allow for sideways and trending markets, new options for the
sidestacker can be used. These are a flat increase to the rate or an
automatic oscillating effect. Volatile markets can be achieved by
running the whale bot separately that randomly buys, or sells, large
sums moving the market violently.
@JoeGruffins
Copy link
Member Author

@buck54321 buck54321 merged commit 8fad253 into decred:master Aug 25, 2023
5 checks passed
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.

None yet

5 participants