Remove old simulated order price on update
parent
fff9efe4aa
commit
7e214180a6
|
@ -70,15 +70,15 @@ class PaperBoi:
|
||||||
if brid is None:
|
if brid is None:
|
||||||
reqid = str(uuid.uuid4())
|
reqid = str(uuid.uuid4())
|
||||||
|
|
||||||
# register order internally
|
|
||||||
self._reqids[reqid] = (oid, symbol, action, price)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# order is already existing, this is a modify
|
# order is already existing, this is a modify
|
||||||
(oid, symbol, action, old_price) = self._reqids[brid]
|
(oid, symbol, action, old_price) = self._reqids[brid]
|
||||||
assert old_price != price
|
assert old_price != price
|
||||||
reqid = brid
|
reqid = brid
|
||||||
|
|
||||||
|
# register order internally
|
||||||
|
self._reqids[reqid] = (oid, symbol, action, price)
|
||||||
|
|
||||||
if action == 'alert':
|
if action == 'alert':
|
||||||
# bypass all fill simulation
|
# bypass all fill simulation
|
||||||
return reqid
|
return reqid
|
||||||
|
@ -129,6 +129,10 @@ class PaperBoi:
|
||||||
# and trigger by the simulated clearing task normally
|
# and trigger by the simulated clearing task normally
|
||||||
# running ``simulate_fills()``.
|
# running ``simulate_fills()``.
|
||||||
|
|
||||||
|
if brid is not None:
|
||||||
|
# remove any existing order for the old price
|
||||||
|
orders[symbol].pop((oid, old_price))
|
||||||
|
|
||||||
# buys/sells: (symbol -> (price -> order))
|
# buys/sells: (symbol -> (price -> order))
|
||||||
orders.setdefault(symbol, {})[(oid, price)] = (size, reqid, action)
|
orders.setdefault(symbol, {})[(oid, price)] = (size, reqid, action)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue