Price Level Entries (PRL) Creating#

In OneTick parlance, book entries are also called price level entries. The fields that identify a price level entry (that is, distinguish it from other entries) are called price level keys. In a detailed feed, an order identifier is a price level key. PRICE and SIDE are always price level keys. Side should not be indicated as such whereas price should (otherwise the system does not recognize the tick as a price level). Other fields in a price level entry are value fields. Those determine the current state of the price level entry. SIZE is the most common value field.

More detailed description as well as the list of mandatory fields of price level entries can be found in Onetick documentation.

Example#

Unfortunatly onetick-py doesn’t natively support PRL, so you should use some tricks to create and store them into the database.

In the following example one PRL tick will be created, store to db and printed. You can modify this sample to call your query for testing it or modify data itself.

db = otp.DB()
prls = otp.Ticks(
    PRICE=[100.0],
    SIZE=[100],
    BUY_SELL_FLAG=[0],
    RECORD_TYPE=["R"],
    DELETED_TIME=[otp.msectime(0)])
prls.sink(otq.Table(fields="TICK_STATUS byte", keep_input_fields=True))
prls.sink(otq.ModifyTsProperties(property_name="STATE_KEYS", property_value="PRICE"))
# modify data before storing it in database here
db.add(prls, tick_type="PRL", symbol="A")
session.use(db)
data = otq.ObSnapshot().tick_type("PRL").symbol(f"{db}::A")  # call your query here
df = otp.run(data, timezone="EST5EDT")
print(df)
        Time  PRICE  SIZE  BUY_SELL_FLAG        DELETED_TIME  TICK_STATUS RECORD_TYPE  LEVEL UPDATE_TIME
0 2003-12-04  100.0   100              0 1969-12-31 19:00:00            0           R      1  2003-12-01