Shortable modeling improvements (#7579)
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
* Shortable modeling improvements - Do not limit live trading because of shortable model, will send algorithm warning - Add Interactive brokers shortable provider - Minor LocalDiskShortableProvider API changes * Fix shorted order update - Fix shorted order update. Updating regression algorithm * Minor improvement * Address reviews
This commit is contained in:
@@ -15,7 +15,7 @@ from AlgorithmImports import *
|
||||
|
||||
class RegressionTestShortableProvider(LocalDiskShortableProvider):
|
||||
def __init__(self):
|
||||
super().__init__(SecurityType.Equity, "testbrokerage", Market.USA)
|
||||
super().__init__("testbrokerage")
|
||||
|
||||
### <summary>
|
||||
### Tests that orders are denied if they exceed the max shortable quantity.
|
||||
@@ -41,8 +41,14 @@ class ShortableProviderOrdersRejectedRegressionAlgorithm(QCAlgorithm):
|
||||
def OnData(self, data):
|
||||
if not self.initialize:
|
||||
self.HandleOrder(self.LimitOrder(self.spy.Symbol, -1001, 10000)) # Should be canceled, exceeds the max shortable quantity
|
||||
self.HandleOrder(self.LimitOrder(self.spy.Symbol, -1000, 10000)) # Allowed, orders at or below 1000 should be accepted
|
||||
orderTicket = self.LimitOrder(self.spy.Symbol, -1000, 10000)
|
||||
self.HandleOrder(orderTicket) # Allowed, orders at or below 1000 should be accepted
|
||||
self.HandleOrder(self.LimitOrder(self.spy.Symbol, -10, 0.01)) # Should be canceled, the total quantity we would be short would exceed the max shortable quantity.
|
||||
|
||||
response = orderTicket.UpdateQuantity(-999) # should be allowed, we are reducing the quantity we want to short
|
||||
if not response.IsSuccess:
|
||||
raise ValueError("Order update should of succeeded!");
|
||||
|
||||
self.initialize = True
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user