Fix sign of order quantity in example algorithm OnMarginCall(). (#8251)
Regression Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled

Despite the comments about avoiding margin calls and about padding, this
turned a proposed sale of 100 shares into a *buy* of 110 shares.
This commit is contained in:
Noah Misch
2024-08-12 13:40:51 -07:00
committed by GitHub
parent 5226b7a468
commit d2d366e3f9
2 changed files with 2 additions and 2 deletions
@@ -48,7 +48,7 @@ class MarginCallEventsAlgorithm(QCAlgorithm):
for order in requests:
# liquidate an extra 10% each time we get a margin call to give us more padding
new_quantity = int(np.sign(order.quantity) * order.quantity * 1.1)
new_quantity = int(order.quantity * 1.1)
requests.remove(order)
requests.append(SubmitOrderRequest(order.order_type, order.security_type, order.symbol, new_quantity, order.stop_price, order.limit_price, self.time, "on_margin_call"))