AvroSerializer: schema for orderbook snapshots

Solution 1:

First, you have a typo. fields needs to be an array in the schema definition.

However, your bid (and ask) objects are not records. They are a map<float, float>. In other words, it does not have literal price and volume keys.

Avro has Map types, but the keys are "assumed to be strings".

You are welcome to try

{"name": "bid", "type": "map", "values": "float"}

Otherwise, you need to reformat your data payloads, for example as a list of objects

'bid': [
     {'price': 100.0, 'volume': 20.0},
     ...,
],

Along with

{"name": "bid", "type": "array", "items": {
  "type": "record",
  "name": "BidItem",
  "fields": [
    {"name": "price", "type": "float"},
    {"name": "volume", "type": "float"}
  ]
}}