Skip to content

Commit c48ae23

Browse files
committed
docs: snapshot with stopbook
1 parent 367d6fb commit c48ae23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ A `snapshot` represents the state of the order book at a specific point in time.
387387

388388
- `asks`: List of ask orders, each with a `price` and a list of associated `orders`.
389389
- `bids`: List of bid orders, each with a `price` and a list of associated `orders`.
390+
- `stopBook`: an object with `bids` and `asks` properties related to every `StopOrder` in the orderbook.
390391
- `ts`: A timestamp indicating when the snapshot was taken, in Unix timestamp format.
391392
- `lastOp`: The id of the last operation included in the snapshot
392393

@@ -405,7 +406,7 @@ await saveLog(order.log)
405406
// ... after some time take a snapshot of the order book and save it on the database
406407

407408
const snapshot = ob.snapshot()
408-
await saveSnapshot(snapshot)
409+
await saveSnapshot(JSON.stringify(snapshot))
409410

410411
// If you want you can safely remove all logs preceding the `lastOp` id of the snapshot, and continue to save each subsequent log to the database
411412
await removePreviousLogs(snapshot.lastOp)
@@ -414,7 +415,7 @@ await removePreviousLogs(snapshot.lastOp)
414415
const logs = await getLogs()
415416
const snapshot = await getSnapshot()
416417

417-
const ob = new OrderBook({ snapshot, journal: log, enableJournaling: true })
418+
const ob = new OrderBook({ snapshot: JSON.parse(snapshot), journal: log, enableJournaling: true })
418419
```
419420

420421
### Journal Logs

0 commit comments

Comments
 (0)