Overall Statistics
Total Trades
6
Average Win
0.00%
Average Loss
0.00%
Compounding Annual Return
0.264%
Drawdown
0.000%
Expectancy
1.926
Net Profit
0.008%
Sharpe Ratio
2.106
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
3.39
Alpha
0.014
Beta
-0.796
Annual Standard Deviation
0.001
Annual Variance
0
Information Ratio
-9.38
Tracking Error
0.001
Treynor Ratio
-0.003
Total Fees
$30.00
class MultidimensionalTransdimensionalReplicator(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 4, 1)  # Set Start Date
        self.SetCash(10000000)  # Set Strategy Cash
        self.AddEquity('SPY', Resolution.Daily)

    def OnData(self, data):
        if not self.Portfolio.Invested:
            ## Establish a long position
            self.MarketOrder('SPY', 1000)
            
        if self.Portfolio.Invested and (len(self.Transactions.GetOpenOrders()) == 0):
            self.Log('Current Position: ' + str(self.Portfolio['SPY'].Quantity))

            ## Place Stop Market Order using the smaller of the two values
            self.StopMarketOrder('SPY', -min(3000, self.Portfolio['SPY'].Quantity), data['SPY'].Close*1.001)