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

Question on addOrdersAtPrice #8

Open
WillySeahh opened this issue Dec 6, 2024 · 3 comments
Open

Question on addOrdersAtPrice #8

WillySeahh opened this issue Dec 6, 2024 · 3 comments

Comments

@WillySeahh
Copy link

https://github.com/PacktPublishing/Building-Low-Latency-Applications-with-CPP/blob/main/Chapter7/exchange/matcher/me_order_book.h

For the else case where we are iterating through the double linked list, why do we need a if (addAfter) and then a while loop? We can combine that right? (abit stuck with it)...

@stacygaudreau
Copy link

Hi @WillySeahh
Which line of the source are you asking about exactly?

Here's my implementation. I wrote a decent amount of code comments; maybe it will help understand the logic in the section.

https://github.com/stacygaudreau/nitek/blob/main/source/nitek/exchange/orders/ome_order_book.cpp

FYI - my method is named add_price_level() and some of the data structures are named in a way I found to be better, just so you know.

Hope it helps

@WillySeahh
Copy link
Author

Thanks @stacygaudreau

Thanks for sharing, i have saw your code in add_price_level()

On your code https://github.com/stacygaudreau/nitek/blob/main/source/nitek/exchange/orders/ome_order_book.cpp, line 199-220.

I was wondering if there is a better way to decide to add_after or add_before. Maybe we can refactor it to only handle add_after? Afterall add_before is basically just add_after of the previous

@stacygaudreau
Copy link

No problem. Yeah, I reckon there are some different approaches to the logic there if you want to change it!

There's a pretty decent set of test cases written for the Order Book logic in tests/test_exchange_order_book.cpp. Those might be useful to run on whatever code changes you make to verify that the order book still works properly with the logic changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants