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

Symmetrical Simulation Freezes at Point of Reversal #752

Closed
pjbollinger opened this issue Nov 26, 2017 · 2 comments
Closed

Symmetrical Simulation Freezes at Point of Reversal #752

pjbollinger opened this issue Nov 26, 2017 · 2 comments

Comments

@pjbollinger
Copy link
Contributor

There is an issue with the sim command when using the --symmetrical option. It will simulate the history of trades like normal. However, once it reaches the point of reversing, it appears to get caught in a loop. I used mongoreplay to capture this log (an excerpt of the full log) and a snippet at time of reversal. There is a lot of data in there but you can see at the point of reversal there a couple of find orders in a row and then starts alternating find and getMore orders. After the reversal, it keeps repeating the same find and getMore orders though.

While debugging #750, I found that the program kept entering this logic of the code, which I think makes sense. However, the cursor does not appear to be moving correctly. I will be investigating this but wanted to share my findings so far.

@pjbollinger
Copy link
Contributor Author

Here is some data of the queries around the code that identifies the original data is complete and it begins the reversal process. Notice how the $lt selector for the time freezes at the end.

Query (opts) at point of entering if (!trades.length) { if (so.symmetrical && !reversing) {...}}:

{ query:
  { selector: 'gdax.ETH-USD',
    time: { '$gt': 1511632608799 } },
  sort: { time: 1 },
  limit: 1000 }

Query (opts) at point of entering if (so.symmetrical && reversing) {...} the first time:

{ query: 
   { selector: 'gdax.ETH-USD',
     time: { '$lt': 1511632608799, '$gte': 1511373600000 } },
  sort: { time: -1 },
  limit: 1000 }

Query (opts) at point of entering if (so.symmetrical && reversing) {...} the second time:

{ query: 
   { selector: 'gdax.ETH-USD',
     time: { '$lt': 1511632981090, '$gte': 1511373600000 } },
  sort: { time: -1 },
  limit: 1000 }

Query (opts) at point of entering if (so.symmetrical && reversing) {...} the third time and forever after:

{ query: 
   { selector: 'gdax.ETH-USD',
     time: { '$lt': 1511632980913, '$gte': 1511373600000 } },
  sort: { time: -1 },
  limit: 1000 }

pjbollinger added a commit to pjbollinger/zenbot that referenced this issue Nov 26, 2017
This should fix issue DeviaVir#752 where using the --symmetrical option in a sim causes it to freeze.
@pjbollinger
Copy link
Contributor Author

I found the issue is caused by the cursor not properly adjusting from the reversal of time.

Here is a screenshot of a simulation HTML report after the fix #753:
screen shot 2017-11-26 at 3 57 23 pm

When running, I recommend using --min_periods=0 to achieve near perfect symmetry.

DeviaVir pushed a commit that referenced this issue Nov 27, 2017
This should fix issue #752 where using the --symmetrical option in a sim causes it to freeze.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant