depth:5 //depth to maintain in book table
stdepth:100*depth //depth to maintain in state dicts
exchange: "Gdax"
bidst😞`u#enlist`)!enlist(`float$())!`float$() //bid state dict
askst😞`u#enlist`)!enlist(`float$())!`float$() //ask state dict
lb😞`u#enlist`)!enlist(`bids`bsizes`asks`asizes!()) //last book state
/* Redefine publish function to pass to TP for real FH */
publish:upsert //define publish function to upsert for example FH
rec.book:{[t;s]
/* determine if book record needs published & publish if so */
bk: `bids`bsizes!depth sublist'(key;value)@\:bidst[s]; //get current bid book up to depth
bk,:`asks`asizes!depth sublist'(key;value)@\:askst[s]; //get current ask book up to depth
if[not bk~lb[s]; //compare to last book
publish[`book;@[bk;`ex`sym`time;:;(`Gdax;s;"p"$t)]]; //publish record if changed
lb[s]:bk; //record state of last book
];
}