Time | Price | Quantity |
---|---|---|
1499530305.593857 | 23.45 | 500 |
1499530305.649646 | 23.46 | 323 |
1499530306.024135 | 23.46 | 107 |
1499530307.153155 | 23.45 | 1,300 |
Side | Price | Quantity | Status |
---|---|---|---|
Buy | 23.40 | 1,500 |
new
pending cancel…
|
Sell |
23.95
24.00
|
900 | new |
Buy | 23.30 | 2,000 | creating… |
get_state
method.
get_state
methods periodically.get_state
methods.
import difflib
x = ('one', 'two', 'three')
y = ('two', 'two point five', 'four')
matcher = difflib.SequenceMatcher(None, x, y)
matcher.get_opcodes()
[('delete', 0, 1, 0, 0), ('equal', 1, 2, 0, 1),
('replace', 2, 3, 1, 3)]
get_state
methods…has_changed
flag.orders.insert(123, new_order)
('insert', 123, new_order)
happened.orders[123] = updated_order
and del orders[123]
import difftrack
orders = difftrack.ListDispatcher()
listener = difftrack.ListListener()
orders.add_listener(listener)
orders.insert(0, Order(side=BUY, price=23.95, quantity=500))
orders.insert(1, Order(side=SELL, price=24.30, quantity=100))
del orders[0]
print(listener.get_new_diffs())
[(<ListDiff.INSERT>, 0, Order(side=BUY, price=23.95, ...)),
(<ListDiff.INSERT>, 1, Order(side=SELL, price=24.30, ...)),
(<ListDiff.DELETE>, 0, None)]
>>> listener.get_snapshot()
[Order(side=SELL, price=24.30, quantity=100)]
>>> listener.get_new_diffs()
[]