Make Future universe selection file-based like option universe
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from AlgorithmImports import *
|
||||
import QuantConnect.Data.UniverseSelection
|
||||
|
||||
### <summary>
|
||||
### This example demonstrates how to add futures with daily resolution.
|
||||
@@ -54,6 +55,12 @@ class BasicTemplateFuturesDailyAlgorithm(QCAlgorithm):
|
||||
elif all(x.exchange.hours.is_open(self.time, True) for x in self.securities.values() if x.invested):
|
||||
self.liquidate()
|
||||
|
||||
def on_securities_changed(self, changes: SecurityChanges) -> None:
|
||||
if len(changes.removed_securities) > 0 and \
|
||||
self.portfolio.invested and \
|
||||
all(x.exchange.hours.is_open(self.time, True) for x in self.securities.values() if x.invested):
|
||||
self.liquidate()
|
||||
|
||||
def get_resolution(self):
|
||||
return Resolution.DAILY
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ class FutureStopMarketOrderOnExtendedHoursRegressionAlgorithm(QCAlgorithm):
|
||||
|
||||
# This method is opened 2 new orders by scheduler
|
||||
def make_market_and_stop_market_order(self):
|
||||
# Don't place orders at the end of the last date, the market-on-stop order won't have time to fill
|
||||
if self.time.date() == self.end_date.date() - timedelta(days=1):
|
||||
return
|
||||
|
||||
self.market_order(self.sp_500_e_mini.mapped, 1)
|
||||
self.stop_market_ticket = self.stop_market_order(self.sp_500_e_mini.mapped, -1, self.sp_500_e_mini.price * 1.1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user