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
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:
@@ -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"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user