Feat: Add Continuous Double Auction (ZI-C) Market Model#471
Conversation
falloficaruss
left a comment
There was a problem hiding this comment.
Make sure you push your changes proplerly and review the PR yourself before requesting for review
…owards the various classes and functions for a easier review
for more information, see https://pre-commit.ci
|
gentle ping @falloficaruss, i have included the order_book.py and its tests, I went ahead and also added some docs on the classes and functions where i felt to need for better readability and an easier review. everything looks good from my end now. However if you want me to tweak anything. I'll be Happy to make any changes. also the i took at the linting errors caught by the CI bot. i will remove the stray page variable in my app.py but i noticed the bot is also failing due to a pre-exisiting unsused variable in |
|
Will take a look at this today |
|
I ran tests locally and they are failing |
may i know what tests ? also can you share your python environment. |
falloficaruss
left a comment
There was a problem hiding this comment.
A few nitpicks before actually reviewing the model
Standard Pytest tests |
|
@falloficaruss thank you for the review, i'm currently a bit preoccupied, i'll have a look soon as i get time. |
Co-authored-by: Abhishek Shinde <139879930+falloficaruss@users.noreply.github.com>
for more information, see https://pre-commit.ci
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @abhishek, just a quick heads-up: I added the self.steps += 1 you suggested, but it actually caused the run_for pytest to fail. i think Mesa auto increments the steps in the background, so adding it manually caused a double-count I reverted that line, and all the pytest checks are passing completely green now. |
falloficaruss
left a comment
There was a problem hiding this comment.
The model only attempts a single match per arrival. So a crossed book can stay crossed after one trade.
|
Also have you tested this locally? |
|
hey @falloficaruss, i have a few comments
i'll push up these fixes shortly |
There was a problem hiding this comment.
Two fixes:
Crossed Book: Swapped the single match check for a while loop in model.py so it fully clears all crosses per arrival.
Mesa 4.0 Compatibility: Updated the tests to assert model.time instead of steps so it doesn't break on the dev branch.
Tested against both 3.5.1 and 4.0 and everything is green. Ready for another look!
|
Thanks @shipitdev this is very cool. @falloficaruss already did a good code review. The only thing I would ask is can you add a summary in the README probably under other Other Examples that mirrors the formatting and style, so users can more easily find it. |
thank you @tpike3, its good to hear that. I'll be going through the readmes in other project for reference and upload a similar project for this version today itself. |
|
i have updated my readme accordingly if there's anything you need me to tweak, happy to do so :) |
@shipitdev, apologies I should have been more explicit. I need you to update the repository README so users can find your model. Your model readme is fine. |
ah i see, i just added the entry under the other-examples right after El Farol since they're both economics-flavored models. Let me know if this looks good to you,Thanks. |
tpike3
left a comment
There was a problem hiding this comment.
LGTM! Thanks @shipitdev this is a great addition.

Hi! This PR adds a new Continuous Double Auction (CDA) model to the
mesa-examplesrepo. It simulates a financial exchange using simple, randomized traders (ZI-C traders) and reproduces the classic economic results from Gode & Sunder (1993).I built this specifically to highlight Mesa's continuous-time and event-driven features, moving away from the old step-by-step tick system.
What's Inside
model.timeand the new priority-queue scheduler. Instead of acting all at once, traders arrive at random, staggered times to simulate realistic network delays.DataCollectorto track market metrics (Clearing Price, Spread, Volume) and pipes them into a real-timeSolaraVizdashboard without needing a spatial grid.Testing
test_order_book.py).test_model.py).Type of Change
Checklist
README.mdfor the new example.