nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
2.02k stars 461 forks source link

Addition of Sequence Number in QuoteTick #1632

Closed rsmb7z closed 4 months ago

rsmb7z commented 4 months ago

Feature Request

Currently, while we have the trade_id field to identify unique trades in TradeTick, there's no unique identifier for QuoteTick. This absence becomes critical when multiple ticks occur simultaneously, necessitating the maintenance of data order.

To address this, I propose adding a sequence number field (preferably integer) to the QuoteTick object. This addition would significantly enhance our ability to maintain data order, particularly in scenarios where multiple ticks occur simultaneously.

cjdsellers commented 4 months ago

Adding a field to QuoteTick would be a large breaking change, and a sequence number for top-of-book data may not fit a use case for the majority of users.

Could you provide a concrete example of where multiple quotes could occur for a single instrument at the same nanosecond, with differing prices or sizes?

rsmb7z commented 4 months ago

The idea sparked while setting primary keys in TimescaleDB. I discovered duplicate QuoteTicks, yet they shared identical prices, and size possibly owing to the structure of the TBBO schema.

Acknowledging the unlikelihood and negligible advantage, I'm closing the issue.

However, in exploring this, I stumbled upon another intriguing observation: sequence numbers may duplicate across multiple trades with varying prices and sizes. Thus, they can't serve as a direct unique identifier in TradeTick. image