Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #28
What is the purpose of the change
The previous implementation of
get_orders_by_owner
did not employ pagination, leading to the possibility of DoS if a user placed a significant amount of orders. These changes add pagination in a cursor-like format by providing:The page size defaults to 50 and has a maximum of 100 (can be adjusted), and all three parameters are optional. A user could iterate through all orders by simply passing the
(order.book_id, order.tick_id, order.order_id)
of the last order in the previous page as themin
parameter. Orders are ordered by the following priority:Testing and Verifying
This change added tests and can be verified as follows:
test_state
Future Work
The current implementation has a troubling ordering due to the tuple used to index orders. A potential approach is to use the multiindex for filtering orders to book/tick and have orders be a direct mapping between order id and the order itself, however this may incur execution overhead at the benefit of easier querying, cancellations and pagination.