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

Add Http request_order_book_snapshot method #1741

Open
graceyangfan opened this issue Jun 26, 2024 · 3 comments
Open

Add Http request_order_book_snapshot method #1741

graceyangfan opened this issue Jun 26, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@graceyangfan
Copy link
Contributor

graceyangfan commented Jun 26, 2024

Feature Request

Due to the high cost of subscribing to the order book, especially for strategies that run multiple instruments and are not high-frequency, it is important to consider the utility of micro-level order book data for strategies. Therefore, adding an HTTP method to fetch order book snapshots should be considered. I request the addition of a request_order_book_snapshot method to obtain this data within the model.

Example usage:

def on_historical_data(self, data):
    if isinstance(data, OrderBookDeltas):
        self.deltas = data

def on_bar(self, bar: Bar):
    self.request_order_book_snapshot(
        instrument_id=self.instrument_id,
        limit=5
    )
    # Process deltas 
@cjdsellers
Copy link
Member

Hi @graceyangfan

Thanks for the contribution here.

I think this makes sense, that a trader may require a snapshot at some arbitrary frequency and depth - but not necessarily be maintaining a book the entire time with deltas.

Thankfully this wasn't too much trouble to implement with the flexible messaging system.

The only thing left here from what I can see is to add some test coverage for the DataEngine. You could use the TestDataProvider.order_book_snapshot(...) method.

Do you have an adapter implementation for Binance?

I can handle Databento and docs.

@cjdsellers
Copy link
Member

Hey @graceyangfan

Did you end up getting your use case working for Binance?

@graceyangfan
Copy link
Contributor Author

@cjdsellers it is now working normally on Binance. The extension to other exchanges might have to rely on other developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In progress
Development

No branches or pull requests

2 participants