persistable srecord noeq PriceDigitizer2(PriceCells cells) { settable int cellNumber = Int.MIN_VALUE; settable int lastCellNumber = Int.MIN_VALUE; settable bool verbose; // returns new digitized price double digitize(double price) { double cn = cells.toCellNumber(price); if (cellNumber == Int.MIN_VALUE) { cellNumber = lastCellNumber = iround(cn); } else { lastCellNumber = cellNumber; cellNumber = iroundTowards(cn, cellNumber); } ret digitizedPrice(); } double digitizedPrice() { ret cells.fromCellNumber(cellNumber); } double lastDigitizedPrice() { ret cells.fromCellNumber(lastCellNumber); } // digitize price without looking at history double digitizeIndividually(double price) { double cn = cells.toCellNumber(price); ret cells.fromCellNumber(round(cn)); } PriceCells priceCells() { ret cells; } // brave void swapPriceCells(PriceCells newPriceCells) { cells = newPriceCells; } }