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

Recursive partial fulfillment may lead to stack overflow #6

Open
serejke opened this issue Dec 7, 2023 · 0 comments
Open

Recursive partial fulfillment may lead to stack overflow #6

serejke opened this issue Dec 7, 2023 · 0 comments

Comments

@serejke
Copy link

serejke commented Dec 7, 2023

Overview

Thanks for this repo. It's a great exercise on the orderbooks. Taking a look for inspiration.

I know you're not going to maintain it. Just thought it would be a good idea to share ideas for potential contributors.

Recursive partial matchmaking

self.process_market_order(

Potential stack overflow

Imagine 10.000 ask limit orders with qty = 1 and the same "best" price, say 1.

Then a bid market order with qty = 10.000 and price 1, too.

To fulfill the bid, all 10.000 need to be executed. I haven't run the example, but I guess a stack overflow error will be thrown in runtime.

Solution

Use a non-recursive loop: pull the best opposite order, fill it fully, and partially fill the big order.

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

No branches or pull requests

1 participant