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:
+2
-6
@@ -14,7 +14,7 @@
|
||||
from AlgorithmImports import *
|
||||
|
||||
### <summary>
|
||||
### Basic template algorithm for the Atreyu brokerage
|
||||
### Basic template algorithm for the Axos brokerage
|
||||
### </summary>
|
||||
### <meta name="tag" content="using data" />
|
||||
### <meta name="tag" content="using quantconnect" />
|
||||
@@ -29,13 +29,9 @@ class BasicTemplateAtreyuAlgorithm(QCAlgorithm):
|
||||
self.SetEndDate(2013,10,11) #Set End Date
|
||||
self.SetCash(100000) #Set Strategy Cash
|
||||
|
||||
self.SetBrokerageModel(BrokerageName.Atreyu)
|
||||
self.SetBrokerageModel(BrokerageName.Axos)
|
||||
self.AddEquity("SPY", Resolution.Minute)
|
||||
|
||||
self.DefaultOrderProperties = AtreyuOrderProperties()
|
||||
# Currently only support order for the day
|
||||
self.DefaultOrderProperties.TimeInForce = TimeInForce.Day
|
||||
|
||||
def OnData(self, data):
|
||||
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
|
||||
|
||||
@@ -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