Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
2.124
Tracking Error
0.147
Treynor Ratio
0
Total Fees
$0.00
import math
from datetime import date, timedelta
import numpy as np
from Selection.FutureUniverseSelectionModel import FutureUniverseSelectionModel


FUTURES = [ Futures.Indices.SP500EMini ]


class FuturesUniverseSelectionModel(FutureUniverseSelectionModel):
    def __init__(self, select_future_chain_symbols):
        super().__init__(timedelta(1), select_future_chain_symbols)

    def Filter(self, filter):
        return (filter.FrontMonth())


class Security:
    def __init__(self, security):
        self.Security = security
        
    @property
    def Symbol(self):
        return self.Security.Symbol


class TurtleSystemAlgo(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2010, 1, 1)
        self.SetEndDate(2010, 1, 30)
        self.SetCash(100000)
        self.resolution = Resolution.Minute
        self.UniverseSettings.Resolution = self.resolution
        self.SetUniverseSelection(FuturesUniverseSelectionModel(self._select_futures_symbols))
        self.symbol_data = {}

    def _select_futures_symbols(self, utcTime):
        return [ Symbol.Create(ticker, SecurityType.Future, Market.USA) for ticker in FUTURES ]

    def OnOrderEvent(self, order):
        if order.Status == OrderStatus.Filled:
            self._plot(order.Symbol, 'Buy' if order.FillQuantity > 0 else 'Sell', order.FillPrice)

    def OnSecuritiesChanged(self, changes):
        for security in changes.AddedSecurities:
            self.symbol_data[security.Symbol] = Security(security)

    def OnData(self, data):
        for s, security in self.symbol_data.items():
            symbol = security.Symbol
            if symbol not in data.Keys or not data[symbol]:
                continue
            
          
            prc = data.Bars[symbol].Close
            
            
            self.Debug(data.Bars[symbol].EndTime)