Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Prevent balanced strategy from modifiying orders when nothing has changed #52

Closed
Reidmcc opened this issue Nov 13, 2018 · 5 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@Reidmcc
Copy link
Contributor

Reidmcc commented Nov 13, 2018

Desired Behavior

Currently, if the balanced strategy has LEVEL_DENSITY < 1.0 it will modify its orders to re-randomize the levels even if no offers have been taken.

I want to have the balanced strategy leave all levels in place if no trades have happened since the last refresh; I don't think re-randomizing is useful when nothing has changed.

Impact

The current behavior submits unnecessary operations to the network. This change will increase efficiency and reduce user fee spending.

Feature Suggestion

We can implement this by having the bot stop modifying offers if the first offer is still in place and within tolerances. I'm submitting a pull request shortly.

@nikhilsaraf
Copy link
Contributor

@Reidmcc this is a good idea.
The change should probably be made in balancedLevelProvider.go

balancedLevelProvider can save (in memory) it's asset balances and the levels it returns from the GetLevels call. Anytime we call GetLevels it can first check if the asset balances have changed from what it has saved in memory:

  • if it has changed then it can recompute new levels
  • otherwise it can return the levels it has saved in memory.

This will be a pretty quick and simple code change.

The suggested approach will not consider amount tolerances since any balance change will trigger levels to be recomputed. Adjusting this to handle amount tolerances can be worked on as a separate issue which is a relatively small improvement over the suggested approach.

@nikhilsaraf nikhilsaraf added the bug Something isn't working label Nov 17, 2018
@Reidmcc
Copy link
Contributor Author

Reidmcc commented Nov 17, 2018

That makes sense. Do you have the code change planned out or shall I take a crack at it?

@nikhilsaraf
Copy link
Contributor

@Reidmcc The approach described above is what I had been thinking about for a while but never got to making the change. Would be great if you could take a crack at it!

@Reidmcc
Copy link
Contributor Author

Reidmcc commented Nov 17, 2018

Ok, will do.

@nikhilsaraf
Copy link
Contributor

@Reidmcc I've uploaded the fill tracking and handling logic, you can take a look at how that works for the mirror strategy as an example: https://github.com/interstellar/kelp/blob/master/plugins/mirrorStrategy.go#L312

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants