Skip to content

Recursive partial fulfillment may lead to stack overflow #6

@serejke

Description

@serejke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions